metricmap.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  * A repertory of multi primitive-to-primitive (MP2P) ICP algorithms in C++
3  * Copyright (C) 2018-2024 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
12 #pragma once
13 
15 #include <mp2p_icp/layer_name_t.h>
16 #include <mp2p_icp/plane_patch.h>
17 #include <mp2p_icp/render_params.h>
18 #include <mrpt/maps/CPointsMap.h>
19 #include <mrpt/maps/NearestNeighborsCapable.h>
20 #include <mrpt/math/TLine3D.h>
21 #include <mrpt/math/TPoint3D.h>
22 #include <mrpt/math/geometry.h>
23 #include <mrpt/poses/CPose3DPDFGaussian.h>
24 #include <mrpt/serialization/CSerializable.h>
25 #include <mrpt/topography/data_types.h>
26 
27 #include <map>
28 #include <memory>
29 #include <optional>
30 #include <string>
31 #include <vector>
32 
33 namespace mp2p_icp
34 {
49 class metric_map_t : public mrpt::serialization::CSerializable,
50  public std::enable_shared_from_this<metric_map_t>
51 {
52  DEFINE_SERIALIZABLE(metric_map_t, mp2p_icp)
53 
54  public:
58  constexpr static const char* PT_LAYER_RAW = "raw";
59  constexpr static const char* PT_LAYER_PLANE_CENTROIDS = "plane_centroids";
60 
76  std::map<layer_name_t, mrpt::maps::CMetricMap::Ptr> layers;
77 
79  std::vector<mrpt::math::TLine3D> lines;
80 
82  std::vector<plane_patch_t> planes;
83 
89  std::optional<uint64_t> id;
90 
97  std::optional<std::string> label;
98 
100  {
103  mrpt::topography::TGeodeticCoords geo_coord;
104 
112  mrpt::poses::CPose3DPDFGaussian T_enu_to_map;
113  };
114 
117  std::optional<Georeferencing> georeferencing;
118 
125  virtual bool empty() const;
126 
128  virtual size_t size() const;
129 
131  virtual size_t size_points_only() const;
132 
135  virtual std::string contents_summary() const;
136 
138  virtual void clear();
139 
144  bool save_to_file(const std::string& fileName) const;
145 
149  bool load_from_file(const std::string& fileName);
150 
160  mrpt::maps::CPointsMap::Ptr point_layer(const layer_name_t& name) const;
161 
171  virtual auto get_visualization(const render_params_t& p = render_params_t())
172  const -> std::shared_ptr<mrpt::opengl::CSetOfObjects>;
173 
182  virtual void merge_with(
183  const metric_map_t& otherPc,
184  const std::optional<mrpt::math::TPose3D>& otherRelativePose =
185  std::nullopt);
186 
189  mrpt::opengl::CSetOfObjects& o, const render_params_planes_t& p) const;
190 
193  mrpt::opengl::CSetOfObjects& o, const render_params_lines_t& p) const;
194 
197  mrpt::opengl::CSetOfObjects& o, const render_params_points_t& p) const;
198 
200  static void get_visualization_map_layer(
201  mrpt::opengl::CSetOfObjects& o, const render_params_point_layer_t& p,
202  const mrpt::maps::CMetricMap::Ptr& map);
203 
207  Ptr get_shared_from_this();
208 
213 
214  // const versions:
215  ConstPtr get_shared_from_this() const;
216  ConstPtr get_shared_from_this_or_clone() const;
217 
220  protected:
222  virtual void derivedSerializeTo(
223  [[maybe_unused]] mrpt::serialization::CArchive& out) const
224  {
225  }
226 
228  virtual void derivedSerializeFrom(
229  [[maybe_unused]] mrpt::serialization::CArchive& in)
230  {
231  }
232 };
233 
247 const mrpt::maps::CPointsMap* MapToPointsMap(const mrpt::maps::CMetricMap& map);
248 
250 mrpt::maps::CPointsMap* MapToPointsMap(mrpt::maps::CMetricMap& map);
251 
257 const mrpt::maps::NearestNeighborsCapable* MapToNN(
258  const mrpt::maps::CMetricMap& map, bool throwIfNotImplemented);
259 
266  const mrpt::maps::CMetricMap& map, bool throwIfNotImplemented);
267 
268 // Serialization of geo-reference information:
269 mrpt::serialization::CArchive& operator>>(
270  mrpt::serialization::CArchive& in,
271  std::optional<metric_map_t::Georeferencing>& g);
272 mrpt::serialization::CArchive& operator<<(
273  mrpt::serialization::CArchive& out,
274  const std::optional<metric_map_t::Georeferencing>& g);
275 
278 } // namespace mp2p_icp
mp2p_icp
Definition: covariance.h:17
mp2p_icp::metric_map_t::empty
virtual bool empty() const
Definition: metricmap.cpp:362
mp2p_icp::operator>>
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, Pairings &obj)
Definition: Pairings.cpp:55
mp2p_icp::metric_map_t::Georeferencing::geo_coord
mrpt::topography::TGeodeticCoords geo_coord
Definition: metricmap.h:103
mp2p_icp::metric_map_t::get_visualization_map_layer
static void get_visualization_map_layer(mrpt::opengl::CSetOfObjects &o, const render_params_point_layer_t &p, const mrpt::maps::CMetricMap::Ptr &map)
Definition: metricmap.cpp:211
mp2p_icp::render_params_point_layer_t
Definition: render_params.h:124
mp2p_icp::layer_name_t
std::string layer_name_t
Definition: layer_name_t.h:22
render_params.h
Render parameters for the different geometric entities.
mp2p_icp::metric_map_t::PT_LAYER_PLANE_CENTROIDS
constexpr static const char * PT_LAYER_PLANE_CENTROIDS
Definition: metricmap.h:59
mp2p_icp::metric_map_t::save_to_file
bool save_to_file(const std::string &fileName) const
Definition: metricmap.cpp:567
mp2p_icp::metric_map_t::get_visualization_points
void get_visualization_points(mrpt::opengl::CSetOfObjects &o, const render_params_points_t &p) const
Definition: metricmap.cpp:177
mp2p_icp::metric_map_t::derivedSerializeTo
virtual void derivedSerializeTo([[maybe_unused]] mrpt::serialization::CArchive &out) const
Definition: metricmap.h:222
mp2p_icp::metric_map_t::clear
virtual void clear()
Definition: metricmap.cpp:366
mrpt
Definition: LogRecord.h:100
plane_patch.h
Defines plane_patch_t.
mp2p_icp::render_params_planes_t
Definition: render_params.h:32
mp2p_icp::metric_map_t::PT_LAYER_RAW
constexpr static const char * PT_LAYER_RAW
Definition: metricmap.h:58
testing::internal::string
::std::string string
Definition: gtest.h:1979
mp2p_icp::metric_map_t::label
std::optional< std::string > label
Definition: metricmap.h:97
layer_name_t.h
kitti-batch-convert.out
string out
Definition: kitti-batch-convert.py:7
mp2p_icp::metric_map_t::derivedSerializeFrom
virtual void derivedSerializeFrom([[maybe_unused]] mrpt::serialization::CArchive &in)
Definition: metricmap.h:228
mp2p_icp::render_params_lines_t
Definition: render_params.h:53
mp2p_icp::metric_map_t::planes
std::vector< plane_patch_t > planes
Definition: metricmap.h:82
mp2p_icp::MapToPointsMap
const mrpt::maps::CPointsMap * MapToPointsMap(const mrpt::maps::CMetricMap &map)
Definition: metricmap.cpp:648
mp2p_icp::metric_map_t::lines
std::vector< mrpt::math::TLine3D > lines
Definition: metricmap.h:79
mp2p_icp::metric_map_t::point_layer
mrpt::maps::CPointsMap::Ptr point_layer(const layer_name_t &name) const
Definition: metricmap.cpp:629
mp2p_icp::NearestPlaneCapable
Definition: NearestPlaneCapable.h:25
mp2p_icp::metric_map_t::merge_with
virtual void merge_with(const metric_map_t &otherPc, const std::optional< mrpt::math::TPose3D > &otherRelativePose=std::nullopt)
Definition: metricmap.cpp:370
mp2p_icp::metric_map_t::contents_summary
virtual std::string contents_summary() const
Definition: metricmap.cpp:500
mp2p_icp::render_params_t
Definition: render_params.h:184
mp2p_icp::metric_map_t::size
virtual size_t size() const
Definition: metricmap.cpp:475
mp2p_icp::metric_map_t::Georeferencing
Definition: metricmap.h:99
mp2p_icp::metric_map_t::get_visualization
virtual auto get_visualization(const render_params_t &p=render_params_t()) const -> std::shared_ptr< mrpt::opengl::CSetOfObjects >
Definition: metricmap.cpp:121
mp2p_icp::metric_map_t::get_visualization_lines
void get_visualization_lines(mrpt::opengl::CSetOfObjects &o, const render_params_lines_t &p) const
Definition: metricmap.cpp:157
mp2p_icp::metric_map_t::load_from_file
bool load_from_file(const std::string &fileName)
Definition: metricmap.cpp:578
mp2p_icp::metric_map_t::Georeferencing::T_enu_to_map
mrpt::poses::CPose3DPDFGaussian T_enu_to_map
Definition: metricmap.h:112
std
mp2p_icp::render_params_points_t
Definition: render_params.h:156
mp2p_icp::operator<<
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &out, const Pairings &obj)
Definition: Pairings.cpp:48
NearestPlaneCapable.h
Defines a virtual interface for maps capable of finding pt-plane pairings.
mp2p_icp::metric_map_t
Generic container of pointcloud(s), extracted features and other maps.
Definition: metricmap.h:49
mp2p_icp::metric_map_t::get_visualization_planes
void get_visualization_planes(mrpt::opengl::CSetOfObjects &o, const render_params_planes_t &p) const
Definition: metricmap.cpp:135
mp2p_icp::metric_map_t::id
std::optional< uint64_t > id
Definition: metricmap.h:89
mp2p_icp::metric_map_t::georeferencing
std::optional< Georeferencing > georeferencing
Definition: metricmap.h:117
mp2p_icp::metric_map_t::get_shared_from_this
Ptr get_shared_from_this()
Definition: metricmap.cpp:589
mp2p_icp::metric_map_t::size_points_only
virtual size_t size_points_only() const
Definition: metricmap.cpp:485
mp2p_icp::metric_map_t::get_shared_from_this_or_clone
Ptr get_shared_from_this_or_clone()
Definition: metricmap.cpp:602
mp2p_icp::MapToNN
const mrpt::maps::NearestNeighborsCapable * MapToNN(const mrpt::maps::CMetricMap &map, bool throwIfNotImplemented)
Definition: metricmap.cpp:686
mp2p_icp::metric_map_t::layers
std::map< layer_name_t, mrpt::maps::CMetricMap::Ptr > layers
Definition: metricmap.h:76
mp2p_icp::MapToNP
const mp2p_icp::NearestPlaneCapable * MapToNP(const mrpt::maps::CMetricMap &map, bool throwIfNotImplemented)
Definition: metricmap.cpp:701


mp2p_icp
Author(s):
autogenerated on Fri Dec 20 2024 03:45:59