MRPT  2.0.4
CPointPDFParticles.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
13 #include <mrpt/math/CMatrixF.h>
14 #include <mrpt/math/TPoint3D.h>
15 #include <mrpt/poses/CPointPDF.h>
16 
17 namespace mrpt::poses
18 {
19 /** A probability distribution of a 2D/3D point, represented as a set of random
20  * samples (particles).
21  * \sa CPointPDF
22  * \ingroup poses_pdf_grp
23  */
25  : public CPointPDF,
26  public mrpt::bayes::CParticleFilterData<mrpt::math::TPoint3Df>,
28  CPointPDFParticles, mrpt::bayes::CParticleFilterData<
29  mrpt::math::TPoint3Df>::CParticleList>
30 {
32 
33  public:
34  /** Default constructor */
35  CPointPDFParticles(size_t numParticles = 1);
36 
37  /** Clear all the particles (free memory) */
38  void clear();
39 
40  /** Erase all the previous particles and change the number of particles,
41  * with a given initial value */
42  void setSize(
43  size_t numberParticles,
44  const mrpt::math::TPoint3Df& defaultValue = mrpt::math::TPoint3Df{0, 0,
45  0});
46 
47  /** Returns the number of particles */
48  size_t size() const { return m_particles.size(); }
49 
50  void getMean(CPoint3D& mean_point) const override;
51 
52  std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const override;
53 
54  /** Copy operator, translating if necesary (for example, between particles
55  * and gaussian representations) */
56  void copyFrom(const CPointPDF& o) override;
57 
58  /** Save PDF's particles to a text file, where each line is: X Y Z LOG_W */
59  bool saveToTextFile(const std::string& file) const override;
60 
61  /** this = p (+) this. This can be used to convert a PDF from local
62  * coordinates to global, providing the point (newReferenceBase) from which
63  * "to project" the current pdf. Result PDF substituted the currently
64  * stored one in the object. Both the mean value and the covariance matrix
65  * are updated correctly. */
66  void changeCoordinatesReference(const CPose3D& newReferenceBase) override;
67 
68  /** Compute the kurtosis of the distribution */
69  double computeKurtosis();
70 
71  /** Draw a sample from the pdf */
72  void drawSingleSample(CPoint3D& outSample) const override;
73 
74  /** Bayesian fusion of two point distributions (product of two
75  * distributions->new distribution), then save the result in this object
76  * (WARNING: See implementing classes to see classes that can and cannot be
77  * mixtured!)
78  * \param p1 The first distribution to fuse
79  * \param p2 The second distribution to fuse
80  * \param minMahalanobisDistToDrop If set to different of 0, the result of
81  * very separate Gaussian modes (that will result in negligible components)
82  * in SOGs will be dropped to reduce the number of modes in the output.
83  */
84  void bayesianFusion(
85  const CPointPDF& p1, const CPointPDF& p2,
86  const double minMahalanobisDistToDrop = 0) override;
87 
88 }; // End of class def.
89 } // namespace mrpt::poses
mrpt::poses::CPointPDFParticles::computeKurtosis
double computeKurtosis()
Compute the kurtosis of the distribution.
Definition: CPointPDFParticles.cpp:217
mrpt::poses::CPointPDFParticles::setSize
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
Definition: CPointPDFParticles.cpp:37
mrpt::math::TPoint3D_< float >
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:152
mrpt::poses::CPointPDFParticles::getMean
void getMean(CPoint3D &mean_point) const override
Definition: CPointPDFParticles.cpp:54
mrpt::poses::CPointPDFParticles::size
size_t size() const
Returns the number of particles.
Definition: CPointPDFParticles.h:48
mrpt::poses::CPointPDFParticles
A probability distribution of a 2D/3D point, represented as a set of random samples (particles).
Definition: CPointPDFParticles.h:24
CParticleFilterData.h
mrpt::poses::CPointPDFParticles::getCovarianceAndMean
std::tuple< cov_mat_t, type_value > getCovarianceAndMean() const override
Definition: CPointPDFParticles.cpp:83
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:22
mrpt::poses::CPointPDFParticles::saveToTextFile
bool saveToTextFile(const std::string &file) const override
Save PDF's particles to a text file, where each line is: X Y Z LOG_W.
Definition: CPointPDFParticles.cpp:177
mrpt::poses::CPointPDFParticles::copyFrom
void copyFrom(const CPointPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations)
Definition: CPointPDFParticles.cpp:166
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::poses::CPointPDFParticles::clear
void clear()
Clear all the particles (free memory)
Definition: CPointPDFParticles.cpp:33
mrpt::bayes::CParticleFilterData
This template class declares the array of particles and its internal data, managing some memory-relat...
Definition: CParticleFilterData.h:184
CParticleFilterCapable.h
mrpt::poses::CPointPDFParticles::bayesianFusion
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),...
Definition: CPointPDFParticles.cpp:278
mrpt::bayes::CParticleFilterData< mrpt::math::TPoint3Df >::m_particles
CParticleList m_particles
The array of particles.
Definition: CParticleFilterData.h:196
TPoint3D.h
mrpt::poses::CPointPDFParticles::changeCoordinatesReference
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
Definition: CPointPDFParticles.cpp:198
mrpt::poses::CPointPDFParticles::drawSingleSample
void drawSingleSample(CPoint3D &outSample) const override
Draw a sample from the pdf.
Definition: CPointPDFParticles.cpp:269
mrpt::bayes::CParticleFilterDataImpl
A curiously recurring template pattern (CRTP) approach to providing the basic functionality of any CP...
Definition: CParticleFilterData.h:32
CPointPDF.h
mrpt::poses::CPointPDF
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x,...
Definition: CPointPDF.h:36
mrpt::poses::CPoint3D
A class used to store a 3D point.
Definition: CPoint3D.h:31
CMatrixF.h
mrpt::poses::CPointPDFParticles::CPointPDFParticles
CPointPDFParticles(size_t numParticles=1)
Default constructor.
Definition: CPointPDFParticles.cpp:27



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020