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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020