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-2017, 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  void 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
double productIntegralNormalizedWith(const CPoint2DPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
double productIntegralWith(const CPoint2DPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
A gaussian distribution for 2D points.
void copyFrom(const CPoint2DPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
void drawSingleSample(CPoint2D &outSample) const override
Draw a sample from the pdf.
A numeric matrix of compile-time fixed size.
CPoint2DPDFGaussian()
Default constructor.
void bayesianFusion(const CPoint2DPDFGaussian &p1, const CPoint2DPDFGaussian &p2)
Bayesian fusion of two points gauss.
Declares a class that represents a Probability Distribution function (PDF) of a 2D point (x...
Definition: CPoint2DPDF.h:37
double mahalanobisDistanceToPoint(const double x, const double y) const
Returns the Mahalanobis distance from this PDF to some point.
GLsizei const GLchar ** string
Definition: glext.h:4101
A class used to store a 2D point.
Definition: CPoint2D.h:36
void getMean(CPoint2D &p) const override
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF) ...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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...
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
GLenum GLint GLint y
Definition: glext.h:3538
void saveToTextFile(const std::string &file) const override
Save PDF&#39;s particles to a text file, containing the 2D pose in the first line, then the covariance ma...
GLenum GLint x
Definition: glext.h:3538
GLfloat GLfloat p
Definition: glext.h:6305
mrpt::math::CMatrixDouble22 cov
The 2x2 covariance matrix.
double mahalanobisDistanceTo(const CPoint2DPDFGaussian &other) const
Returns the Mahalanobis distance from this PDF to another PDF, that is, it&#39;s evaluation at (0...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019