GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
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 <exception>
21 
22 #include <gtsam/inference/Key.h>
23 
24 namespace gtsam {
25 
32  class MarginalizeNonleafException : public std::exception {
33  Key key_;
34  KeyFormatter formatter_;
35  mutable std::string what_;
36  public:
37  MarginalizeNonleafException(Key key, KeyFormatter formatter = DefaultKeyFormatter) noexcept :
38  key_(key), formatter_(formatter) {}
39  virtual ~MarginalizeNonleafException() noexcept {}
40  Key key() const { return key_; }
41  const char* what() const noexcept override {
42  if(what_.empty())
43  what_ =
44 "\nRequested to marginalize out variable " + formatter_(key_) + ", but this variable\n\
45 is not a leaf. To make the variables you would like to marginalize be leaves,\n\
46 their ordering should be constrained using the constrainedKeys argument to\n\
47 ISAM2::update().\n";
48  return what_.c_str();
49  }
50  };
51 
52 }
Definition: nonlinearExceptions.h:32
std::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
Definition: chartTesting.h:28
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102