Main MRPT website > C++ reference for MRPT 1.4.0
CPosePDFGrid.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 CPosePDFGrid_H
10 #define CPosePDFGrid_H
11 
12 #include <mrpt/poses/CPosePDF.h>
14 #include <mrpt/utils/bits.h> // DEG2RAD()
15 
16 namespace mrpt
17 {
18 namespace poses
19 {
20  // This must be added to any CSerializable derived class:
22 
23  /** Declares a class that represents a Probability Distribution
24  * function (PDF) of a 2D pose (x,y,phi).
25  * This class implements that PDF using a 3D grid.
26  *
27  * \sa CPose2D, CPosePDF, CPose2DGridTemplate
28  * \ingroup poses_pdf_grp
29  */
30  class BASE_IMPEXP CPosePDFGrid : public CPosePDF, public CPose2DGridTemplate<double>
31  {
32  // This must be added to any CSerializable derived class:
34 
35  protected:
36 
37 
38  public:
39  /** Constructor: Initializes a, uniform distribution over the whole given range.
40  */
42  double xMin = -1.0f,
43  double xMax = 1.0f,
44  double yMin = -1.0f,
45  double yMax = 1.0f,
46  double resolutionXY = 0.5f,
47  double resolutionPhi = mrpt::utils::DEG2RAD(180),
48  double phiMin = -M_PIf,
49  double phiMax = M_PIf
50  );
51 
52  virtual ~CPosePDFGrid(); //!< Destructor
53 
54  void copyFrom(const CPosePDF &o) MRPT_OVERRIDE; //!< Copy operator, translating if necesary (for example, between particles and gaussian representations)
55 
56  void normalize(); //!< Normalizes the PDF, such as all cells sum the unity.
57  void uniformDistribution(); //!< Assigns the same value to all the cells in the grid, so the sum 1.
58  void getMean(CPose2D &mean_pose) const MRPT_OVERRIDE; //!< Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF). \sa getCovariance
59  void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov,CPose2D &mean_point) const MRPT_OVERRIDE; //!< Returns an estimate of the pose covariance matrix (3x3 cov matrix) and the mean, both at once. \sa getMean
60  void saveToTextFile(const std::string &dataFile) const MRPT_OVERRIDE; //!< Save the contents of the 3D grid in one file, as a vertical concatenation of rectangular matrix for the different "PHI" discrete levels, and the size in X,Y,and PHI in another file named "<filename>_dims.txt"
61 
62  /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
63  * "to project" the current pdf. Result PDF substituted the currently stored one in the object. */
64  void changeCoordinatesReference( const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
65  void bayesianFusion(const CPosePDF &p1,const CPosePDF &p2, const double &minMahalanobisDistToDrop = 0 ) MRPT_OVERRIDE; //!< Bayesian fusion of 2 densities (In the grid representation this becomes a pointwise multiplication)
66  void inverse(CPosePDF &o) const MRPT_OVERRIDE; //!< Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
67  void drawSingleSample( CPose2D &outPart ) const MRPT_OVERRIDE; //!< Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!)
68  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 1x3 vectors, where each row contains a (x,y,phi) datum.
69 
70  }; // End of class def.
72  } // End of namespace
73 } // End of namespace
74 #endif
mrpt::poses::CPosePDFGrid::bayesianFusion
void bayesianFusion(const CPosePDF &p1, const CPosePDF &p2, const double &minMahalanobisDistToDrop=0) MRPT_OVERRIDE
Bayesian fusion of 2 densities (In the grid representation this becomes a pointwise multiplication)
mrpt::poses::CPosePDFGrid
Declares a class that represents a Probability Distribution function (PDF) of a 2D pose (x,...
Definition: CPosePDFGrid.h:31
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
Definition: CSerializable.h:182
mrpt::poses::CPosePDFGrid::uniformDistribution
void uniformDistribution()
Assigns the same value to all the cells in the grid, so the sum 1.
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:17
mrpt::pbmap::inverse
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
Definition: Miscellaneous.h:74
M_PIf
#define M_PIf
Definition: mrpt_macros.h:366
bits.h
mrpt::poses::CPosePDFGrid::CPosePDFGrid
CPosePDFGrid(double xMin=-1.0f, double xMax=1.0f, double yMin=-1.0f, double yMax=1.0f, double resolutionXY=0.5f, double resolutionPhi=mrpt::utils::DEG2RAD(180), double phiMin=-M_PIf, double phiMax=M_PIf)
Constructor: Initializes a, uniform distribution over the whole given range.
mrpt::math::CVectorDouble
dynamic_vector< double > CVectorDouble
Column vector, like Eigen::MatrixXd, but automatically initialized to zeros since construction.
Definition: eigen_frwds.h:37
mrpt::poses::CPosePDFGrid::normalize
void normalize()
Normalizes the PDF, such as all cells sum the unity.
mrpt::poses::CPosePDFGrid::getCovarianceAndMean
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, CPose2D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the pose covariance matrix (3x3 cov matrix) and the mean, both at once.
mrpt::utils::DEG2RAD
double DEG2RAD(const double x)
Degrees to radians.
Definition: bits.h:69
CPose2DGridTemplate.h
CPosePDF.h
mrpt::poses::CPose2D
A class used to store a 2D pose.
Definition: CPose2D.h:37
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
mrpt::poses::CPose2DGridTemplate
This is a template class for storing a 3D (2D+heading) grid containing any kind of data.
Definition: CPose2DGridTemplate.h:25
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:43
mrpt::poses::CPosePDF
Declares a class that represents a probability density function (pdf) of a 2D pose (x,...
Definition: CPosePDF.h:40
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
mrpt::poses::CPosePDFGrid::changeCoordinatesReference
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
mrpt::poses::CPosePDFGrid::~CPosePDFGrid
virtual ~CPosePDFGrid()
Destructor.
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::CPosePDFGrid::getMean
void getMean(CPose2D &mean_pose) const MRPT_OVERRIDE
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF).
MRPT_OVERRIDE
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
mrpt::poses::CPosePDFGrid::copyFrom
void copyFrom(const CPosePDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between particles and gaussian representations)
mrpt::poses::CPosePDFGrid::saveToTextFile
void saveToTextFile(const std::string &dataFile) const MRPT_OVERRIDE
Save the contents of the 3D grid in one file, as a vertical concatenation of rectangular matrix for t...
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