Main MRPT website > C++ reference
MRPT logo
CMetricMapBuilder.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 CMetricMapBuilder_H
00029 #define CMetricMapBuilder_H
00030 
00031 #include <mrpt/utils/CSerializable.h>
00032 #include <mrpt/utils/CListOfClasses.h>
00033 #include <mrpt/utils/CDebugOutputCapable.h>
00034 #include <mrpt/synch.h>
00035 #include <mrpt/slam/CMultiMetricMap.h>
00036 #include <mrpt/slam/CSensoryFrame.h>
00037 #include <mrpt/slam/CSimpleMap.h>
00038 #include <mrpt/poses/CPose3DPDF.h>
00039 #include <mrpt/slam/CActionCollection.h>
00040 
00041 #include <mrpt/slam/link_pragmas.h>
00042 
00043 namespace mrpt
00044 {
00045 namespace slam
00046 {
00047         /** @defgroup metric_slam_grp Metric SLAM algorithms
00048           * \ingroup mrpt_slam_grp */
00049 
00050         /** This virtual class is the base for SLAM implementations. See derived classes for more information.
00051          *
00052          * \sa CMetricMap  \ingroup metric_slam_grp
00053          */
00054         class SLAM_IMPEXP CMetricMapBuilder : public mrpt::utils::CDebugOutputCapable
00055         {
00056         protected:
00057                 /** Critical zones
00058                   */
00059                 synch::CCriticalSection critZoneChangingMap;
00060 
00061                 /** Enter critical section for map updating:
00062                   */
00063                 inline void  enterCriticalSection() { critZoneChangingMap.enter(); }
00064 
00065                 /** Leave critical section for map updating:
00066                   */
00067                 inline void  leaveCriticalSection() { critZoneChangingMap.leave(); }
00068 
00069         public:
00070                 CMetricMapBuilder();           //!< Constructor
00071                 virtual ~CMetricMapBuilder( ); //!< Destructor.
00072 
00073                 // ---------------------------------------------------------------------
00074                 /** @name Pure virtual methods to implement in any particular SLAM algorithm
00075                     @{ */
00076 
00077                 /** Initialize the method, starting with a known location PDF "x0"(if supplied, set to NULL to left unmodified) and a given fixed, past map. */
00078                 virtual void  initialize(
00079                                 const CSimpleMap &initialMap = CSimpleMap(),
00080                                 CPosePDF                                        *x0 = NULL
00081                                 ) = 0;
00082 
00083                 /** Returns a copy of the current best pose estimation as a pose PDF. */
00084                 virtual CPose3DPDFPtr  getCurrentPoseEstimation() const = 0;
00085 
00086                 /** Process a new action and observations pair to update this map: See the description of the class at the top of this page to see a more complete description.
00087                  *  \param action The estimation of the incremental pose change in the robot pose.
00088                  *      \param observations The set of observations that robot senses at the new pose.
00089                  */
00090                 virtual void  processActionObservation( CActionCollection &action,CSensoryFrame &observations ) = 0;
00091 
00092                 /** Fills "out_map" with the set of "poses"-"sensory-frames", thus the so far built map. */
00093                 virtual void  getCurrentlyBuiltMap(CSimpleMap &out_map) const = 0;
00094 
00095                 /** Returns just how many sensory-frames are stored in the currently build map. */
00096                 virtual unsigned int  getCurrentlyBuiltMapSize() = 0;
00097 
00098                 /** Returns the map built so far. NOTE that for efficiency a pointer to the internal object is passed, DO NOT delete nor modify the object in any way, if desired, make a copy of ir with "duplicate()". */
00099                 virtual CMultiMetricMap*   getCurrentlyBuiltMetricMap() = 0;
00100 
00101                 /** A useful method for debugging: the current map (and/or poses) estimation is dumped to an image file.
00102                   * \param file The output file name
00103                   * \param formatEMF_BMP Output format = true:EMF, false:BMP
00104                   */
00105                 virtual void  saveCurrentEstimationToImage(const std::string &file, bool formatEMF_BMP = true) = 0;
00106 
00107                 /** @} */ 
00108                 // ---------------------------------------------------------------------
00109 
00110                 /** Clear all elements of the maps, and reset localization to (0,0,0deg). */
00111                 void  clear();
00112 
00113                 /** Enables or disables the map updating (default state is enabled) */
00114                 void  enableMapUpdating( bool enable )
00115                 {
00116                         options.enableMapUpdating = enable;
00117                 }
00118 
00119                 /** Load map (mrpt::slam::CSimpleMap) from a ".simplemap" file */
00120                 void  loadCurrentMapFromFile(const std::string &fileName);
00121 
00122                 /** Save map (mrpt::slam::CSimpleMap) to a ".simplemap" file. */
00123                 void  saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const;
00124 
00125                 /** Options for the algorithm */
00126                 struct SLAM_IMPEXP TOptions
00127                 {
00128                         TOptions() : verbose(true),
00129                                                  enableMapUpdating(true),
00130                                                  debugForceInsertion(false),
00131                                                  alwaysInsertByClass()
00132                         {
00133                         }
00134 
00135                         bool    verbose;             //!< If true shows debug information in the console, default is true.
00136                         bool    enableMapUpdating;   //!< Enable map updating, default is true.
00137                         bool    debugForceInsertion; //!< Always insert into map. Default is false: detect if necesary.
00138 
00139                         /** A list of observation classes (derived from mrpt::slam::CObservation) which will be always inserted in the map, disregarding the minimum insertion distances).
00140                           *  Default: Empty. How to insert classes:
00141                           *   \code
00142                           *     alwaysInserByClass.insert(CLASS_ID(CObservationImage));
00143                           *   \endcode
00144                           * \sa mrpt::utils::CListOfClasses
00145                           */
00146                         mrpt::utils::CListOfClasses             alwaysInsertByClass;
00147 
00148                 };
00149 
00150                 TOptions options;
00151 
00152         }; // End of class def.
00153 
00154         } // End of namespace
00155 } // End of namespace
00156 
00157 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011