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