MRPT  1.9.9
CPosePDF.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
13 #include <mrpt/poses/CPose2D.h>
15 
16 namespace mrpt::poses
17 {
18 class CPosePDFGaussian; // frd decl.
19 
20 /** Declares a class that represents a probability density function (pdf) of a
21  * 2D pose (x,y,phi).
22  * This class is just the base class for unifying many diferent ways this pdf
23  * can be implemented.
24  *
25  * For convenience, a pose composition is also defined for any pdf derived
26  * class,
27  * changeCoordinatesReference, in the form of a method rather than an
28  * operator.
29  *
30  *
31  * See also the tutorial on <a
32  * href="http://www.mrpt.org/Probability_Density_Distributions_Over_Spatial_Representations"
33  * >probabilistic spatial representations in the MRPT</a>.
34  *
35  * \sa CPose2D, CPose3DPDF, CPoseRandomSampler
36  * \ingroup poses_pdf_grp
37  */
40 {
42 
43  public:
44  /** Copy operator, translating if necesary (for example, between particles
45  * and gaussian representations)
46  */
47  virtual void copyFrom(const CPosePDF& o) = 0;
48 
49  /** Bayesian fusion of two pose distributions (product of two
50  * distributions->new distribution), then save the result in this object
51  * (WARNING: See implementing classes to see classes that can and cannot be
52  * mixtured!)
53  * \param p1 The first distribution to fuse
54  * \param p2 The second distribution to fuse
55  * \param minMahalanobisDistToDrop If set to different of 0, the result of
56  * very separate Gaussian modes (that will result in negligible components)
57  * in SOGs will be dropped to reduce the number of modes in the output.
58  */
59  virtual void bayesianFusion(
60  const CPosePDF& p1, const CPosePDF& p2,
61  const double minMahalanobisDistToDrop = 0) = 0;
62 
63  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
64  */
65  virtual void inverse(CPosePDF& o) const = 0;
66 
67  virtual void changeCoordinatesReference(
68  const CPose3D& newReferenceBase) = 0;
69 
70  /** This static method computes the pose composition Jacobians, with these
71  formulas:
72  \code
73  df_dx =
74  [ 1, 0, -sin(phi_x)*x_u-cos(phi_x)*y_u ]
75  [ 0, 1, cos(phi_x)*x_u-sin(phi_x)*y_u ]
76  [ 0, 0, 1 ]
77 
78  df_du =
79  [ cos(phi_x) , -sin(phi_x) , 0 ]
80  [ sin(phi_x) , cos(phi_x) , 0 ]
81  [ 0 , 0 , 1 ]
82  \endcode
83  */
84  static void jacobiansPoseComposition(
85  const CPose2D& x, const CPose2D& u, mrpt::math::CMatrixDouble33& df_dx,
86  mrpt::math::CMatrixDouble33& df_du, const bool compute_df_dx = true,
87  const bool compute_df_du = true);
88 
89  /** \overload */
90  static void jacobiansPoseComposition(
91  const CPosePDFGaussian& x, const CPosePDFGaussian& u,
93 
94  enum
95  {
97  };
98  static constexpr bool is_3D() { return is_3D_val != 0; }
99  enum
100  {
102  };
103  static constexpr bool is_PDF() { return is_PDF_val != 0; }
104  /** Returns a 3D representation of this PDF (it doesn't clear the current
105  * contents of out_obj, but append new OpenGL objects to that list)
106  * \note Needs the mrpt-opengl library, and using
107  * mrpt::opengl::CSetOfObjects::Ptr as template argument.
108  * \note By default, ellipsoids for the confidence intervals of "q=3" are
109  * drawn; for more mathematical details, see
110  * CGeneralizedEllipsoidTemplate::setQuantiles()
111  */
112  template <class OPENGL_SETOFOBJECTSPTR>
113  inline void getAs3DObject(OPENGL_SETOFOBJECTSPTR& out_obj) const
114  {
115  using SETOFOBJECTS = typename OPENGL_SETOFOBJECTSPTR::element_type;
116  out_obj->insertCollection(*SETOFOBJECTS::posePDF2opengl(*this));
117  }
118 
119  /** Returns a 3D representation of this PDF.
120  * \note Needs the mrpt-opengl library, and using
121  * mrpt::opengl::CSetOfObjects::Ptr as template argument.
122  */
123  template <class OPENGL_SETOFOBJECTSPTR>
124  inline OPENGL_SETOFOBJECTSPTR getAs3DObject() const
125  {
126  using SETOFOBJECTS = typename OPENGL_SETOFOBJECTSPTR::element_type;
127  return SETOFOBJECTS::posePDF2opengl(*this);
128  }
129 
130  public:
131 }; // End of class def.
132 
133 } // namespace mrpt::poses
static constexpr bool is_3D()
Definition: CPosePDF.h:98
OPENGL_SETOFOBJECTSPTR getAs3DObject() const
Returns a 3D representation of this PDF.
Definition: CPosePDF.h:124
static constexpr bool is_PDF()
Definition: CPosePDF.h:103
virtual void changeCoordinatesReference(const CPose3D &newReferenceBase)=0
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
virtual void copyFrom(const CPosePDF &o)=0
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:38
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
CSetOfObjects::Ptr posePDF2opengl(const POSE_PDF &o)
Returns a representation of a the PDF - this is just an auxiliary function, it&#39;s more natural to call...
Definition: pose_pdfs.h:21
virtual void inverse(CPosePDF &o) const =0
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:39
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:84
static void jacobiansPoseComposition(const CPose2D &x, const CPose2D &u, mrpt::math::CMatrixDouble33 &df_dx, mrpt::math::CMatrixDouble33 &df_du, const bool compute_df_dx=true, const bool compute_df_du=true)
This static method computes the pose composition Jacobians, with these formulas:
Definition: CPosePDF.cpp:32
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
void getAs3DObject(OPENGL_SETOFOBJECTSPTR &out_obj) const
Returns a 3D representation of this PDF (it doesn&#39;t clear the current contents of out_obj...
Definition: CPosePDF.h:113
GLenum GLint x
Definition: glext.h:3542
virtual void bayesianFusion(const CPosePDF &p1, const CPosePDF &p2, const double minMahalanobisDistToDrop=0)=0
Bayesian fusion of two pose distributions (product of two distributions->new distribution), then save the result in this object (WARNING: See implementing classes to see classes that can and cannot be mixtured!)
A generic template for probability density distributions (PDFs).



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 765b969e7 Sun Sep 22 19:55:28 2019 +0200 at dom sep 22 20:00:14 CEST 2019