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 
12 #include <mrpt/poses/CPose3DPDF.h>
16 
17 namespace 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
mrpt::poses::CPose3DPDFParticles::drawSingleSample
void drawSingleSample(CPose3D &outPart) const MRPT_OVERRIDE
Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!...
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.
mrpt::poses::CPose3DPDFParticles::changeCoordinatesReference
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
mrpt::bayes::CParticleFilterData< CPose3D >::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::CPose3DPDFParticles::getParticlePose
CPose3D getParticlePose(int i) const
Returns the pose of the i'th particle.
mrpt::poses::CPose3DPDFParticles::copyFrom
void copyFrom(const CPose3DPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between m_particles and gaussian representations...
mrpt::poses::CPose3DPDFParticles::~CPose3DPDFParticles
virtual ~CPose3DPDFParticles()
Destructor.
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
Definition: CSerializable.h:182
mrpt::poses::CPose3DPDF
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
Definition: CPose3DPDF.h:41
mrpt::poses::CPose3DPDFParticles::size
size_t size() const
Get the m_particles count (equivalent to "particlesCount")
Definition: CPose3DPDFParticles.h:72
CParticleFilterData.h
mrpt::poses::CPose3DPDFParticles::CPose3DPDFParticles
CPose3DPDFParticles(size_t M=1)
Constructor.
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:17
mrpt::poses::CPose3DPDFParticles::CPose3DPDFParticles
CPose3DPDFParticles(const CPose3DPDFParticles &obj)
Copy constructor.
Definition: CPose3DPDFParticles.h:48
mrpt::poses::CPose3DPDFParticles::getMean
void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF),...
mrpt::poses::CPose3DPDFParticles::inverse
void inverse(CPose3DPDF &o) const MRPT_OVERRIDE
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
mrpt::math::operator+=
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
Definition: ops_vectors.h:70
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
mrpt::poses::CPose3DPDFParticles
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
Definition: CPose3DPDFParticles.h:37
CParticleFilterCapable.h
mrpt::poses::CPose3DPDFParticles::saveToTextFile
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".
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:43
mrpt::poses::CPose3DPDFParticles::getMostLikelyParticle
CPose3D getMostLikelyParticle() const
Returns the particle with the highest weight.
mrpt::poses::CPose3DPDFParticles::getCovarianceAndMean
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.
mrpt::poses::CPose3DPDFParticles::resetDeterministic
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.
mrpt::poses::CPose3DPDFParticles::drawManySamples
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_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:147
CPose3DPDF.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::CPose3DPDFParticles::bayesianFusion
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) MRPT_OVERRIDE
Bayesian fusion.
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.20 for MRPT 1.4.0 SVN: at Thu Aug 27 02:40:23 UTC 2020