class mrpt::maps::CHeightGridMap2D
Digital Elevation Model (DEM), a mesh or grid representation of a surface which keeps the estimated height for each (x,y) location.
Important implemented features are the insertion of 2D laser scans (from arbitrary 6D poses) and the exportation as 3D scenes.
Each cell contains the up-to-date average height from measured falling in that cell. Algorithms that can be used:
mrSimpleAverage: Each cell only stores the current average value.
This class implements generic version of mrpt::maps::CMetric::insertObservation() accepting these types of sensory data:
mrpt::obs::CObservation2DRangeScan : 2D range scans
#include <mrpt/maps/CHeightGridMap2D.h> class CHeightGridMap2D: public mrpt::maps::CMetricMap, public mrpt::containers::CDynamicGrid, public mrpt::maps::CHeightGridMap2D_Base { public: // enums enum TMapRepresentation; // structs struct TInsertionOptions; // fields mrpt::maps::CHeightGridMap2D::TInsertionOptions insertionOptions; TMapRepresentation m_mapType; double min_x {-2}; double max_x {2}; double min_y {-2}; double max_y {2}; double resolution {0.10f}; mrpt::maps::CHeightGridMap2D::TMapRepresentation mapType { CHeightGridMap2D::mrSimpleAverage}; mrpt::maps::CHeightGridMap2D::TInsertionOptions insertionOpts; // construction CHeightGridMap2D( TMapRepresentation mapType = mrSimpleAverage, double x_min = -2, double x_max = 2, double y_min = -2, double y_max = 2, double resolution = 0.1 ); // methods bool intersectLine3D(const mrpt::math::TLine3D& r1, mrpt::math::TObject3D& obj) const; bool getMinMaxHeight(float& z_min, float& z_max) const; void clear(); float cell2float(const THeightGridmapCell& c) const; virtual std::string asString() const; virtual bool isEmpty() const; virtual float compute3DMatchingRatio(const mrpt::maps::CMetricMap* otherMap, const mrpt::poses::CPose3D& otherMapPose, const TMatchingRatioParams& params) const; virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const; virtual void getVisualizationInto(mrpt::opengl::CSetOfObjects& outObj) const; TMapRepresentation getMapType(); size_t countObservedCells() const; virtual bool insertIndividualPoint( const double x, const double y, const double z, const CHeightGridMap2D_Base::TPointInsertParams& params = CHeightGridMap2D_Base::TPointInsertParams() ); virtual double dem_get_resolution() const; virtual size_t dem_get_size_x() const; virtual size_t dem_get_size_y() const; virtual bool dem_get_z_by_cell(const size_t cx, const size_t cy, double& z_out) const; virtual bool dem_get_z(const double x, const double y, double& z_out) const; virtual void dem_update_map(); virtual void internal_clear(); virtual bool internal_insertObservation( const mrpt::obs::CObservation& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt ); virtual double internal_computeObservationLikelihood(const mrpt::obs::CObservation& obs, const mrpt::poses::CPose3D& takenFrom) const; bool dem_internal_insertObservation(const mrpt::obs::CObservation& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt); };
Inherited Members
public: // structs struct TPointInsertParams; // methods virtual bool isEmpty() const = 0; virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const = 0; virtual std::string asString() const = 0; virtual void getVisualizationInto(mrpt::opengl::CSetOfObjects& o) const = 0; virtual bool insertIndividualPoint( const double x, const double y, const double z, const TPointInsertParams& params = TPointInsertParams() ) = 0; virtual double dem_get_resolution() const = 0; virtual size_t dem_get_size_x() const = 0; virtual size_t dem_get_size_y() const = 0; virtual bool dem_get_z_by_cell(const size_t cx, const size_t cy, double& z_out) const = 0; virtual bool dem_get_z(const double x, const double y, double& z_out) const = 0; virtual void dem_update_map() = 0;
Fields
TMapRepresentation m_mapType
The map representation type of this map.
double min_x {-2}
See CHeightGridMap2D::CHeightGridMap2D.
mrpt::maps::CHeightGridMap2D::TMapRepresentation mapType { CHeightGridMap2D::mrSimpleAverage}
The kind of map representation (see CHeightGridMap2D::CHeightGridMap2D)
Construction
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.
Methods
bool intersectLine3D(const mrpt::math::TLine3D& r1, mrpt::math::TObject3D& obj) const
Gets the intersection between a 3D line and a Height Grid map (taking into account the different heights of each individual cell)
bool getMinMaxHeight(float& z_min, float& z_max) const
Computes the minimum and maximum height in the grid.
Returns:
False if there is no observed cell yet.
void clear()
Calls the base CMetricMap::clear Declared here to avoid ambiguity between the two clear() in both base classes.
virtual std::string asString() const
Returns a short description of the map.
virtual bool isEmpty() const
Returns true if the map is empty/no observation has been inserted.
virtual float compute3DMatchingRatio( const mrpt::maps::CMetricMap* otherMap, const mrpt::poses::CPose3D& otherMapPose, const TMatchingRatioParams& params ) const
See docs in base class: in this class it always returns 0.
virtual void saveMetricMapRepresentationToFile(const std::string& filNamePrefix) const
This virtual method saves the map to a file “filNamePrefix”+< some_file_extension >, as an image or in any other applicable way (Notice that other methods to save the map may be implemented in classes implementing this virtual interface).
virtual void getVisualizationInto(mrpt::opengl::CSetOfObjects& outObj) const
Returns a 3D object representing the map: by default, it will be a mrpt::opengl::CMesh object, unless it is specified otherwise in mrpt::global_settings::HEIGHTGRIDMAP_EXPORT3D_AS_MESH.
TMapRepresentation getMapType()
Return the type of the gas distribution map, according to parameters passed on construction.
size_t countObservedCells() const
Return the number of cells with at least one height data inserted.
virtual bool insertIndividualPoint( const double x, const double y, const double z, const CHeightGridMap2D_Base::TPointInsertParams& params = CHeightGridMap2D_Base::TPointInsertParams() )
Update the DEM with one new point.
Returns:
true if updated OK, false if (x,y) is out of bounds
See also:
mrpt::maps::CMetricMap::insertObservation() for inserting higher-level objects like 2D/3D LIDAR scans
virtual bool dem_get_z_by_cell(const size_t cx, const size_t cy, double& z_out) const
Get cell ‘z’ by (cx,cy) cell indices.
Returns:
false if out of bounds or un-observed cell.
virtual bool dem_get_z(const double x, const double y, double& z_out) const
Get cell ‘z’ (x,y) by metric coordinates.
Returns:
false if out of bounds or un-observed cell.
virtual void dem_update_map()
Ensure that all observations are reflected in the map estimate.
virtual void internal_clear()
Internal method called by clear()
virtual bool internal_insertObservation( const mrpt::obs::CObservation& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt )
Internal method called by insertObservation()
virtual double internal_computeObservationLikelihood( const mrpt::obs::CObservation& obs, const mrpt::poses::CPose3D& takenFrom ) const
Internal method called by computeObservationLikelihood()
bool dem_internal_insertObservation( const mrpt::obs::CObservation& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt )
Internal method called by internal_insertObservation()