Main MRPT website > C++ reference for MRPT 1.5.7
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-2017, 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  CPointPDFParticles(size_t numParticles = 1);
65 
66  /** Clear all the particles (free memory) */
67  void clear();
68 
69  /** Erase all the previous particles and change the number of particles, with a given initial value */
70  void setSize(size_t numberParticles, const CPoint3D &defaultValue = CPoint3D(0,0,0) );
71 
72  /** Returns the number of particles */
73  size_t size() const
74  {
75  return m_particles.size();
76  }
77 
78  /** Returns an estimate of the point, (the mean, or mathematical expectation of the PDF) \sa getCovariance */
79  void getMean(CPoint3D &mean_point) const MRPT_OVERRIDE;
80 
81  /** Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once. \sa getMean */
82  void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov,CPoint3D &mean_point) const MRPT_OVERRIDE;
83 
84  /** Copy operator, translating if necesary (for example, between particles and gaussian representations) */
85  void copyFrom(const CPointPDF &o) MRPT_OVERRIDE;
86 
87  /** Save PDF's particles to a text file, where each line is: X Y Z LOG_W */
88  void saveToTextFile(const std::string &file) const MRPT_OVERRIDE;
89 
90  /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
91  * "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. */
92  void changeCoordinatesReference( const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
93 
94  /** Compute the kurtosis of the distribution */
95  double computeKurtosis();
96 
97  /** Draw a sample from the pdf */
98  void drawSingleSample(CPoint3D &outSample) const MRPT_OVERRIDE;
99 
100  /** 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!)
101  * \param p1 The first distribution to fuse
102  * \param p2 The second distribution to fuse
103  * \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.
104  */
105  void bayesianFusion( const CPointPDF &p1, const CPointPDF &p2, const double &minMahalanobisDistToDrop = 0) MRPT_OVERRIDE;
106 
107  }; // End of class def.
109 
110 
111  } // End of namespace
112 } // End of namespace
113 
114 #endif
GLdouble GLdouble z
Definition: glext.h:3734
size_t size() const
Returns the number of particles.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
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...
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:113
TSimple3DPoint(const CPoint3D &v)
TSimple3DPoint(const TSimple3DPoint &o)
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
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 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Data within each particle.
GLsizei const GLchar ** string
Definition: glext.h:3919
A class used to store a 3D point.
Definition: CPoint3D.h:32
const GLdouble * v
Definition: glext.h:3603
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...
std::deque< CParticleData > CParticleList
Use this type to refer to the list of particles m_particles.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
GLenum GLint GLint y
Definition: glext.h:3516
GLenum GLint x
Definition: glext.h:3516
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
Definition: CPointPDF.h:38
A probability distribution of a 2D/3D point, represented as a set of random samples (particles)...



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019