This Learning Experience introduces you to the Time-of-Flight (ToF) range sensors on the Duckiedrone DD24. You will learn what a ToF sensor measures, how the five VL53L1X sensors on the DD24 are wired, how the readings flow from hardware through DTPS to a standard ROS 2 sensor_msgs/Range topic, and how to write a ROS 2 node that consumes them in real time and turns them into a simple obstacle-proximity indicator.
- The physics of time-of-flight sensing, and the VL53L1X datasheet in particular
- How ToF data flows on the DD24:
VL53L1X (I²C) → DTPS driver → ROS 2 bridge → /<robot>/range - How to subscribe to
sensor_msgs/Rangetopics from a ROS 2 Jazzy node - The tradeoffs between
SHORT_RANGE/LONG_RANGEmodes and how timing budget limits the update rate - How to combine readings from multiple sensors into a single proximity indicator
Work through the notebooks in order:
| # | Notebook | Description |
|---|---|---|
| 1 | 1-tof-basics.ipynb |
How time-of-flight sensing works; the VL53L1X datasheet in one page |
| 2 | 2-dd24-tof-architecture.ipynb |
DD24 data flow from hardware to /<robot>/range |
| 3 | 3-subscribing-to-tof.ipynb |
Write a ROS 2 node that reads sensor_msgs/Range messages |
| 4 | 4-tof-modes-and-efficiency.ipynb |
SHORT_RANGE vs LONG_RANGE; multi-sensor timing budget |
| 5 | 5-obstacle-proximity.ipynb |
Fuse five ToFs into a single closest-obstacle indicator |
In packages/solution/solution/tof_subscriber.py you implement a ToFSubscriber class that:
- Subscribes to one or more
sensor_msgs/Rangetopics (per configured sensor name) - Keeps the latest reading from each sensor in
latest_readings - Flags invalid readings (out-of-range sentinel, NaN, below
min_range, abovemax_range) - Logs a one-line summary at 1 Hz and raises a proximity alert when the closest valid reading drops below a configurable threshold
The pure-Python helpers (ToFReading, closest_valid, proximity_alert, ToFMode, combined_max_rate_hz) live in packages/solution/solution/tof_math.py so they can be imported from the notebooks and unit tests without needing rclpy.
Your written answers to the theory questions go in packages/solution/solution/answers_tof.md.
cd dd24-sensors-tof-lx-solution
pytest tests/# Build on the robot
dts code build -R DRONE_NAME
# Launch the ToF listener (robot_namespace defaults to the VEHICLE_NAME env var)
ros2 launch tof_listener tof_listener_node.launch.py \
robot_namespace:=DRONE_NAME \
sensor_names:="['bottom']" \
sensor_topics:="['/range']"On the virtual drone, note that the Duckiematrix renderer must be running to get physically-meaningful ToF values.