Public Member Functions | Private Types | Private Attributes | List of all members
gtsam::FunctorizedFactor< R, T > Class Template Reference

#include <FunctorizedFactor.h>

Inheritance diagram for gtsam::FunctorizedFactor< R, T >:
Inheritance graph
[legend]

Public Member Functions

NonlinearFactor::shared_ptr clone () const override
 
Vector evaluateError (const T &params, OptionalMatrixType H) const override
 
 FunctorizedFactor ()
 
 FunctorizedFactor (Key key, const R &z, const SharedNoiseModel &model, const std::function< R(T, OptionalMatrixType)> func)
 
 ~FunctorizedFactor () override
 
Testable
void print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
 print More...
 
bool equals (const NonlinearFactor &other, double tol=1e-9) const override
 
- Public Member Functions inherited from gtsam::NoiseModelFactorN< T >
Key key () const
 
 ~NoiseModelFactorN () override
 
 NoiseModelFactorN ()
 Default Constructor for I/O. More...
 
 NoiseModelFactorN (const SharedNoiseModel &noiseModel, KeyType< ValueTypes >... keys)
 
 NoiseModelFactorN (const SharedNoiseModel &noiseModel, CONTAINER keys)
 
Vector unwhitenedError (const Values &x, OptionalMatrixVecType H=nullptr) const override
 
