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 
12 #include <mrpt/poses/CPointPDF.h>
13 #include <mrpt/math/CMatrix.h>
17 
18 namespace mrpt
19 {
20 namespace 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  };
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  */
69  virtual ~CPointPDFParticles();
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 */
90  void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov,CPoint3D &mean_point) const MRPT_OVERRIDE;
91 
92  /** Copy operator, translating if necesary (for example, between particles and gaussian representations) */
93  void copyFrom(const CPointPDF &o) MRPT_OVERRIDE;
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 */
103  double computeKurtosis();
104 
105  /** Draw a sample from the pdf */
106  void drawSingleSample(CPoint3D &outSample) const MRPT_OVERRIDE;
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
mrpt::poses::TSimple3DPoint
Data within each particle.
Definition: CPointPDFParticles.h:27
mrpt::bayes::CParticleFilterData< TSimple3DPoint >::CParticleList
std::deque< CParticleData > CParticleList
Use this type to refer to the list of particles m_particles.
Definition: CParticleFilterData.h:182
CProbabilityParticle.h
mrpt::poses::TSimple3DPoint::TSimple3DPoint
TSimple3DPoint()
Definition: CPointPDFParticles.h:36
mrpt::poses::CPointPDFParticles::size
size_t size() const
Returns the number of particles.
Definition: CPointPDFParticles.h:81
mrpt::poses::CPointPDFParticles
A probability distribution of a 2D/3D point, represented as a set of random samples (particles).
Definition: CPointPDFParticles.h:54
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
Definition: CSerializable.h:182
CParticleFilterData.h
CMatrix.h
mrpt::poses::TSimple3DPoint::TSimple3DPoint
TSimple3DPoint(const CPoint3D &v)
Definition: CPointPDFParticles.h:40
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:16
mrpt::poses::TSimple3DPoint::z
float z
Definition: CPointPDFParticles.h:44
saveToTextFile
void saveToTextFile(const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string()) const
Save matrix to a text file, compatible with MATLAB text format (see also the methods of matrix classe...
mrpt::poses::TSimple3DPoint::TSimple3DPoint
TSimple3DPoint(const TSimple3DPoint &o)
Definition: CPointPDFParticles.h:32
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
mrpt::poses::CPointPDFParticles::clear
void clear()
Clear all the particles (free memory)
Definition: CPointPDFParticles.h:73
CParticleFilterCapable.h
setSize
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...
Definition: eigen_plugins.h:280
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:34
mrpt::utils::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:39
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:147
CPointPDF.h
mrpt::math::cov
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:135
mrpt::poses::CPointPDF
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x,...
Definition: CPointPDF.h:38
mrpt::poses::CPoint3D
A class used to store a 3D point.
Definition: CPoint3D.h:32
MRPT_OVERRIDE
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Definition: CSerializable.h:178



Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 23:08:25 UTC 2019