Main MRPT website > C++ reference for MRPT 1.4.0
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-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 CPointPDFParticles_H
10#define CPointPDFParticles_H
11
13#include <mrpt/math/CMatrix.h>
17
18namespace mrpt
19{
20namespace poses
21{
23
24 /** Data within each particle
25 * \ingroup poses_pdf_grp
26 */
27 class BASE_IMPEXP TSimple3DPoint : public mrpt::utils::CSerializable
28 {
29 // This must be added to any CSerializable derived class:
31 public:
32 TSimple3DPoint(const TSimple3DPoint&o) : x(o.x),y(o.y),z(o.z)
33 {
34 }
35
36 TSimple3DPoint() : x(0),y(0),z(0)
37 {
38 }
39
40 TSimple3DPoint(const CPoint3D &v) : x(v.x()),y(v.y()),z(v.z())
41 {
42 }
43
44 float x,y,z;
45 };
46 DEFINE_SERIALIZABLE_POST_CUSTOM_BASE( TSimple3DPoint, mrpt::utils::CSerializable )
47
49
50 /** A probability distribution of a 2D/3D point, represented as a set of random samples (particles).
51 * \sa CPointPDF
52 * \ingroup poses_pdf_grp
53 */
55 public CPointPDF,
56 public mrpt::bayes::CParticleFilterData<TSimple3DPoint>,
57 public mrpt::bayes::CParticleFilterDataImpl<CPointPDFParticles,mrpt::bayes::CParticleFilterData<TSimple3DPoint>::CParticleList>
58 {
59 // This must be added to any CSerializable derived class:
61
62 public:
63 /** Default constructor
64 */
65 CPointPDFParticles(size_t numParticles = 1);
66
67 /** Destructor
68 */
70
71 /** Clear all the particles (free memory)
72 */
73 void clear() { setSize(0); }
74
75 /** Erase all the previous particles and change the number of particles, with a given initial value
76 */
77 void setSize(size_t numberParticles, const CPoint3D &defaultValue = CPoint3D(0,0,0) );
78
79 /** Returns the number of particles
80 */
81 size_t size() const
82 {
83 return m_particles.size();
84 }
85
86 /** Returns an estimate of the point, (the mean, or mathematical expectation of the PDF) \sa getCovariance */
87 void getMean(CPoint3D &mean_point) const MRPT_OVERRIDE;
88
89 /** Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once. \sa getMean */
91
92 /** Copy operator, translating if necesary (for example, between particles and gaussian representations) */
94
95 /** Save PDF's particles to a text file, where each line is: X Y Z LOG_W */
96 void saveToTextFile(const std::string &file) const MRPT_OVERRIDE;
97
98 /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
99 * "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. */
100 void changeCoordinatesReference( const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
101
102 /** Compute the kurtosis of the distribution */
104
105 /** Draw a sample from the pdf */
107
108 /** 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!)
109 * \param p1 The first distribution to fuse
110 * \param p2 The second distribution to fuse
111 * \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.
112 */
113 void bayesianFusion( const CPointPDF &p1, const CPointPDF &p2, const double &minMahalanobisDistToDrop = 0) MRPT_OVERRIDE;
114
115 }; // End of class def.
117
118
119 } // End of namespace
120} // End of namespace
121
122#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...
std::deque< CParticleData > CParticleList
Use this type to refer to the list of particles m_particles.
A numeric matrix of compile-time fixed size.
A class used to store a 3D point.
Definition CPoint3D.h:33
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x,...
Definition CPointPDF.h:39
A probability distribution of a 2D/3D point, represented as a set of random samples (particles).
void clear()
Clear all the particles (free memory)
virtual ~CPointPDFParticles()
Destructor.
double computeKurtosis()
Compute the kurtosis of the distribution.
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
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.
void getMean(CPoint3D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF)
size_t size() const
Returns the number of particles.
void drawSingleSample(CPoint3D &outSample) const MRPT_OVERRIDE
Draw a sample from the pdf.
void saveToTextFile(const std::string &file) const MRPT_OVERRIDE
Save PDF's particles to a text file, where each line is: X Y Z LOG_W.
CPointPDFParticles(size_t numParticles=1)
Default 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 copyFrom(const CPointPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between particles and gaussian representations)
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.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition CPose3D.h:73
Data within each particle.
TSimple3DPoint(const CPoint3D &v)
TSimple3DPoint(const TSimple3DPoint &o)
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
#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.7 for MRPT 1.4.0 SVN: at Tue Jun 13 13:45:58 UTC 2023