virtual Vector evaluateError (const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
 
Vector evaluateError (const ValueTypes &... x, MatrixTypeT< ValueTypes > &... H) const
 
Vector evaluateError (const ValueTypes &... x) const
 
AreAllMatrixRefs< Vector, OptionalJacArgs... > evaluateError (const ValueTypes &... x, OptionalJacArgs &&... H) const
 
AreAllMatrixPtrs< Vector, OptionalJacArgs... > evaluateError (const ValueTypes &... x, OptionalJacArgs &&... H) const
 
Key key1 () const
 
Key key2 () const
 
Key key3 () const
 
Key key4 () const
 
Key key5 () const
 
Key key6 () const
 
- Public Member Functions inherited from gtsam::NoiseModelFactor
shared_ptr cloneWithNewNoiseModel (const SharedNoiseModel newNoise) const
 
size_t dim () const override
 
bool equals (const NonlinearFactor &f, double tol=1e-9) const override
 
double error (const Values &c) const override
 
std::shared_ptr< GaussianFactorlinearize (const Values &x) const override
 
const SharedNoiseModelnoiseModel () const
 access to the noise model More...
 
 NoiseModelFactor ()
 
template<typename CONTAINER >
 NoiseModelFactor (const SharedNoiseModel &noiseModel, const CONTAINER &keys)
 
void print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
 
Vector unweightedWhitenedError (const Values &c) const
 
Vector unwhitenedError (const Values &x, std::vector< Matrix > &H) const
 
double weight (const Values &c) const
 
Vector whitenedError (const Values &c) const
 
 ~NoiseModelFactor () override
 
- Public Member Functions inherited from gtsam::NonlinearFactor
 NonlinearFactor ()
 
template<typename CONTAINER >
 NonlinearFactor (const CONTAINER &keys)
 
double error (const HybridValues &c) const override
 
virtual bool active (const Values &) 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
 
- Public Member Functions inherited from gtsam::Factor
virtual ~Factor ()=default
 Default destructor. More...
 
bool empty () const
 Whether the factor is empty (involves zero variables). More...
 
Key front () const
 First key. More...
 
Key back () const
 Last key. More...
 
const_iterator find (Key key) const
 find More...
 
const KeyVectorkeys () const
 Access the factor's involved variable keys. More...
 
const_iterator begin () const
 
const_iterator end () const
 
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 More...
 
KeyVectorkeys ()
 
iterator begin ()
 
iterator end ()
 

Private Types

using Base = NoiseModelFactorN< T >
 

Private Attributes

std::function< R(T, OptionalMatrixType)> func_
 functor instance More...
 
R measured_
 value that is compared with functor return value More...
 
SharedNoiseModel noiseModel_
 noise model More...
 

Additional Inherited Members

- Public Types inherited from gtsam::NoiseModelFactorN< T >
enum  
 N is the number of variables (N-way factor) More...
 
using ValueType = typename std::tuple_element< I - 1, std::tuple< ValueTypes... > >::type
 
- Public Types inherited from gtsam::NoiseModelFactor
typedef std::shared_ptr< Thisshared_ptr
 
- Public Types inherited from gtsam::NonlinearFactor
typedef std::shared_ptr< Thisshared_ptr
 
- Public Types inherited from gtsam::Factor
typedef KeyVector::const_iterator const_iterator
 Const iterator over keys. More...
 
typedef KeyVector::iterator iterator
 Iterator over keys. More...
 
- Protected Types inherited from gtsam::NoiseModelFactorN< T >
using Base = NoiseModelFactor
 
using KeyType = Key
 
using MatrixTypeT = Matrix
 
using OptionalMatrixTypeT = Matrix *
 
using This = NoiseModelFactorN< ValueTypes... >
 
using IsConvertible = typename std::enable_if< std::is_convertible< From, To >::value, void >::type
 
using IndexIsValid = typename std::enable_if<(I >=1) &&(I<=N), void >::type
 
using ContainerElementType = typename std::decay< decltype(*std::declval< Container >().begin())>::type
 
using IsContainerOfKeys = IsConvertible< ContainerElementType< Container >, Key >
 
using AreAllMatrixRefs = std::enable_if_t<(... &&std::is_convertible< Args, Matrix &>::value), Ret >
 
using IsMatrixPointer = std::is_same< typename std::decay_t< Arg >, Matrix *>
 
using IsNullpointer = std::is_same< typename std::decay_t< Arg >, std::nullptr_t >
 
using AreAllMatrixPtrs = std::enable_if_t<(... &&(IsMatrixPointer< Args >::value||IsNullpointer< Args >::value)), Ret >
 
- Protected Types inherited from gtsam::NoiseModelFactor
typedef NonlinearFactor Base
 
typedef NoiseModelFactor This
 
- Protected Types inherited from gtsam::NonlinearFactor
typedef Factor Base
 
typedef NonlinearFactor This
 
- Protected Member Functions inherited from gtsam::NoiseModelFactor
 NoiseModelFactor (const SharedNoiseModel &noiseModel)
 
- Protected Member Functions inherited from gtsam::Factor
 Factor ()
 
template<typename CONTAINER >
 Factor (const CONTAINER &keys)
 
template<typename ITERATOR >
 Factor (ITERATOR first, ITERATOR last)
 
- Static Protected Member Functions inherited from gtsam::Factor
template<typename CONTAINER >
static Factor FromKeys (const CONTAINER &keys)
 
template<typename ITERATOR >
static Factor FromIterators (ITERATOR first, ITERATOR last)
 
- Protected Attributes inherited from gtsam::NoiseModelFactor
SharedNoiseModel noiseModel_
 
- Protected Attributes inherited from gtsam::Factor
KeyVector keys_
 The keys involved in this factor. More...
 

Detailed Description

template<typename R, typename T>
class gtsam::FunctorizedFactor< R, T >

Factor which evaluates provided unary functor and uses the result to compute error with respect to the provided measurement.

Template parameters are

Parameters
RThe return type of the functor after evaluation.
TThe argument type for the functor.

Example: Key key = Symbol('X', 0); auto model = noiseModel::Isotropic::Sigma(9, 1);

/// Functor that takes a matrix and multiplies every element by m class MultiplyFunctor { double m_; ///< simple multiplier public: MultiplyFunctor(double m) : m_(m) {} Matrix operator()(const Matrix &X, OptionalJacobian<-1, -1> H = {}) const { if (H) *H = m_ * Matrix::Identity(X.rows()*X.cols(), X.rows()*X.cols()); return m_ * X; } };

Matrix measurement = Matrix::Identity(3, 3); double multiplier = 2.0;

FunctorizedFactor<Matrix, Matrix> factor(keyX, measurement, model, MultiplyFunctor(multiplier));

Definition at line 59 of file FunctorizedFactor.h.

Member Typedef Documentation

◆ Base

template<typename R, typename T>
using gtsam::FunctorizedFactor< R, T >::Base = NoiseModelFactorN<T>
private

Definition at line 61 of file FunctorizedFactor.h.

Constructor & Destructor Documentation

◆ FunctorizedFactor() [1/2]

template<typename R, typename T>
gtsam::FunctorizedFactor< R, T >::FunctorizedFactor ( )
inline

default constructor - only use for serialization

Definition at line 73 of file FunctorizedFactor.h.

◆ FunctorizedFactor() [2/2]

template<typename R, typename T>
gtsam::FunctorizedFactor< R, T >::FunctorizedFactor ( Key  key,
const R z,
const SharedNoiseModel model,
const std::function< R(T, OptionalMatrixType)>  func 
)
inline

Construct with given x and the parameters of the basis

Parameters
keyFactor key
zMeasurement object of same type as that returned by functor
modelNoise model
funcThe instance of the functor object

Definition at line 82 of file FunctorizedFactor.h.

◆ ~FunctorizedFactor()

template<typename R, typename T>
gtsam::FunctorizedFactor< R, T >::~FunctorizedFactor ( )
inlineoverride

Definition at line 86 of file FunctorizedFactor.h.

Member Function Documentation

◆ clone()

template<typename R, typename T>
NonlinearFactor::shared_ptr gtsam::FunctorizedFactor< R, T >::clone ( ) const
inlineoverridevirtual
Returns
a deep copy of this factor

Reimplemented from gtsam::NonlinearFactor.

Definition at line 89 of file FunctorizedFactor.h.

◆ equals()

template<typename R, typename T>
bool gtsam::FunctorizedFactor< R, T >::equals ( const NonlinearFactor f,
double  tol = 1e-9 
) const
inlineoverridevirtual

Check if two factors are equal

Reimplemented from gtsam::NonlinearFactor.

Definition at line 113 of file FunctorizedFactor.h.

◆ evaluateError()

template<typename R, typename T>
Vector gtsam::FunctorizedFactor< R, T >::evaluateError ( const T params,
OptionalMatrixType  H 
) const
inlineoverride

Definition at line 94 of file FunctorizedFactor.h.

◆ print()

template<typename R, typename T>
void gtsam::FunctorizedFactor< R, T >::print ( const std::string &  s = "",
const KeyFormatter formatter = DefaultKeyFormatter 
) const
inlineoverridevirtual

print

Reimplemented from gtsam::Factor.

Definition at line 102 of file FunctorizedFactor.h.

Member Data Documentation

◆ func_

template<typename R, typename T>
std::function<R(T, OptionalMatrixType)> gtsam::FunctorizedFactor< R, T >::func_
private

functor instance

Definition at line 65 of file FunctorizedFactor.h.

◆ measured_

template<typename R, typename T>
R gtsam::FunctorizedFactor< R, T >::measured_
private

value that is compared with functor return value

Definition at line 63 of file FunctorizedFactor.h.

◆ noiseModel_

template<typename R, typename T>
SharedNoiseModel gtsam::FunctorizedFactor< R, T >::noiseModel_
private

noise model

Definition at line 64 of file FunctorizedFactor.h.


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


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:46:19