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-2018, 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/img/color_maps.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 mrpt::maps::CMetricMap,
65  public mrpt::containers::CDynamicGrid<THeightGridmapCell>,
67 {
69  public:
70  /** Calls the base CMetricMap::clear
71  * Declared here to avoid ambiguity between the two clear() in both base
72  * classes.
73  */
74  inline void clear() { CMetricMap::clear(); }
75  float cell2float(const THeightGridmapCell& c) const override
76  {
77  return float(c.h);
78  }
79 
80  /** The type of map representation to be used.
81  * See mrpt::maps::CHeightGridMap2D for discussion.
82  */
84  {
86  };
87 
88  /** Constructor */
90  TMapRepresentation mapType = mrSimpleAverage, double x_min = -2,
91  double x_max = 2, double y_min = -2, double y_max = 2,
92  double resolution = 0.1);
93 
94  /** Returns true if the map is empty/no observation has been inserted. */
95  bool isEmpty() const override;
96 
97  /** Parameters related with inserting observations into the map */
99  {
100  /** Default values loader */
102 
103  void loadFromConfigFile(
105  const std::string& section) override; // See base docs
106  void dumpToTextStream(
107  std::ostream& out) const override; // See base docs
108 
109  /** Whether to perform filtering by z-coordinate (default=false):
110  * coordinates are always RELATIVE to the robot for this filter.vvv */
112  /** Only when filterByHeight is true: coordinates are always RELATIVE to
113  * the robot for this filter. */
114  float z_min, z_max;
115 
118 
119  /** See docs in base class: in this class it always returns 0 */
121  const mrpt::maps::CMetricMap* otherMap,
122  const mrpt::poses::CPose3D& otherMapPose,
123  const TMatchingRatioParams& params) const override;
124 
125  void saveMetricMapRepresentationToFile(const std::string& filNamePrefix)
126  const override; // See base class docs
127 
128  /** Returns a 3D object representing the map: by default, it will be a
129  * mrpt::opengl::CMesh object, unless
130  * it is specified otherwise in
131  * mrpt::global_settings::HEIGHTGRIDMAP_EXPORT3D_AS_MESH */
132  void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& outObj) const override;
133 
134  /** Return the type of the gas distribution map, according to parameters
135  * passed on construction */
137 
138  /** Return the number of cells with at least one height data inserted. */
139  size_t countObservedCells() const;
140 
141  virtual bool insertIndividualPoint(
142  const double x, const double y, const double z,
145  virtual double dem_get_resolution() const override;
146  virtual size_t dem_get_size_x() const override;
147  virtual size_t dem_get_size_y() const override;
148  virtual bool dem_get_z_by_cell(
149  const size_t cx, const size_t cy, double& z_out) const override;
150  virtual bool dem_get_z(
151  const double x, const double y, double& z_out) const override;
152  virtual void dem_update_map() override;
153 
154  /** The map representation type of this map */
156 
157  // See docs in base class
158  void internal_clear() override;
160  const mrpt::obs::CObservation* obs,
161  const mrpt::poses::CPose3D* robotPose = nullptr) override;
163  const mrpt::obs::CObservation* obs,
164  const mrpt::poses::CPose3D& takenFrom) override;
165 
167  /** See CHeightGridMap2D::CHeightGridMap2D */
168  double min_x, max_x, min_y, max_y, resolution;
169  /** The kind of map representation (see CHeightGridMap2D::CHeightGridMap2D)
170  */
172  mrpt::maps::CHeightGridMap2D::TInsertionOptions insertionOpts;
174 };
175 
176 } // namespace maps
177 
178 namespace global_settings
179 {
180 /** If set to true (default), mrpt::maps::CHeightGridMap2D will be exported as a
181  *opengl::CMesh, otherwise, as a opengl::CPointCloudColoured
182  * Affects to:
183  * - CHeightGridMap2D::getAs3DObject
184  */
187 } // namespace global_settings
188 } // namespace mrpt
189 
194 
195 #endif
mrpt::maps::THeightGridmapCell::v
float v
Auxiliary (in meters)
Definition: CHeightGridMap2D.h:38
mrpt::img::TColormap
TColormap
Different colormaps for use in mrpt::img::colormap()
Definition: color_maps.h:31
mrpt::maps::CHeightGridMap2D::insertionOptions
mrpt::maps::CHeightGridMap2D::TInsertionOptions insertionOptions
MRPT_ENUM_TYPE_END
#define MRPT_ENUM_TYPE_END()
Definition: TEnumType.h:74
mrpt::maps::CHeightGridMap2D::TInsertionOptions
Parameters related with inserting observations into the map.
Definition: CHeightGridMap2D.h:98
mrpt::global_settings::HEIGHTGRIDMAP_EXPORT3D_AS_MESH
bool HEIGHTGRIDMAP_EXPORT3D_AS_MESH()
Definition: CHeightGridMap2D.cpp:96
mrpt::maps::THeightGridmapCell::THeightGridmapCell
THeightGridmapCell()
Definition: CHeightGridMap2D.h:43
mrpt::maps::CHeightGridMap2D::internal_clear
void internal_clear() override
Internal method called by clear()
Definition: CHeightGridMap2D.cpp:120
mrpt::maps::CHeightGridMap2D::TInsertionOptions::z_min
float z_min
Only when filterByHeight is true: coordinates are always RELATIVE to the robot for this filter.
Definition: CHeightGridMap2D.h:114
mrpt::maps::CHeightGridMap2D::TInsertionOptions::loadFromConfigFile
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
Definition: CHeightGridMap2D.cpp:272
c
const GLubyte * c
Definition: glext.h:6313
mrpt::maps::CHeightGridMap2D_Base::TPointInsertParams
Extra params for insertIndividualPoint()
Definition: CHeightGridMap2D_Base.h:42
mrpt::maps::CHeightGridMap2D_Base
Virtual base class for Digital Elevation Model (DEM) maps.
Definition: CHeightGridMap2D_Base.h:24
color_maps.h
mrpt::maps::CHeightGridMap2D::internal_insertObservation
bool internal_insertObservation(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D *robotPose=nullptr) override
Internal method called by insertObservation()
Definition: CHeightGridMap2D.cpp:154
mrpt::maps::CHeightGridMap2D::dem_get_z_by_cell
virtual bool dem_get_z_by_cell(const size_t cx, const size_t cy, double &z_out) const override
Get cell 'z' by (cx,cy) cell indices.
Definition: CHeightGridMap2D.cpp:397
mrpt::maps::TMatchingRatioParams
Parameters for CMetricMap::compute3DMatchingRatio()
Definition: metric_map_types.h:75
mrpt::maps::CHeightGridMap2D::isEmpty
bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted.
Definition: CHeightGridMap2D.cpp:124
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
w
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
MRPT_ENUM_TYPE_BEGIN
#define MRPT_ENUM_TYPE_BEGIN(_ENUM_TYPE_WITH_NS)
Definition: TEnumType.h:58
mrpt::maps::THeightGridmapCell
The contents of each cell in a CHeightGridMap2D map.
Definition: CHeightGridMap2D.h:28
mrpt::maps::CHeightGridMap2D::cell2float
float cell2float(const THeightGridmapCell &c) const override
Definition: CHeightGridMap2D.h:75
CMetricMap.h
MRPT_FILL_ENUM_MEMBER
MRPT_FILL_ENUM_MEMBER(maps::CHeightGridMap2D::TMapRepresentation, mrSimpleAverage)
source
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
mrpt::maps::CHeightGridMap2D::m_mapType
TMapRepresentation m_mapType
The map representation type of this map.
Definition: CHeightGridMap2D.h:155
mrpt::maps::CHeightGridMap2D::TInsertionOptions::filterByHeight
bool filterByHeight
Whether to perform filtering by z-coordinate (default=false): coordinates are always RELATIVE to the ...
Definition: CHeightGridMap2D.h:111
v
const GLdouble * v
Definition: glext.h:3678
mrpt::maps::THeightGridmapCell::var
float var
The current standard deviation of the height (in meters)
Definition: CHeightGridMap2D.h:33
mrpt::maps::CHeightGridMap2D::saveMetricMapRepresentationToFile
void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const override
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >,...
Definition: CHeightGridMap2D.cpp:289
mrpt::maps::CMetricMap
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:56
mrpt::maps::CHeightGridMap2D
Digital Elevation Model (DEM), a mesh or grid representation of a surface which keeps the estimated h...
Definition: CHeightGridMap2D.h:63
mrpt::maps::CHeightGridMap2D::mrSimpleAverage
@ mrSimpleAverage
Definition: CHeightGridMap2D.h:85
mrpt::maps::CHeightGridMap2D::countObservedCells
size_t countObservedCells() const
Return the number of cells with at least one height data inserted.
Definition: CHeightGridMap2D.cpp:375
CDynamicGrid.h
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::maps::CHeightGridMap2D::getMapType
TMapRepresentation getMapType()
Return the type of the gas distribution map, according to parameters passed on construction.
TEnumType.h
mrpt::config::CLoadableOptions
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
Definition: config/CLoadableOptions.h:28
mrpt::maps::CHeightGridMap2D::TMapRepresentation
TMapRepresentation
The type of map representation to be used.
Definition: CHeightGridMap2D.h:83
CHeightGridMap2D_Base.h
mrpt::maps::THeightGridmapCell::h
float h
The current average height (in meters)
Definition: CHeightGridMap2D.h:31
obs_frwds.h
mrpt::maps::CHeightGridMap2D::compute3DMatchingRatio
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.
Definition: CHeightGridMap2D.cpp:428
mrpt::maps::CHeightGridMap2D::insertIndividualPoint
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.
Definition: CHeightGridMap2D.cpp:125
mrpt::opengl::CSetOfObjects::Ptr
std::shared_ptr< CSetOfObjects > Ptr
Definition: CSetOfObjects.h:30
mrpt::maps::CHeightGridMap2D::TInsertionOptions::dumpToTextStream
void dumpToTextStream(std::ostream &out) const override
This method should clearly display all the contents of the structure in textual form,...
Definition: CHeightGridMap2D.cpp:250
mrpt::maps::CHeightGridMap2D::dem_update_map
virtual void dem_update_map() override
Ensure that all observations are reflected in the map estimate.
Definition: CHeightGridMap2D.cpp:423
MAP_DEFINITION_START
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
Definition: TMetricMapTypesRegistry.h:57
mrpt::maps::CHeightGridMap2D::dem_get_size_y
virtual size_t dem_get_size_y() const override
Definition: CHeightGridMap2D.cpp:396
mrpt::maps::CHeightGridMap2D::clear
void clear()
Calls the base CMetricMap::clear Declared here to avoid ambiguity between the two clear() in both bas...
Definition: CHeightGridMap2D.h:74
mrpt::maps::CHeightGridMap2D::getAs3DObject
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,...
Definition: CHeightGridMap2D.cpp:299
CLoadableOptions.h
mrpt::containers::CDynamicGrid
A 2D grid of dynamic size which stores any kind of data at each cell.
Definition: CDynamicGrid.h:38
poses_frwds.h
MAP_DEFINITION_END
#define MAP_DEFINITION_END(_CLASS_NAME_)
Definition: TMetricMapTypesRegistry.h:67
mrpt::maps::CHeightGridMap2D::internal_computeObservationLikelihood
double internal_computeObservationLikelihood(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D &takenFrom) override
Internal method called by computeObservationLikelihood()
Definition: CHeightGridMap2D.cpp:163
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::maps::THeightGridmapCell::u
float u
Auxiliary variable for storing the incremental mean value (in meters).
Definition: CHeightGridMap2D.h:36
value
GLsizei const GLfloat * value
Definition: glext.h:4117
mrpt::maps::CHeightGridMap2D::dem_get_z
virtual bool dem_get_z(const double x, const double y, double &z_out) const override
Get cell 'z' (x,y) by metric coordinates.
Definition: CHeightGridMap2D.cpp:409
mrpt::maps::CHeightGridMap2D::TInsertionOptions::colorMap
mrpt::img::TColormap colorMap
Definition: CHeightGridMap2D.h:116
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: CObservation.h:43
z
GLdouble GLdouble z
Definition: glext.h:3872
mrpt::maps::CHeightGridMap2D::TInsertionOptions::TInsertionOptions
TInsertionOptions()
Default values loader.
Definition: CHeightGridMap2D.cpp:245
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::maps::CMetricMap::clear
void clear()
Erase all the contents of the map.
Definition: CMetricMap.cpp:31
mrpt::maps::THeightGridmapCell::w
uint32_t w
[For mrSimpleAverage model] The accumulated weight: initially zero if un-observed,...
Definition: CHeightGridMap2D.h:41
mrpt::maps::CHeightGridMap2D::CHeightGridMap2D
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.
Definition: CHeightGridMap2D.cpp:108
CSerializable.h
mrpt::maps::CHeightGridMap2D::dem_get_resolution
virtual double dem_get_resolution() const override
Definition: CHeightGridMap2D.cpp:394
mrpt::maps::CHeightGridMap2D::TInsertionOptions::z_max
float z_max
Definition: CHeightGridMap2D.h:114
y
GLenum GLint GLint y
Definition: glext.h:3538
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
x
GLenum GLint x
Definition: glext.h:3538
mrpt::maps::CHeightGridMap2D::dem_get_size_x
virtual size_t dem_get_size_x() const override
Definition: CHeightGridMap2D.cpp:395
params
GLenum const GLfloat * params
Definition: glext.h:3534



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST