15 #include <mrpt/core/exceptions.h>
16 #include <mrpt/core/round.h>
17 #include <mrpt/version.h>
25 mrpt::system::COutputLogger::setLoggerName(
"Matcher_Point2Line");
33 MCP_LOAD_REQ(params,
knn);
40 const mrpt::maps::CMetricMap& pcGlobalMap,
41 const mrpt::maps::CPointsMap& pcLocal,
42 const mrpt::poses::CPose3D& localPose,
MatchState& ms,
48 const mrpt::maps::NearestNeighborsCapable& nnGlobal =
51 out.potential_pairings += pcLocal.size();
54 if (pcGlobalMap.isEmpty() || pcLocal.empty())
return;
60 if (!pcGlobalMap.boundingBox().intersection(
61 {tl.localMin, tl.localMax},
66 out.paired_pt2pl.reserve(
out.paired_pt2pl.size() + pcLocal.size() / 10);
70 const float maxDistForCorrespondenceSquared =
73 const auto& lxs = pcLocal.getPointsBufferRef_x();
74 const auto& lys = pcLocal.getPointsBufferRef_y();
75 const auto& lzs = pcLocal.getPointsBufferRef_z();
77 std::vector<float> kddSqrDist;
78 std::vector<uint64_t> kddIdxs;
79 std::vector<mrpt::math::TPoint3Df> kddPts;
80 std::vector<float> kddXs, kddYs, kddZs;
82 for (
size_t i = 0; i < tl.
x_locals.size(); i++)
84 const size_t localIdx = tl.
idxs.has_value() ? (*tl.
idxs)[i] : i;
101 nnGlobal.nn_multiple_search(
103 knn, kddPts, kddSqrDist, kddIdxs);
108 if (!kddSqrDist.empty() &&
109 kddSqrDist.back() < maxDistForCorrespondenceSquared)
115 for (
size_t j = 0; j < kddSqrDist.size(); j++)
117 if (kddSqrDist[j] > maxDistForCorrespondenceSquared)
120 kddSqrDist.resize(j);
132 kddXs.data(), kddYs.data(), kddZs.data(), std::nullopt,
137 std::cout <<
"eig values: " << eig.
eigVals[0] <<
" " << eig.
eigVals[1]
139 <<
" eigvec0: " << eig.
eigVectors[0].asString() <<
"\n"
140 <<
" eigvec1: " << eig.
eigVectors[1].asString() <<
"\n"
141 <<
" eigvec2: " << eig.
eigVectors[2].asString() <<
"\n";
148 auto& p =
out.paired_pt2ln.emplace_back();
149 p.pt_local = {lxs[localIdx], lys[localIdx], lzs[localIdx]};
152 p.ln_global.pBase = {
154 p.ln_global.director = normal.unitarize();