Main MRPT website > C++ reference
MRPT logo
CReflectivityGridMap2D.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 
29 #ifndef CReflectivityGridMap2D_H
30 #define CReflectivityGridMap2D_H
31 
32 #include <mrpt/utils/CImage.h>
37 
38 #include <mrpt/slam/CMetricMap.h>
40 
41 #include <mrpt/maps/link_pragmas.h>
42 
43 namespace mrpt
44 {
45  namespace slam
46  {
47  using namespace mrpt;
48  using namespace mrpt::utils;
49 
50  class CObservation;
51 
53 
54  /** A 2D grid map representing the reflectivity of the environment (for example, measured with an IR proximity sensor).
55  *
56  * Important implemented features are:
57  * - Insertion of mrpt::slam::CObservationReflectivity observations.
58  * - Probability estimation of observations. See base class.
59  * - Rendering as 3D object: a 2D textured plane.
60  * - Automatic resizing of the map limits when inserting observations close to the border.
61  *
62  * Each cell contains the up-to-date average height from measured falling in that cell. Algorithms that can be used:
63  * - mrSimpleAverage: Each cell only stores the current average value.
64  * \ingroup mrpt_maps_grp
65  */
67  public CMetricMap,
68  public utils::CDynamicGrid<int8_t>,
69  public CLogOddsGridMap2D<int8_t>
70  {
71  // This must be added to any CSerializable derived class:
73 
74  protected:
75  static CLogOddsGridMapLUT<cell_t> m_logodd_lut; //!< Lookup tables for log-odds
76 
77  public:
78 
79  /** Calls the base CMetricMap::clear
80  * Declared here to avoid ambiguity between the two clear() in both base classes.
81  */
82  inline void clear() { CMetricMap::clear(); }
83 
84  float cell2float(const int8_t& c) const
85  {
86  return m_logodd_lut.l2p(c);
87  }
88 
89  /** Constructor
90  */
92  float x_min = -2,
93  float x_max = 2,
94  float y_min = -2,
95  float y_max = 2,
96  float resolution = 0.1
97  );
98 
99  /** Returns true if the map is empty/no observation has been inserted.
100  */
101  bool isEmpty() const;
102 
103  /** Computes the likelihood that a given observation was taken from a given pose in the world being modeled with this map.
104  *
105  * \param takenFrom The robot's pose the observation is supposed to be taken from.
106  * \param obs The observation.
107  * \return This method returns a likelihood in the range [0,1].
108  *
109  * \sa Used in particle filter algorithms, see: CMultiMetricMapPDF::update
110  */
111  double computeObservationLikelihood( const CObservation *obs, const CPose3D &takenFrom );
112 
113  /** Parameters related with inserting observations into the map.
114  */
116  {
117  /** Default values loader:
118  */
120 
121  /** See utils::CLoadableOptions
122  */
123  void loadFromConfigFile(
124  const mrpt::utils::CConfigFileBase &source,
125  const std::string &section);
126 
127  /** See utils::CLoadableOptions
128  */
129  void dumpToTextStream(CStream &out) const;
130 
131  } insertionOptions;
132 
133  /** Computes the ratio in [0,1] of correspondences between "this" and the "otherMap" map, whose 6D pose relative to "this" is "otherMapPose"
134  * In the case of a multi-metric map, this returns the average between the maps. This method always return 0 for grid maps.
135  * \param otherMap [IN] The other map to compute the matching with.
136  * \param otherMapPose [IN] The 6D pose of the other map as seen from "this".
137  * \param minDistForCorr [IN] The minimum distance between 2 non-probabilistic map elements for counting them as a correspondence.
138  * \param minMahaDistForCorr [IN] The minimum Mahalanobis distance between 2 probabilistic map elements for counting them as a correspondence.
139  *
140  * \return The matching ratio [0,1]
141  * \sa computeMatchingWith2D
142  */
143  float compute3DMatchingRatio(
144  const CMetricMap *otherMap,
145  const CPose3D &otherMapPose,
146  float minDistForCorr = 0.10f,
147  float minMahaDistForCorr = 2.0f
148  ) const;
149 
150  /** The implementation in this class just calls all the corresponding method of the contained metric maps.
151  */
152  void saveMetricMapRepresentationToFile(
153  const std::string &filNamePrefix
154  ) const;
155 
156  /** Returns a 3D object representing the map: by default, it will be a mrpt::opengl::CMesh object, unless
157  * it is specified otherwise in mrpt::
158  */
159  void getAs3DObject ( mrpt::opengl::CSetOfObjectsPtr &outObj ) const;
160 
161  /** Returns the grid as a 8-bit graylevel image, where each pixel is a cell (output image is RGB only if forceRGB is true)
162  */
163  void getAsImage( utils::CImage &img, bool verticalFlip = false, bool forceRGB=false) const;
164 
165  protected:
166 
167  /** Erase all the contents of the map
168  */
169  virtual void internal_clear();
170 
171  /** Insert the observation information into this map. This method must be implemented
172  * in derived classes.
173  * \param obs The observation
174  * \param robotPose The 3D pose of the robot mobile base in the map reference system, or NULL (default) if you want to use CPose2D(0,0,deg)
175  *
176  * \sa CObservation::insertObservationInto
177  */
178  virtual bool internal_insertObservation( const CObservation *obs, const CPose3D *robotPose = NULL );
179 
180  };
181 
182 
183  } // End of namespace
184 
185 
186 } // End of namespace
187 
188 #endif



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