gtsam  4.1.0
gtsam
nonlinearExceptions.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
18 #pragma once
19 
20 #include <boost/lexical_cast.hpp>
21 #include <exception>
22 
23 #include <gtsam/inference/Key.h>
24 
25 namespace gtsam {
26 
33  class MarginalizeNonleafException : public std::exception {
34  Key key_;
35  KeyFormatter formatter_;
36  mutable std::string what_;
37  public:
38  MarginalizeNonleafException(Key key, KeyFormatter formatter = DefaultKeyFormatter) noexcept :
39  key_(key), formatter_(formatter) {}
40  virtual ~MarginalizeNonleafException() noexcept {}
41  Key key() const { return key_; }
42  const char* what() const noexcept override {
43  if(what_.empty())
44  what_ =
45 "\nRequested to marginalize out variable " + formatter_(key_) + ", but this variable\n\
46 is not a leaf. To make the variables you would like to marginalize be leaves,\n\
47 their ordering should be constrained using the constrainedKeys argument to\n\
48 ISAM2::update().\n";
49  return what_.c_str();
50  }
51  };
52 
53 }
gtsam::MarginalizeNonleafException
Thrown when requesting to marginalize out variables from ISAM2 that are not leaves.
Definition: nonlinearExceptions.h:33
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
gtsam
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Key.h
gtsam::KeyFormatter
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35