Main MRPT website > C++ reference
MRPT logo
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-2014, 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  using namespace mrpt::math;
23 
24  class CPosePDFGaussian; // frd decl.
25 
26  // This must be added to any CSerializable derived class:
28 
29  /** Declares a class that represents a probability density function (pdf) of a 2D pose (x,y,phi).
30  * This class is just the base class for unifying many diferent ways this pdf can be implemented.
31  *
32  * For convenience, a pose composition is also defined for any pdf derived class,
33  * changeCoordinatesReference, in the form of a method rather than an operator.
34  *
35  *
36  * See also the tutorial on <a href="http://www.mrpt.org/Probability_Density_Distributions_Over_Spatial_Representations" >probabilistic spatial representations in the MRPT</a>.
37  *
38  * \sa CPose2D, CPose3DPDF, CPoseRandomSampler
39  * \ingroup poses_pdf_grp
40  */
41  class BASE_IMPEXP CPosePDF : public mrpt::utils::CSerializable, public mrpt::utils::CProbabilityDensityFunction<CPose2D,3>
42  {
44 
45  public:
46  /** Copy operator, translating if necesary (for example, between particles and gaussian representations)
47  */
48  virtual void copyFrom(const CPosePDF &o) = 0;
49 
50 
51  /** 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!)
52  * \param p1 The first distribution to fuse
53  * \param p2 The second distribution to fuse
54  * \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.
55  */
56  virtual void bayesianFusion(const CPosePDF &p1,const CPosePDF &p2, const double&minMahalanobisDistToDrop = 0) = 0 ;
57 
58  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
59  */
60  virtual void inverse(CPosePDF &o) const = 0;
61 
62 
63  /** This static method computes the pose composition Jacobians, with these formulas:
64  \code
65  df_dx =
66  [ 1, 0, -sin(phi_x)*x_u-cos(phi_x)*y_u ]
67  [ 0, 1, cos(phi_x)*x_u-sin(phi_x)*y_u ]
68  [ 0, 0, 1 ]
69 
70  df_du =
71  [ cos(phi_x) , -sin(phi_x) , 0 ]
72  [ sin(phi_x) , cos(phi_x) , 0 ]
73  [ 0 , 0 , 1 ]
74  \endcode
75  */
76  static void jacobiansPoseComposition(
77  const CPose2D &x,
78  const CPose2D &u,
79  CMatrixDouble33 &df_dx,
80  CMatrixDouble33 &df_du,
81  const bool compute_df_dx = true,
82  const bool compute_df_du = true );
83 
84  /** \overload */
85  static void jacobiansPoseComposition(
86  const CPosePDFGaussian &x,
87  const CPosePDFGaussian &u,
88  CMatrixDouble33 &df_dx,
89  CMatrixDouble33 &df_du);
90 
91 
92 
93  enum { is_3D_val = 0 };
94  static inline bool is_3D() { return is_3D_val!=0; }
95  enum { is_PDF_val = 1 };
96  static inline bool is_PDF() { return is_PDF_val!=0; }
97 
98  /** 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)
99  * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
100  */
101  template <class OPENGL_SETOFOBJECTSPTR>
102  inline void getAs3DObject(OPENGL_SETOFOBJECTSPTR &out_obj) const {
103  typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
104  out_obj->insertCollection( *SETOFOBJECTS::posePDF2opengl(*this) );
105  }
106 
107  /** Returns a 3D representation of this PDF.
108  * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
109  */
110  template <class OPENGL_SETOFOBJECTSPTR>
111  inline OPENGL_SETOFOBJECTSPTR getAs3DObject() const {
112  typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
113  return SETOFOBJECTS::posePDF2opengl(*this);
114  }
115 
116 
117  }; // End of class def.
118 
119 
120  } // End of namespace
121 } // End of namespace
122 
123 #endif
static bool is_3D()
Definition: CPosePDF.h:94
static bool is_PDF()
Definition: CPosePDF.h:96
OPENGL_SETOFOBJECTSPTR getAs3DObject() const
Returns a 3D representation of this PDF.
Definition: CPosePDF.h:111
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:32
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
Definition: CArray.h:19
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
class BASE_IMPEXP CSerializable
Definition: CStream.h:21
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
Definition: Miscellaneous.h:71
#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:41
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose.
Definition: CPose2D.h:35
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:102
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.1.0 SVN: at lun oct 28 00:54:49 CET 2019 Hosted on:
SourceForge.net Logo