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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019