cartographer/sensor/internal/voxel_filter.h¶
Overview¶
VoxelFilter downsamples point clouds by dividing space into 3D voxels and keeping one point per voxel (typically the first or centroid).
Class: cartographer::sensor::VoxelFilter¶
Construction¶
explicit VoxelFilter(float voxel_size);
voxel_size— Voxel edge length in meters
Filtering¶
PointCloud Filter(const PointCloud& point_cloud) const;
Returns downsampled point cloud.
Algorithm¶
Compute voxel index for each point:
index = floor(point / voxel_size)Use hash map to track first point per voxel
Return collected points
Complexity¶
Time: O(N) for N points
Space: O(M) for M occupied voxels
Usage¶
// Create filter
sensor::VoxelFilter filter(0.025f); // 2.5cm voxels
// Filter point cloud
sensor::PointCloud raw = lidar->GetScan();
sensor::PointCloud filtered = filter.Filter(raw);
// Typical reduction: 100k points -> 10-20k points
Configuration¶
Used in trajectory builder configs:
TRAJECTORY_BUILDER_2D = {
voxel_filter_size = 0.025, -- 2.5cm
}
TRAJECTORY_BUILDER_3D = {
voxel_filter_size = 0.15, -- 15cm (3D lidars denser)
}
See Also¶
PointCloud — Input/output format
RangeData — Uses filtered point clouds