GTSAM
4.0.2
C++ library for smoothing and mapping (SAM)
|
#include <NonlinearFactor.h>
Public Types | |
typedef std::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 |
Protected Attributes | |
KeyVector | keys_ |
The keys involved in this factor. | |
Standard Constructors | |
template<typename CONTAINER > | |
static Factor | FromKeys (const CONTAINER &keys) |
template<typename ITERATOR > | |
static Factor | FromIterators (ITERATOR first, ITERATOR last) |
Standard Interface | |
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 |
const_iterator | end () const |
size_t | size () const |
Testable | |
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 | |
Advanced Interface | |
KeyVector & | keys () |
iterator | begin () |
iterator | end () |
Standard Constructors | |
NonlinearFactor () | |
template<typename CONTAINER > | |
NonlinearFactor (const CONTAINER &keys) | |
Testable | |
void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override |
virtual bool | equals (const NonlinearFactor &f, double tol=1e-9) const |
Standard Interface | |
virtual double | error (const Values &c) const |
double | error (const HybridValues &c) const override |
virtual size_t | dim () const =0 |
virtual bool | active (const Values &) const |
virtual std::shared_ptr< GaussianFactor > | linearize (const Values &c) const =0 |
virtual shared_ptr | clone () const |
virtual shared_ptr | rekey (const std::map< Key, Key > &rekey_mapping) const |
virtual shared_ptr | rekey (const KeyVector &new_keys) const |
virtual bool | sendable () const |
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:
|
inline |
Default constructor for I/O only
|
inline |
Constructor from a collection of 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::BoundingConstraint2< VALUE1, VALUE2 >, gtsam::AntiFactor, and gtsam::BoundingConstraint1< VALUE >.
|
inlineinherited |
Iterator at beginning of involved variable keys
|
inlineinherited |
Iterator at beginning of involved variable keys
|
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::EssentialMatrixFactor4< CALIBRATION >, gtsam::NonlinearEquality2< T >, gtsam::CombinedImuFactor, gtsam::ImuFactor2, gtsam::EssentialMatrixFactor3, gtsam::NonlinearEquality1< VALUE >, gtsam::GeneralSFMFactor2< CALIBRATION >, gtsam::ImuFactor, gtsam::LinearizedHessianFactor, gtsam::PendulumFactorPk1, gtsam::FunctorizedFactor2< R, T1, T2 >, gtsam::MagFactor3, gtsam::Pose3AttitudeFactor, gtsam::SmartRangeFactor, gtsam::NonlinearEquality< VALUE >, gtsam::AHRSFactor, gtsam::EssentialMatrixFactor2, gtsam::ExpressionFactor< T >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::MagFactor2, gtsam::PendulumFactorPk, gtsam::GPSFactor2, gtsam::ProjectionFactorRollingShutter, gtsam::RangeFactorWithTransform< A1, A2, T >, gtsam::LinearContainerFactor, gtsam::LinearizedJacobianFactor, gtsam::Rot3AttitudeFactor, gtsam::MagFactor1, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::DiscreteEulerPoincareHelicopter, gtsam::MultiProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::ProjectionFactorPPP< POSE, LANDMARK, CALIBRATION >, gtsam::TransformBtwRobotsUnaryFactorEM< VALUE >, gtsam::GenericStereoFactor< POSE, LANDMARK >, gtsam::TriangulationFactor< CAMERA >, gtsam::RotateDirectionsFactor, gtsam::PendulumFactor2, gtsam::ReferenceFrameFactor< POINT, TRANSFORM >, gtsam::FunctorizedFactor< R, T >, gtsam::PartialPriorFactor< VALUE >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::PartialPriorFactor< PoseRTV >, gtsam::MagPoseFactor< POSE >, gtsam::ProjectionFactorPPPC< POSE, LANDMARK, CALIBRATION >, gtsam::TransformBtwRobotsUnaryFactor< VALUE >, gtsam::BetweenFactor< VALUE >, gtsam::EssentialMatrixFactor, gtsam::VelocityConstraint, gtsam::PriorFactor< VALUE >, gtsam::GPSFactor, gtsam::PoseToPointFactor< POSE, POINT >, gtsam::BarometricFactor, gtsam::EssentialMatrixConstraint, gtsam::DummyFactor, gtsam::PoseBetweenFactor< POSE >, gtsam::BearingRangeFactor< A1, A2, B, R >, gtsam::PosePriorFactor< POSE >, gtsam::MagFactor, gtsam::PoseTranslationPrior< POSE >, gtsam::PoseRotationPrior< POSE >, gtsam::FullIMUFactor< POSE >, gtsam::AntiFactor, gtsam::RangeFactor< A1, A2, T >, gtsam::IMUFactor< POSE >, gtsam::RelativeElevationFactor, gtsam::PendulumFactor1, gtsam::Reconstruction, gtsam::RotateFactor, and gtsam::VelocityConstraint3.
|
pure virtual |
get the dimension of the factor (number of rows on linearization)
Implemented in gtsam::BetweenFactorEM< VALUE >, gtsam::TransformBtwRobotsUnaryFactorEM< VALUE >, gtsam::LinearizedHessianFactor, gtsam::NoiseModelFactor, gtsam::TransformBtwRobotsUnaryFactor< VALUE >, gtsam::SmartFactorBase< CAMERA >, gtsam::SmartFactorBase< PinholePose< CALIBRATION > >, gtsam::SmartFactorBase< StereoCamera >, gtsam::SmartFactorBase< PinholeCamera< Cal3Bundler > >, gtsam::LinearizedJacobianFactor, gtsam::WhiteNoiseFactor, gtsam::ShonanGaugeFactor, gtsam::LinearContainerFactor, gtsam::AntiFactor, gtsam::KarcherMeanFactor< T >, and gtsam::DummyFactor.
|
inlineinherited |
Iterator at end of involved variable keys
|
inlineinherited |
Iterator at end of involved variable keys
|
virtual |
Check if two factors are equal
Reimplemented in gtsam::CombinedImuFactor, gtsam::ImuFactor2, gtsam::GeneralSFMFactor2< CALIBRATION >, gtsam::NoiseModelFactor, gtsam::SmartProjectionPoseFactorRollingShutter< CAMERA >, gtsam::FunctorizedFactor2< R, T1, T2 >, gtsam::ImuFactor, gtsam::LinearizedHessianFactor, gtsam::InvDepthFactorVariant3b, gtsam::Pose3AttitudeFactor, gtsam::SmartProjectionRigFactor< CAMERA >, gtsam::SmartFactorBase< CAMERA >, gtsam::SmartFactorBase< PinholePose< CALIBRATION > >, gtsam::SmartFactorBase< StereoCamera >, gtsam::SmartFactorBase< PinholeCamera< Cal3Bundler > >, gtsam::AHRSFactor, gtsam::ProjectionFactorRollingShutter, gtsam::GPSFactor2, gtsam::EquivInertialNavFactor_GlobalVel_NoBias< POSE, VELOCITY >, gtsam::EquivInertialNavFactor_GlobalVel< POSE, VELOCITY, IMUBIAS >, gtsam::FrobeniusBetweenFactor< Rot >, gtsam::InertialNavFactor_GlobalVelocity< POSE, VELOCITY, IMUBIAS >, gtsam::SmartStereoProjectionFactorPP, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::LinearizedJacobianFactor, gtsam::Rot3AttitudeFactor, gtsam::MultiProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::TransformBtwRobotsUnaryFactorEM< VALUE >, gtsam::NonlinearEquality< VALUE >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::SmartStereoProjectionPoseFactor, gtsam::SmartStereoProjectionFactor, gtsam::GenericStereoFactor< POSE, LANDMARK >, gtsam::ProjectionFactorPPP< POSE, LANDMARK, CALIBRATION >, gtsam::TriangulationFactor< CAMERA >, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::FunctorizedFactor< R, T >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::SmartProjectionPoseFactor< CALIBRATION >, gtsam::MagPoseFactor< POSE >, gtsam::ProjectionFactorPPPC< POSE, LANDMARK, CALIBRATION >, gtsam::PartialPriorFactor< VALUE >, gtsam::TransformBtwRobotsUnaryFactor< VALUE >, gtsam::PartialPriorFactor< PoseRTV >, gtsam::BetweenFactor< VALUE >, gtsam::BetweenFactorEM< VALUE >, gtsam::ExpressionFactor< T >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::PriorFactor< VALUE >, gtsam::SmartRangeFactor, gtsam::GaussMarkov1stOrderFactor< VALUE >, gtsam::PoseBetweenFactor< POSE >, gtsam::InvDepthFactor3< POSE, LANDMARK, INVDEPTH >, gtsam::GPSFactor, gtsam::InvDepthFactorVariant2, gtsam::OrientedPlane3DirectionPrior, gtsam::PoseTranslationPrior< POSE >, gtsam::InvDepthFactorVariant3a, gtsam::BarometricFactor, gtsam::EssentialMatrixConstraint, gtsam::InvDepthFactorVariant1, gtsam::PosePriorFactor< POSE >, gtsam::BiasedGPSFactor, gtsam::ShonanFactor< d >, gtsam::PoseRotationPrior< POSE >, gtsam::LinearContainerFactor, gtsam::AntiFactor, gtsam::FullIMUFactor< POSE >, gtsam::PoseToPointFactor< POSE, POINT >, gtsam::RelativeElevationFactor, gtsam::IMUFactor< POSE >, and gtsam::DummyFactor.
|
overridevirtual |
All factor types need to implement an error function. In factor graphs, this is the negative log-likelihood.
Reimplemented from gtsam::Factor.
|
inlinestaticprotectedinherited |
Construct factor from iterator keys. This is called internally from derived factor static factor methods, as a workaround for not being able to call the protected constructors above.
|
inlinestaticprotectedinherited |
Construct factor from container of keys. This is called internally from derived factor static factor methods, as a workaround for not being able to call the protected constructors above.
|
inlineinherited |
|
pure virtual |
linearize to a GaussianFactor
Implemented in gtsam::SmartProjectionPoseFactorRollingShutter< CAMERA >, gtsam::SmartProjectionRigFactor< CAMERA >, gtsam::SmartStereoProjectionFactor, gtsam::SmartProjectionFactor< CAMERA >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::NoiseModelFactor, gtsam::SmartStereoProjectionFactorPP, gtsam::LinearizedHessianFactor, gtsam::TransformBtwRobotsUnaryFactorEM< VALUE >, gtsam::NonlinearEquality< VALUE >, gtsam::WhiteNoiseFactor, gtsam::TriangulationFactor< CAMERA >, gtsam::LinearizedJacobianFactor, gtsam::TransformBtwRobotsUnaryFactor< VALUE >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::BetweenFactorEM< VALUE >, gtsam::ExpressionFactor< T >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::LinearContainerFactor, gtsam::ShonanGaugeFactor, gtsam::AntiFactor, gtsam::KarcherMeanFactor< T >, gtsam::DummyFactor, and gtsam::PinholeFactor.
|
overridevirtual |
Reimplemented from gtsam::Factor.
Reimplemented in gtsam::EssentialMatrixFactor4< CALIBRATION >, gtsam::EssentialMatrixFactor3, gtsam::GeneralSFMFactor2< CALIBRATION >, gtsam::NoiseModelFactor, gtsam::LinearizedHessianFactor, gtsam::SmartProjectionPoseFactorRollingShutter< CAMERA >, gtsam::InvDepthFactorVariant3b, gtsam::SmartProjectionRigFactor< CAMERA >, gtsam::SmartFactorBase< CAMERA >, gtsam::SmartFactorBase< PinholePose< CALIBRATION > >, gtsam::SmartFactorBase< StereoCamera >, gtsam::SmartFactorBase< PinholeCamera< Cal3Bundler > >, gtsam::EssentialMatrixFactor2, gtsam::RangeFactorWithTransform< A1, A2, T >, gtsam::ProjectionFactorRollingShutter, gtsam::FrobeniusBetweenFactor< Rot >, gtsam::EquivInertialNavFactor_GlobalVel< POSE, VELOCITY, IMUBIAS >, gtsam::EquivInertialNavFactor_GlobalVel_NoBias< POSE, VELOCITY >, gtsam::SmartStereoProjectionFactorPP, gtsam::LinearizedJacobianFactor, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::InertialNavFactor_GlobalVelocity< POSE, VELOCITY, IMUBIAS >, gtsam::SmartStereoProjectionPoseFactor, gtsam::WhiteNoiseFactor, gtsam::MultiProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::ReferenceFrameFactor< POINT, TRANSFORM >, gtsam::ProjectionFactorPPP< POSE, LANDMARK, CALIBRATION >, gtsam::SmartStereoProjectionFactor, gtsam::GenericStereoFactor< POSE, LANDMARK >, gtsam::TriangulationFactor< CAMERA >, gtsam::TransformBtwRobotsUnaryFactorEM< VALUE >, gtsam::SmartProjectionPoseFactor< CALIBRATION >, gtsam::SmartProjectionFactor< CAMERA >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >, gtsam::RotateDirectionsFactor, gtsam::VelocityConstraint, gtsam::ProjectionFactorPPPC< POSE, LANDMARK, CALIBRATION >, gtsam::PartialPriorFactor< VALUE >, gtsam::PartialPriorFactor< PoseRTV >, gtsam::BetweenFactor< VALUE >, gtsam::TransformBtwRobotsUnaryFactor< VALUE >, gtsam::BetweenFactorEM< VALUE >, gtsam::BearingRangeFactor< A1, A2, B, R >, gtsam::EssentialMatrixFactor, gtsam::PoseTranslationPrior< POSE >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::SmartRangeFactor, gtsam::PriorFactor< VALUE >, gtsam::GaussMarkov1stOrderFactor< VALUE >, gtsam::RangeFactor< A1, A2, T >, gtsam::OrientedPlane3DirectionPrior, gtsam::EssentialMatrixConstraint, gtsam::PoseRotationPrior< POSE >, gtsam::InvDepthFactor3< POSE, LANDMARK, INVDEPTH >, gtsam::InvDepthFactorVariant2, gtsam::InvDepthFactorVariant3a, gtsam::LocalOrientedPlane3Factor, gtsam::PoseBetweenFactor< POSE >, gtsam::InvDepthFactorVariant1, gtsam::FullIMUFactor< POSE >, gtsam::PosePriorFactor< POSE >, gtsam::ShonanFactor< d >, gtsam::RelativeElevationFactor, gtsam::IMUFactor< POSE >, gtsam::AntiFactor, gtsam::BiasedGPSFactor, gtsam::BearingFactor< A1, A2, T >, gtsam::PoseToPointFactor< POSE, POINT >, gtsam::RotateFactor, gtsam::OrientedPlane3Factor, and gtsam::DummyFactor.
|
virtual |
Creates a shared_ptr clone of the factor with different keys using a map from old->new keys
Reimplemented in gtsam::LinearContainerFactor.
|
virtual |
Clones a factor and fully replaces its keys
new_keys | is the full replacement set of 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.
|
inlineinherited |