00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 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/CDebugOutputCapable.h> 00033 #include <mrpt/synch.h> 00034 #include <mrpt/slam/CMultiMetricMap.h> 00035 #include <mrpt/slam/CSensoryFrame.h> 00036 #include <mrpt/slam/CSensFrameProbSequence.h> 00037 #include <mrpt/poses/CPose3DPDF.h> 00038 #include <mrpt/slam/CActionCollection.h> 00039 00040 namespace mrpt 00041 { 00042 namespace slam 00043 { 00044 /** This virtual class is the base for SLAM implementations. See derived classes for more information. 00045 * 00046 * \sa CMetricMap 00047 */ 00048 class MRPTDLLIMPEXP CMetricMapBuilder : public mrpt::utils::CDebugOutputCapable 00049 { 00050 protected: 00051 /** Critical zones 00052 */ 00053 synch::CCriticalSection critZoneChangingMap; 00054 00055 /** Enter critical section for map updating: 00056 */ 00057 void enterCriticalSection() 00058 { 00059 critZoneChangingMap.enter(); 00060 } 00061 00062 /** Leave critical section for map updating: 00063 */ 00064 void leaveCriticalSection() 00065 { 00066 critZoneChangingMap.leave(); 00067 } 00068 00069 public: 00070 /** Constructor 00071 */ 00072 CMetricMapBuilder(); 00073 00074 /** Destructor. 00075 */ 00076 virtual ~CMetricMapBuilder( ); 00077 00078 /** Initialize the method, starting with a known location PDF "x0"(if supplied, set to NULL to left unmodified) and a given fixed, past map. 00079 */ 00080 virtual void initialize( 00081 CSensFrameProbSequence &initialMap, 00082 CPosePDF *x0 = NULL 00083 ) = 0; 00084 00085 /** Clear all elements of the maps, and reset localization to (0,0,0deg). 00086 */ 00087 void clear(); 00088 00089 /** Returns a copy of the current best pose estimation as a pose PDF. 00090 */ 00091 virtual CPose3DPDFPtr getCurrentPoseEstimation() const = 0; 00092 00093 /** 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. 00094 * \param action The estimation of the incremental pose change in the robot pose. 00095 * \param observations The set of observations that robot senses at the new pose. 00096 */ 00097 virtual void processActionObservation( CActionCollection &action,CSensoryFrame &observations ) = 0; 00098 00099 /** Fills "out_map" with the set of "poses"-"sensorial frames", thus the so far built map. 00100 */ 00101 virtual void getCurrentlyBuiltMap(CSensFrameProbSequence &out_map) const = 0; 00102 00103 /** Returns just how many sensorial frames are stored in the currently build map. 00104 */ 00105 virtual unsigned int getCurrentlyBuiltMapSize() = 0; 00106 00107 /** 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()". 00108 */ 00109 virtual CMultiMetricMap* getCurrentlyBuiltMetricMap() = 0; 00110 00111 /** Enables or disables the map updating (default state is enabled) 00112 */ 00113 void enableMapUpdating( bool enable ); 00114 00115 /** A useful method for debugging: the current map (and/or poses) estimation is dumped to an image file. 00116 * \param file The output file name 00117 * \param formatEMF_BMP Output format = true:EMF, false:BMP 00118 */ 00119 virtual void saveCurrentEstimationToImage(const std::string &file, bool formatEMF_BMP = true) = 0; 00120 00121 00122 /** Load map (CSensFrameProbSequence) from a ".simplemap" file 00123 */ 00124 void loadCurrentMapFromFile(const std::string &fileName); 00125 00126 /** Save map (CSensFrameProbSequence) to a ".simplemap" file. 00127 */ 00128 void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const; 00129 00130 00131 /** Options for the algorithm 00132 */ 00133 struct MRPTDLLIMPEXP TOptions 00134 { 00135 TOptions() : verbose(true), 00136 enableMapUpdating(true), 00137 debugForceInsertion(false), 00138 insertImagesAlways(false) 00139 { 00140 } 00141 00142 /** If true shows debug information in the console, default is true. 00143 */ 00144 bool verbose; 00145 00146 /** Enable map updating, default is true. 00147 */ 00148 bool enableMapUpdating; 00149 00150 /** Always insert into map. Default is false: detect if necesary. 00151 */ 00152 bool debugForceInsertion; 00153 00154 /** Always include a SF into the map if an image is included. Default is false. 00155 */ 00156 bool insertImagesAlways; 00157 00158 } options; 00159 00160 }; // End of class def. 00161 00162 } // End of namespace 00163 } // End of namespace 00164 00165 #endif
Page generated by Doxygen 1.5.9 for MRPT 0.7.1 SVN: at Mon Aug 17 22:27:43 EDT 2009 |