Main MRPT website > C++ reference for MRPT 1.4.0
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-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 CPose3DPDFParticles_H
10#define CPose3DPDFParticles_H
11
16
17namespace mrpt
18{
19 namespace poses
20 {
21 // This must be added to any CSerializable derived class:
23
24 /** Declares a class that represents a Probability Density function (PDF) of a 3D pose
25 *
26 * This class is also the base for the implementation of Monte-Carlo Localization (MCL), in mrpt::slam::CMonteCarloLocalization2D.
27 *
28 * See the application "app/pf-localization" for an example of usage.
29 *
30 * \sa CPose3D, CPose3DPDF, CPoseGaussianPDF
31 * \ingroup poses_pdf_grp
32 */
34 public CPose3DPDF,
35 public mrpt::bayes::CParticleFilterData<CPose3D>,
36 public mrpt::bayes::CParticleFilterDataImpl<CPose3DPDFParticles,mrpt::bayes::CParticleFilterData<CPose3D>::CParticleList>
37 {
38 // This must be added to any CSerializable derived class:
40
41 public:
42 /** Constructor
43 * \param M The number of m_particles.
44 */
45 CPose3DPDFParticles( size_t M = 1 );
46
47 /** Copy constructor */
49 CPose3DPDF(),
50 CParticleFilterData<CPose3D>()
51 {
52 copyFrom( obj );
53 }
54 virtual ~CPose3DPDFParticles();//!< Destructor
55
56 void copyFrom(const CPose3DPDF &o) MRPT_OVERRIDE; //!< Copy operator, translating if necesary (for example, between m_particles and gaussian representations)
57
58 /** Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose.
59 * \param location The location to set all the m_particles.
60 * \param particlesCount If this is set to 0 the number of m_particles remains unchanged.
61 * \sa resetUniform, resetUniformFreeSpace */
62 void resetDeterministic( const CPose3D &location, size_t particlesCount = 0);
63
64 void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE; //!< Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF), computed as a weighted average over all m_particles. \sa getCovariance
65 void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov,CPose3D &mean_point) const MRPT_OVERRIDE; //!< Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once. \sa getMean
66
67 CPose3D getParticlePose(int i) const; //!< Returns the pose of the i'th particle
68
69 void saveToTextFile(const std::string &file) const MRPT_OVERRIDE; //!< Save PDF's m_particles to a text file. In each line it will go: "x y z"
70
71 /** Get the m_particles count (equivalent to "particlesCount") */
72 size_t size() const { return m_particles.size(); }
73
74 /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
75 * "to project" the current pdf. Result PDF substituted the currently stored one in the object. */
76 void changeCoordinatesReference( const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
77 void drawSingleSample( CPose3D &outPart ) const MRPT_OVERRIDE; //!< Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!)
78 void drawManySamples( size_t N, std::vector<mrpt::math::CVectorDouble> & outSamples ) const MRPT_OVERRIDE; //!< Draws a number of samples from the distribution, and saves as a list of 1x6 vectors, where each row contains a (x,y,phi) datum.
79 void operator += ( const CPose3D &Ap); //!< Appends (pose-composition) a given pose "p" to each particle
80 void append( CPose3DPDFParticles &o ); //!< Appends (add to the list) a set of m_particles to the existing ones, and then normalize weights.
81 void inverse(CPose3DPDF &o) const MRPT_OVERRIDE; //!< Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
82 CPose3D getMostLikelyParticle() const; //!< Returns the particle with the highest weight.
83 void bayesianFusion( const CPose3DPDF &p1, const CPose3DPDF &p2 ) MRPT_OVERRIDE; //!< Bayesian fusion
84
85 }; // End of class def.
87 } // End of namespace
88} // End of namespace
89#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 pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
Definition: CPose3DPDF.h:41
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
void inverse(CPose3DPDF &o) const MRPT_OVERRIDE
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
CPose3D getMostLikelyParticle() const
Returns the particle with the highest weight.
void append(CPose3DPDFParticles &o)
Appends (add to the list) a set of m_particles to the existing ones, and then normalize weights.
void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov, CPose3D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once.
CPose3D getParticlePose(int i) const
Returns the pose of the i'th particle.
void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF),...
void resetDeterministic(const CPose3D &location, size_t particlesCount=0)
Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose.
size_t size() const
Get the m_particles count (equivalent to "particlesCount")
void drawSingleSample(CPose3D &outPart) const MRPT_OVERRIDE
Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!...
void copyFrom(const CPose3DPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between m_particles and gaussian representations...
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) MRPT_OVERRIDE
Bayesian fusion.
void saveToTextFile(const std::string &file) const MRPT_OVERRIDE
Save PDF's m_particles to a text file. In each line it will go: "x y z".
CPose3DPDFParticles(size_t M=1)
Constructor.
virtual ~CPose3DPDFParticles()
Destructor.
CPose3DPDFParticles(const CPose3DPDFParticles &obj)
Copy constructor.
void drawManySamples(size_t N, std::vector< mrpt::math::CVectorDouble > &outSamples) const MRPT_OVERRIDE
Draws a number of samples from the distribution, and saves as a list of 1x6 vectors,...
#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.6 for MRPT 1.4.0 SVN: at Tue Jan 17 22:27:43 UTC 2023