PID Controllers

This document gives a very brief overview of the desired functionality of the PID controllers inside ZeroPilot 3.5’s Attitude Manager.

 

Understanding PID’s

Hopefully, PID’s make sense to you, but if they don’t, check out the following guides:

 

Within Attitude Manager, we run PID’s on each axis exclusively. Since the axis are (mostly) decoupled from each other, we can do this to great success in both quadcopters and fixed-wing aircraft. The output from each PID essentially decides how much to “drive” actuators in that axis to move our current angle / rate to the desired angle / rate. For quadcopters, multiple-axis PID’s are combined on different motors. In a fixed-wing, most actuators only correspond with one PID - and that axis' PID will deal with secondary effects such as adverse yaw.

The PID Class

Typically, PID exists as a class which is then implemented per-axis. This means that each axis has a singular output, so it’s necessary to determine Positive and Negative orientations, as certain actuators may need to reverse the PID output depending on their orientation. See the ZP3.0 architecture for our drone reference frame ZeroPilot 3.0 Architecture - Embedded Flight Software - WARG (atlassian.net)

Although the inputs may be angles or rates, the output of a PID should be a motor % that can be understood by each actuator.

Implementation

The goal is to have a PID controller class that can be used by multiple managers (although will be used by attitude manager at first), each object of the class will calculate their own integral & derivative terms being independently, also the PID’s will update at the same fixed frequency, so that derivative and integral calculations work properly. By having one PID instance per axis rather than one per motor the output will be cleaner and more consistent. When the PID does its computations to output, it will calculate it’s own derivative and integral values. The PID will be implemented in the PID.hpp and PID.cpp files in the Attitude Manager Folder, updating/replacing the previous PID controller.

Laslty, the PID will also need to utilize the input-map to be able to convert angles/rates into motor % when outputting. Meaning the PID input and target point will be angles/rates, however it will convert the angle/rate to a motor % before outputting so that the motor can adjust to reach the desired set point.

Fixed Time Frequency Updating:

The goal, is have the PID controller for an axis update at a fixed frequency, all axis do not necessarily have to update at the same frequency. This will be implemented using freeRTOS, where the PID update method will use a task and vTaskDelayUntil from freeRTOS, to ensure that the controller for an axis is updating at a fixed frequency. When an object of the class is instantiated one of the parameters will be the frequency at which the PID should update.