Main MRPT website > C++ reference for MRPT 1.9.9
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-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 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 /** Declares a class that represents a Probability Distribution
21  * function (PDF) of a 2D pose (x,y,phi).
22  * This class implements that PDF using a 3D grid.
23  *
24  * \sa CPose2D, CPosePDF, CPose2DGridTemplate
25  * \ingroup poses_pdf_grp
26  */
27 class CPosePDFGrid : public CPosePDF, public CPose2DGridTemplate<double>
28 {
30 
31  protected:
32  public:
33  /** Constructor: Initializes a, uniform distribution over the whole given
34  * range.
35  */
37  double xMin = -1.0f, double xMax = 1.0f, double yMin = -1.0f,
38  double yMax = 1.0f, double resolutionXY = 0.5f,
39  double resolutionPhi = mrpt::utils::DEG2RAD(180),
40  double phiMin = -M_PIf, double phiMax = M_PIf);
41 
42  /** Destructor */
43  virtual ~CPosePDFGrid();
44 
45  /** Copy operator, translating if necesary (for example, between particles
46  * and gaussian representations) */
47  void copyFrom(const CPosePDF& o) override;
48 
49  /** Normalizes the PDF, such as all cells sum the unity. */
50  void normalize();
51  /** Assigns the same value to all the cells in the grid, so the sum 1. */
52  void uniformDistribution();
53  /** Returns an estimate of the pose, (the mean, or mathematical expectation
54  * of the PDF). \sa getCovariance */
55  void getMean(CPose2D& mean_pose) const override;
56  /** Returns an estimate of the pose covariance matrix (3x3 cov matrix) and
57  * the mean, both at once. \sa getMean */
59  mrpt::math::CMatrixDouble33& cov, CPose2D& mean_point) const override;
60  /** Save the contents of the 3D grid in one file, as a vertical
61  * concatenation of rectangular matrix for the different "PHI" discrete
62  * levels, and the size in X,Y,and PHI in another file named
63  * "<filename>_dims.txt" */
64  void saveToTextFile(const std::string& dataFile) const override;
65 
66  /** this = p (+) this. This can be used to convert a PDF from local
67  * coordinates to global, providing the point (newReferenceBase) from which
68  * "to project" the current pdf. Result PDF substituted the currently
69  * stored one in the object. */
70  void changeCoordinatesReference(const CPose3D& newReferenceBase) override;
71  /** Bayesian fusion of 2 densities (In the grid representation this becomes
72  * a pointwise multiplication) */
73  void bayesianFusion(
74  const CPosePDF& p1, const CPosePDF& p2,
75  const double& minMahalanobisDistToDrop = 0) override;
76  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF */
77  void inverse(CPosePDF& o) const override;
78  /** Draws a single sample from the distribution (WARNING: weights are
79  * assumed to be normalized!) */
80  void drawSingleSample(CPose2D& outPart) const override;
81  /** Draws a number of samples from the distribution, and saves as a list of
82  * 1x3 vectors, where each row contains a (x,y,phi) datum. */
83  void drawManySamples(
84  size_t N,
85  std::vector<mrpt::math::CVectorDouble>& outSamples) const override;
86 
87 }; // End of class def.
88 } // End of namespace
89 } // End of namespace
90 #endif
void getMean(CPose2D &mean_pose) const override
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF).
double DEG2RAD(const double x)
Degrees to radians.
void uniformDistribution()
Assigns the same value to all the cells in the grid, so the sum 1.
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
void drawSingleSample(CPose2D &outPart) const override
Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!) ...
#define M_PIf
void copyFrom(const CPosePDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
GLsizei const GLchar ** string
Definition: glext.h:4101
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:41
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 1x3 vectors, where each row contains a (x,y,phi) datum.
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...
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
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.
virtual ~CPosePDFGrid()
Destructor.
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, CPose2D &mean_point) const override
Returns an estimate of the pose covariance matrix (3x3 cov matrix) and the mean, both at once...
void inverse(CPosePDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
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
Declares a class that represents a Probability Distribution function (PDF) of a 2D pose (x...
Definition: CPosePDFGrid.h:27
void normalize()
Normalizes the PDF, such as all cells sum the unity.
void saveToTextFile(const std::string &dataFile) const override
Save the contents of the 3D grid in one file, as a vertical concatenation of rectangular matrix for t...
This is a template class for storing a 3D (2D+heading) grid containing any kind of data...
void bayesianFusion(const CPosePDF &p1, const CPosePDF &p2, const double &minMahalanobisDistToDrop=0) override
Bayesian fusion of 2 densities (In the grid representation this becomes a pointwise multiplication) ...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019