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