Main MRPT website > C++ reference for MRPT 1.4.0
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-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 CPointPDFGaussian_H
10#define CPointPDFGaussian_H
11
13#include <mrpt/math/CMatrix.h>
14
15namespace mrpt
16{
17namespace poses
18{
20
21 /** A gaussian distribution for 3D points. Also a method for bayesian fusion is provided.
22 *
23 * \sa CPointPDF
24 * \ingroup poses_pdf_grp
25 */
27 {
28 // This must be added to any CSerializable derived class:
30
31 public:
32 /** Default constructor
33 */
35
36 /** Constructor
37 */
38 CPointPDFGaussian( const CPoint3D &init_Mean );
39
40 /** Constructor
41 */
42 CPointPDFGaussian( const CPoint3D &init_Mean, const mrpt::math::CMatrixDouble33 &init_Cov );
43
44 CPoint3D mean; //!< The mean value
45 mrpt::math::CMatrixDouble33 cov; //!< The 3x3 covariance matrix
46
47 void getMean(CPoint3D &p) const MRPT_OVERRIDE; //!< Returns an estimate of the point, (the mean, or mathematical expectation of the PDF)
48
49 /** Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once. \sa getMean */
51
52 /** Copy operator, translating if necesary (for example, between particles and gaussian representations) */
54
55 /** Save PDF's particles to a text file, containing the 2D pose in the first line, then the covariance matrix in next 3 lines. */
56 void saveToTextFile(const std::string &file) const MRPT_OVERRIDE;
57
58 /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
59 * "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. */
60 void changeCoordinatesReference( const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
61
62 /** Bayesian fusion of two points gauss. distributions, then save the result in this object.
63 * The process is as follows:<br>
64 * - (x1,S1): Mean and variance of the p1 distribution.
65 * - (x2,S2): Mean and variance of the p2 distribution.
66 * - (x,S): Mean and variance of the resulting distribution.
67 *
68 * S = (S1<sup>-1</sup> + S2<sup>-1</sup>)<sup>-1</sup>;
69 * x = S * ( S1<sup>-1</sup>*x1 + S2<sup>-1</sup>*x2 );
70 */
72
73 /** 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.
74 * The resulting number is >=0.
75 * \sa productIntegralNormalizedWith
76 * \exception std::exception On errors like covariance matrix with null determinant, etc...
77 */
78 double productIntegralWith( const CPointPDFGaussian &p) const;
79
80 /** 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.
81 * The resulting number is >=0.
82 * NOTE: This version ignores the "z" coordinates!!
83 * \sa productIntegralNormalizedWith
84 * \exception std::exception On errors like covariance matrix with null determinant, etc...
85 */
87
88 /** 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.
89 * The resulting number is in the range [0,1]
90 * Note that the resulting value is in fact
91 * \f[ exp( -\frac{1}{2} D^2 ) \f]
92 * , with \f$ D^2 \f$ being the square Mahalanobis distance between the two pdfs.
93 * \sa productIntegralWith
94 * \exception std::exception On errors like covariance matrix with null determinant, etc...
95 */
97
98 /** 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.
99 * The resulting number is in the range [0,1]. This versions ignores the "z" coordinate.
100 *
101 * Note that the resulting value is in fact
102 * \f[ exp( -\frac{1}{2} D^2 ) \f]
103 * , with \f$ D^2 \f$ being the square Mahalanobis distance between the two pdfs.
104 * \sa productIntegralWith
105 * \exception std::exception On errors like covariance matrix with null determinant, etc...
106 */
108
109 /** Draw a sample from the pdf */
111
112 /** 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!)
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 very separate Gaussian modes (that will result in negligible components) in SOGs will be dropped to reduce the number of modes in the output.
116 */
117 void bayesianFusion( const CPointPDF &p1,const CPointPDF &p2, const double &minMahalanobisDistToDrop = 0) MRPT_OVERRIDE;
118
119
120 /** Returns the Mahalanobis distance from this PDF to another PDF, that is, it's evaluation at (0,0,0) */
121 double mahalanobisDistanceTo( const CPointPDFGaussian & other, bool only_2D = false ) const;
122
123
124 }; // End of class def.
126
127
128 } // End of namespace
129} // End of namespace
130
131#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 3D point.
Definition CPoint3D.h:33
A gaussian distribution for 3D points.
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...
CPointPDFGaussian()
Default constructor.
CPointPDFGaussian(const CPoint3D &init_Mean)
Constructor.
void bayesianFusion(const CPointPDF &p1, const CPointPDF &p2, const double &minMahalanobisDistToDrop=0) MRPT_OVERRIDE
Bayesian fusion of two point distributions (product of two distributions->new distribution),...
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
void copyFrom(const CPointPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between particles and gaussian representations)
double productIntegralWith(const CPointPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
double productIntegralNormalizedWith2D(const CPointPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
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.
CPointPDFGaussian(const CPoint3D &init_Mean, const mrpt::math::CMatrixDouble33 &init_Cov)
Constructor.
double productIntegralWith2D(const CPointPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
void bayesianFusion(const CPointPDFGaussian &p1, const CPointPDFGaussian &p2)
Bayesian fusion of two points gauss.
void getMean(CPoint3D &p) const MRPT_OVERRIDE
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF)
void drawSingleSample(CPoint3D &outSample) const MRPT_OVERRIDE
Draw a sample from the pdf.
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, CPoint3D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once.
CPoint3D mean
The mean value.
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x,...
Definition CPointPDF.h:39
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition CPose3D.h:73
#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 Thu Dec 14 17:13:25 UTC 2023