gtsam  4.1.0
gtsam
gtsam::ExpressionFactor< T > Class Template Reference

Detailed Description

template<typename T>
class gtsam::ExpressionFactor< T >

Factor that supports arbitrary expressions via AD.

Arbitrary instances of this template can be directly inserted into a factor graph for optimization. However, to enable the correct (de)serialization of such instances, the user should declare derived classes from this template, implementing expresion(), serialize(), clone(), print(), and defining the corresponding struct traits<NewFactor> : public Testable<NewFactor> {}.

Template Parameters
TType for measurements.
+ Inheritance diagram for gtsam::ExpressionFactor< T >:

Public Member Functions

 ExpressionFactor (const SharedNoiseModel &noiseModel, const T &measurement, const Expression< T > &expression)
 Constructor: creates a factor from a measurement and measurement function. More...
 
virtual ~ExpressionFactor ()
 Destructor.
 
const T & measured () const
 return the measurement
 
void print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
 print relies on Testable traits being defined for T
 
bool equals (const NonlinearFactor &f, double tol) const override
 equals relies on Testable traits being defined for T
 
Vector unwhitenedError (const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
 Error function without the NoiseModel, \( z-h(x) -> Local(h(x),z) \). More...
 
boost::shared_ptr< GaussianFactorlinearize (const Values &x) const override
 
gtsam::NonlinearFactor::shared_ptr clone () const override
 

Public Types

typedef boost::shared_ptr< ExpressionFactor< T > > shared_ptr
 

Protected Types

typedef ExpressionFactor< T > This
 

Protected Member Functions

 ExpressionFactor (const SharedNoiseModel &noiseModel, const T &measurement)
 Default constructor, for serialization. More...
 
void initialize (const Expression< T > &expression)
 Initialize with constructor arguments.
 
virtual Expression< T > expression () const
 Recreate expression from keys_ and measured_, used in load below. More...
 

Protected Attributes

measured_
 the measurement to be compared with the expression
 
Expression< T > expression_
 the expression that is AD enabled
 
FastVector< int > dims_
 dimensions of the Jacobian matrices
 

Static Protected Attributes

static const int Dim = traits<T>::dimension
 

Friends

class boost::serialization::access
 

Constructor & Destructor Documentation

◆ ExpressionFactor() [1/2]

template<typename T >
gtsam::ExpressionFactor< T >::ExpressionFactor ( const SharedNoiseModel noiseModel,
const T &  measurement,
const Expression< T > &  expression 
)
inline

Constructor: creates a factor from a measurement and measurement function.

Parameters
noiseModelthe noise model associated with a measurement
measurementactual value of the measurement, of type T
expressionpredicts the measurement from Values The keys associated with the factor, returned by keys(), are sorted.

◆ ExpressionFactor() [2/2]

template<typename T >
gtsam::ExpressionFactor< T >::ExpressionFactor ( const SharedNoiseModel noiseModel,
const T &  measurement 
)
inlineprotected

Default constructor, for serialization.

Constructor for serializable derived classes

Member Function Documentation

◆ clone()

template<typename T >
gtsam::NonlinearFactor::shared_ptr gtsam::ExpressionFactor< T >::clone ( ) const
inlineoverride
Returns
a deep copy of this factor

◆ expression()

template<typename T >
virtual Expression<T> gtsam::ExpressionFactor< T >::expression ( ) const
inlineprotectedvirtual

Recreate expression from keys_ and measured_, used in load below.

Needed to deserialize a derived factor

◆ unwhitenedError()

template<typename T >
Vector gtsam::ExpressionFactor< T >::unwhitenedError ( const Values x,
boost::optional< std::vector< Matrix > & >  H = boost::none 
) const
inlineoverride

Error function without the NoiseModel, \( z-h(x) -> Local(h(x),z) \).

We override this method to provide both the function evaluation and its derivative(s) in H.


The documentation for this class was generated from the following files: