gtsam 4.2.0
gtsam
|
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.
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. More... | |
bool | equals (const NonlinearFactor &f, double tol=1e-9) const override |
Check if two factors are equal. More... | |
size_t | dim () const override |
get the dimension of the factor (number of rows on linearization) More... | |
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) \). More... | |
Vector | whitenedError (const Values &c) const |
Vector of errors, whitened This is the raw error, i.e., i.e. More... | |
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. More... | |
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) \). More... | |
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. | |
virtual | ~NonlinearFactor () |
Destructor. | |
double | error (const HybridValues &c) const override |
All factor types need to implement an error function. More... | |
virtual bool | active (const Values &) const |
Checks whether a factor should be used based on a set of values. More... | |
virtual shared_ptr | clone () const |
Creates a shared_ptr clone of the factor - needs to be specialized to allow for subclasses. More... | |
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. More... | |
virtual shared_ptr | rekey (const KeyVector &new_keys) const |
Clones a factor and fully replaces its keys. More... | |
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) More... | |
![]() | |
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 More... | |
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. | |
![]() | |
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 NonlinearFactor | Base |
typedef NoiseModelFactor | This |
![]() | |
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. More... | |
template<typename ITERATOR > | |
Factor (ITERATOR first, ITERATOR last) | |
Construct factor from iterator keys. More... | |
Protected Attributes | |
SharedNoiseModel | noiseModel_ |
![]() | |
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. More... | |
template<typename ITERATOR > | |
static Factor | FromIterators (ITERATOR first, ITERATOR last) |
Construct factor from iterator keys. More... | |
|
inlineoverridevirtual |
get the dimension of the factor (number of rows on linearization)
Implements gtsam::NonlinearFactor.
|
overridevirtual |
Check if two factors are equal.
Reimplemented from gtsam::NonlinearFactor.
Reimplemented in gtsam::PriorFactor< VALUE >, gtsam::ShonanFactor< d >, gtsam::BetweenFactor< VALUE >, gtsam::EssentialMatrixConstraint, gtsam::FrobeniusBetweenFactor< Rot >, gtsam::OrientedPlane3DirectionPrior, gtsam::PoseRotationPrior< POSE >, gtsam::PoseTranslationPrior< POSE >, gtsam::ExpressionFactor< typename Bearing< A1, A2 >::result_type >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::ExpressionFactor< typename Range< A1, A1 >::result_type >, gtsam::GenericStereoFactor< POSE, LANDMARK >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::GeneralSFMFactor2< CALIBRATION >, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, and gtsam::TriangulationFactor< CAMERA >.
|
overridevirtual |
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.
|
overridevirtual |
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::GeneralSFMFactor< CAMERA, LANDMARK >, gtsam::ExpressionFactor< typename Bearing< A1, A2 >::result_type >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::ExpressionFactor< typename Range< A1, A1 >::result_type >, and gtsam::TriangulationFactor< CAMERA >.
|
overridevirtual |
Print.
Reimplemented from gtsam::NonlinearFactor.
Reimplemented in gtsam::PriorFactor< VALUE >, gtsam::ShonanFactor< d >, gtsam::FrobeniusBetweenFactor< Rot >, gtsam::ReferenceFrameFactor< POINT, TRANSFORM >, gtsam::ExpressionFactor< typename Bearing< A1, A2 >::result_type >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::ExpressionFactor< typename Range< A1, A1 >::result_type >, gtsam::FunctorizedFactor< double, ParameterMatrix< P > >, gtsam::FunctorizedFactor< double, BASIS::Parameters >, gtsam::FunctorizedFactor< double, Vector >, gtsam::FunctorizedFactor< T, ParameterMatrix< traits< T >::dimension > >, gtsam::FunctorizedFactor< Vector, ParameterMatrix< M > >, gtsam::RangeFactorWithTransform< A1, A2, T >, gtsam::BetweenFactor< VALUE >, gtsam::EssentialMatrixConstraint, gtsam::EssentialMatrixFactor, gtsam::EssentialMatrixFactor2, gtsam::EssentialMatrixFactor3, gtsam::EssentialMatrixFactor4< CALIBRATION >, gtsam::PoseRotationPrior< POSE >, gtsam::PoseTranslationPrior< POSE >, gtsam::GenericProjectionFactor< POSE, LANDMARK, CALIBRATION >, gtsam::RotateFactor, gtsam::RotateDirectionsFactor, gtsam::GenericStereoFactor< POSE, LANDMARK >, gtsam::TriangulationFactor< CAMERA >, gtsam::BearingFactor< A1, A2, T >, gtsam::BearingRangeFactor< A1, A2, B, R >, gtsam::RangeFactor< A1, A2, T >, gtsam::OrientedPlane3DirectionPrior, gtsam::OrientedPlane3Factor, gtsam::GeneralSFMFactor< CAMERA, LANDMARK >, and gtsam::GeneralSFMFactor2< CALIBRATION >.
|
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< typename Bearing< A1, A2 >::result_type >, gtsam::ExpressionFactor< BearingRange< A1, A2 > >, gtsam::ExpressionFactor< double >, gtsam::ExpressionFactor< typename Range< A1, A1 >::result_type >, gtsam::NoiseModelFactorN< ValueTypes >, gtsam::NoiseModelFactorN< Rot3, Rot3, Vector3 >, gtsam::NoiseModelFactorN< Pose3, double >, gtsam::NoiseModelFactorN< VALUE, VALUE >, gtsam::NoiseModelFactorN< VALUE >, gtsam::NoiseModelFactorN< VALUE1, VALUE2 >, gtsam::NoiseModelFactorN< Pose3, Vector3, Pose3, Vector3, imuBias::ConstantBias, imuBias::ConstantBias >, gtsam::NoiseModelFactorN< ParameterMatrix< P > >, gtsam::NoiseModelFactorN< NavState, NavState >, gtsam::NoiseModelFactorN< BASIS::Parameters >, gtsam::NoiseModelFactorN< Pose3, Pose3 >, gtsam::NoiseModelFactorN< EssentialMatrix >, gtsam::NoiseModelFactorN< EssentialMatrix, double >, gtsam::NoiseModelFactorN< EssentialMatrix, CALIBRATION >, gtsam::NoiseModelFactorN< Vector >, gtsam::NoiseModelFactorN< Rot, Rot >, gtsam::NoiseModelFactorN< Rot >, gtsam::NoiseModelFactorN< T >, gtsam::NoiseModelFactorN< T1, T2 >, gtsam::NoiseModelFactorN< Pose3 >, gtsam::NoiseModelFactorN< NavState >, gtsam::NoiseModelFactorN< CAMERA, LANDMARK >, gtsam::NoiseModelFactorN< Pose3, Point3, CALIBRATION >, gtsam::NoiseModelFactorN< Pose3, Point3 >, gtsam::NoiseModelFactorN< POSE, LANDMARK >, gtsam::NoiseModelFactorN< Pose3, Vector3, Pose3, Vector3, imuBias::ConstantBias >, gtsam::NoiseModelFactorN< NavState, NavState, imuBias::ConstantBias >, gtsam::NoiseModelFactorN< Rot2 >, gtsam::NoiseModelFactorN< Rot3 >, gtsam::NoiseModelFactorN< Point3, Point3 >, gtsam::NoiseModelFactorN< double, Unit3, Point3 >, gtsam::NoiseModelFactorN< POSE >, gtsam::NoiseModelFactorN< ParameterMatrix< traits< T >::dimension > >, gtsam::NoiseModelFactorN< T, T >, gtsam::NoiseModelFactorN< OrientedPlane3 >, gtsam::NoiseModelFactorN< Pose3, OrientedPlane3 >, gtsam::NoiseModelFactorN< POINT, TRANSFORM, POINT >, gtsam::NoiseModelFactorN< SOn, SOn >, gtsam::NoiseModelFactorN< Point3 >, and gtsam::NoiseModelFactorN< ParameterMatrix< M > >.
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