17 #include <mrpt/maps/CSimplePointsMap.h>
23 auto pts = mrpt::maps::CSimplePointsMap::Create();
26 for (
int ix = 0; ix < 10; ix++)
27 for (
int iy = 0; iy < 10; iy++) pts->insertPoint(ix * 0.01f, 5.0f + iy * 0.01f, .0f);
30 for (
int iy = 0; iy < 10; iy++)
31 for (
int iz = 0; iz < 10; iz++) pts->insertPoint(10.0f, iy * 0.01f, iz * 0.01f);
34 for (
int ix = 0; ix < 10; ix++)
35 for (
int iy = 0; iy < 10; iy++)
36 for (
int iz = 0; iz < 10; iz++)
37 pts->insertPoint(20.0f + ix * 0.01f, iy * 0.01f, iz * 0.01f);
44 auto pts = mrpt::maps::CSimplePointsMap::Create();
46 pts->insertPointFast(0.
f, 0.
f, 0.
f);
47 pts->insertPointFast(2.
f, 0.
f, 0.
f);
53 int main([[maybe_unused]]
int argc, [[maybe_unused]]
char** argv)
64 auto m = mp2p_icp::Matcher_Point2Plane::Create();
66 mrpt::containers::yaml p;
67 p[
"distanceThreshold"] = 0.1;
68 p[
"searchRadius"] = 0.1;
69 p[
"minimumPlanePoints"] = 5.0;
71 p[
"planeEigenThreshold"] = 0.1;
79 m->match(pcGlobal, pcLocal, {0, 0, 0, 0, 0, 0}, {}, ms, pairs);
80 ASSERT_(pairs.
empty());
87 m->match(pcGlobal, pcLocal, {0, 5, 0, 0, 0, 0}, {}, ms, pairs);
88 ASSERT_EQUAL_(pairs.
size(), 1U);
96 m->match(pcGlobal, pcLocal, {8.04, 0, 0.0, 0, 0, 0}, {}, ms, pairs);
97 ASSERT_EQUAL_(pairs.
size(), 1U);
102 ASSERT_NEAR_(p0.pt_local.x, 2.0, 1e-3);
103 ASSERT_NEAR_(p0.pt_local.y, 0.0, 1e-3);
104 ASSERT_NEAR_(p0.pt_local.z, 0.0, 1e-3);
106 ASSERT_NEAR_(p0.pl_global.centroid.x, 10.0, 0.01);
107 ASSERT_NEAR_(p0.pl_global.centroid.y, 0.0, 0.01);
108 ASSERT_NEAR_(p0.pl_global.centroid.z, 0.0, 0.01);
111 ASSERT_NEAR_(p0.pl_global.plane.coefs[0], 1.0, 1e-3);
112 ASSERT_NEAR_(p0.pl_global.plane.coefs[1], 0.0, 1e-3);
113 ASSERT_NEAR_(p0.pl_global.plane.coefs[2], 0.0, 1e-3);
114 ASSERT_NEAR_(p0.pl_global.plane.coefs[3], -10.0, 1e-3);
121 m->match(pcGlobal, pcLocal, {18.053, 0.05, 0.03, 0, 0, 0}, {}, ms, pairs);
128 auto mPt2Pt = mp2p_icp::Matcher_Points_DistanceThreshold::Create();
129 mrpt::containers::yaml p2;
130 p2[
"threshold"] = 0.1;
131 p2[
"thresholdAngularDeg"] = .0;
132 p2[
"allowMatchAlreadyMatchedPoints"] =
true;
133 mPt2Pt->initialize(p2);
136 {m, mPt2Pt}, pcGlobal, pcLocal, {8.04, 0, 0.0, 0, 0, 0}, {});
139 ASSERT_EQUAL_(pairs.
size(), 2U);
147 auto mPt2Pt = mp2p_icp::Matcher_Points_DistanceThreshold::Create();
148 mrpt::containers::yaml p2;
149 p2[
"threshold"] = 0.1;
150 p2[
"thresholdAngularDeg"] = .0;
151 p2[
"allowMatchAlreadyMatchedPoints"] =
false;
152 mPt2Pt->initialize(p2);
155 {m, mPt2Pt}, pcGlobal, pcLocal, {8.04, 0, 0.0, 0, 0, 0}, {});
158 ASSERT_EQUAL_(pairs.
size(), 1U);
163 catch (std::exception& e)
165 std::cerr << mrpt::exception_to_str(e) <<
"\n";