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 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 /** This virtual class is the base for SLAM implementations. See derived classes for more information. 00048 * 00049 * \sa CMetricMap 00050 */ 00051 class SLAM_IMPEXP CMetricMapBuilder : public mrpt::utils::CDebugOutputCapable 00052 { 00053 protected: 00054 /** Critical zones 00055 */ 00056 synch::CCriticalSection critZoneChangingMap; 00057 00058 /** Enter critical section for map updating: 00059 */ 00060 void enterCriticalSection() 00061 { 00062 critZoneChangingMap.enter(); 00063 } 00064 00065 /** Leave critical section for map updating: 00066 */ 00067 void leaveCriticalSection() 00068 { 00069 critZoneChangingMap.leave(); 00070 } 00071 00072 public: 00073 /** Constructor 00074 */ 00075 CMetricMapBuilder(); 00076 00077 /** Destructor. 00078 */ 00079 virtual ~CMetricMapBuilder( ); 00080 00081 /** Initialize the method, starting with a known location PDF "x0"(if supplied, set to NULL to left unmodified) and a given fixed, past map. 00082 */ 00083 virtual void initialize( 00084 const CSimpleMap &initialMap = CSimpleMap(), 00085 CPosePDF *x0 = NULL 00086 ) = 0; 00087 00088 /** Clear all elements of the maps, and reset localization to (0,0,0deg). 00089 */ 00090 void clear(); 00091 00092 /** Returns a copy of the current best pose estimation as a pose PDF. 00093 */ 00094 virtual CPose3DPDFPtr getCurrentPoseEstimation() const = 0; 00095 00096 /** 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. 00097 * \param action The estimation of the incremental pose change in the robot pose. 00098 * \param observations The set of observations that robot senses at the new pose. 00099 */ 00100 virtual void processActionObservation( CActionCollection &action,CSensoryFrame &observations ) = 0; 00101 00102 /** Fills "out_map" with the set of "poses"-"sensory-frames", thus the so far built map. 00103 */ 00104 virtual void getCurrentlyBuiltMap(CSimpleMap &out_map) const = 0; 00105 00106 /** Returns just how many sensory-frames are stored in the currently build map. 00107 */ 00108 virtual unsigned int getCurrentlyBuiltMapSize() = 0; 00109 00110 /** 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()". 00111 */ 00112 virtual CMultiMetricMap* getCurrentlyBuiltMetricMap() = 0; 00113 00114 /** Enables or disables the map updating (default state is enabled) 00115 */ 00116 void enableMapUpdating( bool enable ); 00117 00118 /** A useful method for debugging: the current map (and/or poses) estimation is dumped to an image file. 00119 * \param file The output file name 00120 * \param formatEMF_BMP Output format = true:EMF, false:BMP 00121 */ 00122 virtual void saveCurrentEstimationToImage(const std::string &file, bool formatEMF_BMP = true) = 0; 00123 00124 00125 /** Load map (CSimpleMap) from a ".simplemap" file 00126 */ 00127 void loadCurrentMapFromFile(const std::string &fileName); 00128 00129 /** Save map (CSimpleMap) to a ".simplemap" file. 00130 */ 00131 void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const; 00132 00133 00134 /** Options for the algorithm 00135 */ 00136 struct SLAM_IMPEXP TOptions 00137 { 00138 TOptions() : verbose(true), 00139 enableMapUpdating(true), 00140 debugForceInsertion(false), 00141 insertImagesAlways(false), 00142 alwaysInsertByClass() 00143 { 00144 } 00145 00146 /** If true shows debug information in the console, default is true. 00147 */ 00148 bool verbose; 00149 00150 /** Enable map updating, default is true. 00151 */ 00152 bool enableMapUpdating; 00153 00154 /** Always insert into map. Default is false: detect if necesary. 00155 */ 00156 bool debugForceInsertion; 00157 00158 /** *DEPRECATED (Use "alwaysInserByClass") * Always include a SF into the map if an image is included. Default is false. 00159 */ 00160 bool insertImagesAlways; 00161 00162 /** A list of observation classes (derived from mrpt::slam::CObservation) which will be always inserted in the map, disregarding the minimum insertion distances). 00163 * Default: Empty. How to insert classes: 00164 * \code 00165 * alwaysInserByClass.insert(CLASS_ID(CObservationImage)); 00166 * \endcode 00167 * \sa mrpt::utils::CListOfClasses 00168 */ 00169 mrpt::utils::CListOfClasses alwaysInsertByClass; 00170 00171 } options; 00172 00173 }; // End of class def. 00174 00175 } // End of namespace 00176 } // End of namespace 00177 00178 #endif
Page generated by Doxygen 1.7.1 for MRPT 0.9.4 SVN: at Mon Jan 10 23:33:19 UTC 2011 |