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-2024 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
6 
15 #include <mp2p_icp/metricmap.h>
16 #include <mrpt/maps/CSimplePointsMap.h>
17 
18 static mrpt::maps::CSimplePointsMap::Ptr generateGlobalPoints()
19 {
20  auto pts = mrpt::maps::CSimplePointsMap::Create();
21 
22  for (int i = 0; i < 10; i++) pts->insertPoint(i * 0.01f, 5.0f, .0f);
23  for (int i = 0; i < 10; i++) pts->insertPoint(10.0f, i * 0.01f, 1.0f);
24 
25  return pts;
26 }
27 
28 static mrpt::maps::CSimplePointsMap::Ptr generateLocalPoints()
29 {
30  auto pts = mrpt::maps::CSimplePointsMap::Create();
31 
32  pts->insertPointFast(0.f, 0.f, 0.f);
33  pts->insertPointFast(2.f, 0.f, 0.f);
34 
35  return pts;
36 }
37 
38 int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
39 {
40  try
41  {
42  mp2p_icp::metric_map_t pcGlobal;
44 
45  mp2p_icp::metric_map_t pcLocal;
47 
48  {
50  mrpt::containers::yaml p;
51  p["threshold"] = 1.05;
52  p["thresholdAngularDeg"] = .001;
53 
54  m.initialize(p);
55 
56  // Ensure initialize is correctly parsing the values:
57  ASSERT_NEAR_(m.threshold, 1.05, 1e-4);
58  ASSERT_NEAR_(m.thresholdAngularDeg, .001, 1e-4);
59 
60  {
61  // For pose: identity
62  mp2p_icp::Pairings pairs;
63  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
64  m.match(pcGlobal, pcLocal, {0, 0, 0, 0, 0, 0}, {}, ms, pairs);
65  ASSERT_(pairs.empty());
66  }
67 
68  // note: on MRPT naming convention: "this"=global; "other"=local.
69 
70  {
71  // For pose #1
72  mp2p_icp::Pairings pairs;
73  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
74  m.match(pcGlobal, pcLocal, {0, 5, 0, 0, 0, 0}, {}, ms, pairs);
75  ASSERT_EQUAL_(pairs.size(), 1);
76  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 0);
77  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 0);
78  }
79 
80  {
81  // For pose #2
82  mp2p_icp::Pairings pairs;
83  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
84  m.match(pcGlobal, pcLocal, {-2, 5, 0, 0, 0, 0}, {}, ms, pairs);
85  ASSERT_EQUAL_(pairs.size(), 1);
86  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 0);
87  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 1);
88  }
89 
90  {
91  // For pose #3
92  mp2p_icp::Pairings pairs;
93  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
94  m.match(
95  pcGlobal, pcLocal, {8.5, -1.0, 1, mrpt::DEG2RAD(45.0f), 0, 0}, {}, ms, pairs);
96  ASSERT_EQUAL_(pairs.size(), 1);
97  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 1);
98  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 19);
99  }
100  }
101  }
102  catch (std::exception& e)
103  {
104  std::cerr << mrpt::exception_to_str(e) << "\n";
105  return 1;
106  }
107 }
mp2p_icp::Matcher_Points_DistanceThreshold::initialize
void initialize(const mrpt::containers::yaml &params) override
Definition: Matcher_Points_DistanceThreshold.cpp:32
kitti-run-seq.f
string f
Definition: kitti-run-seq.py:12
mp2p_icp::Pairings
Definition: Pairings.h:76
mp2p_icp::Pairings::empty
virtual bool empty() const
Definition: Pairings.h:109
generateLocalPoints
static mrpt::maps::CSimplePointsMap::Ptr generateLocalPoints()
Definition: test-mp2p_matcher_pt2pt.cpp:28
mp2p_icp::Matcher::match
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
Definition: mp2p_icp/src/Matcher.cpp:27
mp2p_icp::Matcher_Points_DistanceThreshold::thresholdAngularDeg
double thresholdAngularDeg
Definition: Matcher_Points_DistanceThreshold.h:53
mp2p_icp::Matcher_Points_DistanceThreshold
Definition: Matcher_Points_DistanceThreshold.h:30
mp2p_icp::Matcher_Points_DistanceThreshold::threshold
double threshold
Definition: Matcher_Points_DistanceThreshold.h:52
mp2p_icp::metric_map_t::PT_LAYER_RAW
constexpr static const char * PT_LAYER_RAW
Definition: metricmap.h:64
mp2p_icp::MatchState
Definition: Matcher.h:37
Matcher_Points_DistanceThreshold.h
Pointcloud matcher: fixed distance thresholds.
main
int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
Definition: test-mp2p_matcher_pt2pt.cpp:38
mp2p_icp::Pairings::size
virtual size_t size() const
Definition: Pairings.cpp:135
generateGlobalPoints
static mrpt::maps::CSimplePointsMap::Ptr generateGlobalPoints()
Definition: test-mp2p_matcher_pt2pt.cpp:18
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::Pairings::paired_pt2pt
mrpt::tfest::TMatchingPairList paired_pt2pt
Definition: Pairings.h:86
mp2p_icp::metric_map_t::layers
std::map< layer_name_t, mrpt::maps::CMetricMap::Ptr > layers
Definition: metricmap.h:82


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