14 #include <mrpt/containers/yaml.h>
15 #include <mrpt/maps/CSimplePointsMap.h>
16 #include <mrpt/math/utils.h>
17 #include <mrpt/obs/CObservationRotatingScan.h>
18 #include <mrpt/version.h>
43 const std::optional<mrpt::poses::CPose3D>& robotPose)
const
46 using namespace mrpt::obs;
50 "initialize() must be called once before using process().");
54 const auto obsClassName = o.GetRuntimeClass()->className;
59 bool processed =
false;
67 if (
auto oRS =
dynamic_cast<const CObservationRotatingScan*
>(&o); oRS)
71 if (processed)
return true;
74 mrpt::maps::CPointsMap::Ptr outPc;
76 itLy !=
out.layers.end())
78 outPc = std::dynamic_pointer_cast<mrpt::maps::CPointsMap>(itLy->second);
81 "Layer '%s' must be of point cloud type.",
86 outPc = mrpt::maps::CSimplePointsMap::Create();
90 if (!outPc) outPc = mrpt::maps::CSimplePointsMap::Create();
102 const std::optional<mrpt::poses::CPose3D>& robotPose)
const
104 #if MRPT_VERSION >= 0x020b04
105 auto outPc = mrpt::maps::CSimplePointsMap::Create();
107 ASSERT_(!pc.organizedPoints.empty());
109 const auto nRows = pc.rowCount;
110 const auto nCols = pc.columnCount;
112 ASSERT_EQUAL_(nRows, pc.organizedPoints.rows());
113 ASSERT_EQUAL_(nCols, pc.organizedPoints.cols());
115 ASSERT_EQUAL_(nRows, pc.rangeImage.rows());
116 ASSERT_EQUAL_(nCols, pc.rangeImage.cols());
119 for (
size_t r = 0; r < nRows; r++)
122 for (
size_t i = 1; i + 1 < nCols; i++)
125 if (!pc.rangeImage(r, i - 1) || !pc.rangeImage(r, i) ||
126 !pc.rangeImage(r, i + 1))
129 const auto& pt_im1 = pc.organizedPoints(r, i - 1);
130 const auto& pt_i = pc.organizedPoints(r, i);
131 const auto& pt_ip1 = pc.organizedPoints(r, i + 1);
133 const auto v1 = (pt_i - pt_im1);
134 const auto v2 = (pt_ip1 - pt_i);
135 const auto v1n = v1.norm();
136 const auto v2n = v2.norm();
142 const float score = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
149 robotPose->composePoint(pc.organizedPoints(r, i)));
151 outPc->insertPoint(pc.organizedPoints(r, i));
161 THROW_EXCEPTION(
"This class requires MRPT >=v2.11.4");