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

## Detailed Description

Nonlinear factor base class.

This is the base class for all factor types, as well as conditionals, which are implemented as specialized factors.

This class does not store any data other than its keys. Derived classes store data such as matrices and probability tables.

The error method is used to evaluate the factor, and is the only method that is required to be implemented in derived classes, although it has a default implementation that throws an exception.

There are five broad classes of factors that derive from Factor:

- Nonlinear factors, such as NoiseModelFactor, which represent a nonlinear likelihood function over a set of variables.
- Gaussian factors, such as

Inheritance diagram for gtsam::NonlinearFactor:

## Standard Constructors

| 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.

## Testable

void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
| print
virtual bool | equals (const NonlinearFactor &f, double tol=1e-9) const
| Check if two factors are equal.

## Standard Interface

virtual | ~NonlinearFactor ()
| Destructor.
virtual double | error (const Values &c) const
double | error (const HybridValues &c) const override
| All factor types need to implement an error function.
virtual size_t | dim () const =0
| get the dimension of the factor (number of rows on linearization)
virtual bool | active (const Values &) const
| Checks whether a factor should be used based on a set of values.
virtual boost::shared_ptr< GaussianFactor > | linearize (const Values &c) const =0
| linearize to a GaussianFactor
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 Types

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 Factor | Base
typedef NonlinearFactor | This

## Additional Inherited Members

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.
| 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.
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.
Protected Attributes inherited from gtsam::Factor
KeyVector | keys_
| The keys involved in this factor.

## Member Function Documentation

## active()

virtual bool gtsam::NonlinearFactor::active | ( | const Values & |  | ) | const

inline virtual

Checks whether a factor should be used based on a set of values.

This is primarily used to implement inequality constraints that require a variable active set. For all others, the default implementation returning true solves this problem.

In an inequality/bounding constraint, this active() returns true when the constraint is NOT fulfilled.

Returns
  true if the constraint is active

Reimplemented in gtsam::AntiFactor, gtsam::BoundingConstraint1< VALUE >, and gtsam::BoundingConstraint2< VALUE1, VALUE2 >.

## clone()

virtual shared_ptr gtsam::NonlinearFactor::clone | ( |  | ) | const

inline virtual

Creates a shared_ptr clone of the factor - needs to be specialized to allow for subclasses.

By default, throws exception if subclass does not implement the function.

Reimplemented in gtsam::AHRSFactor, gtsam::AntiFactor, gtsam::BarometricFactor, gtsam::BearingRangeFactor< A1, A2, B, R >, gtsam::BetweenFactor< VALUE >, gtsam::CombinedImuFactor, gtsam::EssentialMatrixConstraint, gtsam::EssentialMatrixFactor2, gtsam::EssentialMatrixFactor3, gtsam::EssentialMatrixFactor4< CALIBRATION >, gtsam::EssentialMatrixFactor, 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::FunctorizedFactor2< R, T1, T2 >, gtsam::FunctorizedFactor< R, T >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::FunctorizedFactor< double, typename BASIS::Parameters >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::GeneralSFMFactor2< CALIBRATION >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::GenericStereoFactor< POSE, LANDMARK >, gtsam::GPSFactor2, gtsam::GPSFactor, gtsam::ImuFactor2, gtsam::ImuFactor, gtsam::LinearContainerFactor, gtsam::MagFactor1, gtsam::MagFactor2, gtsam::MagFactor3, gtsam::MagFactor, gtsam::MagPoseFactor< POSE >, gtsam::NonlinearEquality1< VALUE >, gtsam::NonlinearEquality2< T >, gtsam::NonlinearEquality< VALUE >, 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, and gtsam::TriangulationFactor< CAMERA >.

## dim()

virtual size_t gtsam::NonlinearFactor::dim | ( |  | ) | const

pure virtual

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

Implemented in gtsam::AntiFactor, gtsam::KarcherMeanFactor< T >, gtsam::LinearContainerFactor, gtsam::NoiseModelFactor, gtsam::ShonanGaugeFactor, gtsam::SmartFactorBase< CAMERA >, gtsam::SmartFactorBase< PinholePose< CALIBRATION > >, and gtsam::WhiteNoiseFactor.

