Main MRPT website > C++ reference
MRPT logo
CPosePDF.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef CPOSEPDF_H
00029 #define CPOSEPDF_H
00030 
00031 #include <mrpt/utils/CSerializable.h>
00032 #include <mrpt/poses/CPose2D.h>
00033 #include <mrpt/math/CMatrixTemplateNumeric.h>
00034 #include <mrpt/utils/CProbabilityDensityFunction.h>
00035 
00036 
00037 namespace mrpt
00038 {
00039 namespace poses
00040 {
00041         using namespace mrpt::math;
00042 
00043         class CPosePDFGaussian; // frd decl.
00044 
00045         // This must be added to any CSerializable derived class:
00046         DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CPosePDF, mrpt::utils::CSerializable )
00047 
00048         /** Declares a class that represents a probability density function (pdf) of a 2D pose (x,y,phi).
00049          *   This class is just the base class for unifying many diferent ways this pdf can be implemented.
00050          *
00051          *  For convenience, a pose composition is also defined for any pdf derived class,
00052          *   changeCoordinatesReference, in the form of a method rather than an operator.
00053          *
00054          *
00055          *  See also the tutorial on <a href="http://www.mrpt.org/Probability_Density_Distributions_Over_Spatial_Representations" >probabilistic spatial representations in the MRPT</a>.
00056          *
00057          * \sa CPose2D, CPose3DPDF, CPoseRandomSampler
00058          * \ingroup poses_pdf_grp
00059          */
00060         class BASE_IMPEXP CPosePDF : public mrpt::utils::CSerializable, public mrpt::utils::CProbabilityDensityFunction<CPose2D,3>
00061         {
00062                 DEFINE_VIRTUAL_SERIALIZABLE( CPosePDF )
00063 
00064         public:
00065                 /** Copy operator, translating if necesary (for example, between particles and gaussian representations)
00066                   */
00067                 virtual void  copyFrom(const CPosePDF &o) = 0;
00068 
00069 
00070                 /** 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!)
00071                   * \param p1 The first distribution to fuse
00072                   * \param p2 The second distribution to fuse
00073                   * \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.
00074                   */
00075                 virtual void  bayesianFusion(const  CPosePDF &p1,const  CPosePDF &p2, const double&minMahalanobisDistToDrop = 0)  = 0 ;
00076 
00077                 /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
00078                   */
00079                 virtual void  inverse(CPosePDF &o) const = 0;
00080 
00081 
00082                 /** This static method computes the pose composition Jacobians, with these formulas:
00083                         \code
00084                                 df_dx =
00085                                 [ 1, 0, -sin(phi_x)*x_u-cos(phi_x)*y_u ]
00086                                 [ 0, 1,  cos(phi_x)*x_u-sin(phi_x)*y_u ]
00087                                 [ 0, 0,                              1 ]
00088 
00089                                 df_du =
00090                                 [ cos(phi_x) , -sin(phi_x) ,  0  ]
00091                                 [ sin(phi_x) ,  cos(phi_x) ,  0  ]
00092                                 [         0  ,          0  ,  1  ]
00093                         \endcode
00094                   */
00095                 static void jacobiansPoseComposition(
00096                         const CPose2D &x,
00097                         const CPose2D &u,
00098                         CMatrixDouble33                  &df_dx,
00099                         CMatrixDouble33                  &df_du);
00100 
00101                 /** \overload */
00102                 static void jacobiansPoseComposition(
00103                         const CPosePDFGaussian &x,
00104                         const CPosePDFGaussian &u,
00105                         CMatrixDouble33                  &df_dx,
00106                         CMatrixDouble33                  &df_du);
00107 
00108 
00109 
00110                 enum { is_3D_val = 0 };
00111                 static inline bool is_3D() { return is_3D_val!=0; }
00112                 enum { is_PDF_val = 1 };
00113                 static inline bool is_PDF() { return is_PDF_val!=0; }
00114 
00115                 /** Returns a 3D representation of this PDF.
00116                   * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
00117                   */
00118                 template <class OPENGL_SETOFOBJECTSPTR>
00119                 inline void getAs3DObject(OPENGL_SETOFOBJECTSPTR &out_obj) const {
00120                         typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
00121                         *out_obj = *SETOFOBJECTS::posePDF2opengl(*this);
00122                 }
00123 
00124                 /** Returns a 3D representation of this PDF.
00125                   * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument.
00126                   */
00127                 template <class OPENGL_SETOFOBJECTSPTR>
00128                 inline OPENGL_SETOFOBJECTSPTR getAs3DObject() const {
00129                         typedef typename OPENGL_SETOFOBJECTSPTR::value_type SETOFOBJECTS;
00130                         return SETOFOBJECTS::posePDF2opengl(*this);
00131                 }
00132 
00133 
00134         }; // End of class def.
00135 
00136 
00137         } // End of namespace
00138 } // End of namespace
00139 
00140 #endif



Page generated by Doxygen 1.7.4 for MRPT 0.9.5 SVN:2717 at Sun Oct 16 16:08:03 PDT 2011 Hosted on:
SourceForge.net Logo