MRPT  1.9.9
CPosePDF.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 CPOSEPDF_H
10 #define CPOSEPDF_H
11 
13 #include <mrpt/poses/CPose2D.h>
16 
17 namespace mrpt::poses
18 {
19 class CPosePDFGaussian; // frd decl.
20 
21 /** Declares a class that represents a probability density function (pdf) of a
22  * 2D pose (x,y,phi).
23  * This class is just the base class for unifying many diferent ways this pdf
24  * can be implemented.
25  *
26  * For convenience, a pose composition is also defined for any pdf derived
27  * class,
28  * changeCoordinatesReference, in the form of a method rather than an
29  * operator.
30  *
31  *
32  * See also the tutorial on <a
33  * href="http://www.mrpt.org/Probability_Density_Distributions_Over_Spatial_Representations"
34  * >probabilistic spatial representations in the MRPT</a>.
35  *
36  * \sa CPose2D, CPose3DPDF, CPoseRandomSampler
37  * \ingroup poses_pdf_grp
38  */
41 {
43 
44  public:
45  /** Copy operator, translating if necesary (for example, between particles
46  * and gaussian representations)
47  */
48  virtual void copyFrom(const CPosePDF& o) = 0;
49 
50  /** Bayesian fusion of two pose distributions (product of two
51  * distributions->new distribution), then save the result in this object
52  * (WARNING: See implementing classes to see classes that can and cannot be
53  * mixtured!)
54  * \param p1 The first distribution to fuse
55  * \param p2 The second distribution to fuse
56  * \param minMahalanobisDistToDrop If set to different of 0, the result of
57  * very separate Gaussian modes (that will result in negligible components)
58  * in SOGs will be dropped to reduce the number of modes in the output.
59  */
60  virtual void bayesianFusion(
61  const CPosePDF& p1, const CPosePDF& p2,
62  const double minMahalanobisDistToDrop = 0) = 0;
63 
64  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
65  */
66  virtual void inverse(CPosePDF& o) const = 0;
67 
68  virtual void changeCoordinatesReference(
69  const CPose3D& newReferenceBase) = 0;
70 
71  /** This static method computes the pose composition Jacobians, with these
72  formulas:
73  \code
74  df_dx =
75  [ 1, 0, -sin(phi_x)*x_u-cos(phi_x)*y_u ]
76  [ 0, 1, cos(phi_x)*x_u-sin(phi_x)*y_u ]
77  [ 0, 0, 1 ]
78 
79  df_du =
80  [ cos(phi_x) , -sin(phi_x) , 0 ]
81  [ sin(phi_x) , cos(phi_x) , 0 ]
82  [ 0 , 0 , 1 ]
83  \endcode
84  */
85  static void jacobiansPoseComposition(
86  const CPose2D& x, const CPose2D& u, mrpt::math::CMatrixDouble33& df_dx,
87  mrpt::math::CMatrixDouble33& df_du, const bool compute_df_dx = true,
88  const bool compute_df_du = true);
89 
90  /** \overload */
91  static void jacobiansPoseComposition(
92  const CPosePDFGaussian& x, const CPosePDFGaussian& u,
94 
95  enum
96  {
98  };
99  static constexpr bool is_3D() { return is_3D_val != 0; }
100  enum
101  {
103  };
104  static constexpr bool is_PDF() { return is_PDF_val != 0; }
105  /** Returns a 3D representation of this PDF (it doesn't clear the current
106  * contents of out_obj, but append new OpenGL objects to that list)
107  * \note Needs the mrpt-opengl library, and using
108  * mrpt::opengl::CSetOfObjects::Ptr as template argument.
109  * \note By default, ellipsoids for the confidence intervals of "q=3" are
110  * drawn; for more mathematical details, see
111  * CGeneralizedEllipsoidTemplate::setQuantiles()
112  */
113  template <class OPENGL_SETOFOBJECTSPTR>
114  inline void getAs3DObject(OPENGL_SETOFOBJECTSPTR& out_obj) const
115  {
116  using SETOFOBJECTS = typename OPENGL_SETOFOBJECTSPTR::element_type;
117  out_obj->insertCollection(*SETOFOBJECTS::posePDF2opengl(*this));
118  }
119 
120  /** Returns a 3D representation of this PDF.
121  * \note Needs the mrpt-opengl library, and using
122  * mrpt::opengl::CSetOfObjects::Ptr as template argument.
123  */
124  template <class OPENGL_SETOFOBJECTSPTR>
125  inline OPENGL_SETOFOBJECTSPTR getAs3DObject() const
126  {
127  using SETOFOBJECTS = typename OPENGL_SETOFOBJECTSPTR::element_type;
128  return SETOFOBJECTS::posePDF2opengl(*this);
129  }
130 
131  public:
133 }; // End of class def.
134 
135 }
136 #endif
137 
138 
static constexpr bool is_3D()
Definition: CPosePDF.h:99
OPENGL_SETOFOBJECTSPTR getAs3DObject() const
Returns a 3D representation of this PDF.
Definition: CPosePDF.h:125
static constexpr bool is_PDF()
Definition: CPosePDF.h:104
virtual void changeCoordinatesReference(const CPose3D &newReferenceBase)=0
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
Put this macro inside any class with members that require {16,32,64}-byte memory alignment (e...
#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:39
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:22
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:38
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
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:114
GLenum GLint x
Definition: glext.h:3538
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020