## equals()

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

virtual

Check if two factors are equal.

Reimplemented in gtsam::AHRSFactor, gtsam::AntiFactor, gtsam::BarometricFactor, gtsam::BetweenFactor< VALUE >, gtsam::CombinedImuFactor, gtsam::EssentialMatrixConstraint, 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::FrobeniusBetweenFactor< Rot >, gtsam::FunctorizedFactor2< R, T1, T2 >, gtsam::FunctorizedFactor< R, T >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::FunctorizedFactor< double, typename BASIS::Parameters >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::GeneralSFMFactor2< CALIBRATION >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::GenericStereoFactor< POSE, LANDMARK >, gtsam::GPSFactor2, gtsam::GPSFactor, gtsam::ImuFactor2, gtsam::ImuFactor, gtsam::LinearContainerFactor, gtsam::MagPoseFactor< POSE >, gtsam::NoiseModelFactor, 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 >, gtsam::SmartFactorBase< CAMERA >, gtsam::SmartFactorBase< PinholePose< CALIBRATION > >, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< Camera >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::SmartProjectionPoseFactor< CALIBRATION >, gtsam::SmartProjectionRigFactor< CAMERA >, and gtsam::TriangulationFactor< CAMERA >.

## error() [1/2]

double NonlinearFactor::error | ( | const HybridValues & | c | ) | const

override virtual

All factor types need to implement an error function.

In factor graphs, this is the negative log-likelihood.

Reimplemented from gtsam::Factor.

## error() [2/2]

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

virtual

Reimplemented in gtsam::AntiFactor, gtsam::KarcherMeanFactor< T >, gtsam::LinearContainerFactor, gtsam::NoiseModelFactor, gtsam::NonlinearEquality< VALUE >, gtsam::ShonanGaugeFactor, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< Camera >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::SmartProjectionPoseFactor< CALIBRATION >, gtsam::SmartProjectionRigFactor< CAMERA >, and gtsam::WhiteNoiseFactor.

## linearize()

virtual boost::shared_ptr< GaussianFactor > gtsam::NonlinearFactor::linearize | ( | const Values & | c | ) | const

pure virtual

linearize to a GaussianFactor

Implemented in gtsam::AntiFactor, 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::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::KarcherMeanFactor< T >, gtsam::LinearContainerFactor, gtsam::NoiseModelFactor, gtsam::NonlinearEquality< VALUE >, gtsam::ShonanGaugeFactor, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< Camera >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::SmartProjectionRigFactor< CAMERA >, gtsam::TriangulationFactor< CAMERA >, and gtsam::WhiteNoiseFactor.

## print()

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

override virtual

print

Reimplemented from gtsam::Factor.

Reimplemented in 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 >, gtsam::SmartFactorBase< CAMERA >, gtsam::SmartFactorBase< PinholePose< CALIBRATION > >, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< Camera >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::SmartProjectionPoseFactor< CALIBRATION >, gtsam::SmartProjectionRigFactor< CAMERA >, gtsam::TriangulationFactor< CAMERA >, and gtsam::WhiteNoiseFactor.

## rekey() [1/2]

NonlinearFactor::shared_ptr NonlinearFactor::rekey | ( | const KeyVector & | new_keys | ) | const

virtual

Clones a factor and fully replaces its keys.

Parameters

  new_keys | is the full replacement set of keys

Reimplemented in gtsam::LinearContainerFactor.

## rekey() [2/2]

NonlinearFactor::shared_ptr NonlinearFactor::rekey | ( | const std::map< Key, Key > & | rekey_mapping | ) | const

virtual

Creates a shared_ptr clone of the factor with different keys using a map from old->new keys.

Reimplemented in gtsam::LinearContainerFactor.

## sendable()

virtual bool gtsam::NonlinearFactor::sendable | ( |  | ) | const

inline virtual

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).

Reimplemented in gtsam::CustomFactor.

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