Using your Time-of-flight Sensor#

In this part of the project, you will learn how to estimate the drone’s height using its time-of-flight sensor. The drone is equipped with a VL53L0X distance sensor, which is used for estimating the distance from the drone to the ground. The sensor outputs a digital signal containing the distance from the sensor which is read in by the Raspberry Pi via I2C communication using the associated Python library.

Setup

Change to ~/catkin_ws/src on your drone, and then run

git clone https://github.com/h2r/project-sensors-implementation-yourGithubName

You should create a GitHub personal access token for your drone to make this possible. It only needs permissions to read and write to repositories.

Change directories into ~/catkin_ws/src/project-sensors-implementation-yourGithubName. You can run

rosrun project-sensors-yourGithubName student_tof_pub.py  

You may stop student_tof_pub.py with ctrl-c, edit it within that tab, and then re-run

rosrun project-sensors-yourGithubName student_tof_pub.py

to test your changes.

Problem 1: Publish your TOF Reading#

In student_tof_pub.py, fill in the minimum range, maximum range, and current range read from the sensor into the ROS message. When you run this node, you will be publishing a ROS Range message which is a standard message included with ROS.

Checkoff:#

Using rostopic echo /pidrone/range or the height graph on the web interface, verify that:

  • The TOF node is publishing a message with all the fields you want

  • The range field of the message is a roughly accurate measure of the drone’s altitude

You can now fly your drone with your own range node!