Main MRPT website > C++ reference for MRPT 1.5.7
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-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 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:
22  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(CPose3DPDFParticles,CPose3DPDF)
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  void copyFrom(const CPose3DPDF &o) MRPT_OVERRIDE; //!< Copy operator, translating if necesary (for example, between m_particles and gaussian representations)
48 
49  /** Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose.
50  * \param location The location to set all the m_particles.
51  * \param particlesCount If this is set to 0 the number of m_particles remains unchanged.
52  * \sa resetUniform, resetUniformFreeSpace */
53  void resetDeterministic( const CPose3D &location, size_t particlesCount = 0);
54 
55  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
56  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
57 
58  CPose3D getParticlePose(int i) const; //!< Returns the pose of the i'th particle
59 
60  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"
61 
62  /** Get the m_particles count (equivalent to "particlesCount") */
63  size_t size() const { return m_particles.size(); }
64 
65  /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
66  * "to project" the current pdf. Result PDF substituted the currently stored one in the object. */
67  void changeCoordinatesReference( const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
68  void drawSingleSample( CPose3D &outPart ) const MRPT_OVERRIDE; //!< Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!)
69  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.
70  void operator += ( const CPose3D &Ap); //!< Appends (pose-composition) a given pose "p" to each particle
71  void append( CPose3DPDFParticles &o ); //!< Appends (add to the list) a set of m_particles to the existing ones, and then normalize weights.
72  void inverse(CPose3DPDF &o) const MRPT_OVERRIDE; //!< Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
73  CPose3D getMostLikelyParticle() const; //!< Returns the particle with the highest weight.
74  void bayesianFusion( const CPose3DPDF &p1, const CPose3DPDF &p2 ) MRPT_OVERRIDE; //!< Bayesian fusion
75 
76  }; // End of class def.
77  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(CPose3DPDFParticles,CPose3DPDF)
78  } // End of namespace
79 } // End of namespace
80 #endif
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
GLint location
Definition: glext.h:3910
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...
A numeric matrix of compile-time fixed size.
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
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
Definition: ops_vectors.h:70
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
Definition: Miscellaneous.h:74
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
size_t size() const
Get the m_particles count (equivalent to "particlesCount")
GLsizei const GLchar ** string
Definition: glext.h:3919
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)
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
Definition: CPose3DPDF.h:40
Declares a class that represents a Probability Density function (PDF) of a 3D pose.



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