Loading...
Searching...
No Matches
gtsam::NoiseModelFactor Class Referenceabstract

## Detailed Description

A nonlinear sum-of-squares factor with a zero-mean noise model implementing the density \( P(z|x) \propto exp -0.5*|z-h(x)|^2_C \) Templated on the parameter type X and the values structure Values There is no return type specified for h(x).

Instead, we require the derived class implements \( \mathtt{error\_vector}(x) = h(x)-z \approx A \delta x - b \) This allows a graph to have factors with measurements of mixed type.

The noise model is typically Gaussian, but robust and constrained error models are also supported.

Inheritance diagram for gtsam::NoiseModelFactor:

## Public Member Functions

| NoiseModelFactor ()
| Default constructor for I/O only.
| ~NoiseModelFactor () override
| Destructor.
template<typename CONTAINER>
| NoiseModelFactor (const SharedNoiseModel &noiseModel, const CONTAINER &keys)
| Constructor.
void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
| Print.
bool | equals (const NonlinearFactor &f, double tol=1e-9) const override
| Check if two factors are equal.
size_t | dim () const override
| get the dimension of the factor (number of rows on linearization)
const SharedNoiseModel & | noiseModel () const
| access to the noise model
virtual Vector | unwhitenedError (const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const =0
| Error function without the NoiseModel, \( z-h(x) \).
Vector | whitenedError (const Values &c) const
| Vector of errors, whitened This is the raw error, i.e., i.e.
Vector | unweightedWhitenedError (const Values &c) const
| Vector of errors, whitened, but unweighted by any loss function.
double | weight (const Values &c) const
| Compute the effective weight of the factor from the noise model.
double | error (const Values &c) const override
| Calculate the error of the factor.
boost::shared_ptr< GaussianFactor > | linearize (const Values &x) const override
| Linearize a non-linearFactorN to get a GaussianFactor, \( Ax-b \approx h(x+\delta x)-z = h(x) + A \delta x - z \) Hence \( b = z - h(x) = - \mathtt{error\_vector}(x) \).
shared_ptr | cloneWithNewNoiseModel (const SharedNoiseModel newNoise) const
| Creates a shared_ptr clone of the factor with a new noise model.
| NonlinearFactor ()
| Default constructor for I/O only.
template<typename CONTAINER>
| NonlinearFactor (const CONTAINER &keys)
| Constructor from a collection of the keys involved in this factor.
void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
| print
virtual | ~NonlinearFactor ()
| Destructor.
double | error (const HybridValues &c) const override
| All factor types need to implement an error function.
virtual bool | active (const Values &) const
| Checks whether a factor should be used based on a set of values.
virtual shared_ptr | clone () const
| Creates a shared_ptr clone of the factor - needs to be specialized to allow for subclasses.
virtual shared_ptr | rekey (const std::map< Key, Key > &rekey_mapping) const
| Creates a shared_ptr clone of the factor with different keys using a map from old->new keys.
virtual shared_ptr | rekey (const KeyVector &new_keys) const
| Clones a factor and fully replaces its keys.
virtual bool | sendable () const
| Should the factor be evaluated in the same thread as the caller This is to enable factors that has shared states (like the Python GIL lock).
Public Member Functions inherited from gtsam::Factor
virtual | ~Factor ()=default
| Default destructor.
bool | empty () const
| Whether the factor is empty (involves zero variables).
Key | front () const
| First key.
Key | back () const
| Last key.
const_iterator | find (Key key) const
| find
const KeyVector & | keys () const
| Access the factor's involved variable keys.
const_iterator | begin () const
| Iterator at beginning of involved variable keys.
const_iterator | end () const
| Iterator at end of involved variable keys.
size_t | size () const
virtual void | printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
| print only keys
bool | equals (const This &other, double tol=1e-9) const
| check equality
KeyVector & | keys ()
iterator | begin ()
| Iterator at beginning of involved variable keys.
iterator | end ()
| Iterator at end of involved variable keys.

## Public Types

typedef boost::shared_ptr< This > | shared_ptr
| Noise model.
Public Types inherited from gtsam::NonlinearFactor
typedef boost::shared_ptr< This > | shared_ptr
Public Types inherited from gtsam::Factor
typedef KeyVector::iterator | iterator
| Iterator over keys.
typedef KeyVector::const_iterator | const_iterator
| Const iterator over keys.

## Protected Types

typedef NonlinearFactor | Base
typedef NoiseModelFactor | This
Protected Types inherited from gtsam::NonlinearFactor
typedef Factor | Base
typedef NonlinearFactor | This

## Protected Member Functions

| NoiseModelFactor (const SharedNoiseModel &noiseModel)
| Constructor - only for subclasses, as this does not set keys.
| Factor ()
| Default constructor for I/O.
template<typename CONTAINER>
| Factor (const CONTAINER &keys)
| Construct factor from container of keys.
template<typename ITERATOR>
| Factor (ITERATOR first, ITERATOR last)
| Construct factor from iterator keys.

## Protected Attributes

SharedNoiseModel | noiseModel_
Protected Attributes inherited from gtsam::Factor
KeyVector | keys_
| The keys involved in this factor.

## Friends

class | boost::serialization::access
| Serialization function.

## Additional Inherited Members

template<typename CONTAINER>
static Factor | FromKeys (const CONTAINER &keys)
| Construct factor from container of keys.
template<typename ITERATOR>
static Factor | FromIterators (ITERATOR first, ITERATOR last)
| Construct factor from iterator keys.

## Member Function Documentation

## dim()

size_t gtsam::NoiseModelFactor::dim | ( |  | ) | const

inline override virtual

get the dimension of the factor (number of rows on linearization)

Implements gtsam::NonlinearFactor.

## equals()

bool NoiseModelFactor::equals | ( | const NonlinearFactor & | f,
|  | double | tol = 1e-9 ) const

override virtual

Check if two factors are equal.

Reimplemented from gtsam::NonlinearFactor.

Reimplemented in gtsam::NonlinearEquality< VALUE >, gtsam::OrientedPlane3DirectionPrior, gtsam::Pose3AttitudeFactor, gtsam::PoseRotationPrior< POSE >, gtsam::PoseTranslationPrior< POSE >, gtsam::PriorFactor< VALUE >, gtsam::Rot3AttitudeFactor, gtsam::ShonanFactor< d >, gtsam::ShonanFactor< 2 >, gtsam::ShonanFactor< 3 >, and gtsam::TriangulationFactor< CAMERA >.

## error()

double NoiseModelFactor::error | ( | const Values & | c | ) | const

override virtual

Calculate the error of the factor.

This is the log-likelihood, e.g. \( 0.5(h(x)-z)^2/\sigma^2 \) in case of Gaussian. In this class, we take the raw prediction error \( h(x)-z \), ask the noise model to transform it to \( (h(x)-z)^2/\sigma^2 \), and then multiply by 0.5.

Reimplemented from gtsam::NonlinearFactor.

Reimplemented in gtsam::NonlinearEquality< VALUE >.

## linearize()

boost::shared_ptr< GaussianFactor > NoiseModelFactor::linearize | ( | const Values & | x | ) | const

override virtual

Linearize a non-linearFactorN to get a GaussianFactor, \( Ax-b \approx h(x+\delta x)-z = h(x) + A \delta x - z \) Hence \( b = z - h(x) = - \mathtt{error\_vector}(x) \).

Implements gtsam::NonlinearFactor.

Reimplemented in gtsam::NonlinearEquality< VALUE >, and gtsam::TriangulationFactor< CAMERA >.

## print()

void NoiseModelFactor::print | ( | const std::string & | s = "",
|  | const KeyFormatter & | keyFormatter = DefaultKeyFormatter ) const

override virtual

Print.

Reimplemented from gtsam::Factor.

Reimplemented in gtsam::NonlinearEquality1< VALUE >, gtsam::NonlinearEquality< VALUE >, gtsam::OrientedPlane3DirectionPrior, gtsam::OrientedPlane3Factor, gtsam::Pose3AttitudeFactor, gtsam::PoseRotationPrior< POSE >, gtsam::PoseTranslationPrior< POSE >, gtsam::PriorFactor< VALUE >, gtsam::RangeFactor< A1, A2, T >, gtsam::RangeFactor< A1, A2 >, gtsam::RangeFactorWithTransform< A1, A2, T >, gtsam::RangeFactorWithTransform< A1, A2 >, gtsam::ReferenceFrameFactor< POINT, TRANSFORM >, gtsam::Rot3AttitudeFactor, gtsam::RotateDirectionsFactor, gtsam::RotateFactor, gtsam::ShonanFactor< d >, gtsam::ShonanFactor< 2 >, gtsam::ShonanFactor< 3 >, and gtsam::TriangulationFactor< CAMERA >.

## unwhitenedError()

virtual Vector gtsam::NoiseModelFactor::unwhitenedError | ( | const Values & | x,
|  | boost::optional< std::vector< Matrix > & > | H = boost::none ) const

pure virtual

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

Override this method to finish implementing an N-way factor. If the optional arguments is specified, it should compute both the function evaluation and its derivative(s) in H.

Implemented in gtsam::CustomFactor, gtsam::ExpressionFactor< T >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::ExpressionFactor< typename Bearing< A1, A2 >::result_type >, gtsam::ExpressionFactor< typename Range< A1, A1 >::result_type >, gtsam::NoiseModelFactorN< ValueTypes >, gtsam::NoiseModelFactorN< BASIS::Parameters >, gtsam::NoiseModelFactorN< CAMERA, LANDMARK >, gtsam::NoiseModelFactorN< double, Unit3, Point3 >, gtsam::NoiseModelFactorN< EssentialMatrix >, gtsam::NoiseModelFactorN< EssentialMatrix, CALIBRATION >, gtsam::NoiseModelFactorN< EssentialMatrix, double >, gtsam::NoiseModelFactorN< NavState >, gtsam::NoiseModelFactorN< NavState, NavState >, gtsam::NoiseModelFactorN< NavState, NavState, imuBias::ConstantBias >, gtsam::NoiseModelFactorN< OrientedPlane3 >, gtsam::NoiseModelFactorN< POINT, TRANSFORM, POINT >, gtsam::NoiseModelFactorN< Point3 >, gtsam::NoiseModelFactorN< Point3, Point3 >, gtsam::NoiseModelFactorN< POSE >, gtsam::NoiseModelFactorN< POSE, LANDMARK >, gtsam::NoiseModelFactorN< Pose3 >, gtsam::NoiseModelFactorN< Pose3, double >, gtsam::NoiseModelFactorN< Pose3, OrientedPlane3 >, gtsam::NoiseModelFactorN< Pose3, Point3 >, gtsam::NoiseModelFactorN< Pose3, Point3, CALIBRATION >, gtsam::NoiseModelFactorN< Pose3, Pose3 >, gtsam::NoiseModelFactorN< Pose3, Vector3, Pose3, Vector3, imuBias::ConstantBias >, gtsam::NoiseModelFactorN< Pose3, Vector3, Pose3, Vector3, imuBias::ConstantBias, imuBias::ConstantBias >, gtsam::NoiseModelFactorN< Rot >, gtsam::NoiseModelFactorN< Rot, Rot >, gtsam::NoiseModelFactorN< Rot2 >, gtsam::NoiseModelFactorN< Rot3 >, gtsam::NoiseModelFactorN< Rot3, Rot3, Vector3 >, gtsam::NoiseModelFactorN< SOn, SOn >, gtsam::NoiseModelFactorN< T >, gtsam::NoiseModelFactorN< T, T >, gtsam::NoiseModelFactorN< T1, T2 >, gtsam::NoiseModelFactorN< VALUE >, gtsam::NoiseModelFactorN< VALUE, VALUE >, gtsam::NoiseModelFactorN< VALUE1, VALUE2 >, and gtsam::NoiseModelFactorN< ValueTypes... >.

## whitenedError()

Vector NoiseModelFactor::whitenedError | ( | const Values & | c | ) | const

Vector of errors, whitened This is the raw error, i.e., i.e.

\( (h(x)-z)/\sigma \) in case of a Gaussian

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

- /build/gtsam-gchP9J/gtsam-4.2.2+dfsg/gtsam/nonlinear/NonlinearFactor.h
- /build/gtsam-gchP9J/gtsam-4.2.2+dfsg/gtsam/nonlinear/NonlinearFactor.cpp