MRPT  1.9.9
CPointPDFGaussian.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 CPointPDFGaussian_H
10 #define CPointPDFGaussian_H
11 
12 #include <mrpt/poses/CPointPDF.h>
13 #include <mrpt/math/CMatrix.h>
14 
15 namespace mrpt::poses
16 {
17 /** A gaussian distribution for 3D points. Also a method for bayesian fusion is
18  * provided.
19  *
20  * \sa CPointPDF
21  * \ingroup poses_pdf_grp
22  */
24 {
26 
27  public:
28  /** Default constructor
29  */
31 
32  /** Constructor
33  */
34  CPointPDFGaussian(const CPoint3D& init_Mean);
35 
36  /** Constructor
37  */
39  const CPoint3D& init_Mean, const mrpt::math::CMatrixDouble33& init_Cov);
40 
41  /** The mean value */
43  /** The 3x3 covariance matrix */
45 
46  /** Returns an estimate of the point, (the mean, or mathematical expectation
47  * of the PDF) */
48  void getMean(CPoint3D& p) const override;
49 
50  /** Returns an estimate of the point covariance matrix (3x3 cov matrix) and
51  * the mean, both at once. \sa getMean */
53  mrpt::math::CMatrixDouble33& cov, CPoint3D& mean_point) const override;
54 
55  /** Copy operator, translating if necesary (for example, between particles
56  * and gaussian representations) */
57  void copyFrom(const CPointPDF& o) override;
58 
59  /** Save PDF's particles to a text file, containing the 2D pose in the first
60  * line, then the covariance matrix in next 3 lines. */
61  bool saveToTextFile(const std::string& file) const override;
62 
63  /** this = p (+) this. This can be used to convert a PDF from local
64  * coordinates to global, providing the point (newReferenceBase) from which
65  * "to project" the current pdf. Result PDF substituted the currently
66  * stored one in the object. Both the mean value and the covariance matrix
67  * are updated correctly. */
68  void changeCoordinatesReference(const CPose3D& newReferenceBase) override;
69 
70  /** Bayesian fusion of two points gauss. distributions, then save the result
71  *in this object.
72  * The process is as follows:<br>
73  * - (x1,S1): Mean and variance of the p1 distribution.
74  * - (x2,S2): Mean and variance of the p2 distribution.
75  * - (x,S): Mean and variance of the resulting distribution.
76  *
77  * S = (S1<sup>-1</sup> + S2<sup>-1</sup>)<sup>-1</sup>;
78  * x = S * ( S1<sup>-1</sup>*x1 + S2<sup>-1</sup>*x2 );
79  */
80  void bayesianFusion(
81  const CPointPDFGaussian& p1, const CPointPDFGaussian& p2);
82 
83  /** Computes the "correspondence likelihood" of this PDF with another one:
84  * This is implemented as the integral from -inf to +inf of the product of
85  * both PDF.
86  * The resulting number is >=0.
87  * \sa productIntegralNormalizedWith
88  * \exception std::exception On errors like covariance matrix with null
89  * determinant, etc...
90  */
91  double productIntegralWith(const CPointPDFGaussian& p) const;
92 
93  /** Computes the "correspondence likelihood" of this PDF with another one:
94  * This is implemented as the integral from -inf to +inf of the product of
95  * both PDF.
96  * The resulting number is >=0.
97  * NOTE: This version ignores the "z" coordinates!!
98  * \sa productIntegralNormalizedWith
99  * \exception std::exception On errors like covariance matrix with null
100  * determinant, etc...
101  */
102  double productIntegralWith2D(const CPointPDFGaussian& p) const;
103 
104  /** Computes the "correspondence likelihood" of this PDF with another one:
105  * This is implemented as the integral from -inf to +inf of the product of
106  * both PDF.
107  * The resulting number is in the range [0,1]
108  * Note that the resulting value is in fact
109  * \f[ exp( -\frac{1}{2} D^2 ) \f]
110  * , with \f$ D^2 \f$ being the square Mahalanobis distance between the
111  * two pdfs.
112  * \sa productIntegralWith
113  * \exception std::exception On errors like covariance matrix with null
114  * determinant, etc...
115  */
117 
118  /** Computes the "correspondence likelihood" of this PDF with another one:
119  * This is implemented as the integral from -inf to +inf of the product of
120  * both PDF.
121  * The resulting number is in the range [0,1]. This versions ignores the
122  * "z" coordinate.
123  *
124  * Note that the resulting value is in fact
125  * \f[ exp( -\frac{1}{2} D^2 ) \f]
126  * , with \f$ D^2 \f$ being the square Mahalanobis distance between the
127  * two pdfs.
128  * \sa productIntegralWith
129  * \exception std::exception On errors like covariance matrix with null
130  * determinant, etc...
131  */
133 
134  /** Draw a sample from the pdf */
135  void drawSingleSample(CPoint3D& outSample) const override;
136 
137  /** Bayesian fusion of two point distributions (product of two
138  * distributions->new distribution), then save the result in this object
139  * (WARNING: See implementing classes to see classes that can and cannot be
140  * mixtured!)
141  * \param p1 The first distribution to fuse
142  * \param p2 The second distribution to fuse
143  * \param minMahalanobisDistToDrop If set to different of 0, the result of
144  * very separate Gaussian modes (that will result in negligible components)
145  * in SOGs will be dropped to reduce the number of modes in the output.
146  */
147  void bayesianFusion(
148  const CPointPDF& p1, const CPointPDF& p2,
149  const double minMahalanobisDistToDrop = 0) override;
150 
151  /** Returns the Mahalanobis distance from this PDF to another PDF, that is,
152  * it's evaluation at (0,0,0) */
153  double mahalanobisDistanceTo(
154  const CPointPDFGaussian& other, bool only_2D = false) const;
155 
156 }; // End of class def.
157 }
158 #endif
159 
160 
void copyFrom(const CPointPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
void getMean(CPoint3D &p) const override
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF) ...
CPoint3D mean
The mean value.
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
void bayesianFusion(const CPointPDFGaussian &p1, const CPointPDFGaussian &p2)
Bayesian fusion of two points gauss.
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...
double productIntegralNormalizedWith(const CPointPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
GLsizei const GLchar ** string
Definition: glext.h:4101
A class used to store a 3D point.
Definition: CPoint3D.h:31
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
double productIntegralNormalizedWith2D(const CPointPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
double mahalanobisDistanceTo(const CPointPDFGaussian &other, bool only_2D=false) const
Returns the Mahalanobis distance from this PDF to another PDF, that is, it&#39;s evaluation at (0...
double productIntegralWith(const CPointPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
void drawSingleSample(CPoint3D &outSample) const override
Draw a sample from the pdf.
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
Definition: CPointPDF.h:37
GLfloat GLfloat p
Definition: glext.h:6305
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, CPoint3D &mean_point) const override
Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once...
CPointPDFGaussian()
Default constructor.
double productIntegralWith2D(const CPointPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
A gaussian distribution for 3D points.



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