Main MRPT website > C++ reference for MRPT 1.9.9
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-2017, 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 
14 #include <mrpt/maps/CMetricMap.h>
18 #include <mrpt/utils/color_maps.h>
19 #include <mrpt/utils/TEnumType.h>
20 #include <mrpt/poses/poses_frwds.h>
21 #include <mrpt/obs/obs_frwds.h>
22 
23 namespace mrpt
24 {
25 namespace maps
26 {
27 /** The contents of each cell in a CHeightGridMap2D map */
29 {
30  /** The current average height (in meters) */
31  float h;
32  /** The current standard deviation of the height (in meters) */
33  float var;
34  /** Auxiliary variable for storing the incremental mean value (in meters).
35  */
36  float u;
37  /** Auxiliary (in meters) */
38  float v;
39  /** [For mrSimpleAverage model] The accumulated weight: initially zero if
40  * un-observed, increased by one for each observation */
42 
43  THeightGridmapCell() : h(), var(), u(), v(), w() {}
44 };
45 
46 /** Digital Elevation Model (DEM), a mesh or grid representation of a surface
47  * which keeps the estimated height for each (x,y) location.
48  * Important implemented features are the insertion of 2D laser scans (from
49  * arbitrary 6D poses) and the exportation as 3D scenes.
50  *
51  * Each cell contains the up-to-date average height from measured falling in
52  * that cell. Algorithms that can be used:
53  * - mrSimpleAverage: Each cell only stores the current average value.
54  *
55  * This class implements generic version of
56  * mrpt::maps::CMetric::insertObservation() accepting these types of sensory
57  * data:
58  * - mrpt::obs::CObservation2DRangeScan: 2D range scans
59  * - mrpt::obs::CObservationVelodyneScan
60  *
61  * \ingroup mrpt_maps_grp
62  */
64  public utils::CDynamicGrid<THeightGridmapCell>,
66 {
68  public:
69  /** Calls the base CMetricMap::clear
70  * Declared here to avoid ambiguity between the two clear() in both base
71  * classes.
72  */
73  inline void clear() { CMetricMap::clear(); }
74  float cell2float(const THeightGridmapCell& c) const override
75  {
76  return float(c.h);
77  }
78 
79  /** The type of map representation to be used.
80  * See mrpt::maps::CHeightGridMap2D for discussion.
81  */
83  {
85  };
86 
87  /** Constructor */
89  TMapRepresentation mapType = mrSimpleAverage, double x_min = -2,
90  double x_max = 2, double y_min = -2, double y_max = 2,
91  double resolution = 0.1);
92 
93  /** Returns true if the map is empty/no observation has been inserted. */
94  bool isEmpty() const override;
95 
96  /** Parameters related with inserting observations into the map */
98  {
99  /** Default values loader */
101 
102  void loadFromConfigFile(
104  const std::string& section) override; // See base docs
105  void dumpToTextStream(
106  mrpt::utils::CStream& out) const override; // See base docs
107 
108  /** Whether to perform filtering by z-coordinate (default=false):
109  * coordinates are always RELATIVE to the robot for this filter.vvv */
111  /** Only when filterByHeight is true: coordinates are always RELATIVE to
112  * the robot for this filter. */
113  float z_min, z_max;
114 
117 
118  /** See docs in base class: in this class it always returns 0 */
120  const mrpt::maps::CMetricMap* otherMap,
121  const mrpt::poses::CPose3D& otherMapPose,
122  const TMatchingRatioParams& params) const override;
123 
124  void saveMetricMapRepresentationToFile(const std::string& filNamePrefix)
125  const override; // See base class docs
126 
127  /** Returns a 3D object representing the map: by default, it will be a
128  * mrpt::opengl::CMesh object, unless
129  * it is specified otherwise in
130  * mrpt::global_settings::HEIGHTGRIDMAP_EXPORT3D_AS_MESH */
131  void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& outObj) const override;
132 
133  /** Return the type of the gas distribution map, according to parameters
134  * passed on construction */
136 
137  /** Return the number of cells with at least one height data inserted. */
138  size_t countObservedCells() const;
139 
140  virtual bool insertIndividualPoint(
141  const double x, const double y, const double z,
144  virtual double dem_get_resolution() const override;
145  virtual size_t dem_get_size_x() const override;
146  virtual size_t dem_get_size_y() const override;
147  virtual bool dem_get_z_by_cell(
148  const size_t cx, const size_t cy, double& z_out) const override;
149  virtual bool dem_get_z(
150  const double x, const double y, double& z_out) const override;
151  virtual void dem_update_map() override;
152 
153  /** The map representation type of this map */
155 
156  // See docs in base class
157  void internal_clear() override;
159  const mrpt::obs::CObservation* obs,
160  const mrpt::poses::CPose3D* robotPose = nullptr) override;
162  const mrpt::obs::CObservation* obs,
163  const mrpt::poses::CPose3D& takenFrom) override;
164 
166  /** See CHeightGridMap2D::CHeightGridMap2D */
167  double min_x, max_x, min_y, max_y, resolution;
168  /** The kind of map representation (see CHeightGridMap2D::CHeightGridMap2D)
169  */
171  mrpt::maps::CHeightGridMap2D::TInsertionOptions insertionOpts;
173 };
174 
175 } // End of namespace
176 
177 namespace global_settings
178 {
179 /** If set to true (default), mrpt::maps::CHeightGridMap2D will be exported as a
180  *opengl::CMesh, otherwise, as a opengl::CPointCloudColoured
181  * Affects to:
182  * - CHeightGridMap2D::getAs3DObject
183  */
186 }
187 
188 // Specializations MUST occur at the same namespace:
189 namespace utils
190 {
191 template <>
193 {
196  {
197  m_map.insert(
198  maps::CHeightGridMap2D::mrSimpleAverage, "mrSimpleAverage");
199  }
200 };
201 } // End of namespace
202 
203 } // End of namespace
204 
205 #endif
Digital Elevation Model (DEM), a mesh or grid representation of a surface which keeps the estimated h...
void clear()
Erase all the contents of the map.
Definition: CMetricMap.cpp:31
float var
The current standard deviation of the height (in meters)
float h
The current average height (in meters)
Parameters for CMetricMap::compute3DMatchingRatio()
Extra params for insertIndividualPoint()
#define MAP_DEFINITION_END(_CLASS_NAME_, _LINKAGE_)
GLdouble GLdouble z
Definition: glext.h:3872
CHeightGridMap2D(TMapRepresentation mapType=mrSimpleAverage, double x_min=-2, double x_max=2, double y_min=-2, double y_max=2, double resolution=0.1)
Constructor.
virtual void dem_update_map() override
Ensure that all observations are reflected in the map estimate.
TColormap
Different colormaps for use in mrpt::utils::colormap()
Definition: color_maps.h:31
TMapRepresentation
The type of map representation to be used.
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
float compute3DMatchingRatio(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose3D &otherMapPose, const TMatchingRatioParams &params) const override
See docs in base class: in this class it always returns 0.
bool internal_insertObservation(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D *robotPose=nullptr) override
Internal method called by insertObservation()
The contents of each cell in a CHeightGridMap2D map.
virtual bool dem_get_z_by_cell(const size_t cx, const size_t cy, double &z_out) const override
Get cell &#39;z&#39; by (cx,cy) cell indices.
virtual bool dem_get_z(const double x, const double y, double &z_out) const override
Get cell &#39;z&#39; (x,y) by metric coordinates.
Only specializations of this class are defined for each enum type of interest.
Definition: TEnumType.h:24
uint32_t w
[For mrSimpleAverage model] The accumulated weight: initially zero if un-observed, increased by one for each observation
float v
Auxiliary (in meters)
void clear()
Calls the base CMetricMap::clear Declared here to avoid ambiguity between the two clear() in both bas...
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
This class allows loading and storing values and vectors of different types from a configuration text...
mrpt::maps::CHeightGridMap2D::TInsertionOptions insertionOptions
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
virtual size_t dem_get_size_x() const override
virtual bool insertIndividualPoint(const double x, const double y, const double z, const CHeightGridMap2D_Base::TPointInsertParams &params=CHeightGridMap2D_Base::TPointInsertParams()) override
Update the DEM with one new point.
float z_min
Only when filterByHeight is true: coordinates are always RELATIVE to the robot for this filter...
A 2D grid of dynamic size which stores any kind of data at each cell.
Definition: CDynamicGrid.h:40
Parameters related with inserting observations into the map.
const GLubyte * c
Definition: glext.h:6313
std::vector< THeightGridmapCell > m_map
The cells.
Definition: CDynamicGrid.h:44
A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std...
Definition: bimap.h:34
std::shared_ptr< CSetOfObjects > Ptr
Definition: CSetOfObjects.h:32
virtual double dem_get_resolution() const override
float u
Auxiliary variable for storing the incremental mean value (in meters).
GLsizei const GLchar ** string
Definition: glext.h:4101
TMapRepresentation getMapType()
Return the type of the gas distribution map, according to parameters passed on construction.
const GLdouble * v
Definition: glext.h:3678
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...
virtual size_t dem_get_size_y() const override
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:55
bool filterByHeight
Whether to perform filtering by z-coordinate (default=false): coordinates are always RELATIVE to the ...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:41
Virtual base class for Digital Elevation Model (DEM) maps.
void internal_clear() override
Internal method called by clear()
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr &outObj) const override
Returns a 3D object representing the map: by default, it will be a mrpt::opengl::CMesh object...
TMapRepresentation m_mapType
The map representation type of this map.
GLenum GLint GLint y
Definition: glext.h:3538
float cell2float(const THeightGridmapCell &c) const override
double internal_computeObservationLikelihood(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D &takenFrom) override
Internal method called by computeObservationLikelihood()
GLsizei const GLfloat * value
Definition: glext.h:4117
void dumpToTextStream(mrpt::utils::CStream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const override
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >...
GLenum GLint x
Definition: glext.h:3538
bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted.
unsigned __int32 uint32_t
Definition: rptypes.h:47
size_t countObservedCells() const
Return the number of cells with at least one height data inserted.
GLenum const GLfloat * params
Definition: glext.h:3534
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019