Main MRPT website > C++ reference for MRPT 1.4.0
CPose3DPDFGaussianInf.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef CPose3DPDFGaussianInf_H
10#define CPose3DPDFGaussianInf_H
11
12#include <mrpt/poses/CPose3D.h>
14#include <mrpt/poses/CPosePDF.h>
15#include <mrpt/math/CMatrixD.h>
16
17namespace mrpt
18{
19namespace poses
20{
21 class CPosePDFGaussian;
22 class CPose3DQuatPDFGaussian;
23
25
26 /** Declares a class that represents a Probability Density function (PDF) of a 3D pose \f$ p(\mathbf{x}) = [x ~ y ~ z ~ yaw ~ pitch ~ roll]^t \f$ as a Gaussian described by its mean and its inverse covariance matrix.
27 *
28 * This class implements that PDF using a mono-modal Gaussian distribution in "information" form (inverse covariance matrix).
29 *
30 * Uncertainty of pose composition operations (\f$ y = x \oplus u \f$) is implemented in the method "CPose3DPDFGaussianInf::operator+=".
31 *
32 * For further details on implemented methods and the theory behind them,
33 * see <a href="http://www.mrpt.org/6D_poses:equivalences_compositions_and_uncertainty" >this report</a>.
34 *
35 * \sa CPose3D, CPose3DPDF, CPose3DPDFParticles, CPose3DPDFGaussian
36 * \ingroup poses_pdf_grp
37 */
39 {
40 // This must be added to any CSerializable derived class:
42
43 protected:
44 /** Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor lead to non-symmetric matrixes!)
45 */
47
48 public:
49 /** @name Data fields
50 @{ */
51
52 CPose3D mean; //!< The mean value
53 mrpt::math::CMatrixDouble66 cov_inv; //!< The inverse of the 6x6 covariance matrix
54
55 /** @} */
56
57 inline const CPose3D & getPoseMean() const { return mean; }
58 inline CPose3D & getPoseMean() { return mean; }
59
60 /** Default constructor - mean: all zeros, inverse covariance=all zeros -> so be careful! */
62
63 /** Constructor with a mean value, inverse covariance=all zeros -> so be careful! */
64 explicit CPose3DPDFGaussianInf( const CPose3D &init_Mean );
65
66 /** Uninitialized constructor: leave all fields uninitialized - Call with UNINITIALIZED_POSE as argument */
68
69 /** Constructor with mean and inv cov. */
70 CPose3DPDFGaussianInf( const CPose3D &init_Mean, const mrpt::math::CMatrixDouble66 &init_CovInv );
71
72 /** Constructor from a 6D pose PDF described as a Quaternion */
74
75 /** Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF).
76 * \sa getCovariance */
77 void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE {
78 mean_pose = mean;
79 }
80
81 /** Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once.
82 * \sa getMean */
84 mean_point = this->mean;
85 this->cov_inv.inv(cov);
86 }
87
88 /** Returns the information (inverse covariance) matrix (a STATE_LEN x STATE_LEN matrix) \sa getMean, getCovarianceAndMean */
89 virtual void getInformationMatrix(mrpt::math::CMatrixDouble66 &inf) const MRPT_OVERRIDE { inf=cov_inv; }
90
91 /** Copy operator, translating if necesary (for example, between particles and gaussian representations) */
93
94 /** Copy operator, translating if necesary (for example, between particles and gaussian representations) */
95 void copyFrom(const CPosePDF &o);
96
97 /** Copy from a 6D pose PDF described as a Quaternion
98 */
100
101 /** Save the PDF to a text file, containing the 3D pose in the first line, then the covariance matrix in next 3 lines. */
102 void saveToTextFile(const std::string &file) const MRPT_OVERRIDE;
103
104 /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
105 * "to project" the current pdf. Result PDF substituted the currently stored one in the object. */
106 void changeCoordinatesReference( const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
107
108 /** Draws a single sample from the distribution */
109 void drawSingleSample( CPose3D &outPart ) const MRPT_OVERRIDE;
110
111 /** Draws a number of samples from the distribution, and saves as a list of 1x6 vectors, where each row contains a (x,y,phi) datum. */
112 void drawManySamples( size_t N, std::vector<mrpt::math::CVectorDouble> & outSamples ) const MRPT_OVERRIDE;
113
114 /** Bayesian fusion of two points gauss. distributions, then save the result in this object.
115 * The process is as follows:<br>
116 * - (x1,S1): Mean and variance of the p1 distribution.
117 * - (x2,S2): Mean and variance of the p2 distribution.
118 * - (x,S): Mean and variance of the resulting distribution.
119 *
120 * S = (S1<sup>-1</sup> + S2<sup>-1</sup>)<sup>-1</sup>;
121 * x = S * ( S1<sup>-1</sup>*x1 + S2<sup>-1</sup>*x2 );
122 */
123 void bayesianFusion( const CPose3DPDF &p1, const CPose3DPDF &p2 ) MRPT_OVERRIDE;
124
125 /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF */
127
128 /** Unary - operator, returns the PDF of the inverse pose. */
130 {
132 this->inverse(p);
133 return p;
134 }
135
136
137 void operator += ( const CPose3D &Ap); //!< Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the mean, and the covariance matrix are updated)
138 void operator += ( const CPose3DPDFGaussianInf &Ap); //!< Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the mean, and the covariance matrix are updated)
139 void operator -= ( const CPose3DPDFGaussianInf &Ap); //!< Makes: thisPDF = thisPDF - Ap, where "-" is pose inverse composition (both the mean, and the covariance matrix are updated)
140 double evaluatePDF( const CPose3D &x ) const; //!< Evaluates the PDF at a given point
141 double evaluateNormalizedPDF( const CPose3D &x ) const; //!< Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,1]
142 void getInvCovSubmatrix2D( mrpt::math::CMatrixDouble &out_cov ) const; //!< Returns a 3x3 matrix with submatrix of the inverse covariance for the variables (x,y,yaw) only
143
144 /** Computes the Mahalanobis distance between the centers of two Gaussians.
145 * The variables with a variance exactly equal to 0 are not taken into account in the process, but
146 * "infinity" is returned if the corresponding elements are not exactly equal.
147 */
149
150 }; // End of class def.
152
153
154 bool BASE_IMPEXP operator==(const CPose3DPDFGaussianInf &p1,const CPose3DPDFGaussianInf &p2);
155 /** Pose composition for two 3D pose Gaussians \sa CPose3DPDFGaussian::operator += */
157 /** Pose composition for two 3D pose Gaussians \sa CPose3DPDFGaussianInf::operator -= */
159 /** Dumps the mean and covariance matrix to a text stream. */
160 std::ostream BASE_IMPEXP & operator << (std::ostream & out, const CPose3DPDFGaussianInf& obj);
161
162 } // End of namespace
163} // End of namespace
164#endif
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
A numeric matrix of compile-time fixed size.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
Declares a class that represents a Probability Density function (PDF) of a 3D pose as a Gaussian des...
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
void copyFrom(const CPosePDF &o)
Copy operator, translating if necesary (for example, between particles and gaussian representations)
void inverse(CPose3DPDF &o) const MRPT_OVERRIDE
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
void saveToTextFile(const std::string &file) const MRPT_OVERRIDE
Save the PDF to a text file, containing the 3D pose in the first line, then the covariance matrix in ...
mrpt::math::CMatrixDouble66 cov_inv
The inverse of the 6x6 covariance matrix.
CPose3DPDFGaussianInf()
Default constructor - mean: all zeros, inverse covariance=all zeros -> so be careful!
void copyFrom(const CPose3DQuatPDFGaussian &o)
Copy from a 6D pose PDF described as a Quaternion.
void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov, CPose3D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once.
CPose3DPDFGaussianInf(TConstructorFlags_Poses constructor_dummy_param)
Uninitialized constructor: leave all fields uninitialized - Call with UNINITIALIZED_POSE as argument.
void drawManySamples(size_t N, std::vector< mrpt::math::CVectorDouble > &outSamples) const MRPT_OVERRIDE
Draws a number of samples from the distribution, and saves as a list of 1x6 vectors,...
void assureSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...
CPose3DPDFGaussianInf(const CPose3DQuatPDFGaussian &o)
Constructor from a 6D pose PDF described as a Quaternion.
void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF).
void getInvCovSubmatrix2D(mrpt::math::CMatrixDouble &out_cov) const
Returns a 3x3 matrix with submatrix of the inverse covariance for the variables (x,...
CPose3DPDFGaussianInf(const CPose3D &init_Mean)
Constructor with a mean value, inverse covariance=all zeros -> so be careful!
void drawSingleSample(CPose3D &outPart) const MRPT_OVERRIDE
Draws a single sample from the distribution.
virtual void getInformationMatrix(mrpt::math::CMatrixDouble66 &inf) const MRPT_OVERRIDE
Returns the information (inverse covariance) matrix (a STATE_LEN x STATE_LEN matrix)
CPose3DPDFGaussianInf(const CPose3D &init_Mean, const mrpt::math::CMatrixDouble66 &init_CovInv)
Constructor with mean and inv cov.
double mahalanobisDistanceTo(const CPose3DPDFGaussianInf &theOther)
Computes the Mahalanobis distance between the centers of two Gaussians.
double evaluatePDF(const CPose3D &x) const
Evaluates the PDF at a given point.
double evaluateNormalizedPDF(const CPose3D &x) const
Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,...
void copyFrom(const CPose3DPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between particles and gaussian representations)
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) MRPT_OVERRIDE
Bayesian fusion of two points gauss.
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
Definition: CPose3DPDF.h:41
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
Declares a class that represents a probability density function (pdf) of a 2D pose (x,...
Definition: CPosePDF.h:40
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
Definition: ops_vectors.h:70
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample,...
Definition: ops_matrices.h:135
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
Definition: Miscellaneous.h:74
CPose2D BASE_IMPEXP operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
@ UNINITIALIZED_POSE
Definition: CPoseOrPoint.h:35
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
STL namespace.



Page generated by Doxygen 1.9.4 for MRPT 1.4.0 SVN: at Sun Aug 14 11:34:44 UTC 2022