Main MRPT website > C++ reference
MRPT logo
CPosePDF.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CPOSEPDF_H
29 #define CPOSEPDF_H
30 
32 #include <mrpt/poses/CPose2D.h>
35 
36 
37 namespace mrpt
38 {
39 namespace poses
40 {
41  using namespace mrpt::math;
42 
43  class CPosePDFGaussian; // frd decl.
44 
45  // This must be added to any CSerializable derived class:
47 
48  /** Declares a class that represents a probability density function (pdf) of a 2D pose (x,y,phi).
49  * This class is just the base class for unifying many diferent ways this pdf can be implemented.
50  *
51  * For convenience, a pose composition is also defined for any pdf derived class,
52  * changeCoordinatesReference, in the form of a method rather than an operator.
53  *
54  *
55  * See also the tutorial on <a href="http://www.mrpt.org/Probability_Density_Distributions_Over_Spatial_Representations" >probabilistic spatial representations in the MRPT</a>.
56  *
57  * \sa CPose2D, CPose3DPDF, CPoseRandomSampler
58  * \ingroup poses_pdf_grp
59  */
60  class BASE_IMPEXP CPosePDF : public mrpt::utils::CSerializable, public mrpt::utils::CProbabilityDensityFunction<CPose2D,3>
61  {
63 
64  public:
65  /** Copy operator, translating if necesary (for example, between particles and gaussian representations)
66  */
67  virtual void copyFrom(const CPosePDF &o) = 0;
68 
69 
70  /** 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!)
71  * \param p1 The first distribution to fuse
72  * \param p2 The second distribution to fuse
73  * \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.
74  */
75  virtual void bayesianFusion(const CPosePDF &p1,const CPosePDF &p2, const double&minMahalanobisDistToDrop = 0) = 0 ;
76 
77  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
78  */
79  virtual void inverse(CPosePDF &o) const = 0;
80 
81 
82  /** This static method computes the pose composition Jacobians, with these formulas:
83  \code
84  df_dx =
85  [ 1, 0, -sin(phi_x)*x_u-cos(phi_x)*y_u ]
86  [ 0, 1, cos(phi_x)*x_u-sin(phi_x)*y_u ]
87  [ 0, 0, 1 ]
88 
89  df_du =
90  [ cos(phi_x) , -sin(phi_x) , 0 ]
91  [ sin(phi_x) , cos(phi_x) , 0 ]
92  [ 0 , 0 , 1 ]
93  \endcode
94  */
95  static void jacobiansPoseComposition(
96  const CPose2D &x,
97  const CPose2D &u,
98  CMatrixDouble33 &df_dx,
99  CMatrixDouble33 &df_du);
100 
101  /** \overload */
102  static void jacobiansPoseComposition(
103  const CPosePDFGaussian &x,
104  const CPosePDFGaussian &u,
105  CMatrixDouble33 &df_dx,
106  CMatrixDouble33 &df_du);
107 
108 
109 
110  enum { is_3D_val = 0 };
111  static inline bool is_3D() { return is_3D_val!=0; }
112  enum { is_PDF_val = 1 };
113  static inline bool is_PDF() { return is_PDF_val!=0; }
114 
115  /** 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)
116  * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
117  */
118  template <class OPENGL_SETOFOBJECTSPTR>
119  inline void getAs3DObject(OPENGL_SETOFOBJECTSPTR &out_obj) const {
120  typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
121  out_obj->insertCollection( *SETOFOBJECTS::posePDF2opengl(*this) );
122  }
123 
124  /** Returns a 3D representation of this PDF.
125  * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
126  */
127  template <class OPENGL_SETOFOBJECTSPTR>
128  inline OPENGL_SETOFOBJECTSPTR getAs3DObject() const {
129  typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
130  return SETOFOBJECTS::posePDF2opengl(*this);
131  }
132 
133 
134  }; // End of class def.
135 
136 
137  } // End of namespace
138 } // End of namespace
139 
140 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013