15 #include <mrpt/containers/yaml.h>
16 #include <mrpt/maps/COccupancyGridMap2D.h>
17 #include <mrpt/maps/CVoxelMap.h>
18 #include <mrpt/maps/CVoxelMapRGB.h>
19 #include <mrpt/math/TPose3D.h>
20 #include <mrpt/obs/CObservationPointCloud.h>
39 mrpt::system::COutputLogger::setLoggerName(
"FilterVoxelSlice");
46 MRPT_LOG_DEBUG_STREAM(
"Loading these params:\n" << c);
68 auto inVoxelMap = std::dynamic_pointer_cast<mrpt::maps::CVoxelMap>(in);
70 std::dynamic_pointer_cast<mrpt::maps::CVoxelMapRGB>(in);
72 if (!inVoxelMap && !inVoxelMapRGB)
75 "Input layer is of class '%s', expected one of: "
76 "mrpt::maps::CVoxelMap, mrpt::maps::CVoxelMapRGB",
77 in->GetRuntimeClass()->className);
83 auto occGrid = mrpt::maps::COccupancyGridMap2D::Create();
87 occGrid->insertionOptions.mapAltitude =
94 const_cast<Bonxai::VoxelGrid<mrpt::maps::CVoxelMap::voxel_node_t>&
>(
97 const mrpt::math::TBoundingBoxf bbox = inVoxelMap->boundingBox();
100 bbox.min.x, bbox.max.x, bbox.min.y, bbox.max.y, grid.resolution);
102 const auto zCoordMin = Bonxai::PosToCoord(
104 const auto zCoordMax = Bonxai::PosToCoord(
108 auto lmbdPerVoxel = [&](mrpt::maps::CVoxelMap::voxel_node_t& data,
109 const Bonxai::CoordT& coord) {
111 if (coord.z < zCoordMin.z || coord.z > zCoordMax.z)
return;
112 const auto pt = Bonxai::CoordToPos(coord, grid.resolution);
114 const double freeness = inVoxelMap->l2p(data.occupancy);
118 occGrid->x2idx(
pt.x), occGrid->y2idx(
pt.y), freeness);
121 grid.forEachCell(lmbdPerVoxel);
123 else if (inVoxelMapRGB)