Main MRPT website > C++ reference for MRPT 1.9.9
CPose3DPDFParticles.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 CPose3DPDFParticles_H
10 #define CPose3DPDFParticles_H
11 
12 #include <mrpt/poses/CPose3DPDF.h>
15 
16 namespace mrpt
17 {
18 namespace poses
19 {
20 /** Declares a class that represents a Probability Density function (PDF) of a
21  * 3D pose
22  *
23  * This class is also the base for the implementation of Monte-Carlo
24  * Localization (MCL), in mrpt::slam::CMonteCarloLocalization2D.
25  *
26  * See the application "app/pf-localization" for an example of usage.
27  *
28  * \sa CPose3D, CPose3DPDF, CPoseGaussianPDF
29  * \ingroup poses_pdf_grp
30  */
32  : public CPose3DPDF,
34  mrpt::math::TPose3D, mrpt::bayes::particle_storage_mode::VALUE>,
36  CPose3DPDFParticles,
37  mrpt::bayes::CParticleFilterData<
38  mrpt::math::TPose3D,
39  mrpt::bayes::particle_storage_mode::VALUE>::CParticleList>
40 {
42 
43  public:
44  /** Constructor
45  * \param M The number of m_particles.
46  */
47  CPose3DPDFParticles(size_t M = 1);
48 
49  /** Copy operator, translating if necesary (for example, between m_particles
50  * and gaussian representations) */
51  void copyFrom(const CPose3DPDF& o) override;
52 
53  /** Reset the PDF to a single point: All m_particles will be set exactly to
54  * the supplied pose.
55  * \param location The location to set all the m_particles.
56  * \param particlesCount If this is set to 0 the number of m_particles
57  * remains unchanged.
58  * \sa resetUniform, resetUniformFreeSpace */
59  void resetDeterministic(
60  const mrpt::math::TPose3D& location, size_t particlesCount = 0);
61 
62  /** Returns an estimate of the pose, (the mean, or mathematical expectation
63  * of the PDF), computed as a weighted average over all m_particles. \sa
64  * getCovariance */
65  void getMean(CPose3D& mean_pose) const override;
66  /** Returns an estimate of the pose covariance matrix (6x6 cov matrix) and
67  * the mean, both at once. \sa getMean */
69  mrpt::math::CMatrixDouble66& cov, CPose3D& mean_point) const override;
70 
71  /** Returns the pose of the i'th particle */
73 
74  /** Save PDF's m_particles to a text file. In each line it will go: "x y z"
75  */
76  bool saveToTextFile(const std::string& file) const override;
77 
78  /** Get the m_particles count (equivalent to "particlesCount") */
79  size_t size() const { return m_particles.size(); }
80  /** this = p (+) this. This can be used to convert a PDF from local
81  * coordinates to global, providing the point (newReferenceBase) from which
82  * "to project" the current pdf. Result PDF substituted the currently
83  * stored one in the object. */
84  void changeCoordinatesReference(const CPose3D& newReferenceBase) override;
85  /** Draws a single sample from the distribution (WARNING: weights are
86  * assumed to be normalized!) */
87  void drawSingleSample(CPose3D& outPart) const override;
88  /** Draws a number of samples from the distribution, and saves as a list of
89  * 1x6 vectors, where each row contains a (x,y,phi) datum. */
90  void drawManySamples(
91  size_t N,
92  std::vector<mrpt::math::CVectorDouble>& outSamples) const override;
93  /** Appends (pose-composition) a given pose "p" to each particle */
94  void operator+=(const CPose3D& Ap);
95  /** Appends (add to the list) a set of m_particles to the existing ones, and
96  * then normalize weights. */
97  void append(CPose3DPDFParticles& o);
98  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF */
99  void inverse(CPose3DPDF& o) const override;
100  /** Returns the particle with the highest weight. */
102  /** Bayesian fusion */
103  void bayesianFusion(const CPose3DPDF& p1, const CPose3DPDF& p2) override;
104 
105 }; // End of class def.
106 } // End of namespace
107 } // End of namespace
108 #endif
location
GLint location
Definition: glext.h:4086
mrpt::poses::CPose3DPDFParticles::saveToTextFile
bool saveToTextFile(const std::string &file) const override
Save PDF's m_particles to a text file.
Definition: CPose3DPDFParticles.cpp:203
mrpt::poses::CPose3DPDFParticles::operator+=
void operator+=(const CPose3D &Ap)
Appends (pose-composition) a given pose "p" to each particle.
Definition: CPose3DPDFParticles.cpp:247
mrpt::poses::CPose3DPDFParticles::resetDeterministic
void resetDeterministic(const mrpt::math::TPose3D &location, size_t particlesCount=0)
Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose.
Definition: CPose3DPDFParticles.cpp:294
mrpt::poses::CPose3DPDF
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
Definition: CPose3DPDF.h:42
mrpt::poses::CPose3DPDFParticles::size
size_t size() const
Get the m_particles count (equivalent to "particlesCount")
Definition: CPose3DPDFParticles.h:79
CParticleFilterData.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::poses::CPose3DPDFParticles::changeCoordinatesReference
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
Definition: CPose3DPDFParticles.cpp:226
mrpt::poses::CPose3DPDFParticles::bayesianFusion
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) override
Bayesian fusion.
Definition: CPose3DPDFParticles.cpp:286
mrpt::poses::CPose3DPDFParticles::getMostLikelyParticle
mrpt::math::TPose3D getMostLikelyParticle() const
Returns the particle with the highest weight.
Definition: CPose3DPDFParticles.cpp:271
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:148
mrpt::poses::CPose3DPDFParticles::getCovarianceAndMean
void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov, CPose3D &mean_point) const override
Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once.
Definition: CPose3DPDFParticles.cpp:69
mrpt::poses::CPose3DPDFParticles::CPose3DPDFParticles
CPose3DPDFParticles(size_t M=1)
Constructor.
Definition: CPose3DPDFParticles.cpp:26
mrpt::poses::CPose3DPDFParticles::drawManySamples
void drawManySamples(size_t N, std::vector< mrpt::math::CVectorDouble > &outSamples) const override
Draws a number of samples from the distribution, and saves as a list of 1x6 vectors,...
Definition: CPose3DPDFParticles.cpp:239
mrpt::bayes::CParticleFilterDataImpl< CPose3DPDFParticles, mrpt::bayes::CParticleFilterData< mrpt::math::TPose3D, mrpt::bayes::particle_storage_mode::VALUE >::CParticleList >::particlesCount
size_t particlesCount() const override
Definition: CParticleFilterData.h:56
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::poses::CPose3DPDFParticles::drawSingleSample
void drawSingleSample(CPose3D &outPart) const override
Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!...
Definition: CPose3DPDFParticles.cpp:233
mrpt::bayes::CParticleFilterData
This template class declares the array of particles and its internal data, managing some memory-relat...
Definition: CParticleFilterData.h:206
mrpt::math::TPose3D
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: lightweight_geom_data.h:603
mrpt::poses::CPose3DPDFParticles
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
Definition: CPose3DPDFParticles.h:31
CParticleFilterCapable.h
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:40
mrpt::poses::CPose3DPDFParticles::copyFrom
void copyFrom(const CPose3DPDF &o) override
Copy operator, translating if necesary (for example, between m_particles and gaussian representations...
Definition: CPose3DPDFParticles.cpp:33
mrpt::bayes::CParticleFilterData< mrpt::math::TPose3D, mrpt::bayes::particle_storage_mode::VALUE >::m_particles
CParticleList m_particles
The array of particles.
Definition: CParticleFilterData.h:218
mrpt::poses::CPose3DPDFParticles::inverse
void inverse(CPose3DPDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
Definition: CPose3DPDFParticles.cpp:259
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::poses::CPose3DPDFParticles::getParticlePose
mrpt::math::TPose3D getParticlePose(int i) const
Returns the pose of the i'th particle.
Definition: CPose3DPDFParticles.cpp:221
mrpt::poses::CPose3DPDFParticles::getMean
void getMean(CPose3D &mean_pose) const override
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF),...
Definition: CPose3DPDFParticles.cpp:51
CPose3DPDF.h
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::bayes::CParticleFilterDataImpl
A curiously recurring template pattern (CRTP) approach to providing the basic functionality of any CP...
Definition: CParticleFilterData.h:33
mrpt::poses::CPose3DPDFParticles::append
void append(CPose3DPDFParticles &o)
Appends (add to the list) a set of m_particles to the existing ones, and then normalize weights.
Definition: CPose3DPDFParticles.cpp:253



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST