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;
45 
46  mp2p_icp::metric_map_t pcLocal;
49 
50  {
52  mrpt::containers::yaml p;
53  p["threshold"] = 1.05;
54  p["thresholdAngularDeg"] = .001;
55 
56  m.initialize(p);
57 
58  // Ensure initialize is correctly parsing the values:
59  ASSERT_NEAR_(m.threshold, 1.05, 1e-4);
60  ASSERT_NEAR_(m.thresholdAngularDeg, .001, 1e-4);
61 
62  {
63  // For pose: identity
64  mp2p_icp::Pairings pairs;
65  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
66  m.match(pcGlobal, pcLocal, {0, 0, 0, 0, 0, 0}, {}, ms, pairs);
67  ASSERT_(pairs.empty());
68  }
69 
70  // note: on MRPT naming convention: "this"=global; "other"=local.
71 
72  {
73  // For pose #1
74  mp2p_icp::Pairings pairs;
75  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
76  m.match(pcGlobal, pcLocal, {0, 5, 0, 0, 0, 0}, {}, ms, pairs);
77  ASSERT_EQUAL_(pairs.size(), 1);
78  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 0);
79  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 0);
80  }
81 
82  {
83  // For pose #2
84  mp2p_icp::Pairings pairs;
85  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
86  m.match(pcGlobal, pcLocal, {-2, 5, 0, 0, 0, 0}, {}, ms, pairs);
87  ASSERT_EQUAL_(pairs.size(), 1);
88  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 0);
89  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 1);
90  }
91 
92  {
93  // For pose #3
94  mp2p_icp::Pairings pairs;
95  mp2p_icp::MatchState ms(pcGlobal, pcLocal);
96  m.match(
97  pcGlobal, pcLocal,
98  {8.5, -1.0, 1, mrpt::DEG2RAD(45.0f), 0, 0}, {}, ms, pairs);
99  ASSERT_EQUAL_(pairs.size(), 1);
100  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).localIdx, 1);
101  ASSERT_EQUAL_(pairs.paired_pt2pt.at(0).globalIdx, 19);
102  }
103  }
104  }
105  catch (std::exception& e)
106  {
107  std::cerr << mrpt::exception_to_str(e) << "\n";
108  return 1;
109  }
110 }
mp2p_icp::Matcher_Points_DistanceThreshold::initialize
void initialize(const mrpt::containers::yaml &params) override
Definition: Matcher_Points_DistanceThreshold.cpp:33
kitti-run-seq.f
string f
Definition: kitti-run-seq.py:12
mp2p_icp::Pairings
Definition: Pairings.h:94
mp2p_icp::Pairings::empty
virtual bool empty() const
Definition: Pairings.h:127
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:54
mp2p_icp::Matcher_Points_DistanceThreshold
Definition: Matcher_Points_DistanceThreshold.h:30
mp2p_icp::Matcher_Points_DistanceThreshold::threshold
double threshold
Definition: Matcher_Points_DistanceThreshold.h:53
mp2p_icp::metric_map_t::PT_LAYER_RAW
constexpr static const char * PT_LAYER_RAW
Definition: metricmap.h:57
mp2p_icp::MatchState
Definition: Matcher.h:36
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:141
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:48
mp2p_icp::Pairings::paired_pt2pt
mrpt::tfest::TMatchingPairList paired_pt2pt
Definition: Pairings.h:104
mp2p_icp::metric_map_t::layers
std::map< layer_name_t, mrpt::maps::CMetricMap::Ptr > layers
Definition: metricmap.h:75


mp2p_icp
Author(s): Jose-Luis Blanco-Claraco
autogenerated on Tue Jul 2 2024 02:47:26