Main MRPT website > C++ reference for MRPT 1.4.0
CPoint2DPDFGaussian.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 CPoint2DPDFGaussian_H
10#define CPoint2DPDFGaussian_H
11
13
14namespace mrpt
15{
16namespace poses
17{
19
20 /** A gaussian distribution for 2D points. Also a method for bayesian fusion is provided.
21 * \ingroup poses_pdf_grp
22 * \sa CPoint2DPDF
23 */
25 {
26 // This must be added to any CSerializable derived class:
28
29 public:
30 CPoint2DPDFGaussian(); //!< Default constructor
31 CPoint2DPDFGaussian( const CPoint2D &init_Mean ); //!< Constructor
32 CPoint2DPDFGaussian( const CPoint2D &init_Mean, const mrpt::math::CMatrixDouble22 &init_Cov ); //!< Constructor
33
34 CPoint2D mean; //!< The mean value
35 mrpt::math::CMatrixDouble22 cov; //!< The 2x2 covariance matrix
36
37 /** Returns an estimate of the point, (the mean, or mathematical expectation of the PDF) */
39 p = this->mean;
40 }
41
42 /** Returns an estimate of the point covariance matrix (2x2 cov matrix) and the mean, both at once. \sa getMean */
44 cov = this->cov;
45 mean_point = this->mean;
46 }
47
48 void copyFrom(const CPoint2DPDF &o) MRPT_OVERRIDE; //!< Copy operator, translating if necesary (for example, between particles and gaussian representations)
49
50 void saveToTextFile(const std::string &file) const MRPT_OVERRIDE; //!< Save PDF's particles to a text file, containing the 2D pose in the first line, then the covariance matrix in next 3 lines
51
52 /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
53 * "to project" the current pdf. Result PDF substituted the currently stored one in the object. Both the mean value and the covariance matrix are updated correctly. */
54 void changeCoordinatesReference( const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
55
56 /** Bayesian fusion of two points gauss. distributions, then save the result in this object.
57 * The process is as follows:<br>
58 * - (x1,S1): Mean and variance of the p1 distribution.
59 * - (x2,S2): Mean and variance of the p2 distribution.
60 * - (x,S): Mean and variance of the resulting distribution.
61 *
62 * S = (S1<sup>-1</sup> + S2<sup>-1</sup>)<sup>-1</sup>;
63 * x = S * ( S1<sup>-1</sup>*x1 + S2<sup>-1</sup>*x2 );
64 */
66
67 /** Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the integral from -inf to +inf of the product of both PDF.
68 * The resulting number is >=0.
69 * \sa productIntegralNormalizedWith
70 * \exception std::exception On errors like covariance matrix with null determinant, etc...
71 */
73
74 /** Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the integral from -inf to +inf of the product of both PDF.
75 * The resulting number is in the range [0,1].
76 * Note that the resulting value is in fact
77 * \f[ exp( -\frac{1}{2} D^2 ) \f]
78 * , with \f$ D^2 \f$ being the square Mahalanobis distance between the two pdfs.
79 * \sa productIntegralWith
80 * \exception std::exception On errors like covariance matrix with null determinant, etc...
81 */
83
84 void drawSingleSample(CPoint2D &outSample) const MRPT_OVERRIDE; //!< Draw a sample from the pdf
85
86 /** Bayesian fusion of two point distributions (product of two distributions->new distribution), then save the result in this object (WARNING: See implementing classes to see classes that can and cannot be mixtured!)
87 * \param p1 The first distribution to fuse
88 * \param p2 The second distribution to fuse
89 * \param minMahalanobisDistToDrop If set to different of 0, the result of very separate Gaussian modes (that will result in negligible components) in SOGs will be dropped to reduce the number of modes in the output.
90 */
91 void bayesianFusion( const CPoint2DPDF &p1, const CPoint2DPDF &p2, const double &minMahalanobisDistToDrop = 0) MRPT_OVERRIDE;
92
93 double mahalanobisDistanceTo( const CPoint2DPDFGaussian & other ) const; //!< Returns the Mahalanobis distance from this PDF to another PDF, that is, it's evaluation at (0,0,0)
94 double mahalanobisDistanceToPoint( const double x, const double y ) const; //!< Returns the Mahalanobis distance from this PDF to some point
95
96 }; // End of class def.
98 } // End of namespace
99} // End of namespace
100#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 2D point.
Definition CPoint2D.h:37
A gaussian distribution for 2D points.
CPoint2DPDFGaussian(const CPoint2D &init_Mean)
Constructor.
void getCovarianceAndMean(mrpt::math::CMatrixDouble22 &cov, CPoint2D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the point covariance matrix (2x2 cov matrix) and the mean, both at once.
CPoint2DPDFGaussian()
Default constructor.
void bayesianFusion(const CPoint2DPDF &p1, const CPoint2DPDF &p2, const double &minMahalanobisDistToDrop=0) MRPT_OVERRIDE
Bayesian fusion of two point distributions (product of two distributions->new distribution),...
double productIntegralWith(const CPoint2DPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
void drawSingleSample(CPoint2D &outSample) const MRPT_OVERRIDE
Draw a sample from the pdf.
CPoint2DPDFGaussian(const CPoint2D &init_Mean, const mrpt::math::CMatrixDouble22 &init_Cov)
Constructor.
void copyFrom(const CPoint2DPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between particles and gaussian representations)
void bayesianFusion(const CPoint2DPDFGaussian &p1, const CPoint2DPDFGaussian &p2)
Bayesian fusion of two points gauss.
mrpt::math::CMatrixDouble22 cov
The 2x2 covariance matrix.
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
void getMean(CPoint2D &p) const MRPT_OVERRIDE
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF)
void saveToTextFile(const std::string &file) const MRPT_OVERRIDE
Save PDF's particles to a text file, containing the 2D pose in the first line, then the covariance ma...
double productIntegralNormalizedWith(const CPoint2DPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
Declares a class that represents a Probability Distribution function (PDF) of a 2D point (x,...
Definition CPoint2DPDF.h:36
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition CPose3D.h:73
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition mrpt_macros.h:28
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.8 for MRPT 1.4.0 SVN: at Fri Dec 15 05:36:48 UTC 2023