Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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 
12 #include <mrpt/poses/CPoint2DPDF.h>
13 
14 namespace mrpt
15 {
16 namespace poses
17 {
18 /** A gaussian distribution for 2D points. Also a method for bayesian fusion is
19  * provided.
20  * \ingroup poses_pdf_grp
21  * \sa CPoint2DPDF
22  */
24 {
26 
27  public:
28  /** Default constructor */
30  /** Constructor */
31  CPoint2DPDFGaussian(const CPoint2D& init_Mean);
32  /** Constructor */
34  const CPoint2D& init_Mean, const mrpt::math::CMatrixDouble22& init_Cov);
35 
36  /** The mean value */
38  /** The 2x2 covariance matrix */
40 
41  /** Returns an estimate of the point, (the mean, or mathematical expectation
42  * of the PDF) */
43  void getMean(CPoint2D& p) const override { p = this->mean; }
44  /** Returns an estimate of the point covariance matrix (2x2 cov matrix) and
45  * the mean, both at once. \sa getMean */
48  CPoint2D& mean_point) const override
49  {
50  out_cov = this->cov;
51  mean_point = this->mean;
52  }
53 
54  /** Copy operator, translating if necesary (for example, between particles
55  * and gaussian representations) */
56  void copyFrom(const CPoint2DPDF& o) override;
57 
58  /** Save PDF's particles to a text file, containing the 2D pose in the first
59  * line, then the covariance matrix in next 3 lines */
60  bool saveToTextFile(const std::string& file) const override;
61 
62  /** this = p (+) this. This can be used to convert a PDF from local
63  * coordinates to global, providing the point (newReferenceBase) from which
64  * "to project" the current pdf. Result PDF substituted the currently
65  * stored one in the object. Both the mean value and the covariance matrix
66  * are updated correctly. */
67  void changeCoordinatesReference(const CPose3D& newReferenceBase) override;
68 
69  /** Bayesian fusion of two points gauss. distributions, then save the result
70  *in this object.
71  * The process is as follows:<br>
72  * - (x1,S1): Mean and variance of the p1 distribution.
73  * - (x2,S2): Mean and variance of the p2 distribution.
74  * - (x,S): Mean and variance of the resulting distribution.
75  *
76  * S = (S1<sup>-1</sup> + S2<sup>-1</sup>)<sup>-1</sup>;
77  * x = S * ( S1<sup>-1</sup>*x1 + S2<sup>-1</sup>*x2 );
78  */
79  void bayesianFusion(
80  const CPoint2DPDFGaussian& p1, const CPoint2DPDFGaussian& p2);
81 
82  /** Computes the "correspondence likelihood" of this PDF with another one:
83  * This is implemented as the integral from -inf to +inf of the product of
84  * both PDF.
85  * The resulting number is >=0.
86  * \sa productIntegralNormalizedWith
87  * \exception std::exception On errors like covariance matrix with null
88  * determinant, etc...
89  */
90  double productIntegralWith(const CPoint2DPDFGaussian& p) const;
91 
92  /** Computes the "correspondence likelihood" of this PDF with another one:
93  * This is implemented as the integral from -inf to +inf of the product of
94  * both PDF.
95  * The resulting number is in the range [0,1].
96  * Note that the resulting value is in fact
97  * \f[ exp( -\frac{1}{2} D^2 ) \f]
98  * , with \f$ D^2 \f$ being the square Mahalanobis distance between the
99  * two pdfs.
100  * \sa productIntegralWith
101  * \exception std::exception On errors like covariance matrix with null
102  * determinant, etc...
103  */
105 
106  /** Draw a sample from the pdf */
107  void drawSingleSample(CPoint2D& outSample) const override;
108 
109  /** Bayesian fusion of two point distributions (product of two
110  * distributions->new distribution), then save the result in this object
111  * (WARNING: See implementing classes to see classes that can and cannot be
112  * mixtured!)
113  * \param p1 The first distribution to fuse
114  * \param p2 The second distribution to fuse
115  * \param minMahalanobisDistToDrop If set to different of 0, the result of
116  * very separate Gaussian modes (that will result in negligible components)
117  * in SOGs will be dropped to reduce the number of modes in the output.
118  */
119  void bayesianFusion(
120  const CPoint2DPDF& p1, const CPoint2DPDF& p2,
121  const double minMahalanobisDistToDrop = 0) override;
122 
123  /** Returns the Mahalanobis distance from this PDF to another PDF, that is,
124  * it's evaluation at (0,0,0) */
125  double mahalanobisDistanceTo(const CPoint2DPDFGaussian& other) const;
126  /** Returns the Mahalanobis distance from this PDF to some point */
127  double mahalanobisDistanceToPoint(const double x, const double y) const;
128 
129 }; // End of class def.
130 } // End of namespace
131 } // End of namespace
132 #endif
mrpt::poses::CPoint2DPDFGaussian::productIntegralNormalizedWith
double productIntegralNormalizedWith(const CPoint2DPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
Definition: CPoint2DPDFGaussian.cpp:175
mrpt::poses::CPoint2DPDFGaussian::getMean
void getMean(CPoint2D &p) const override
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF)
Definition: CPoint2DPDFGaussian.h:43
mrpt::poses::CPoint2DPDFGaussian::drawSingleSample
void drawSingleSample(CPoint2D &outSample) const override
Draw a sample from the pdf.
Definition: CPoint2DPDFGaussian.cpp:184
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
p
GLfloat GLfloat p
Definition: glext.h:6305
CPoint2DPDF.h
mrpt::poses::CPoint2DPDFGaussian::copyFrom
void copyFrom(const CPoint2DPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations)
Definition: CPoint2DPDFGaussian.cpp:70
mrpt::poses::CPoint2DPDFGaussian::CPoint2DPDFGaussian
CPoint2DPDFGaussian()
Default constructor.
Definition: CPoint2DPDFGaussian.cpp:32
mrpt::poses::CPoint2DPDFGaussian::mahalanobisDistanceTo
double mahalanobisDistanceTo(const CPoint2DPDFGaussian &other) const
Returns the Mahalanobis distance from this PDF to another PDF, that is, it's evaluation at (0,...
Definition: CPoint2DPDFGaussian.cpp:222
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::poses::CPoint2DPDFGaussian::getCovarianceAndMean
void getCovarianceAndMean(mrpt::math::CMatrixDouble22 &out_cov, CPoint2D &mean_point) const override
Returns an estimate of the point covariance matrix (2x2 cov matrix) and the mean, both at once.
Definition: CPoint2DPDFGaussian.h:46
mrpt::poses::CPoint2DPDFGaussian::cov
mrpt::math::CMatrixDouble22 cov
The 2x2 covariance matrix.
Definition: CPoint2DPDFGaussian.h:39
mrpt::poses::CPoint2DPDFGaussian::mean
CPoint2D mean
The mean value.
Definition: CPoint2DPDFGaussian.h:37
mrpt::poses::CPoint2DPDFGaussian
A gaussian distribution for 2D points.
Definition: CPoint2DPDFGaussian.h:23
mrpt::poses::CPoint2DPDFGaussian::changeCoordinatesReference
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
Definition: CPoint2DPDFGaussian.cpp:101
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:40
mrpt::poses::CPoint2DPDFGaussian::bayesianFusion
void bayesianFusion(const CPoint2DPDFGaussian &p1, const CPoint2DPDFGaussian &p2)
Bayesian fusion of two points gauss.
Definition: CPoint2DPDFGaussian.cpp:118
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::poses::CPoint2DPDFGaussian::mahalanobisDistanceToPoint
double mahalanobisDistanceToPoint(const double x, const double y) const
Returns the Mahalanobis distance from this PDF to some point.
Definition: CPoint2DPDFGaussian.cpp:236
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::poses::CPoint2DPDF
Declares a class that represents a Probability Distribution function (PDF) of a 2D point (x,...
Definition: CPoint2DPDF.h:35
mrpt::poses::CPoint2D
A class used to store a 2D point.
Definition: CPoint2D.h:35
mrpt::poses::CPoint2DPDFGaussian::productIntegralWith
double productIntegralWith(const CPoint2DPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
Definition: CPoint2DPDFGaussian.cpp:147
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538
mrpt::poses::CPoint2DPDFGaussian::saveToTextFile
bool saveToTextFile(const std::string &file) const override
Save PDF's particles to a text file, containing the 2D pose in the first line, then the covariance ma...
Definition: CPoint2DPDFGaussian.cpp:81



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST