Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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 
18 namespace mrpt
19 {
20 namespace poses
21 {
22  class CPosePDFGaussian; // frd decl.
23 
24  // This must be added to any CSerializable derived class:
26 
27  /** Declares a class that represents a probability density function (pdf) of a 2D pose (x,y,phi).
28  * This class is just the base class for unifying many diferent ways this pdf can be implemented.
29  *
30  * For convenience, a pose composition is also defined for any pdf derived class,
31  * changeCoordinatesReference, in the form of a method rather than an operator.
32  *
33  *
34  * See also the tutorial on <a href="http://www.mrpt.org/Probability_Density_Distributions_Over_Spatial_Representations" >probabilistic spatial representations in the MRPT</a>.
35  *
36  * \sa CPose2D, CPose3DPDF, CPoseRandomSampler
37  * \ingroup poses_pdf_grp
38  */
39  class BASE_IMPEXP CPosePDF : public mrpt::utils::CSerializable, public mrpt::utils::CProbabilityDensityFunction<CPose2D,3>
40  {
42 
43  public:
44  /** Copy operator, translating if necesary (for example, between particles and gaussian representations)
45  */
46  virtual void copyFrom(const CPosePDF &o) = 0;
47 
48 
49  /** 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!)
50  * \param p1 The first distribution to fuse
51  * \param p2 The second distribution to fuse
52  * \param minMahalanobisDistToDrop If set to different of 0, the result of very separate Gaussian modes (that will result in negligible components) in SOGs will be dropped to reduce the number of modes in the output.
53  */
54  virtual void bayesianFusion(const CPosePDF &p1,const CPosePDF &p2, const double&minMahalanobisDistToDrop = 0) = 0 ;
55 
56  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
57  */
58  virtual void inverse(CPosePDF &o) const = 0;
59 
60 
61  /** This static method computes the pose composition Jacobians, with these formulas:
62  \code
63  df_dx =
64  [ 1, 0, -sin(phi_x)*x_u-cos(phi_x)*y_u ]
65  [ 0, 1, cos(phi_x)*x_u-sin(phi_x)*y_u ]
66  [ 0, 0, 1 ]
67 
68  df_du =
69  [ cos(phi_x) , -sin(phi_x) , 0 ]
70  [ sin(phi_x) , cos(phi_x) , 0 ]
71  [ 0 , 0 , 1 ]
72  \endcode
73  */
74  static void jacobiansPoseComposition(
75  const CPose2D &x,
76  const CPose2D &u,
79  const bool compute_df_dx = true,
80  const bool compute_df_du = true );
81 
82  /** \overload */
83  static void jacobiansPoseComposition(
84  const CPosePDFGaussian &x,
85  const CPosePDFGaussian &u,
88 
89 
90 
91  enum { is_3D_val = 0 };
92  static inline bool is_3D() { return is_3D_val!=0; }
93  enum { is_PDF_val = 1 };
94  static inline bool is_PDF() { return is_PDF_val!=0; }
95 
96  /** Returns a 3D representation of this PDF (it doesn't clear the current contents of out_obj, but append new OpenGL objects to that list)
97  * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
98  * \note By default, ellipsoids for the confidence intervals of "q=3" are drawn; for more mathematical details, see CGeneralizedEllipsoidTemplate::setQuantiles()
99  */
100  template <class OPENGL_SETOFOBJECTSPTR>
101  inline void getAs3DObject(OPENGL_SETOFOBJECTSPTR &out_obj) const {
102  typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
103  out_obj->insertCollection( *SETOFOBJECTS::posePDF2opengl(*this) );
104  }
105 
106  /** Returns a 3D representation of this PDF.
107  * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
108  */
109  template <class OPENGL_SETOFOBJECTSPTR>
110  inline OPENGL_SETOFOBJECTSPTR getAs3DObject() const {
111  typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
112  return SETOFOBJECTS::posePDF2opengl(*this);
113  }
114 
115 
116  }; // End of class def.
118 
119 
120  } // End of namespace
121 } // End of namespace
122 
123 #endif
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(CPose3DPDFGaussianInf, CPose3DPDF)
static bool is_3D()
Definition: CPosePDF.h:92
static bool is_PDF()
Definition: CPosePDF.h:94
OPENGL_SETOFOBJECTSPTR getAs3DObject() const
Returns a 3D representation of this PDF.
Definition: CPosePDF.h:110
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
#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 ...
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
Definition: Miscellaneous.h:74
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:39
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:36
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:101
GLenum GLint x
Definition: glext.h:3516
CSetOfObjectsPtr 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:23



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019