15 #include <mrpt/containers/yaml.h>
16 #include <mrpt/maps/CSimplePointsMap.h>
17 #include <mrpt/math/ops_containers.h>
18 #include <mrpt/poses/Lie/SO.h>
19 #include <mrpt/random/RandomGenerators.h>
20 #include <mrpt/version.h>
22 #if MRPT_VERSION >= 0x020b04
23 #include <mrpt/maps/CPointsMapXYZIRT.h>
26 #if defined(MP2P_HAS_TBB)
27 #include <tbb/parallel_for.h>
38 MRPT_LOG_DEBUG_STREAM(
"Loading these params:\n" << c);
47 ASSERT_(c.has(
"twist") && c[
"twist"].isSequence());
48 ASSERT_EQUAL_(c[
"twist"].asSequence().size(), 6UL);
50 const auto yamlTwist = c[
"twist"].asSequence();
52 for (
int i = 0; i < 6; i++)
53 Parameterizable::parseAndDeclareParameter(yamlTwist.at(i).as<
std::string>(),
twist[i]);
59 #if MRPT_VERSION >= 0x020b04
73 const mrpt::maps::CPointsMap* inPc =
nullptr;
81 outPc->reserve(outPc->size() + inPc->size());
93 MRPT_LOG_DEBUG_STREAM(
99 const auto& xs = inPc->getPointsBufferRef_x();
100 const auto& ys = inPc->getPointsBufferRef_y();
101 const auto& zs = inPc->getPointsBufferRef_z();
102 const size_t n = xs.size();
105 const auto* Is = inPc->getPointsBufferRef_intensity();
106 const auto* Ts = inPc->getPointsBufferRef_timestamp();
107 const auto* Rs = inPc->getPointsBufferRef_ring();
109 auto* out_Is = outPc->getPointsBufferRef_intensity();
110 auto* out_Rs = outPc->getPointsBufferRef_ring();
111 auto* out_Ts = outPc->getPointsBufferRef_timestamp();
120 for (
size_t i = 0; i < n; i++)
121 outPc->insertPointFrom(*inPc, i);
123 MRPT_LOG_DEBUG_STREAM(
125 <<
"' with contents: " << inPc->asString());
130 "Input layer '%s' does not contain per-point timestamps, "
131 "cannot do scan deskew. Set "
132 "'silently_ignore_no_timestamps=true' to skip de-skew."
133 "Input map contents: '%s'",
139 ASSERT_EQUAL_(Ts->size(), n);
142 const size_t n0 = outPc->size();
143 outPc->resize(n0 + n);
148 #if defined(MP2P_HAS_TBB)
150 static_cast<size_t>(0), n,
153 for (
size_t i = 0; i < n; i++)
156 const auto pt = mrpt::math::TPoint3Df(xs[i], ys[i], zs[i]);
157 if (!(
pt.x == 0 &&
pt.y == 0 &&
pt.z == 0))
160 const mrpt::math::TVector3D v_dt = v * (*Ts)[i];
161 const mrpt::math::TVector3D w_dt = w * (*Ts)[i];
163 const auto p = mrpt::poses::CPose3D::FromRotationAndTranslation(
165 mrpt::poses::Lie::SO<3>::exp(mrpt::math::CVectorFixedDouble<3>(w_dt)),
169 const auto corrPt = p.composePoint(
pt);
171 outPc->setPointFast(n0 + i, corrPt.x, corrPt.y, corrPt.z);
172 if (Is && out_Is) (*out_Is)[n0 + i] = (*Is)[i];
173 if (Rs && out_Rs) (*out_Rs)[n0 + i] = (*Rs)[i];
174 if (Ts && out_Ts) (*out_Ts)[n0 + i] = (*Ts)[i];
177 #if defined(MP2P_HAS_TBB)
182 outPc->mark_as_modified();
184 THROW_EXCEPTION(
"This class requires MRPT >=v2.11.4");