Interfacing with the IMU#

Your drone is equipped with a Skyline32 Flight Controller which has a built in IMU. In this part of the project, you will learn how to interface with the flight controller board to extract the attitude, accelerations, angular rates of the drone from the built-in IMU. In addition, you will extract the battery levels from the flight controller so that you’ll be able to tell when you’re battery is too low.

Setup Change directories into ~/ws/src/pidrone_pkg and modify pi.screenrc to start up with your flight controller node by changing python\n to rosrun project-sensors-yourGithubName\n (or, alternatively, python \path\to\\n).

Problem 1: Extracting the Battery Data#

The flight controller is capable of reading the voltage and current of the power source plugged into the drone. This is possible because of the red and brown wire pair (i.e. battery monitor wire pair) plugged into the FC. The power information is useful because it allows us to programmatically shut down the drone if the voltage is too low (e.g. LiPo batteries are quickly ruined if discharged too low).


  1. Take a look at Battery.msg in the ~/ws/src/pidrone_pkg/msg directory on your drone. This is a custom message we’ve created to communicate the battery values.

  2. In, do the following:

    • Fill in each TODO regarding the battery_message in the __init__ method.

    • Fill in each TODO in the update_battery_message method.

Problem 2: Extracting IMU data#

Linear accelerations and attitude (i.e. roll, pitch, yaw) can also be extracted from the FC, thanks to the accelerometer and gyroscope. In addition, the angular rates (e.g. change in roll over change in time) can be calculated by using the attitude measurements.


  1. Take a look at the Imu ROS message type to get an understanding of the data you’ll be collecting.

  2. In, do the following:

    • Fill in each TODO regarding the imu_message in the __init__ method.

    • Fill in each TODO in the update_imu_message method.