14 #include <mrpt/containers/yaml.h>
15 #include <mrpt/maps/CSimplePointsMap.h>
16 #include <mrpt/obs/CObservation2DRangeScan.h>
17 #include <mrpt/obs/CObservation3DRangeScan.h>
18 #include <mrpt/obs/CObservationPointCloud.h>
19 #include <mrpt/obs/CObservationRotatingScan.h>
20 #include <mrpt/obs/CObservationVelodyneScan.h>
21 #include <mrpt/obs/CSensoryFrame.h>
22 #include <mrpt/version.h>
42 MRPT_LOG_DEBUG_STREAM(
"Loading these params:\n" << c);
57 using namespace mrpt::obs;
61 "initialize() must be called once before using process().");
63 const auto obsClassName = o.GetRuntimeClass()->className;
69 bool processed =
false;
71 if (
auto o0 =
dynamic_cast<const CObservationPointCloud*
>(&o); o0)
73 ASSERT_(o0->pointcloud);
76 else if (
auto o1 =
dynamic_cast<const CObservation2DRangeScan*
>(&o); o1)
78 else if (
auto o2 =
dynamic_cast<const CObservation3DRangeScan*
>(&o); o2)
80 else if (
auto o3 =
dynamic_cast<const CObservationVelodyneScan*
>(&o); o3)
87 mrpt::maps::CPointsMap::Ptr outPc;
89 itLy !=
out.layers.end())
92 std::dynamic_pointer_cast<mrpt::maps::CPointsMap>(itLy->second);
95 "Layer '%s' must be of point cloud type.",
100 outPc = mrpt::maps::CSimplePointsMap::Create();
104 if (!outPc) outPc = mrpt::maps::CSimplePointsMap::Create();
112 dynamic_cast<const mrpt::obs::CObservation3DRangeScan*
>(&o);
113 obs3D && obs3D->points3D_x.empty())
115 mrpt::maps::CSimplePointsMap tmpMap;
117 mrpt::obs::T3DPointsProjectionParams pp;
118 pp.takeIntoAccountSensorPoseOnRobot =
true;
119 const_cast<mrpt::obs::CObservation3DRangeScan*
>(obs3D)
120 ->unprojectInto(tmpMap, pp);
122 outPc->insertAnotherMap(&tmpMap, mrpt::poses::CPose3D::Identity());
127 #if MRPT_VERSION >= 0x240
128 auto& thePc = *outPc;
130 auto* thePc = outPc.get();
132 const bool insertDone = o.insertObservationInto(thePc);
137 "Observation of type '%s' could not be converted into a "
138 "point cloud, and none of the specializations handled it, "
140 "do not know what to do with this observation!",
145 #if MRPT_VERSION >= 0x233
149 const_cast<mrpt::obs::CObservation&
>(o).unload();
157 [[maybe_unused]]
const mrpt::obs::CObservation2DRangeScan& pc,
164 [[maybe_unused]]
const mrpt::obs::CObservationVelodyneScan& pc,
171 [[maybe_unused]]
const mrpt::obs::CObservation3DRangeScan& pc,
181 mrpt::maps::CPointsMap::Ptr outPc;
183 itLy !=
out.layers.end())
185 outPc = std::dynamic_pointer_cast<mrpt::maps::CPointsMap>(itLy->second);
188 "Layer '%s' must be of point cloud type.",
193 outPc = mrpt::maps::CSimplePointsMap::Create();
197 outPc->insertAnotherMap(&pc, mrpt::poses::CPose3D::Identity());
203 [[maybe_unused]]
const mrpt::obs::CObservationRotatingScan& pc,
216 ASSERT_(g.get() !=
nullptr);
217 g->process(obs, output);
244 ASSERT_(g.get() !=
nullptr);
245 for (
const auto& obs : sf)
248 g->process(*obs, output);
254 const mrpt::containers::yaml& c,
const mrpt::system::VerbosityLevel& vLevel)
256 if (c.isNullNode())
return {};
258 ASSERT_(c.isSequence());
262 for (
const auto& entry : c.asSequence())
264 const auto& e = entry.asMap();
266 const auto sClass = e.at(
"class_name").as<
std::string>();
267 auto o = mrpt::rtti::classFactory(sClass);
270 auto f = std::dynamic_pointer_cast<Generator>(o);
273 "`%s` class seems not to be derived from Generator",
276 f->setMinLoggingLevel(vLevel);
278 f->initialize(e.at(
"params"));
288 const auto yamlContent = mrpt::containers::yaml::FromFile(
filename);
291 yamlContent.has(
"generators") &&
292 yamlContent[
"generators"].isSequence());