class mp2p_icp::metric_map_t
Overview
Generic container of pointcloud(s), extracted features and other maps.
This class could be derived by users to define custom point cloud features, for use in custom alignment algorithms.
The class supports C++11/C++17 std::shared_from_this() via get_shared_from_this();
#include <metricmap.h> class metric_map_t: public mrpt::serialization::CSerializable, public std::enable_shared_from_this< metric_map_t > { public: // structs struct Georeferencing; // fields static constexpr static const char* PT_LAYER_RAW = "raw"; static constexpr static const char* PT_LAYER_PLANE_CENTROIDS = "plane_centroids"; std::map<layer_name_t, mrpt::maps::CMetricMap::Ptr> layers; std::vector<mrpt::math::TLine3D> lines; std::vector<plane_patch_t> planes; std::optional<uint64_t> id; std::optional<std::string> label; std::optional<Georeferencing> georeferencing; // methods virtual bool empty() const; virtual size_t size() const; virtual size_t size_points_only() const; virtual std::string contents_summary() const; virtual void clear(); bool save_to_file(const std::string& fileName) const; bool load_from_file(const std::string& fileName); mrpt::maps::CPointsMap::Ptr point_layer(const layer_name_t& name) const; virtual auto get_visualization(const render_params_t& p = render_params_t()) const; virtual void merge_with( const metric_map_t& otherPc, const std::optional<mrpt::math::TPose3D>& otherRelativePose = std::nullopt ); void get_visualization_planes(mrpt::opengl::CSetOfObjects& o, const render_params_planes_t& p) const; void get_visualization_lines(mrpt::opengl::CSetOfObjects& o, const render_params_lines_t& p) const; void get_visualization_points(mrpt::opengl::CSetOfObjects& o, const render_params_points_t& p) const; Ptr get_shared_from_this(); Ptr get_shared_from_this_or_clone(); ConstPtr get_shared_from_this() const; ConstPtr get_shared_from_this_or_clone() const; static void get_visualization_map_layer( mrpt::opengl::CSetOfObjects& o, const render_params_point_layer_t& p, const mrpt::maps::CMetricMap::Ptr& map ); };
Fields
std::map<layer_name_t, mrpt::maps::CMetricMap::Ptr> layers
Different layers indexed by a descriptive name, with point-clouds, 2D/3D gridmap, etc.
Standarized layer names: See section above.
PT_LAYER_RAW: reserved to the original, full point cloud (if kept)
PT_LAYER_PLANE_CENTROIDS: a point for each plane in
planes
(same order).
See also:
point_layers()
std::vector<mrpt::math::TLine3D> lines
3D lines (infinite lines, not segments)
std::vector<plane_patch_t> planes
Plane patches=centroid point + infinite plane
std::optional<uint64_t> id
An optional numerical ID to identify the pointcloud in some higher-level system. Used to build the names of ICP debug files, if so requested. It is not mandatory and even duplicates may exist without problems: just a placeholder for the user of this library to use it.
std::optional<std::string> label
An optional textual identification/description of the pointcloud in some higher-level system. Used to build the names of ICP debug files, if so requested. It is not mandatory and even duplicates may exist without problems: just a placeholder for the user of this library to use it.
std::optional<Georeferencing> georeferencing
If provided, gives the placement of the map with respect to the Earth.
Methods
virtual bool empty() const
return true if all point cloud layers, feature lists, etc. are empty
virtual size_t size() const
Overall number of elements (points, lines, planes)
virtual size_t size_points_only() const
Overall number of points, including all layers.
virtual std::string contents_summary() const
Returns a string summarizing all the elements in the container (points, lines, planes)
virtual void clear()
clear all containers
bool save_to_file(const std::string& fileName) const
Saves the metric_map_t object to file, using MRPT serialization and using on-the-fly GZIP compression.
Returns:
true on success.
bool load_from_file(const std::string& fileName)
Loads the metric_map_t object from a file. See save_to_file()
Returns:
true on success.
mrpt::maps::CPointsMap::Ptr point_layer(const layer_name_t& name) const
Returns a shared_ptr to the given point cloud layer, or throws if the layer does not exist or it contains a different type of metric map (e.g. if it is a gridmap).
Note that this method is only provided by convenience and backwards-compatibility: users can always directly access layers
and perform a std::dynamic_pointer_cast<>
.
virtual auto get_visualization(const render_params_t& p = render_params_t()) const
Gets a renderizable view of all geometric entities.
See render_params_t for options to show/hide the different geometric entities and point layers.
If deriving user classes inheriting from metric_map_t, remember to reimplement this method and call this base class method to render common elements.
virtual void merge_with( const metric_map_t& otherPc, const std::optional<mrpt::math::TPose3D>& otherRelativePose = std::nullopt )
Merges all geometric entities from another point cloud into this one, with an optional relative pose transformation.
Point layers will be merged for coinciding names, or created if the layer did not exist in this
.
This method is virtual for user-extended point clouds can handle other geometric primitives as needed.
void get_visualization_planes(mrpt::opengl::CSetOfObjects& o, const render_params_planes_t& p) const
Used inside get_visualization(), renders planes only.
void get_visualization_lines(mrpt::opengl::CSetOfObjects& o, const render_params_lines_t& p) const
Used inside get_visualization(), renders lines only.
void get_visualization_points(mrpt::opengl::CSetOfObjects& o, const render_params_points_t& p) const
Used inside get_visualization(), renders points only.
Ptr get_shared_from_this()
Returns a shared_ptr to this object, if it was already created initially as a shared_ptr, or an empty pointer otherwise.
Ptr get_shared_from_this_or_clone()
Like get_shared_from_this(), or makes a deep copy if the original object was allocated in the stack, etc.
static void get_visualization_map_layer( mrpt::opengl::CSetOfObjects& o, const render_params_point_layer_t& p, const mrpt::maps::CMetricMap::Ptr& map )
Used inside get_visualization_points(), renders points only.