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-2018, 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/core/bits_math.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::DEG2RAD(180.0), double phiMin = -M_PI,
40  double phiMax = M_PI);
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". \return false on error */
64  bool 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
mrpt::poses::CPosePDFGrid::normalize
void normalize()
Normalizes the PDF, such as all cells sum the unity.
Definition: CPosePDFGrid.cpp:226
mrpt::poses::CPosePDFGrid::drawSingleSample
void drawSingleSample(CPose2D &outPart) const override
Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!...
Definition: CPosePDFGrid.cpp:205
mrpt::poses::CPosePDFGrid::~CPosePDFGrid
virtual ~CPosePDFGrid()
Destructor.
Definition: CPosePDFGrid.cpp:51
mrpt::poses::CPosePDFGrid
Declares a class that represents a Probability Distribution function (PDF) of a 2D pose (x,...
Definition: CPosePDFGrid.h:27
mrpt::poses::CPosePDFGrid::copyFrom
void copyFrom(const CPosePDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations)
Definition: CPosePDFGrid.cpp:41
mrpt::poses::CPosePDFGrid::getCovarianceAndMean
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.
Definition: CPosePDFGrid.cpp:76
mrpt::poses::CPosePDFGrid::getMean
void getMean(CPose2D &mean_pose) const override
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF).
Definition: CPosePDFGrid.cpp:58
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
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:148
mrpt::poses::CPosePDFGrid::inverse
void inverse(CPosePDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
Definition: CPosePDFGrid.cpp:196
M_PI
#define M_PI
Definition: core/include/mrpt/core/bits_math.h:38
mrpt::poses::CPosePDFGrid::changeCoordinatesReference
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
Definition: CPosePDFGrid.cpp:174
CPose2DGridTemplate.h
CPosePDF.h
mrpt::poses::CPose2D
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:40
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::poses::CPosePDFGrid::uniformDistribution
void uniformDistribution()
Assigns the same value to all the cells in the grid, so the sum 1.
Definition: CPosePDFGrid.cpp:247
mrpt::poses::CPose2DGridTemplate
This is a template class for storing a 3D (2D+heading) grid containing any kind of data.
Definition: CPose2DGridTemplate.h:24
mrpt::math::CMatrixFixedNumeric< double, 3, 3 >
mrpt::poses::CPosePDF
Declares a class that represents a probability density function (pdf) of a 2D pose (x,...
Definition: CPosePDF.h:41
bits_math.h
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::poses::CPosePDFGrid::drawManySamples
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,...
Definition: CPosePDFGrid.cpp:214
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::poses::CPosePDFGrid::bayesianFusion
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)
Definition: CPosePDFGrid.cpp:183
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::DEG2RAD(180.0), double phiMin=-M_PI, double phiMax=M_PI)
Constructor: Initializes a, uniform distribution over the whole given range.
Definition: CPosePDFGrid.cpp:32
mrpt::poses::CPosePDFGrid::saveToTextFile
bool 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...
Definition: CPosePDFGrid.cpp:144
mrpt::DEG2RAD
double DEG2RAD(const double x)
Degrees to radians.
Definition: core/include/mrpt/core/bits_math.h:42



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST