Main MRPT website > C++ reference
MRPT logo
CMetricMapBuilder.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CMetricMapBuilder_H
29 #define CMetricMapBuilder_H
30 
34 #include <mrpt/synch.h>
37 #include <mrpt/slam/CSimpleMap.h>
38 #include <mrpt/poses/CPose3DPDF.h>
40 
41 #include <mrpt/slam/link_pragmas.h>
42 
43 namespace mrpt
44 {
45 namespace slam
46 {
47  /** @defgroup metric_slam_grp Metric SLAM algorithms
48  * \ingroup mrpt_slam_grp */
49 
50  /** This virtual class is the base for SLAM implementations. See derived classes for more information.
51  *
52  * \sa CMetricMap \ingroup metric_slam_grp
53  */
55  {
56  protected:
57  /** Critical zones
58  */
60 
61  /** Enter critical section for map updating:
62  */
63  inline void enterCriticalSection() { critZoneChangingMap.enter(); }
64 
65  /** Leave critical section for map updating:
66  */
67  inline void leaveCriticalSection() { critZoneChangingMap.leave(); }
68 
69  public:
70  CMetricMapBuilder(); //!< Constructor
71  virtual ~CMetricMapBuilder( ); //!< Destructor.
72 
73  // ---------------------------------------------------------------------
74  /** @name Pure virtual methods to implement in any particular SLAM algorithm
75  @{ */
76 
77  /** Initialize the method, starting with a known location PDF "x0"(if supplied, set to NULL to left unmodified) and a given fixed, past map. */
78  virtual void initialize(
79  const CSimpleMap &initialMap = CSimpleMap(),
80  CPosePDF *x0 = NULL
81  ) = 0;
82 
83  /** Returns a copy of the current best pose estimation as a pose PDF. */
84  virtual CPose3DPDFPtr getCurrentPoseEstimation() const = 0;
85 
86  /** 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.
87  * \param action The estimation of the incremental pose change in the robot pose.
88  * \param observations The set of observations that robot senses at the new pose.
89  */
90  virtual void processActionObservation( CActionCollection &action,CSensoryFrame &observations ) = 0;
91 
92  /** Fills "out_map" with the set of "poses"-"sensory-frames", thus the so far built map. */
93  virtual void getCurrentlyBuiltMap(CSimpleMap &out_map) const = 0;
94 
95  /** Returns just how many sensory-frames are stored in the currently build map. */
96  virtual unsigned int getCurrentlyBuiltMapSize() = 0;
97 
98  /** 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()". */
99  virtual CMultiMetricMap* getCurrentlyBuiltMetricMap() = 0;
100 
101  /** A useful method for debugging: the current map (and/or poses) estimation is dumped to an image file.
102  * \param file The output file name
103  * \param formatEMF_BMP Output format = true:EMF, false:BMP
104  */
105  virtual void saveCurrentEstimationToImage(const std::string &file, bool formatEMF_BMP = true) = 0;
106 
107  /** @} */
108  // ---------------------------------------------------------------------
109 
110  /** Clear all elements of the maps, and reset localization to (0,0,0deg). */
111  void clear();
112 
113  /** Enables or disables the map updating (default state is enabled) */
114  void enableMapUpdating( bool enable )
115  {
116  options.enableMapUpdating = enable;
117  }
118 
119  /** Load map (mrpt::slam::CSimpleMap) from a ".simplemap" file */
120  void loadCurrentMapFromFile(const std::string &fileName);
121 
122  /** Save map (mrpt::slam::CSimpleMap) to a ".simplemap" file. */
123  void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const;
124 
125  /** Options for the algorithm */
127  {
128  TOptions() : verbose(true),
129  enableMapUpdating(true),
130  debugForceInsertion(false),
131  alwaysInsertByClass()
132  {
133  }
134 
135  bool verbose; //!< If true shows debug information in the console, default is true.
136  bool enableMapUpdating; //!< Enable map updating, default is true.
137  bool debugForceInsertion; //!< Always insert into map. Default is false: detect if necesary.
138 
139  /** A list of observation classes (derived from mrpt::slam::CObservation) which will be always inserted in the map, disregarding the minimum insertion distances).
140  * Default: Empty. How to insert classes:
141  * \code
142  * alwaysInserByClass.insert(CLASS_ID(CObservationImage));
143  * \endcode
144  * \sa mrpt::utils::CListOfClasses
145  */
147 
148  };
149 
151 
152  }; // End of class def.
153 
154  } // End of namespace
155 } // End of namespace
156 
157 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013