16 #include <mrpt/containers/yaml.h>
17 #include <mrpt/maps/CVoxelMap.h>
38 mrpt::system::COutputLogger::setLoggerName(
"FilterRemoveByVoxelOccupancy");
45 MRPT_LOG_DEBUG_STREAM(
"Loading these params:\n" << c);
64 "Input layer '%s' not found.",
73 "Input point cloud layer '%s' could not be converted into a "
74 "point cloud (class='%s')",
76 mapPtr->GetRuntimeClass()->className));
88 std::dynamic_pointer_cast<mrpt::maps::CVoxelMap>(voxelMapPtr);
90 voxelPtr, mrpt::format(
91 "Input voxel layer '%s' not of type mrpt::maps::CVoxelMap"
92 "(actual class='%s')",
94 voxelMapPtr->GetRuntimeClass()->className));
103 pcPtr->GetRuntimeClass()->className);
105 outPcStatic->reserve(outPcStatic->size() + pcPtr->size() / 2);
112 pcPtr->GetRuntimeClass()->className);
114 outPcDynamic->reserve(outPcDynamic->size() + pcPtr->size() / 2);
117 outPcStatic || outPcDynamic,
118 "At least one 'output_layer_static_objects' or "
119 "'output_layer_dynamic_objects' output layers must be provided.");
125 const double occThres = 1.0 - occFree;
128 const auto& xs = pcPtr->getPointsBufferRef_x();
129 const auto& ys = pcPtr->getPointsBufferRef_y();
130 const auto& zs = pcPtr->getPointsBufferRef_z();
131 const size_t N = xs.size();
133 size_t nStatic = 0, nDynamic = 0;
135 for (
size_t i = 0; i < N; i++)
137 double prob_occupancy = 0.5;
139 voxelPtr->getPointOccupancy(xs[i], ys[i], zs[i], prob_occupancy);
140 if (!withinMap)
continue;
142 mrpt::maps::CPointsMap* trgMap =
nullptr;
144 if (prob_occupancy > occThres)
146 trgMap = outPcStatic.get();
149 else if (prob_occupancy < occFree)
151 trgMap = outPcDynamic.get();
155 if (!trgMap)
continue;
157 trgMap->insertPointFrom(*pcPtr, i);
160 MRPT_LOG_DEBUG_STREAM(
161 "Parsed " << N <<
" points: static=" << nStatic
162 <<
", dynamic=" << nDynamic);