Main MRPT website > C++ reference
MRPT logo
CHeightGridMap2D.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef CHeightGridMap2D_H
11 #define CHeightGridMap2D_H
12 
16 #include <mrpt/utils/color_maps.h>
17 #include <mrpt/utils/TEnumType.h>
18 #include <mrpt/slam/CMetricMap.h>
19 #include <mrpt/maps/link_pragmas.h>
20 #include <mrpt/poses/poses_frwds.h>
21 
22 namespace mrpt
23 {
24  namespace slam
25  {
26  using namespace mrpt::utils;
27 
28  class CObservation;
29 
30  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CHeightGridMap2D, CMetricMap, MAPS_IMPEXP )
31 
32  /** The contents of each cell in a CHeightGridMap2D map.
33  **/
35  {
36  /** Constructor
37  */
38  THeightGridmapCell() : h(0), w(0)
39  {}
40 
41  /** The current average height (in meters).
42  */
43  float h;
44 
45  /** The current standard deviation of the height (in meters).
46  */
47  float var;
48 
49  /** Auxiliary variable for storing the incremental mean value (in meters).
50  */
51  float u;
52 
53  /** Auxiliary (in meters).
54  */
55  float v;
56 
57 
58  /** [mrSimpleAverage model] The accumulated weight: initially zero if un-observed, increased by one for each observation.
59  */
60  uint32_t w;
61  };
62 
63  /** A mesh representation of a surface which keeps the estimated height for each (x,y) location.
64  * Important implemented features are the insertion of 2D laser scans (from arbitrary 6D poses) and the exportation as 3D scenes.
65  *
66  * Each cell contains the up-to-date average height from measured falling in that cell. Algorithms that can be used:
67  * - mrSimpleAverage: Each cell only stores the current average value.
68  */
69  class MAPS_IMPEXP CHeightGridMap2D : public CMetricMap, public utils::CDynamicGrid<THeightGridmapCell>
70  {
71  // This must be added to any CSerializable derived class:
73  public:
74 
75  /** Calls the base CMetricMap::clear
76  * Declared here to avoid ambiguity between the two clear() in both base classes.
77  */
78  inline void clear() { CMetricMap::clear(); }
79 
80  float cell2float(const THeightGridmapCell& c) const
81  {
82  return float(c.h);
83  }
84 
85  /** The type of map representation to be used.
86  * See mrpt::slam::CHeightGridMap2D for discussion.
87  */
89  {
90  mrSimpleAverage = 0
91 // mrSlidingWindow
92  };
93 
94  /** Constructor
95  */
97  TMapRepresentation mapType = mrSimpleAverage,
98  float x_min = -2,
99  float x_max = 2,
100  float y_min = -2,
101  float y_max = 2,
102  float resolution = 0.1
103  );
104 
105  /** Returns true if the map is empty/no observation has been inserted.
106  */
107  bool isEmpty() const;
108 
109  // See docs in base class
110  double computeObservationLikelihood( const CObservation *obs, const CPose3D &takenFrom );
111 
112  /** Parameters related with inserting observations into the map.
113  */
115  {
116  /** Default values loader:
117  */
119 
120  /** See utils::CLoadableOptions
121  */
122  void loadFromConfigFile(
123  const mrpt::utils::CConfigFileBase &source,
124  const std::string &section);
125 
126  /** See utils::CLoadableOptions
127  */
128  void dumpToTextStream(CStream &out) const;
129 
130  /** Wether to perform filtering by z-coordinate (default=false): coordinates are always RELATIVE to the robot for this filter.
131  */
133 
134  /** Only when filterByHeight is true: coordinates are always RELATIVE to the robot for this filter.
135  */
136  float z_min,z_max;
137 
138  float minDistBetweenPointsWhenInserting; //!< When inserting a scan, a point cloud is first created with this minimum distance between the 3D points (default=0).
139 
141 
142  } insertionOptions;
143 
144  /** See docs in base class: in this class it always returns 0 */
145  float compute3DMatchingRatio(
146  const CMetricMap *otherMap,
147  const CPose3D &otherMapPose,
148  float maxDistForCorr = 0.10f,
149  float maxMahaDistForCorr = 2.0f
150  ) const;
151 
152  /** The implementation in this class just calls all the corresponding method of the contained metric maps.
153  */
154  void saveMetricMapRepresentationToFile(
155  const std::string &filNamePrefix
156  ) const;
157 
158  /** Returns a 3D object representing the map: by default, it will be a mrpt::opengl::CMesh object, unless
159  * it is specified otherwise in mrpt::
160  */
161  void getAs3DObject ( mrpt::opengl::CSetOfObjectsPtr &outObj ) const;
162 
163  /** Return the type of the gas distribution map, according to parameters passed on construction.
164  */
165  TMapRepresentation getMapType();
166 
167 
168  /** Gets the intersection between a 3D line and a Height Grid map (taking into account the different heights of each individual cell).
169  */
170  bool intersectLine3D(const mrpt::math::TLine3D &r1, mrpt::math::TObject3D &obj) const;
171 
172  /** Computes the minimum and maximum height in the grid.
173  * \return False if there is no observed cell yet.
174  */
175  bool getMinMaxHeight(float &z_min, float &z_max) const;
176 
177  /** Return the number of cells with at least one height data inserted. */
178  size_t countObservedCells() const;
179 
180  protected:
181 
182  /** The map representation type of this map.
183  */
185 
186  /** Erase all the contents of the map
187  */
188  virtual void internal_clear();
189 
190  /** Insert the observation information into this map. This method must be implemented
191  * in derived classes.
192  * \param obs The observation
193  * \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)
194  *
195  * \sa CObservation::insertObservationInto
196  */
197  virtual bool internal_insertObservation( const CObservation *obs, const CPose3D *robotPose = NULL );
198 
199  };
201 
202 
203  } // End of namespace
204 
205  namespace global_settings
206  {
207  /** If set to true (default), mrpt::slam::CHeightGridMap2D will be exported as a opengl::CMesh, otherwise, as a opengl::CPointCloudColoured
208  * Affects to:
209  * - CHeightGridMap2D::getAs3DObject
210  */
212  }
213 
214  // Specializations MUST occur at the same namespace:
215  namespace utils
216  {
217  template <>
219  {
221  static void fill(bimap<enum_t,std::string> &m_map)
222  {
223  m_map.insert(slam::CHeightGridMap2D::mrSimpleAverage, "mrSimpleAverage");
224  }
225  };
226  } // End of namespace
227 
228 } // End of namespace
229 
230 #endif
void clear()
Erase all the contents of the map.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
float var
The current standard deviation of the height (in meters).
Standard object for storing any 3D lightweight object.
A mesh representation of a surface which keeps the estimated height for each (x,y) location...
Only specializations of this class are defined for each enum type of interest.
Definition: TEnumType.h:23
float cell2float(const THeightGridmapCell &c) const
The contents of each cell in a CHeightGridMap2D map.
float h
The current average height (in meters).
This class allows loading and storing values and vectors of different types from a configuration text...
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:83
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
float u
Auxiliary variable for storing the incremental mean value (in meters).
TColormap
Different colormaps.
Definition: color_maps.h:44
A 2D grid of dynamic size which stores any kind of data at each cell.
Definition: CDynamicGrid.h:39
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
float minDistBetweenPointsWhenInserting
When inserting a scan, a point cloud is first created with this minimum distance between the 3D point...
Declares a class that represents any robot's observation.
Definition: CObservation.h:52
A bidirectional version of std::map, declared as bimap and which actually contains two std...
Definition: bimap.h:27
bool filterByHeight
Wether to perform filtering by z-coordinate (default=false): coordinates are always RELATIVE to the r...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
uint32_t w
[mrSimpleAverage model] The accumulated weight: initially zero if un-observed, increased by one for e...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:69
float z_min
Only when filterByHeight is true: coordinates are always RELATIVE to the robot for this filter...
Parameters related with inserting observations into the map.
void insert(const KEY &k, const VALUE &v)
Insert a new pair KEY<->VALUE in the bi-map.
Definition: bimap.h:68
TMapRepresentation
The type of map representation to be used.
float v
Auxiliary (in meters).
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
MAPS_IMPEXP bool HEIGHTGRIDMAP_EXPORT3D_AS_MESH
If set to true (default), mrpt::slam::CHeightGridMap2D will be exported as a opengl::CMesh, otherwise, as a opengl::CPointCloudColoured Affects to:
TMapRepresentation m_mapType
The map representation type of this map.
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
3D line, represented by a base point and a director vector.



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014