class mrpt::maps::CHeightGridMap2D
Python API: mrpt.maps.CHeightGridMap2D
Overview
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 mrpt::config::OptionsCapable { public: // typedefs typedef std::shared_ptr<mrpt::maps ::CHeightGridMap2D> Ptr; typedef std::shared_ptr<const mrpt::maps ::CHeightGridMap2D> ConstPtr; typedef std::unique_ptr<mrpt::maps ::CHeightGridMap2D> UniquePtr; typedef std::unique_ptr<const mrpt::maps ::CHeightGridMap2D> ConstUniquePtr; // enums enum TMapRepresentation; // structs struct TInsertionOptions; struct TMapDefinition; struct TMapDefinitionBase; // fields static constexpr const char* className = "mrpt::maps" "::" "CHeightGridMap2D"; static const size_t m_private_map_register_id = mrpt::maps::internal::TMetricMapTypesRegistry::Instance().doRegister("mrpt::maps::CHeightGridMap2D,heightMap,dem" ,& mrpt::maps::CHeightGridMap2D ::MapDefinition,& mrpt::maps::CHeightGridMap2D ::internal_CreateFromMapDefinition); mrpt::maps::CHeightGridMap2D::TInsertionOptions insertionOptions; TMapRepresentation m_mapType; // 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 static constexpr auto getClassName(); static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); static std::shared_ptr<CObject> CreateObject(); template <typename... Args> static Ptr Create(Args&&... args); template <typename Alloc, typename... Args> static Ptr CreateAlloc( const Alloc& alloc, Args&&... args ); template <typename... Args> static UniquePtr CreateUnique(Args&&... args); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; virtual mrpt::rtti::CObject* clone() const; static std::shared_ptr<mrpt::maps::TMetricMapInitializer> MapDefinition(); static std::shared_ptr<CHeightGridMap2D> CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def); static std::shared_ptr<mrpt::maps::CMetricMap> internal_CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def); void clear(); float cell2float(const THeightGridmapCell& c) const; virtual std::string asString() const; virtual bool isEmpty() const; virtual std::map<std::string, mrpt::config::CLoadableOptions*> optionsByName(); 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::viz::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(size_t cx, 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); virtual double internal_computeObservationLikelihood(const mrpt::obs::CObservation& obs, const mrpt::poses::CPose3D& takenFrom) const; };
Inherited Members
public: // typedefs typedef std::shared_ptr<CObject> Ptr; typedef std::shared_ptr<const CObject> ConstPtr; typedef std::unique_ptr<CObject> UniquePtr; typedef std::unique_ptr<const CObject> ConstUniquePtr; typedef std::shared_ptr<CSerializable> Ptr; typedef std::shared_ptr<const CSerializable> ConstPtr; typedef std::shared_ptr<CMetricMap> Ptr; typedef std::shared_ptr<const CMetricMap> ConstPtr; typedef std::vector<T> grid_data_t; typedef typename grid_data_t::iterator iterator; typedef typename grid_data_t::const_iterator const_iterator; // structs struct TPointInsertParams; // fields TMapGenericParams genericMapParams; // methods mrpt::rtti::CObject::Ptr duplicateGetSmartPtr() const; static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; virtual CObject* clone() const = 0; virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); virtual std::string asString() const = 0; Visualizable& operator = (const Visualizable&); Visualizable& operator = (Visualizable&&); virtual void getVisualizationInto(mrpt::viz::CSetOfObjects& o) const = 0; std::shared_ptr<mrpt::viz::CSetOfObjects> getVisualization() const; virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); void clear(); virtual bool isEmpty() const = 0; virtual auto boundingBox() const; void loadFromSimpleMap(const mrpt::maps::CSimpleMap& Map); bool insertObservation(const mrpt::obs::CObservation& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt); bool insertObservationPtr(const mrpt::obs::CObservation::Ptr& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt); double computeObservationLikelihood(const mrpt::obs::CObservation& obs, const mrpt::poses::CPose3D& takenFrom) const; virtual bool canComputeObservationLikelihood(const mrpt::obs::CObservation& obs) const; double computeObservationsLikelihood(const mrpt::obs::CSensoryFrame& sf, const mrpt::poses::CPose3D& takenFrom); bool canComputeObservationsLikelihood(const mrpt::obs::CSensoryFrame& sf) const; virtual void determineMatching2D( const mrpt::maps::CMetricMap* otherMap, const mrpt::poses::CPose2D& otherMapPose, mrpt::tfest::TMatchingPairList& correspondences, const TMatchingParams& params, TMatchingExtraResults& extraResults ) const; virtual void determineMatching3D( const mrpt::maps::CMetricMap* otherMap, const mrpt::poses::CPose3D& otherMapPose, mrpt::tfest::TMatchingPairList& correspondences, const TMatchingParams& params, TMatchingExtraResults& extraResults ) 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 = 0; virtual void auxParticleFilterCleanUp(); virtual float squareDistanceToClosestCorrespondence(float x0, float y0) const; const grid_data_t& data() const; iterator begin(); iterator end(); const_iterator begin() const; const_iterator end() const; void setSize( const double x_min, const double x_max, const double y_min, const double y_max, const double resolution, const T* fill_value = nullptr ); void clear(); void fill(const T& value); virtual void resize( double new_x_min, double new_x_max, double new_y_min, double new_y_max, const T& defaultValueNewCells, double additionalMarginMeters = 2.0 ); T* cellByPos(double x, double y); const T* cellByPos(double x, double y) const; T* cellByIndex(unsigned int cx, unsigned int cy); const T* cellByIndex(unsigned int cx, unsigned int cy) const; size_t getSizeX() const; size_t getSizeY() const; double getXMin() const; double getXMax() const; double getYMin() const; double getYMax() const; double getResolution() const; int x2idx(double x) const; int y2idx(double y) const; int xy2idx(double x, double y) const; void idx2cxcy(int idx, int& cx, int& cy) const; double idx2x(int cx) const; double idx2y(int cy) const; template <class MAT> void getAsMatrix(MAT& m) const; virtual float cell2float(const T&) const; bool saveToTextFile(const std::string& fileName) const; bool intersectLine3D(const mrpt::math::TLine3D& r1, mrpt::math::TObject3D& obj) const; bool getMinMaxHeight(float& z_min, float& z_max) const; std::optional<std::pair<float, float>> getMinMaxHeightOpt() const; 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(size_t cx, 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; bool dem_internal_insertObservation(const mrpt::obs::CObservation& obs, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt); OptionsCapable& operator = (const OptionsCapable&); OptionsCapable& operator = (OptionsCapable&&); virtual std::map<std::string, mrpt::config::CLoadableOptions*> optionsByName() = 0; virtual bool trySetCreationOptions(] const mrpt::config::CConfigFileBase& cfg, ] const std::string& section);
Typedefs
typedef std::shared_ptr<mrpt::maps ::CHeightGridMap2D> Ptr
A type for the associated smart pointer.
Fields
static const size_t m_private_map_register_id = mrpt::maps::internal::TMetricMapTypesRegistry::Instance().doRegister("mrpt::maps::CHeightGridMap2D,heightMap,dem" ,& mrpt::maps::CHeightGridMap2D ::MapDefinition,& mrpt::maps::CHeightGridMap2D ::internal_CreateFromMapDefinition)
ID used to initialize class registration (just ignore it)
TMapRepresentation m_mapType
The map representation type of this map.
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
virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const
Returns information about the class of an object in runtime.
virtual mrpt::rtti::CObject* clone() const
Returns a deep copy (clone) of the object, indepently of its class.
static std::shared_ptr<mrpt::maps::TMetricMapInitializer> MapDefinition()
Returns default map definition initializer.
See * mrpt::maps::TMetricMapInitializer
static std::shared_ptr<CHeightGridMap2D> CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer& def)
Constructor from a map definition structure: initializes the map and * its parameters accordingly.
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 std::map<std::string, mrpt::config::CLoadableOptions*> optionsByName()
Maps an options-group name (e.g.
“insertionOptions”) to a pointer to the corresponding, live CLoadableOptions member. Pointers remain valid as long as this is alive, and point directly to the actual option members (no copies), so writes through them (e.g. via loadFromConfigFile()) take effect immediately.
Implementations should list every CLoadableOptions member they define, INCLUDING “creationOptions” if present (so it can be discovered/exported generically); however, callers must use trySetCreationOptions(), not a direct write through this pointer, to safely modify creation options.
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::viz::CSetOfObjects& outObj) const
Returns a 3D object representing the map: by default, it will be a mrpt::viz::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(size_t cx, 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 )
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()