Base class for smart factors This base class has no internal point, but it has a measurement, noise model and an optional sensor pose. This class mainly computes the derivatives and returns them as a variety of factors. The methods take a Cameras argument, which should behave like PinholeCamera, and the value of a point, which is kept in the base class. More...
#include <SmartFactorBase.h>
Public Types | |
typedef CameraSet< CAMERA > | Cameras |
We use the new CameraSte data structure to refer to a set of cameras. More... | |
typedef std::vector< MatrixZD, Eigen::aligned_allocator< MatrixZD > > | FBlocks |
typedef Eigen::Matrix< double, ZDim, Dim > | MatrixZD |
Public Types inherited from gtsam::NonlinearFactor | |
typedef boost::shared_ptr< This > | shared_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... | |
Public Member Functions | |
void | add (const Z &measured, const Key &key) |
void | add (const ZVector &measurements, const KeyVector &cameraKeys) |
template<class SFM_TRACK > | |
void | add (const SFM_TRACK &trackToAdd) |
Pose3 | body_P_sensor () const |
virtual Cameras | cameras (const Values &values) const |
Collect all cameras: important that in key order. More... | |
template<class POINT > | |
void | computeJacobians (FBlocks &Fs, Matrix &E, Vector &b, const Cameras &cameras, const POINT &point) const |
template<class POINT > | |
void | computeJacobiansSVD (FBlocks &Fs, Matrix &Enull, Vector &b, const Cameras &cameras, const POINT &point) const |
SVD version. More... | |
virtual void | correctForMissingMeasurements (const Cameras &cameras, Vector &ue, boost::optional< typename Cameras::FBlocks & > Fs=boost::none, boost::optional< Matrix & > E=boost::none) const |
boost::shared_ptr< RegularHessianFactor< Dim > > | createHessianFactor (const Cameras &cameras, const Point3 &point, const double lambda=0.0, bool diagonalDamping=false) const |
Linearize to a Hessianfactor. More... | |
boost::shared_ptr< JacobianFactorQ< Dim, ZDim > > | createJacobianQFactor (const Cameras &cameras, const Point3 &point, double lambda=0.0, bool diagonalDamping=false) const |
boost::shared_ptr< JacobianFactor > | createJacobianSVDFactor (const Cameras &cameras, const Point3 &point, double lambda=0.0) const |
boost::shared_ptr< RegularImplicitSchurFactor< CAMERA > > | createRegularImplicitSchurFactor (const Cameras &cameras, const Point3 &point, double lambda=0.0, bool diagonalDamping=false) const |
Return Jacobians as RegularImplicitSchurFactor with raw access. More... | |
size_t | dim () const override |
get the dimension (number of rows!) of the factor More... | |
bool | equals (const NonlinearFactor &p, double tol=1e-9) const override |
equals More... | |
const ZVector & | measured () const |
void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override |
SmartFactorBase () | |
Default Constructor, for serialization. More... | |
SmartFactorBase (const SharedNoiseModel &sharedNoiseModel, boost::optional< Pose3 > body_P_sensor=boost::none, size_t expectedNumberCameras=10) | |
Constructor. More... | |
template<class POINT > | |
double | totalReprojectionError (const Cameras &cameras, const POINT &point) const |
template<class POINT > | |
Vector | unwhitenedError (const Cameras &cameras, const POINT &point, boost::optional< typename Cameras::FBlocks & > Fs=boost::none, boost::optional< Matrix & > E=boost::none) const |
void | updateAugmentedHessian (const Cameras &cameras, const Point3 &point, const double lambda, bool diagonalDamping, SymmetricBlockMatrix &augmentedHessian, const KeyVector allKeys) const |
template<class POINT > | |
Vector | whitenedError (const Cameras &cameras, const POINT &point) const |
void | whitenJacobians (FBlocks &F, Matrix &E, Vector &b) const |
Whiten the Jacobians computed by computeJacobians using noiseModel_. More... | |
~SmartFactorBase () override | |
Virtual destructor, subclasses from NonlinearFactor. More... | |
Public Member Functions inherited from gtsam::NonlinearFactor | |
NonlinearFactor () | |
template<typename CONTAINER > | |
NonlinearFactor (const CONTAINER &keys) | |
virtual | ~NonlinearFactor () |
virtual double | error (const Values &c) const =0 |
virtual bool | active (const Values &) const |
virtual boost::shared_ptr< GaussianFactor > | linearize (const Values &c) const =0 |
virtual shared_ptr | clone () const |
shared_ptr | rekey (const std::map< Key, Key > &rekey_mapping) const |
shared_ptr | rekey (const KeyVector &new_keys) const |
Public Member Functions inherited from gtsam::Factor | |
virtual | ~Factor ()=default |
Default destructor. More... | |
Key | front () const |
First key. More... | |
Key | back () const |
Last key. More... | |
const_iterator | find (Key key) const |
find More... | |
const KeyVector & | keys () 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... | |
KeyVector & | keys () |
iterator | begin () |
iterator | end () |
Static Public Member Functions | |
static void | FillDiagonalF (const FBlocks &Fs, Matrix &F) |
Create BIG block-diagonal matrix F from Fblocks. More... | |
static Matrix | PointCov (Matrix &E) |
Computes Point Covariance P from E. More... | |
Public Attributes | |
GTSAM_MAKE_ALIGNED_OPERATOR_NEW typedef boost::shared_ptr< This > | shared_ptr |
shorthand for a smart pointer to a factor More... | |
Static Public Attributes | |
static const int | Dim = traits<CAMERA>::dimension |
Camera dimension. More... | |
static const int | ZDim = traits<Z>::dimension |
Measurement dimension. More... | |
Protected Attributes | |
boost::optional< Pose3 > | body_P_sensor_ |
Pose of the camera in the body frame. More... | |
FBlocks | Fs |
ZVector | measured_ |
SharedIsotropic | noiseModel_ |
Protected Attributes inherited from gtsam::Factor | |
KeyVector | keys_ |
The keys involved in this factor. More... | |
Private Types | |
typedef NonlinearFactor | Base |
typedef SmartFactorBase< CAMERA > | This |
typedef CAMERA::Measurement | Z |
typedef CAMERA::MeasurementVector | ZVector |
Private Member Functions | |
template<class ARCHIVE > | |
void | serialize (ARCHIVE &ar, const unsigned int) |
Friends | |
class | boost::serialization::access |
Serialization function. More... | |
Additional Inherited Members | |
Protected Types inherited from gtsam::NonlinearFactor | |
typedef Factor | Base |
typedef NonlinearFactor | This |
Protected Member Functions inherited from gtsam::Factor | |
Factor () | |
template<typename CONTAINER > | |
Factor (const CONTAINER &keys) | |
template<typename ITERATOR > | |
Factor (ITERATOR first, ITERATOR last) | |
bool | equals (const This &other, double tol=1e-9) const |
check equality More... | |
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) |
Base class for smart factors This base class has no internal point, but it has a measurement, noise model and an optional sensor pose. This class mainly computes the derivatives and returns them as a variety of factors. The methods take a Cameras argument, which should behave like PinholeCamera, and the value of a point, which is kept in the base class.
Definition at line 48 of file SmartFactorBase.h.
|
private |
Definition at line 51 of file SmartFactorBase.h.
typedef CameraSet<CAMERA> gtsam::SmartFactorBase< CAMERA >::Cameras |
We use the new CameraSte data structure to refer to a set of cameras.
Definition at line 91 of file SmartFactorBase.h.
typedef std::vector<MatrixZD, Eigen::aligned_allocator<MatrixZD> > gtsam::SmartFactorBase< CAMERA >::FBlocks |
Definition at line 61 of file SmartFactorBase.h.
typedef Eigen::Matrix<double, ZDim, Dim> gtsam::SmartFactorBase< CAMERA >::MatrixZD |
Definition at line 60 of file SmartFactorBase.h.
|
private |
Definition at line 52 of file SmartFactorBase.h.
|
private |
Definition at line 53 of file SmartFactorBase.h.
|
private |
Definition at line 54 of file SmartFactorBase.h.
|
inline |
Default Constructor, for serialization.
Definition at line 94 of file SmartFactorBase.h.
|
inline |
Constructor.
Definition at line 97 of file SmartFactorBase.h.
|
inlineoverride |
Virtual destructor, subclasses from NonlinearFactor.
Definition at line 115 of file SmartFactorBase.h.
|
inline |
Add a new measurement and pose/camera key
measured | is the 2m dimensional projection of a single landmark |
key | is the index corresponding to the camera observing the landmark |
Definition at line 123 of file SmartFactorBase.h.
|
inline |
Add a bunch of measurements, together with the camera keys
Definition at line 135 of file SmartFactorBase.h.
|
inline |
Adds an entire SfM_track (collection of cameras observing a single point). The noise is assumed to be the same for all measurements
Definition at line 147 of file SmartFactorBase.h.
|
inline |
Definition at line 397 of file SmartFactorBase.h.
|
inlinevirtual |
Collect all cameras: important that in key order.
Reimplemented in gtsam::SmartStereoProjectionPoseFactor, and gtsam::SmartProjectionPoseFactor< CALIBRATION >.
Definition at line 165 of file SmartFactorBase.h.
|
inline |
Compute F, E, and b (called below in both vanilla and SVD versions), where F is a vector of derivatives wrpt the cameras, and E the stacked derivatives with respect to the point. The value of cameras/point are passed as parameters. TODO: Kill this obsolete method
Definition at line 275 of file SmartFactorBase.h.
|
inline |
SVD version.
Definition at line 286 of file SmartFactorBase.h.
|
inlinevirtual |
This corrects the Jacobians for the case in which some pixel measurement is missing (nan) In practice, this does not do anything in the monocular case, but it is implemented in the stereo version
Reimplemented in gtsam::SmartStereoProjectionFactor.
Definition at line 235 of file SmartFactorBase.h.
|
inline |
Linearize to a Hessianfactor.
Definition at line 302 of file SmartFactorBase.h.
|
inline |
Return Jacobians as JacobianFactorQ
Definition at line 357 of file SmartFactorBase.h.
|
inline |
Return Jacobians as JacobianFactorSVD TODO lambda is currently ignored
Definition at line 374 of file SmartFactorBase.h.
|
inline |
Return Jacobians as RegularImplicitSchurFactor with raw access.
Definition at line 342 of file SmartFactorBase.h.
|
inlineoverridevirtual |
get the dimension (number of rows!) of the factor
Implements gtsam::NonlinearFactor.
Definition at line 155 of file SmartFactorBase.h.
|
inlineoverridevirtual |
equals
Reimplemented from gtsam::NonlinearFactor.
Reimplemented in gtsam::SmartProjectionFactor< CAMERA >, and gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >.
Definition at line 190 of file SmartFactorBase.h.
|
inlinestatic |
Create BIG block-diagonal matrix F from Fblocks.
Definition at line 388 of file SmartFactorBase.h.
|
inline |
return the measurements
Definition at line 160 of file SmartFactorBase.h.
|
inlinestatic |
Computes Point Covariance P from E.
Definition at line 264 of file SmartFactorBase.h.
|
inlineoverridevirtual |
s | optional string naming the factor |
keyFormatter | optional formatter useful for printing Symbols |
Reimplemented from gtsam::NonlinearFactor.
Reimplemented in gtsam::SmartProjectionFactor< CAMERA >, and gtsam::SmartProjectionFactor< PinholePose< CALIBRATION > >.
Definition at line 177 of file SmartFactorBase.h.
|
inlineprivate |
Definition at line 409 of file SmartFactorBase.h.
|
inline |
Calculate the error of the factor. This is the log-likelihood, e.g. in case of Gaussian. In this class, we take the raw prediction error , ask the noise model to transform it to , and then multiply by 0.5. Will be used in "error(Values)" function required by NonlinearFactor base class
Definition at line 257 of file SmartFactorBase.h.
|
inline |
Compute reprojection errors [h(x)-z] = [cameras.project(p)-z] and derivatives
Definition at line 205 of file SmartFactorBase.h.
|
inline |
Add the contribution of the smart factor to a pre-allocated Hessian, using sparse linear algebra. More efficient than the creation of the Hessian without preallocation of the SymmetricBlockMatrix
Definition at line 322 of file SmartFactorBase.h.
|
inline |
Calculate vector of re-projection errors [h(x)-z] = [cameras.project(p) - z] Noise model applied
Definition at line 243 of file SmartFactorBase.h.
|
inline |
Whiten the Jacobians computed by computeJacobians using noiseModel_.
Definition at line 333 of file SmartFactorBase.h.
|
friend |
Serialization function.
Definition at line 407 of file SmartFactorBase.h.
|
protected |
Pose of the camera in the body frame.
Definition at line 79 of file SmartFactorBase.h.
|
static |
Camera dimension.
Definition at line 58 of file SmartFactorBase.h.
|
mutableprotected |
Definition at line 82 of file SmartFactorBase.h.
|
protected |
2D measurement and noise model for each of the m views We keep a copy of measurements for I/O and computing the error. The order is kept the same as the keys that we use to create the factor.
Definition at line 77 of file SmartFactorBase.h.
|
protected |
As of Feb 22, 2015, the noise model is the same for all measurements and is isotropic. This allows for moving most calculations of Schur complement etc to be moved to CameraSet very easily, and also agrees pragmatically with what is normally done.
Definition at line 70 of file SmartFactorBase.h.
GTSAM_MAKE_ALIGNED_OPERATOR_NEW typedef boost::shared_ptr<This> gtsam::SmartFactorBase< CAMERA >::shared_ptr |
shorthand for a smart pointer to a factor
Definition at line 88 of file SmartFactorBase.h.
|
static |
Measurement dimension.
Definition at line 59 of file SmartFactorBase.h.