How to Write your own Flight Controller Software — Part 7

The Attitude and Heading Reference System (AHRS)

David Such
25 min readMar 21, 2022

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…

--

--

David Such

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