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-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 CPointPDFParticles_H
10 #define CPointPDFParticles_H
11 
12 #include <mrpt/poses/CPointPDF.h>
13 #include <mrpt/math/CMatrix.h>
17 
18 namespace mrpt
19 {
20 namespace poses
21 {
22 /** A probability distribution of a 2D/3D point, represented as a set of random
23  * samples (particles).
24  * \sa CPointPDF
25  * \ingroup poses_pdf_grp
26  */
28  : public CPointPDF,
29  public mrpt::bayes::CParticleFilterData<mrpt::math::TPoint3Df>,
31  CPointPDFParticles, mrpt::bayes::CParticleFilterData<
32  mrpt::math::TPoint3Df>::CParticleList>
33 {
35 
36  public:
37  /** Default constructor */
38  CPointPDFParticles(size_t numParticles = 1);
39 
40  /** Clear all the particles (free memory) */
41  void clear();
42 
43  /** Erase all the previous particles and change the number of particles,
44  * with a given initial value */
45  void setSize(
46  size_t numberParticles,
47  const mrpt::math::TPoint3Df& defaultValue = mrpt::math::TPoint3Df{0, 0,
48  0});
49 
50  /** Returns the number of particles */
51  size_t size() const { return m_particles.size(); }
52  /** Returns an estimate of the point, (the mean, or mathematical expectation
53  * of the PDF) \sa getCovariance */
54  void getMean(CPoint3D& mean_point) const override;
55 
56  /** Returns an estimate of the point covariance matrix (3x3 cov matrix) and
57  * the mean, both at once. \sa getMean */
59  mrpt::math::CMatrixDouble33& cov, CPoint3D& mean_point) const override;
60 
61  /** Copy operator, translating if necesary (for example, between particles
62  * and gaussian representations) */
63  void copyFrom(const CPointPDF& o) override;
64 
65  /** Save PDF's particles to a text file, where each line is: X Y Z LOG_W */
66  bool saveToTextFile(const std::string& file) const override;
67 
68  /** this = p (+) this. This can be used to convert a PDF from local
69  * coordinates to global, providing the point (newReferenceBase) from which
70  * "to project" the current pdf. Result PDF substituted the currently
71  * stored one in the object. Both the mean value and the covariance matrix
72  * are updated correctly. */
73  void changeCoordinatesReference(const CPose3D& newReferenceBase) override;
74 
75  /** Compute the kurtosis of the distribution */
76  double computeKurtosis();
77 
78  /** Draw a sample from the pdf */
79  void drawSingleSample(CPoint3D& outSample) const override;
80 
81  /** Bayesian fusion of two point distributions (product of two
82  * distributions->new distribution), then save the result in this object
83  * (WARNING: See implementing classes to see classes that can and cannot be
84  * mixtured!)
85  * \param p1 The first distribution to fuse
86  * \param p2 The second distribution to fuse
87  * \param minMahalanobisDistToDrop If set to different of 0, the result of
88  * very separate Gaussian modes (that will result in negligible components)
89  * in SOGs will be dropped to reduce the number of modes in the output.
90  */
91  void bayesianFusion(
92  const CPointPDF& p1, const CPointPDF& p2,
93  const double minMahalanobisDistToDrop = 0) override;
94 
95 }; // End of class def.
96 } // End of namespace
97 } // End of namespace
98 
99 #endif
void drawSingleSample(CPoint3D &outSample) const override
Draw a sample from the pdf.
size_t size() const
Returns the number of particles.
bool 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.
Lightweight 3D point (float version).
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!)
void getMean(CPoint3D &mean_point) const override
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF) ...
GLsizei const GLchar ** string
Definition: glext.h:4101
A class used to store a 3D point.
Definition: CPoint3D.h:33
This template class declares the array of particles and its internal data, managing some memory-relat...
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.
void setSize(size_t numberParticles, const mrpt::math::TPoint3Df &defaultValue=mrpt::math::TPoint3Df{0, 0, 0})
Erase all the previous particles and change the number of particles, with a given initial value...
CPointPDFParticles(size_t numParticles=1)
Default constructor.
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...
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)...
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: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019