Engineering Guides · Module 08
Point-cloud processing workflow
Reduce the data early, in a known order, and measure what each step costs and what it removes.
Assumptions: Numbers in the examples are illustrative and the code is executed by the site’s tests. Facts taken from a cited source are marked; other statements are general engineering knowledge and must be confirmed on the datasheet of the part you use.
1. Engineering problem
A 3D LiDAR can produce hundreds of thousands of points per second. Most algorithms do not need all of them, and processing them all can saturate a CPU. A fixed, measured workflow keeps the data useful and the load predictable.
2. When is this needed?
- Before any LiDAR algorithm (mapping, detection) on an embedded computer.
- When CPU load tracks the point count.
- When changing sensors or resolution.
3. Selection and design decisions
Typical order: validate the message (frame, stamp, fields, is_dense), crop, remove invalid points (NaN), downsample with a voxel grid, remove outliers, then run the task algorithm. The voxel grid keeps one representative per cell; the cell size sets the resolution you keep.
| Step | Effect | Cost | Risk |
|---|---|---|---|
| Validate | Rejects malformed clouds | Negligible | None |
| Crop | Removes irrelevant points early | Low | Cropping needed objects |
| Remove NaN | Avoids propagating invalid values | Low | None |
| Voxel downsample | Cuts the count and evens density | Medium | Loses small details |
| Outlier removal | Removes isolated noise points | Medium to high | Removes thin real structures |
4. Advantages and disadvantages
- Larger voxels reduce load and lose detail; choose from the smallest feature the algorithm needs.
- Order matters: crop and downsample before expensive filters.
- Keeping the first point per cell is fast; averaging the points in the cell is smoother and costs more.
5. Requirements and constraints
- Voxel size is derived from the smallest feature of interest.
- The workflow runs within the frame period with margin.
- Stamp and frame_id of the output equal those of the input (or the transformed frame is stated).
6. Architecture
PointCloud2 ─▶ validate ─▶ crop ─▶ drop NaN ─▶ voxel downsample ─▶ outlier removal ─▶ algorithm7. Implementation
- Check header, fields and is_dense of each cloud.
- Crop and drop invalid points.
- Choose the voxel size from the smallest feature and measure the remaining point count (below).
- Measure per-step time on the target computer.
- Check the output against the input visually and with a metric (for example the nearest-obstacle distance).
import numpy as np
rng = np.random.default_rng(0)
pts = np.concatenate([rng.uniform(-1, 1, (5000, 3)) * [10, 10, 1], rng.normal([5, 0, 0.5], 0.05, (500, 3))])
def voxel(points, size):
keys = np.floor(points / size).astype(np.int64)
_, idx = np.unique(keys, axis=0, return_index=True)
return points[np.sort(idx)]
for size in (0.1, 0.5, 1.0):
d = voxel(pts, size)
print(f"voxel {size} m: {len(pts)} -> {len(d)} points ({len(d) / len(pts) * 100:.0f} %)")Printed (checked by the site’s tests):
voxel 0.1 m: 5500 -> 5015 points (91 %)
voxel 0.5 m: 5500 -> 3454 points (63 %)
voxel 1.0 m: 5500 -> 800 points (15 %)Reading it: a synthetic cloud of 5 500 points (a large sparse volume plus a small dense object) keeps 91 % of its points with 0.1 m voxels, 63 % with 0.5 m and 15 % with 1.0 m. The dense object collapses first, which is the loss of detail the trade-off describes. This implementation keeps the first point per cell. The data are random and illustrative.
8. Real examples
- Mapping on an embedded computer: 0.2 m voxels before scan matching to keep the front end under 50 ms per sweep.
9. Failure scenarios
- A voxel size larger than the smallest obstacle, so it vanishes.
- Outlier removal that deletes thin poles.
- Downsampling after an expensive filter, which wastes the saving.
10. Troubleshooting
- Plot point count after each step.
- Compare nearest-obstacle distance before and after.
- Profile each step’s time.
11. Validation
- The example prints the lines shown (executed by the site tests).
- The task result (detections or map quality) is unchanged within tolerance after downsampling.
- Processing time per frame is within budget on the target computer.
12. Engineering checklist
13. Further references
- ROS 2
sensor_msgs/PointCloud2(Jazzy): PointCloud2.msg, read 2026-11-06. - Library documentation for your point-cloud tool (for example PCL or Open3D) for the exact filter and clustering functions and parameters; the algorithms here are written out in plain Python so they can be checked.