The outcome
Implement conservative decisions and explain the limits of geometry-only sensing.
Documented target: Ubuntu 24.04 · ROS 2 Jazzy · Gazebo Harmonic where used. Browser labs tested; ROS/Ubuntu/hardware execution not performed here.
Before you begin
- Python 3
- LiDAR and drive labs
- No physical motor connection
Prepare with Read sensors without guessing, Turn wheel speeds into robot motion.
Build, observe, explain.
Define observations
Invalid or absent measurements produce a stop. Save and run this complete function exercise.
import math
def forward_speed(ranges, threshold_m=0.35):
if not ranges or any(not math.isfinite(x) or x <= 0 for x in ranges):
return 0.0
return 0.0 if min(ranges) < threshold_m else 0.10
assert forward_speed([0.2, 0.8]) == 0.0
assert forward_speed([0.8, 0.9]) == 0.10
assert forward_speed([]) == 0.0Expected: All assertions pass.
Study angles
Compare forward rays with all rays in the LiDAR lab.
Expected: A side obstacle is distinct from a forward obstacle.
Plan integration
Document scan QoS, sector, command timeout and velocity interface before simulation integration.
Expected: A clear contract; this function is not a deployed safety controller.
Troubleshooting
- Controller used on hardware
- Keep this exercise simulation-only; braking/safety validation are absent.
- Infinity means free space
- Use a defined invalid-data policy.
Take it further
- Add noise and braking distance.
- Implement a watchdog in a documented simulator.
Documentation and next steps
Explore another project · Return to learning · Report a project issue