Member-only story

How to Write your own Flight Controller Software — Part 7

The Attitude and Heading Reference System (AHRS)

--

This article covers the Attitude and Heading Reference System (AHRS), IMU Filters and Sensor Fusion. We have released the open source ReefwingAHRS Arduino library to demonstrate these techniques on the Nano 33 BLE. It is available for download using the Arduino Library Manager.

In Part 5 of this series, we explained how to calculate raw roll, pitch and yaw angles from IMU data. In parts 3 and 4 we spoke about the PID control loop (Figure 2) that we will use to control the drone motors. In this article we will explore options for cleaning up our angle data by removing vibration noise and gyroscopic drift. It is these processed angles which will be fed into the PID controller. This part of the flight controller system is often referred to as the Attitude and Heading Reference System (AHRS — Figure 1).

Figure 1. Attitude and Heading Reference System (AHRS)

PID Control System

The data coming directly from the gyroscope is an angular rate, in degrees per second (DPS). For a PID loop, the best parameter to calculate the error for, is the parameter that you want to control. As all the drone thrust forces are in the +z direction (i.e., up), the quadcopter cannot transverse the x, y plane without some rotation. For example to go forward you need to pitch the drone down. The output of our PID controller is ultimately another angular rate.

For these reasons, we will implement the approach shown in Figure 2 which features cascading PID loops. The other advantage of this approach is that it gives us two flight modes (rate and stabilise), which can be selected by the pilot. The PID Control System will be covered in depth starting with Part 8 of this series.

Figure 2. Cascading PID (angle and rate).

As inputs to our cascading PID controller, we need:

--

--

David Such
David Such

Written by David Such

Reefwing Software · Embedded Systems Engineer · iOS & AI Development · Robotics · Drones · Arduino · Raspberry Pi · Flight Control

No responses yet

Write a response