MRPT  1.9.9
CPose3DQuatPDFGaussianInf.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 CPose3DQuatPDFGaussianInf_H
10 #define CPose3DQuatPDFGaussianInf_H
11 
13 #include <mrpt/poses/CPose3DPDF.h>
14 #include <mrpt/poses/CPosePDF.h>
15 #include <mrpt/math/CMatrixD.h>
16 
17 namespace mrpt::poses
18 {
19 class CPosePDFGaussian;
20 class CPose3DPDFGaussian;
21 
22 /** Declares a class that represents a Probability Density function (PDF) of a
23  * 3D pose using a quaternion \f$ p(\mathbf{x}) = [x ~ y ~ z ~ qr ~ qx ~ qy ~
24  * qz]^\top \f$.
25  *
26  * This class implements that PDF using a mono-modal Gaussian distribution
27  * storing the information matrix instead of its inverse, the covariance matrix.
28  * See mrpt::poses::CPose3DQuatPDF for more details, or
29  * mrpt::poses::CPose3DPDF for classes based on Euler angles instead.
30  *
31  * Uncertainty of pose composition operations (\f$ y = x \oplus u \f$) is
32  * implemented in the methods "CPose3DQuatPDFGaussianInf::operator+=" and
33  * "CPose3DQuatPDF::jacobiansPoseComposition".
34  *
35  * For further details on implemented methods and the theory behind them,
36  * see <a
37  * href="http://www.mrpt.org/6D_poses:equivalences_compositions_and_uncertainty"
38  * >this report</a>.
39  *
40  * \sa CPose3DQuat, CPose3DQuatPDF, CPose3DPDF, CPose3DQuatPDFGaussian
41  * \ingroup poses_pdf_grp
42  */
44 {
45  // This must be added to any CSerializable derived class:
48 
49  public:
50  /** Default constructor - set all values to zero. */
52 
53  /** Constructor which left all the member uninitialized, for using when
54  * speed is critical - as argument, use UNINITIALIZED_QUATERNION. */
56  mrpt::math::TConstructorFlags_Quaternions constructor_dummy_param);
57 
58  /** Constructor from a default mean value, information matrix equals to
59  * zero. */
60  explicit CPose3DQuatPDFGaussianInf(const CPose3DQuat& init_Mean);
61 
62  /** Constructor with mean and inverse covariance (information matrix). */
64  const CPose3DQuat& init_Mean,
65  const mrpt::math::CMatrixDouble77& init_CovInv);
66 
67  /** The mean value */
69  /** The 7x7 information matrix (the inverse of the covariance) */
71 
72  inline const CPose3DQuat& getPoseMean() const { return mean; }
73  inline CPose3DQuat& getPoseMean() { return mean; }
74  /** Returns an estimate of the pose, (the mean, or mathematical expectation
75  * of the PDF) \sa getCovariance */
76  void getMean(CPose3DQuat& mean_pose) const override { mean_pose = mean; }
77  bool isInfType() const override { return true; }
78  /** Returns an estimate of the pose covariance matrix (7x7 cov matrix) and
79  * the mean, both at once. \sa getMean */
82  CPose3DQuat& mean_point) const override
83  {
84  cov_inv.inv(cov);
85  mean_point = mean;
86  }
87 
88  /** Returns the information (inverse covariance) matrix (a STATE_LEN x
89  * STATE_LEN matrix) \sa getMean, getCovarianceAndMean */
91  {
92  inf = cov_inv;
93  }
94 
95  /** Copy operator, translating if necesary (for example, between particles
96  * and gaussian representations) */
97  void copyFrom(const CPose3DQuatPDF& o) override;
98 
99  /** Save the PDF to a text file, containing the 3D pose in the first line (x
100  * y z qr qx qy qz), then the information matrix in the next 7 lines. */
101  bool saveToTextFile(const std::string& file) const override;
102 
103  /** this = p (+) this. This can be used to convert a PDF from local
104  * coordinates to global, providing the point (newReferenceBase) from which
105  * "to project" the current pdf. Result PDF substituted the currently
106  * stored one in the object. */
107  void changeCoordinatesReference(const CPose3DQuat& newReferenceBase);
108 
109  /** this = p (+) this. This can be used to convert a PDF from local
110  * coordinates to global, providing the point (newReferenceBase) from which
111  * "to project" the current pdf. Result PDF substituted the currently
112  * stored one in the object. */
113  void changeCoordinatesReference(const CPose3D& newReferenceBase) override;
114 
115  /** Draws a single sample from the distribution */
116  void drawSingleSample(CPose3DQuat& outPart) const override;
117  /** Draws a number of samples from the distribution, and saves as a list of
118  * 1x7 vectors, where each row contains a (x,y,z,qr,qx,qy,qz) datum */
119  void drawManySamples(
120  size_t N,
121  std::vector<mrpt::math::CVectorDouble>& outSamples) const override;
122  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF */
123  void inverse(CPose3DQuatPDF& o) const override;
124 
125  /** Unary - operator, returns the PDF of the inverse pose. */
127  {
129  this->inverse(p);
130  return p;
131  }
132 
133  /** Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the
134  * mean, and the covariance matrix are updated). */
135  void operator+=(const CPose3DQuat& Ap);
136  /** Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the
137  * mean, and the covariance matrix are updated) (see formulas in
138  * jacobiansPoseComposition ). */
139  void operator+=(const CPose3DQuatPDFGaussianInf& Ap);
140  /** Makes: thisPDF = thisPDF - Ap, where "-" is pose inverse composition
141  * (both the mean, and the covariance matrix are updated). */
142  void operator-=(const CPose3DQuatPDFGaussianInf& Ap);
143 
144  /** Evaluates the PDF at a given point */
145  double evaluatePDF(const CPose3DQuat& x) const;
146  /** Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in
147  * the range [0,1] */
148  double evaluateNormalizedPDF(const CPose3DQuat& x) const;
149 
150 }; // End of class def.
151 
152 bool operator==(
153  const CPose3DQuatPDFGaussianInf& p1, const CPose3DQuatPDFGaussianInf& p2);
154 /** Pose composition for two 3D pose Gaussians \sa
155  * CPose3DQuatPDFGaussianInf::operator += */
156 CPose3DQuatPDFGaussianInf operator+(
157  const CPose3DQuatPDFGaussianInf& x, const CPose3DQuatPDFGaussianInf& u);
158 /** Inverse pose composition for two 3D pose Gaussians \sa
159  * CPose3DQuatPDFGaussianInf::operator -= */
160 CPose3DQuatPDFGaussianInf operator-(
161  const CPose3DQuatPDFGaussianInf& x, const CPose3DQuatPDFGaussianInf& u);
162 
163 /** Dumps the mean and covariance matrix to a text stream. */
164 std::ostream& operator<<(
165  std::ostream& out, const CPose3DQuatPDFGaussianInf& obj);
166 
167 }
168 #endif
169 
170 
void inverse(CPose3DQuatPDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
TConstructorFlags_Quaternions
Definition: CQuaternion.h:20
mrpt::math::TPoint2D operator+(const CPose2D &pose, const mrpt::math::TPoint2D &pnt)
Compose a 2D point from a new coordinate base given by a 2D pose.
Definition: CPose2D.cpp:364
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
void copyFrom(const CPose3DQuatPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
CPose3DQuatPDFGaussianInf operator-() const
Unary - operator, returns the PDF of the inverse pose.
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
double evaluateNormalizedPDF(const CPose3DQuat &x) const
Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,1].
void operator+=(const CPose3DQuat &Ap)
Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the mean, and the covariance matri...
mrpt::math::CMatrixDouble77 cov_inv
The 7x7 information matrix (the inverse of the covariance)
void changeCoordinatesReference(const CPose3DQuat &newReferenceBase)
this = p (+) this.
A numeric matrix of compile-time fixed size.
void getInformationMatrix(mrpt::math::CMatrixDouble77 &inf) const override
Returns the information (inverse covariance) matrix (a STATE_LEN x STATE_LEN matrix) ...
CPose2D operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
Definition: CPose2D.cpp:315
CMatrixFixedNumeric< double, 7, 7 > CMatrixDouble77
Definition: eigen_frwds.h:60
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:46
bool saveToTextFile(const std::string &file) const override
Save the PDF to a text file, containing the 3D pose in the first line (x y z qr qx qy qz)...
double evaluatePDF(const CPose3DQuat &x) const
Evaluates the PDF at a given point.
GLsizei const GLchar ** string
Definition: glext.h:4101
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 1x7 vectors, where each row contains a (x,y,z,qr,qx,qy,qz) datum.
bool isInfType() const override
Returns whether the class instance holds the uncertainty in covariance or information form...
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...
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
Definition: CPoint.h:164
void operator-=(const CPose3DQuatPDFGaussianInf &Ap)
Makes: thisPDF = thisPDF - Ap, where "-" is pose inverse composition (both the mean, and the covariance matrix are updated).
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
void getCovarianceAndMean(mrpt::math::CMatrixDouble77 &cov, CPose3DQuat &mean_point) const override
Returns an estimate of the pose covariance matrix (7x7 cov matrix) and the mean, both at once...
void drawSingleSample(CPose3DQuat &outPart) const override
Draws a single sample from the distribution.
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
GLenum GLint x
Definition: glext.h:3538
void getMean(CPose3DQuat &mean_pose) const override
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF) ...
GLfloat GLfloat p
Definition: glext.h:6305
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].
Definition: CPoint.h:138



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