Main MRPT website > C++ reference
MRPT logo
CPose3DPDF.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 CPose3DPDF_H
29 #define CPose3DPDF_H
30 
32 #include <mrpt/poses/CPose3D.h>
33 #include <mrpt/math/CMatrixD.h>
35 
36 namespace mrpt
37 {
38 namespace poses
39 {
40  using namespace mrpt::math;
41 
42  class CPosePDF;
43 
45 
46  /** Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
47  * This class is just the base class for unifying many diferent
48  * ways this PDF can be implemented.
49  *
50  * For convenience, a pose composition is also defined for any
51  * PDF derived class, changeCoordinatesReference, in the form of a method rather than an operator.
52  *
53  * For a similar class for 3D points (without attitude), see CPointPDF
54  *
55  *
56  * See also the tutorial on <a href="http://www.mrpt.org/Probability_Density_Distributions_Over_Spatial_Representations">probabilistic spatial representations in the MRPT</a>.
57  *
58  * \sa CPose3D, CPosePDF, CPointPDF
59  * \ingroup poses_pdf_grp
60  */
61  class BASE_IMPEXP CPose3DPDF : public mrpt::utils::CSerializable, public mrpt::utils::CProbabilityDensityFunction<CPose3D,6>
62  {
64 
65  public:
66  /** Copy operator, translating if necesary (for example, between particles and gaussian representations)
67  * \sa createFrom2D
68  */
69  virtual void copyFrom(const CPose3DPDF &o) = 0;
70 
71  /** This is a static transformation method from 2D poses to 3D PDFs, preserving the representation type (particles->particles, Gaussians->Gaussians,etc)
72  * It returns a new object of any of the derived classes of CPose3DPDF. This object must be deleted by the user when not required anymore.
73  * \sa copyFrom
74  */
75  static CPose3DPDF* createFrom2D(const CPosePDF &o);
76 
77  /** Bayesian fusion of two pose distributions, then save the result in this object (WARNING: Currently only distributions of the same class can be fused! eg, gaussian with gaussian,etc) */
78  virtual void bayesianFusion( const CPose3DPDF &p1, const CPose3DPDF &p2 ) = 0 ;
79 
80  /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF */
81  virtual void inverse(CPose3DPDF &o) const = 0;
82 
83  /** This static method computes the pose composition Jacobians.
84  *
85  * See this techical report: http:///www.mrpt.org/6D_poses:equivalences_compositions_and_uncertainty
86  *
87  * Direct equations (for the covariances) in yaw-pitch-roll are too complex.
88  * Make a way around them and consider instead this path:
89  * \code
90  * X(6D) U(6D)
91  * | |
92  * v v
93  * X(7D) U(7D)
94  * | |
95  * +--- (+) ---+
96  * |
97  * v
98  * RES(7D)
99  * |
100  * v
101  * RES(6D)
102  * \endcode
103  *
104  */
105  static void jacobiansPoseComposition(
106  const CPose3D &x,
107  const CPose3D &u,
108  CMatrixDouble66 &df_dx,
109  CMatrixDouble66 &df_du);
110 
111 
112  enum { is_3D_val = 1 };
113  static inline bool is_3D() { return is_3D_val!=0; }
114  enum { is_PDF_val = 1 };
115  static inline bool is_PDF() { return is_PDF_val!=0; }
116 
117  /** 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)
118  * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
119  */
120  template <class OPENGL_SETOFOBJECTSPTR>
121  inline void getAs3DObject(OPENGL_SETOFOBJECTSPTR &out_obj) const {
122  typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
123  out_obj->insertCollection( *SETOFOBJECTS::posePDF2opengl(*this) );
124  }
125 
126  /** Returns a 3D representation of this PDF.
127  * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
128  */
129  template <class OPENGL_SETOFOBJECTSPTR>
130  inline OPENGL_SETOFOBJECTSPTR getAs3DObject() const {
131  typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
132  return SETOFOBJECTS::posePDF2opengl(*this);
133  }
134 
135  }; // End of class def.
136 
137 
138  } // End of namespace
139 } // End of namespace
140 
141 #endif



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