test-mp2p_matcher_pt2pt.cpp
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  * A Modular Optimization framework for Localization and mApping (MOLA)
3  * Copyright (C) 2018-2021 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
6 
16 #include <mp2p_icp/metricmap.h>
17 #include <mrpt/maps/CSimplePointsMap.h>
18 
19 static mrpt::maps::CSimplePointsMap::Ptr generateGlobalPoints()
20 {
21  auto pts = mrpt::maps::CSimplePointsMap::Create();
22 
23  for (int i = 0; i < 10; i++) pts->insertPoint(i * 0.01f, 5.0f, .0f);
24  for (int i = 0; i < 10; i++) pts->insertPoint(10.0f, i * 0.01f, 1.0f);
25 
26  return pts;
27 }
28 
29 static mrpt::maps::CSimplePointsMap::Ptr generateLocalPoints()
30 {
31  auto pts = mrpt::maps::CSimplePointsMap::Create();
32 
33  pts->insertPointFast(0.f, 0.f, 0.f);
34  pts->insertPointFast(2.f, 0.f, 0.f);
35 
36  return pts;
37 }
38 
39 int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
40 {
41  try
42  {
43  mp2p_icp::metric_map_t pcGlobal;
46 
47  mp2p_icp::metric_map_t pcLocal;
50 
51  {
53  mrpt::containers::yaml p;
54  p["threshold"] = 1.0;
55 
56  m.initialize(p);
57 
58  {
59  // For pose: identity
60  mp2p_icp::Pairings pairs;
61  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
62  m.match(pcGlobal, pcLocal, {0, 0, 0, 0, 0, 0}, {}, ms, pairs);
63  ASSERT_(pairs.empty());
64  }
65 
66  // note: on MRPT naming convention: "this"=global; "other"=local.
67 
68  {
69  // For pose #1
70  mp2p_icp::Pairings pairs;
71  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
72  m.match(pcGlobal, pcLocal, {0, 5, 0, 0, 0, 0}, {}, ms, pairs);
73  ASSERT_EQUAL_(pairs.size(), 1);
74  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 0);
75  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 0);
76  }
77 
78  {
79  // For pose #2
80  mp2p_icp::Pairings pairs;
81  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
82  m.match(pcGlobal, pcLocal, {-2, 5, 0, 0, 0, 0}, {}, ms, pairs);
83  ASSERT_EQUAL_(pairs.size(), 1);
84  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 0);
85  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 1);
86  }
87 
88  {
89  // For pose #3
90  mp2p_icp::Pairings pairs;
91  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
92  m.match(
93  pcGlobal, pcLocal,
94  {8.5, -1.0, 1, mrpt::DEG2RAD(45.0f), 0, 0}, {}, ms, pairs);
95  ASSERT_EQUAL_(pairs.size(), 1);
96  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 1);
97  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 19);
98  }
99  }
100  }
101  catch (std::exception& e)
102  {
103  std::cerr << mrpt::exception_to_str(e) << "\n";
104  return 1;
105  }
106 }
std::map< layer_name_t, mrpt::maps::CMetricMap::Ptr > layers
Definition: metricmap.h:74
Generic container of pointcloud(s), extracted features and other maps.
Definition: metricmap.h:47
void initialize(const mrpt::containers::yaml &params) override
Generic representation of pointcloud(s) and/or extracted features.
virtual bool empty() const
Definition: Pairings.h:118
virtual bool match(const metric_map_t &pcGlobal, const metric_map_t &pcLocal, const mrpt::poses::CPose3D &localPose, const MatchContext &mc, MatchState &ms, Pairings &out) const
static constexpr const char * PT_LAYER_RAW
Definition: metricmap.h:56
virtual size_t size() const
Definition: Pairings.cpp:135
int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
Pointcloud matcher: fixed ratio of inliers/outliers by distance.
static mrpt::maps::CSimplePointsMap::Ptr generateLocalPoints()
static mrpt::maps::CSimplePointsMap::Ptr generateGlobalPoints()
Pointcloud matcher: fixed distance thresholds.
mrpt::tfest::TMatchingPairList paired_pt2pt
Definition: Pairings.h:101


mrpt_local_obstacles
Author(s): Jose-Luis Blanco-Claraco
autogenerated on Thu Jun 1 2023 03:06:43