29#include <boost/shared_ptr.hpp>
37 class GaussianFactorGraph;
38 class SymbolicFactorGraph;
42 class ExpressionFactor;
49 enum Axis { X, Y, Z, NEGX, NEGY, NEGZ };
63 paperHorizontalAxis(Y), paperVerticalAxis(X),
64 figureWidthInches(5), figureHeightInches(5), scale(1),
65 mergeSimilarFactors(false), plotFactorPoints(true),
66 connectKeysToFactor(true), binaryEdges(true) {}
84 typedef boost::shared_ptr<This> shared_ptr;
90 template<
typename ITERATOR>
94 template<
class CONTAINER>
98 template<
class DERIVEDFACTOR>
106 const std::string& str =
"NonlinearFactorGraph: ",
107 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override;
110 void printErrors(
const Values& values,
const std::string& str =
"NonlinearFactorGraph: ",
112 const std::function<
bool(
const Factor* ,
double ,
size_t )>&
113 printCondition = [](
const Factor *,
double,
size_t) {
return true;})
const;
116 bool equals(
const NonlinearFactorGraph& other,
double tol = 1e-9)
const;
119 void saveGraph(std::ostream& stm,
const Values& values = Values(),
120 const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
121 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
129 void saveGraph(
const std::string& file,
const Values& values = Values(),
130 const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
131 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
134 double error(
const Values& values)
const;
137 double probPrime(
const Values& values)
const;
142 boost::shared_ptr<SymbolicFactorGraph> symbolic()
const;
147 Ordering orderingCOLAMD()
const;
157 Ordering orderingCOLAMDConstrained(
const FastMap<Key, int>& constraints)
const;
160 boost::shared_ptr<GaussianFactorGraph> linearize(
const Values& linearizationPoint)
const;
163 typedef std::function<void(
const boost::shared_ptr<HessianFactor>& hessianFactor)>
Dampen;
172 boost::shared_ptr<HessianFactor> linearizeToHessianFactor(
173 const Values& values,
const Dampen& dampen =
nullptr)
const;
183 boost::shared_ptr<HessianFactor> linearizeToHessianFactor(
189 const Dampen& dampen =
nullptr)
const;
194 const Dampen& dampen =
nullptr)
const;
231 emplace_shared<PriorFactor<T>>(key, prior, model);
245 void addPrior(
Key key,
const T& prior,
const Matrix& covariance) {
246 emplace_shared<PriorFactor<T>>(key, prior, covariance);
255 boost::shared_ptr<HessianFactor> linearizeToHessianFactor(
256 const Values& values,
const Scatter& scatter,
const Dampen& dampen =
nullptr)
const;
259 friend class boost::serialization::access;
260 template<
class ARCHIVE>
261 void serialize(ARCHIVE & ar,
const unsigned int ) {
262 ar & boost::serialization::make_nvp(
"NonlinearFactorGraph",
263 boost::serialization::base_object<Base>(*
this));
268#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V41
270 boost::shared_ptr<HessianFactor> GTSAM_DEPRECATED linearizeToHessianFactor(
271 const Values& values, boost::none_t,
const Dampen& dampen =
nullptr)
const
272 {
return linearizeToHessianFactor(values, dampen);}
275 Values GTSAM_DEPRECATED updateCholesky(
const Values& values, boost::none_t,
276 const Dampen& dampen =
nullptr)
const
277 {
return updateCholesky(values, dampen);}
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:112
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:736
gtsam::enable_if_t< needs_eigen_aligned_allocator< T >::value, boost::shared_ptr< T > > make_shared(Args &&... args)
Add our own make_shared as a layer of wrapping on boost::make_shared This solves the problem with the...
Definition: make_shared.h:57
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
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
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:151
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: FactorGraph.h:93
This is the base class for all factor types.
Definition: Factor.h:56
Definition: Ordering.h:34
Scatter is an intermediate data structure used when building a HessianFactor incrementally,...
Definition: Scatter.h:49
Factor that supports arbitrary expressions via AD.
Definition: ExpressionFactor.h:44
Expression class that supports automatic differentiation.
Definition: Expression.h:48
Formatting options when saving in GraphViz format using NonlinearFactorGraph::saveGraph.
Definition: NonlinearFactorGraph.h:48
bool binaryEdges
just use non-dotted edges for binary factors
Definition: NonlinearFactorGraph.h:58
Axis paperVerticalAxis
The world axis assigned to the vertical paper axis.
Definition: NonlinearFactorGraph.h:51
GraphvizFormatting()
Default constructor sets up robot coordinates.
Definition: NonlinearFactorGraph.h:62
bool plotFactorPoints
Plots each factor as a dot between the variables.
Definition: NonlinearFactorGraph.h:56
bool mergeSimilarFactors
Merge multiple factors that have the same connectivity.
Definition: NonlinearFactorGraph.h:55
double scale
Scale all positions to reduce / increase density.
Definition: NonlinearFactorGraph.h:54
std::map< size_t, Point2 > factorPositions
(optional for each factor) Manually specify factor "dot" positions.
Definition: NonlinearFactorGraph.h:59
double figureWidthInches
The figure width on paper in inches.
Definition: NonlinearFactorGraph.h:52
Axis paperHorizontalAxis
The world axis assigned to the horizontal paper axis.
Definition: NonlinearFactorGraph.h:50
bool connectKeysToFactor
Draw a line from each key within a factor to the dot of the factor.
Definition: NonlinearFactorGraph.h:57
double figureHeightInches
The figure height on paper in inches.
Definition: NonlinearFactorGraph.h:53
A non-linear factor graph is a graph of non-Gaussian, i.e.
Definition: NonlinearFactorGraph.h:78
NonlinearFactorGraph()
Default constructor.
Definition: NonlinearFactorGraph.h:87
void addPrior(Key key, const T &prior, const SharedNoiseModel &model=nullptr)
Convenience method which adds a PriorFactor to the factor graph.
Definition: NonlinearFactorGraph.h:229
NonlinearFactorGraph(const CONTAINER &factors)
Construct from container of factors (shared_ptr or plain objects)
Definition: NonlinearFactorGraph.h:95
void addExpressionFactor(const SharedNoiseModel &R, const T &z, const Expression< T > &h)
Directly add ExpressionFactor that implements |h(x)-z|^2_R.
Definition: NonlinearFactorGraph.h:217
void addPrior(Key key, const T &prior, const Matrix &covariance)
Convenience method which adds a PriorFactor to the factor graph.
Definition: NonlinearFactorGraph.h:245
NonlinearFactorGraph(ITERATOR firstFactor, ITERATOR lastFactor)
Construct from iterator over factors.
Definition: NonlinearFactorGraph.h:91
std::function< void(const boost::shared_ptr< HessianFactor > &hessianFactor)> Dampen
typdef for dampen functions used below
Definition: NonlinearFactorGraph.h:163
NonlinearFactorGraph(const FactorGraph< DERIVEDFACTOR > &graph)
Implicit copy/downcast constructor to override explicit template container constructor.
Definition: NonlinearFactorGraph.h:99
virtual ~NonlinearFactorGraph()
Destructor.
Definition: NonlinearFactorGraph.h:102
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:63