gtsam 4.2.0
gtsam
|
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:
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 |
![]() | |
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 | |
![]() | |
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. | |
![]() | |
KeyVector | keys_ |
The keys involved in this factor. | |
|
inlinevirtual |
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.
Reimplemented in gtsam::AntiFactor, gtsam::BoundingConstraint1< VALUE >, and gtsam::BoundingConstraint2< VALUE1, VALUE2 >.
|
inlinevirtual |
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::Rot3AttitudeFactor, gtsam::Pose3AttitudeFactor, gtsam::BarometricFactor, gtsam::CombinedImuFactor, gtsam::GPSFactor, gtsam::GPSFactor2, gtsam::ImuFactor, gtsam::ImuFactor2, gtsam::MagFactor, gtsam::MagFactor1, gtsam::MagFactor2, gtsam::MagFactor3, gtsam::MagPoseFactor< POSE >, 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::FunctorizedFactor< R, T >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::FunctorizedFactor2< R, T1, T2 >, gtsam::LinearContainerFactor, gtsam::NonlinearEquality< VALUE >, gtsam::NonlinearEquality1< VALUE >, gtsam::NonlinearEquality2< T >, gtsam::PriorFactor< VALUE >, gtsam::BearingRangeFactor< A1, A2, B, R >, gtsam::RangeFactor< A1, A2, T >, gtsam::RangeFactorWithTransform< A1, A2, T >, gtsam::AntiFactor, gtsam::BetweenFactor< VALUE >, gtsam::EssentialMatrixConstraint, gtsam::EssentialMatrixFactor, gtsam::EssentialMatrixFactor2, gtsam::EssentialMatrixFactor3, gtsam::EssentialMatrixFactor4< CALIBRATION >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::GeneralSFMFactor2< CALIBRATION >, gtsam::PoseRotationPrior< POSE >, gtsam::PoseTranslationPrior< POSE >, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::ReferenceFrameFactor< POINT, TRANSFORM >, gtsam::RotateFactor, gtsam::RotateDirectionsFactor, gtsam::GenericStereoFactor< POSE, LANDMARK >, and gtsam::TriangulationFactor< CAMERA >.
|
pure virtual |
get the dimension of the factor (number of rows on linearization)
Implemented in gtsam::LinearContainerFactor, gtsam::NoiseModelFactor, gtsam::WhiteNoiseFactor, gtsam::ShonanGaugeFactor, gtsam::AntiFactor, gtsam::KarcherMeanFactor< T >, gtsam::SmartFactorBase< CAMERA >, and gtsam::SmartFactorBase< PinholePose< CALIBRATION > >.
|
virtual |
Check if two factors are equal.
Reimplemented in gtsam::AHRSFactor, gtsam::Rot3AttitudeFactor, gtsam::Pose3AttitudeFactor, gtsam::BarometricFactor, gtsam::CombinedImuFactor, gtsam::GPSFactor, gtsam::GPSFactor2, gtsam::ImuFactor, gtsam::ImuFactor2, gtsam::MagPoseFactor< POSE >, gtsam::PriorFactor< VALUE >, gtsam::ShonanFactor< d >, gtsam::AntiFactor, gtsam::BetweenFactor< VALUE >, gtsam::EssentialMatrixConstraint, gtsam::FrobeniusBetweenFactor< Rot >, gtsam::OrientedPlane3DirectionPrior, gtsam::PoseRotationPrior< POSE >, gtsam::PoseTranslationPrior< POSE >, 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::LinearContainerFactor, gtsam::NonlinearEquality< VALUE >, gtsam::NoiseModelFactor, gtsam::GenericStereoFactor< POSE, LANDMARK >, gtsam::FunctorizedFactor< R, T >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::FunctorizedFactor2< R, T1, T2 >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::GeneralSFMFactor2< CALIBRATION >, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::SmartFactorBase< CAMERA >, gtsam::SmartFactorBase< PinholePose< CALIBRATION > >, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::SmartProjectionPoseFactor< CALIBRATION >, gtsam::SmartProjectionRigFactor< CAMERA >, and gtsam::TriangulationFactor< CAMERA >.
|
overridevirtual |
All factor types need to implement an error function.
In factor graphs, this is the negative log-likelihood.
Reimplemented from gtsam::Factor.
|
virtual |
Reimplemented in gtsam::LinearContainerFactor, gtsam::NonlinearEquality< VALUE >, gtsam::NoiseModelFactor, gtsam::ShonanGaugeFactor, gtsam::AntiFactor, gtsam::KarcherMeanFactor< T >, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::SmartProjectionPoseFactor< CALIBRATION >, gtsam::SmartProjectionRigFactor< CAMERA >, and gtsam::WhiteNoiseFactor.
|
pure virtual |
linearize to a GaussianFactor
Implemented in gtsam::LinearContainerFactor, gtsam::ShonanGaugeFactor, gtsam::AntiFactor, gtsam::KarcherMeanFactor< T >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::SmartProjectionRigFactor< CAMERA >, 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::NonlinearEquality< VALUE >, gtsam::NoiseModelFactor, gtsam::WhiteNoiseFactor, and gtsam::TriangulationFactor< CAMERA >.
|
overridevirtual |
Reimplemented from gtsam::Factor.
Reimplemented in gtsam::WhiteNoiseFactor, gtsam::PriorFactor< VALUE >, gtsam::ShonanFactor< d >, gtsam::ReferenceFrameFactor< POINT, TRANSFORM >, gtsam::Rot3AttitudeFactor, gtsam::Pose3AttitudeFactor, gtsam::RangeFactorWithTransform< A1, A2, T >, gtsam::PoseRotationPrior< POSE >, gtsam::PoseTranslationPrior< POSE >, gtsam::RotateFactor, gtsam::RotateDirectionsFactor, gtsam::SmartFactorBase< CAMERA >, gtsam::SmartFactorBase< PinholePose< CALIBRATION > >, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::SmartProjectionPoseFactor< CALIBRATION >, gtsam::SmartProjectionRigFactor< CAMERA >, gtsam::TriangulationFactor< CAMERA >, gtsam::RangeFactor< A1, A2, T >, gtsam::OrientedPlane3DirectionPrior, and gtsam::OrientedPlane3Factor.
|
virtual |
Clones a factor and fully replaces its keys.
new_keys | is the full replacement set of keys |
Reimplemented in gtsam::LinearContainerFactor.
|
virtual |
Creates a shared_ptr clone of the factor with different keys using a map from old->new keys.
Reimplemented in gtsam::LinearContainerFactor.
|
inlinevirtual |
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.