test-mp2p_georef_yaml.cpp
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  * A Modular Optimization framework for Localization and mApping (MOLA)
3  * Copyright (C) 2018-2024 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
6 
14 #include <mp2p_icp/metricmap.h>
15 #include <mrpt/containers/yaml.h>
16 #include <mrpt/core/exceptions.h>
17 
18 #include <sstream>
19 
20 namespace
21 {
22 void unit_test()
23 {
24  {
26 
27  std::stringstream ss;
29  const auto str = ss.str();
30 
31  const auto gRead = mp2p_icp::FromYAML(mrpt::containers::yaml::FromText(str));
32  ASSERT_EQUAL_(gRead.has_value(), map.georeferencing.has_value());
33  }
34 
35  {
37  auto& gIn = map.georeferencing.emplace();
38  gIn.geo_coord.lat = 4.2;
39  gIn.geo_coord.lon = 23.0;
40  gIn.geo_coord.height = 100.0;
41 
42  gIn.T_enu_to_map.cov.setDiagonal(0.1);
43  gIn.T_enu_to_map.mean = mrpt::poses::CPose3D(1.0, 2.0, 3.0, 0, 0, 0);
44 
45  std::stringstream ss;
47  const auto str = ss.str();
48 
49  const auto gRead = mp2p_icp::FromYAML(mrpt::containers::yaml::FromText(str));
50  ASSERT_EQUAL_(gRead.has_value(), map.georeferencing.has_value());
51  ASSERT_(gRead->T_enu_to_map.mean == map.georeferencing->T_enu_to_map.mean);
52  ASSERT_(gRead->T_enu_to_map.cov == map.georeferencing->T_enu_to_map.cov);
53  ASSERT_(gRead->geo_coord == map.georeferencing->geo_coord);
54  }
55 }
56 } // namespace
57 
58 int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
59 {
60  try
61  {
62  unit_test();
63  }
64  catch (std::exception& e)
65  {
66  std::cerr << mrpt::exception_to_str(e) << "\n";
67  return 1;
68  }
69 }
unit_test
void unit_test()
Definition: test-mp2p_quality_voxels.cpp:23
main
int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
Definition: test-mp2p_georef_yaml.cpp:58
mp2p_icp::ToYAML
mrpt::containers::yaml ToYAML(const std::optional< metric_map_t::Georeferencing > &gref)
Serialization of geo-reference information as YAML.
Definition: metricmap.cpp:762
mp2p_icp::FromYAML
std::optional< metric_map_t::Georeferencing > FromYAML(const mrpt::containers::yaml &yaml_data)
Serialization of geo-reference information as YAML.
Definition: metricmap.cpp:731
metricmap.h
Generic representation of pointcloud(s) and/or extracted features.
mp2p_icp::metric_map_t
Generic container of pointcloud(s), extracted features and other maps.
Definition: metricmap.h:55
mp2p_icp::metric_map_t::georeferencing
std::optional< Georeferencing > georeferencing
Definition: metricmap.h:119


mp2p_icp
Author(s):
autogenerated on Mon May 26 2025 02:45:50