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>
38 mrpt::system::COutputLogger::setLoggerName(
"FilterVoxelSlice");
45 MRPT_LOG_DEBUG_STREAM(
"Loading these params:\n" << c);
66 auto inVoxelMap = std::dynamic_pointer_cast<mrpt::maps::CVoxelMap>(in);
67 auto inVoxelMapRGB = std::dynamic_pointer_cast<mrpt::maps::CVoxelMapRGB>(in);
69 if (!inVoxelMap && !inVoxelMapRGB)
72 "Input layer is of class '%s', expected one of: "
73 "mrpt::maps::CVoxelMap, mrpt::maps::CVoxelMapRGB",
74 in->GetRuntimeClass()->className);
80 auto occGrid = mrpt::maps::COccupancyGridMap2D::Create();
90 const_cast<Bonxai::VoxelGrid<mrpt::maps::CVoxelMap::voxel_node_t>&
>(inVoxelMap->grid());
92 const mrpt::math::TBoundingBoxf bbox = inVoxelMap->boundingBox();
94 occGrid->setSize(bbox.min.x, bbox.max.x, bbox.min.y, bbox.max.y, grid.resolution);
96 const auto zCoordMin =
98 const auto zCoordMax =
103 [&](mrpt::maps::CVoxelMap::voxel_node_t& data,
const Bonxai::CoordT& coord)
106 if (coord.z < zCoordMin.z || coord.z > zCoordMax.z)
return;
107 const auto pt = Bonxai::CoordToPos(coord, grid.resolution);
109 const double freeness = inVoxelMap->l2p(data.occupancy);
112 occGrid->updateCell(occGrid->x2idx(
pt.x), occGrid->y2idx(
pt.y), freeness);
115 grid.forEachCell(lmbdPerVoxel);
117 else if (inVoxelMapRGB)