00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 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 #include <mrpt/poses/opengl_frwd_decl.h> 00036 00037 00038 namespace mrpt 00039 { 00040 namespace poses 00041 { 00042 using namespace mrpt::math; 00043 00044 // This must be added to any CSerializable derived class: 00045 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CPosePDF, mrpt::utils::CSerializable ) 00046 00047 /** Declares a class that represents a probability density function (pdf) of a 2D pose (x,y,phi). 00048 * This class is just the base class for unifying many diferent ways this pdf can be implemented. 00049 * 00050 * For convenience, a pose composition is also defined for any pdf derived class, 00051 * changeCoordinatesReference, in the form of a method rather than an operator. 00052 * 00053 * 00054 * See also the tutorial on <a href="http://www.mrpt.org/Probability_Density_Distributions_Over_Spatial_Representations">probabilistic spatial representations in the MRPT</a>. 00055 * 00056 * \sa CPose2D, CPose3DPDF, CPoseRandomSampler 00057 */ 00058 class BASE_IMPEXP CPosePDF : public mrpt::utils::CSerializable, public mrpt::utils::CProbabilityDensityFunction<CPose2D,3> 00059 { 00060 DEFINE_VIRTUAL_SERIALIZABLE( CPosePDF ) 00061 00062 public: 00063 /** Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF) 00064 */ 00065 MRPT_DECLARE_DEPRECATED_FUNCTION("**deprecated** Use getMean instead", 00066 CPose2D getEstimatedPose() const ) 00067 { 00068 CPose2D p; 00069 this->getMean(p); 00070 return p; 00071 } 00072 00073 /** Copy operator, translating if necesary (for example, between particles and gaussian representations) 00074 */ 00075 virtual void copyFrom(const CPosePDF &o) = 0; 00076 00077 00078 /** 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!) 00079 * \param p1 The first distribution to fuse 00080 * \param p2 The second distribution to fuse 00081 * \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. 00082 */ 00083 virtual void bayesianFusion(const CPosePDF &p1,const CPosePDF &p2, const double&minMahalanobisDistToDrop = 0) = 0 ; 00084 00085 /** Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF 00086 */ 00087 virtual void inverse(CPosePDF &o) const = 0; 00088 00089 enum { is_3D_val = 0 }; 00090 static inline bool is_3D() { return is_3D_val!=0; } 00091 enum { is_PDF_val = 1 }; 00092 static inline bool is_PDF() { return is_PDF_val!=0; } 00093 00094 /** Returns a 3D representation of this PDF. 00095 * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument. 00096 */ 00097 template <class OPENGL_SETOFOBJECTSPTR> 00098 inline void getAs3DObject(OPENGL_SETOFOBJECTSPTR &out_obj) const { 00099 *out_obj = *mrpt::opengl::posePDF2opengl<CPosePDF,OPENGL_SETOFOBJECTSPTR>(*this); 00100 } 00101 00102 /** Returns a 3D representation of this PDF. 00103 * \note Needs the mrpt-opengl library, and using mrpt::opengl::CSetOfObjectsPtr as template argument. 00104 */ 00105 template <class OPENGL_SETOFOBJECTSPTR> 00106 inline OPENGL_SETOFOBJECTSPTR getAs3DObject() const { 00107 return mrpt::opengl::posePDF2opengl<CPosePDF,OPENGL_SETOFOBJECTSPTR>(*this); 00108 } 00109 00110 00111 }; // End of class def. 00112 00113 00114 } // End of namespace 00115 } // End of namespace 00116 00117 #endif
Page generated by Doxygen 1.7.1 for MRPT 0.9.4 SVN: at Mon Jan 10 23:33:19 UTC 2011 |