Main MRPT website > C++ reference for MRPT 1.9.9
CPointPDFParticles.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 CPointPDFParticles_H
10 #define CPointPDFParticles_H
11 
12 #include <mrpt/poses/CPointPDF.h>
13 #include <mrpt/math/CMatrix.h>
16 
17 namespace mrpt
18 {
19 namespace poses
20 {
21 /** Data within each particle
22  * \ingroup poses_pdf_grp
23  */
25 {
27  public:
28  TSimple3DPoint(const TSimple3DPoint& o) : x(o.x), y(o.y), z(o.z) {}
29  TSimple3DPoint() : x(0), y(0), z(0) {}
30  TSimple3DPoint(const CPoint3D& v) : x(v.x()), y(v.y()), z(v.z()) {}
31  float x, y, z;
32 };
33 
34 /** A probability distribution of a 2D/3D point, represented as a set of random
35  * samples (particles).
36  * \sa CPointPDF
37  * \ingroup poses_pdf_grp
38  */
40  : public CPointPDF,
41  public mrpt::bayes::CParticleFilterData<TSimple3DPoint>,
43  CPointPDFParticles,
44  mrpt::bayes::CParticleFilterData<TSimple3DPoint>::CParticleList>
45 {
47 
48  public:
49  /** Default constructor */
50  CPointPDFParticles(size_t numParticles = 1);
51 
52  /** Clear all the particles (free memory) */
53  void clear();
54 
55  /** Erase all the previous particles and change the number of particles,
56  * with a given initial value */
57  void setSize(
58  size_t numberParticles,
59  const CPoint3D& defaultValue = CPoint3D(0, 0, 0));
60 
61  /** Returns the number of particles */
62  size_t size() const { return m_particles.size(); }
63  /** Returns an estimate of the point, (the mean, or mathematical expectation
64  * of the PDF) \sa getCovariance */
65  void getMean(CPoint3D& mean_point) const override;
66 
67  /** Returns an estimate of the point covariance matrix (3x3 cov matrix) and
68  * the mean, both at once. \sa getMean */
70  mrpt::math::CMatrixDouble33& cov, CPoint3D& mean_point) const override;
71 
72  /** Copy operator, translating if necesary (for example, between particles
73  * and gaussian representations) */
74  void copyFrom(const CPointPDF& o) override;
75 
76  /** Save PDF's particles to a text file, where each line is: X Y Z LOG_W */
77  void saveToTextFile(const std::string& file) const override;
78 
79  /** this = p (+) this. This can be used to convert a PDF from local
80  * coordinates to global, providing the point (newReferenceBase) from which
81  * "to project" the current pdf. Result PDF substituted the currently
82  * stored one in the object. Both the mean value and the covariance matrix
83  * are updated correctly. */
84  void changeCoordinatesReference(const CPose3D& newReferenceBase) override;
85 
86  /** Compute the kurtosis of the distribution */
87  double computeKurtosis();
88 
89  /** Draw a sample from the pdf */
90  void drawSingleSample(CPoint3D& outSample) const override;
91 
92  /** Bayesian fusion of two point distributions (product of two
93  * distributions->new distribution), then save the result in this object
94  * (WARNING: See implementing classes to see classes that can and cannot be
95  * mixtured!)
96  * \param p1 The first distribution to fuse
97  * \param p2 The second distribution to fuse
98  * \param minMahalanobisDistToDrop If set to different of 0, the result of
99  * very separate Gaussian modes (that will result in negligible components)
100  * in SOGs will be dropped to reduce the number of modes in the output.
101  */
102  void bayesianFusion(
103  const CPointPDF& p1, const CPointPDF& p2,
104  const double& minMahalanobisDistToDrop = 0) override;
105 
106 }; // End of class def.
107 } // End of namespace
108 } // End of namespace
109 
110 #endif
void drawSingleSample(CPoint3D &outSample) const override
Draw a sample from the pdf.
GLdouble GLdouble z
Definition: glext.h:3872
size_t size() const
Returns the number of particles.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
TSimple3DPoint(const CPoint3D &v)
CParticleList m_particles
The array of particles.
TSimple3DPoint(const TSimple3DPoint &o)
void setSize(size_t numberParticles, const CPoint3D &defaultValue=CPoint3D(0, 0, 0))
Erase all the previous particles and change the number of particles, with a given initial value...
Data within each particle.
void getMean(CPoint3D &mean_point) const override
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF) ...
void bayesianFusion(const CPointPDF &p1, const CPointPDF &p2, const double &minMahalanobisDistToDrop=0) override
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!)
GLsizei const GLchar ** string
Definition: glext.h:4101
A class used to store a 3D point.
Definition: CPoint3D.h:32
This template class declares the array of particles and its internal data, managing some memory-relat...
const GLdouble * v
Definition: glext.h:3678
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#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
void copyFrom(const CPointPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
CPointPDFParticles(size_t numParticles=1)
Default constructor.
GLenum GLint GLint y
Definition: glext.h:3538
void clear()
Clear all the particles (free memory)
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
Definition: ops_matrices.h:148
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...
GLenum GLint x
Definition: glext.h:3538
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
Definition: CPointPDF.h:39
double computeKurtosis()
Compute the kurtosis of the distribution.
A probability distribution of a 2D/3D point, represented as a set of random samples (particles)...
void saveToTextFile(const std::string &file) const override
Save PDF&#39;s particles to a text file, where each line is: X Y Z LOG_W.
A curiously recurring template pattern (CRTP) approach to providing the basic functionality of any CP...



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