Hazard Detection Node
Location:src/lunabot_perception/lunabot_perception/hazard_detection.py
The HazardDetectionNode processes depth camera data to identify obstacles for the navigation costmap.
Architecture
- Input:
/camera_front/points(PointCloud2 from depth camera) - Output:
/hazards/front(filtered obstacles)
Processing Pipeline
The hazard detection algorithm applies a multi-stage filtering pipeline:Voxel Downsampling
Reduce point density for efficient processing:5 cm voxel grid balances detail with computation speed.
Statistical Outlier Removal
Remove sensor noise and spurious points:Points are removed if their distance to the 20 nearest neighbors exceeds 2 standard deviations from the mean.
Ground Plane Segmentation
Use RANSAC to fit a plane model to the lunar surface:Parameters:
distance_threshold: 5 cm - points within this distance are considered groundransac_n: 3 points to fit planenum_iterations: 1000 iterations for robust fitting
Algorithm Parameters
Voxel Size
- Smaller (e.g., 0.02): Higher resolution, slower processing
- Larger (e.g., 0.10): Faster but may miss small rocks
Outlier Removal
| Parameter | Effect | Typical Range |
|---|---|---|
nb_neighbors | More neighbors = smoother filtering | 10-30 |
std_ratio | Lower = more aggressive noise removal | 1.0-3.0 |
std_ratio=2.0 follows the 95% confidence interval in normal distribution, balancing noise removal with feature preservation.Plane Segmentation
distance_threshold: Accommodates regolith surface roughnessnum_iterations: Ensures convergence even with 50% outliers
Integration with Navigation
The/hazards/front topic is consumed by Nav2’s obstacle layer:
Height Filtering
Error Handling
Empty Point Clouds
Post-Filtering Validation
Visualization
Visualize obstacle detection in RViz:Performance Metrics
Processing Time
Typical pipeline latency on a 640x480 depth image:| Stage | Duration |
|---|---|
| Point extraction | ~5 ms |
| Voxel downsampling | ~10 ms |
| Outlier removal | ~15 ms |
| Plane segmentation | ~20 ms |
| Total | ~50 ms |
Point Cloud Size
- Input: ~300,000 points (640x480 depth image)
- After downsampling: ~8,000 points (5 cm voxels)
- After outlier removal: ~7,000 points
- Obstacles (output): ~500-2000 points (depends on environment)
Running Hazard Detection
Tuning for Different Environments
Rocky Terrain
Increase plane distance threshold to accommodate uneven ground:Dusty Conditions
More aggressive outlier removal to filter sensor noise:High-Speed Navigation
Reduce computation time with larger voxels:The current configuration is optimized for the NASA Lunabotics arena with regolith simulant and distributed rock obstacles.
Future Enhancements
Potential improvements to the perception pipeline:- Crater detection - Identify concave surface features
- Traversability analysis - Classify terrain slope and roughness
- Multi-camera fusion - Combine front and side depth cameras
- Semantic segmentation - Distinguish rock types and excavatable regolith
- Temporal filtering - Track persistent obstacles across frames