Module 2/5 · Weeks 4–6 · 27 h

Cascade control

UAT 305 Autopilot and Control Technology

About 90 minDraft, awaiting reviewLast updated 2 October 2026

Lesson

By the end of this module you will be able to

  1. Explain the structure of ArduPilot's attitude controller from angle to rate
  2. Simulate a cascade loop and see the effect of the outer-loop gain on the response
  3. Compute the time to reach a target angle under an angular acceleration limit
  4. Choose attitude controller parameters to suit the mission
  5. Write a multirotor's equations of motion and compute moment, angular acceleration and horizontal acceleration from motor thrust

Prerequisites: UAT 305 Module 1 · UAT 206 Module 3 (PID controllers)

Why this matters

Every autopilot uses cascade control: nested loops in which the outer loop commands the inner loop. Understanding how the layers interact tells you which value to adjust when a drone oscillates, responds slowly or jerks. The drone knowledge base’s unit on cascade control and flight-controller tuning explains the rate, attitude and position loops and reading logs to tune them. Beard and McLain’s textbook applies the same principle to fixed-wing aircraft.

ArduPilot’s attitude controller

The ArduPilot developer documentation explains that a P controller converts the angle error into a desired rotation rate, and a PID controller then converts the rate error into motor commands. The Copter 4.7.1 defaults are ATC_ANG_RLL_P = 4.5 (range 3–12) and a rate loop of ATC_RAT_RLL_P = 0.135, I = 0.135, D = 0.0036. There is also feedforward of the desired rate and a square-root controller that keeps the approach to the target within the set acceleration. PX4 uses a similar structure: a PID rate loop and a quaternion P law for attitude.

A block diagram: the target angle enters a comparator, passes through the angle P to give a desired rate, enters a second comparator, passes through the rate PID to the motors and airframe; the rate feeds back to the second comparator and is integrated to an angle that feeds back to the first comparator
Figure 1 The angle loop around the rate loop

Example 1 What happens when the outer-loop gain is too high?

A simple roll model: a PI rate loop, motors with a 30 ms time constant and a 10 ms delay. Command a 20° tilt and change only the angle gain (the model’s values are not ArduPilot units, except that the angle gain uses the same range).

import math
import numpy as np

def step(k_angle, k_rp=0.15, k_ri=0.1, T=2.0, dt=0.0025, tau=0.03, J=0.02, delay=0.01):
    n = int(T / dt)
    ang = rate = u_act = integ = 0.0
    buf = [0.0] * int(delay / dt)
    out = []
    for _ in range(n):
        rate_cmd = k_angle * (math.radians(20) - ang)      # outer loop: angle -> rate
        e = rate_cmd - rate
        integ += e * dt
        buf.append(k_rp * e + k_ri * integ)                # inner loop: PI on rate
        u_act += (buf.pop(0) - u_act) * dt / tau           # motor lag
        rate += u_act / J * dt
        ang += rate * dt
        out.append(math.degrees(ang))
    out = np.array(out)
    overshoot = (out.max() - 20) / 20
    outside = np.where(abs(out - 20) > 0.4)[0]
    settle = (outside[-1] + 1) * dt
    rise = np.argmax(out >= 18) * dt
    return overshoot, settle, rise

for k in (3, 4.5, 9, 12):
    os_, ts, tr = step(k)
    print(f"angle P {k:>4}: rise {tr:.2f} s, overshoot {os_:5.1%}, settle (2%) {ts:.2f} s")
angle P    3: rise 0.53 s, overshoot  1.8%, settle (2%) 0.64 s
angle P  4.5: rise 0.37 s, overshoot 12.3%, settle (2%) 1.25 s
angle P    9: rise 0.23 s, overshoot 40.0%, settle (2%) 1.55 s
angle P   12: rise 0.20 s, overshoot 54.4%, settle (2%) 1.96 s

The higher the outer-loop gain, the faster the approach, but the larger the overshoot and the longer the settling, because the outer loop commands rates faster than the inner loop can follow. The inner loop must be clearly faster than the outer loop, so tune the inner loop first and then raise the outer loop. These numbers belong to the model; a real drone must be checked with logs.

Limiting angular acceleration

Commanding an angle change instantly would jerk the motors, so ArduPilot limits angular acceleration with ATC_ACC_R_MAX (in Copter 4.7.1: deg/s², range 0–1800, default 1100; Copter 4.6.3 and earlier called it ATC_ACCEL_R_MAX and used cdeg/s², default 110000) and smooths commands with the time constant ATC_INPUT_TC (default 0.10 s in Copter 4.7.1; it was 0.15 s in 4.6.3). The minimum time to rotate by , accelerating fully for half the way and braking fully for the other half, is .

Example 2 Tilting 20° at different accelerations

import math

presets = {"default 1100": 1100, "Medium 1080": 1080, "Slow 720": 720, "VerySlow 300": 300}   # ATC_ACC_R_MAX, deg/s²
ANGLE = 20                                      # degrees
for name, a in presets.items():
    t = 2 * math.sqrt(ANGLE / a)
    peak = math.sqrt(ANGLE * a)
    print(f"{name:<15} {a:6.0f} deg/s2: {t:.2f} s to {ANGLE} deg, peak rate {peak:5.1f} deg/s")
default 1100      1100 deg/s2: 0.27 s to 20 deg, peak rate 148.3 deg/s
Medium 1080       1080 deg/s2: 0.27 s to 20 deg, peak rate 147.0 deg/s
Slow 720           720 deg/s2: 0.33 s to 20 deg, peak rate 120.0 deg/s
VerySlow 300       300 deg/s2: 0.52 s to 20 deg, peak rate  77.5 deg/s

Slow settings suit camera drones or large drones with slow motors, while fast settings suit small, agile drones. Setting it faster than the motors can deliver saturates them and makes control worse, so match it to the aircraft rather than setting it as fast as possible.

Angle against time from 0 to 2 seconds with four lines for angle gains of 3, 4.5, 9 and 12 and a dashed horizontal target at 20 degrees; higher gains reach the target sooner but overshoot more and oscillate longer
Figure 2 Angle step response by outer-loop gain (model)

Flight dynamics: forces and moments

Every controller layer in this module drives the airframe, which moves according to Newton’s laws. Flight dynamics are the equations that say how forces and moments make the airframe accelerate and rotate. The textbooks by Beard and McLain, Quan, and Corke use the same form for multirotors, treating the airframe as a rigid body that does not bend.

  • Translation, in the north-east-down (NED) world frame: , where is the mass, the total rotor thrust pointing up along the body axis, and the rotation matrix from the airframe’s attitude. Put simply, a multirotor can only redirect its thrust by tilting. To tilt by and hold altitude, thrust must rise to , giving a horizontal acceleration . The ArduPilot 4.7.1 source code uses exactly this relation to turn acceleration into a lean angle (accel_mss_to_angle_rad, called accel_to_angle in 4.6.3) and to turn the maximum lean angle ATC_ANGLE_MAX (default 30°; in 4.6.3 it was ANGLE_MAX in cdeg, default 3000) into a maximum acceleration.
  • Rotation about the centre of gravity, in the body frame: , where is the inertia matrix, the rotation rate and the moment. The term matters when rotating fast about several axes at once; in normal hovering it is small.
  • Where the moments come from. Each rotor’s thrust is roughly proportional to the square of its speed, . Roll and pitch moments come from the difference in thrust between two sides times the moment arm. For an X frame with motors at distance from the centre, the arm about the roll axis is . The yaw moment comes from unequal drag torques of rotors spinning in opposite directions.

The key point for control is that the motors need thrust headroom above what hovering uses. If the aircraft hovers near full thrust, the motors cannot increase thrust on one side, so the rate controller cannot produce the moment it asks for. This is the motor saturation listed in this module’s common mistakes.

Example 3 From motor thrust to angular and horizontal acceleration

An X-frame quadcopter has a mass of 1.6 kg, motors 0.25 m from the centre, a roll inertia of 0.015 kg·m², and each motor gives at most 8 N of thrust (assumed values).

import math

G = 9.81
M, ARM, J_XX = 1.6, 0.25, 0.015                 # kg, m (centre to motor), kg·m² (assumed)
T_MAX = 8.0                                     # N maximum thrust per motor (assumed)
T_HOVER = M * G / 4
dT = min(T_MAX - T_HOVER, T_HOVER)              # raise one side, lower the other, within limits
tau = 4 * dT * ARM / math.sqrt(2)               # X frame: roll moment arm = ARM/√2
alpha = math.degrees(tau / J_XX)
print(f"hover thrust {T_HOVER:.2f} N per motor ({T_HOVER / T_MAX:.0%} of max), headroom {dT:.2f} N")
print(f"max roll torque {tau:.2f} N·m -> angular acceleration {alpha:,.0f} deg/s2")
print(f"ATC_ACC_R_MAX default 1100 deg/s2 uses {1100 / alpha:.0%} of it")
for tilt in (10, 20, 30):                       # ATC_ANGLE_MAX default 30°
    th = math.radians(tilt)
    thrust = M * G / math.cos(th)
    a = G * math.tan(th)
    print(f"tilt {tilt:>2} deg: total thrust {thrust:5.2f} N ({thrust / (4 * T_MAX):.0%} of max), "
          f"horizontal accel {a:.2f} m/s2")
hover thrust 3.92 N per motor (49% of max), headroom 3.92 N
max roll torque 2.77 N·m -> angular acceleration 10,599 deg/s2
ATC_ACC_R_MAX default 1100 deg/s2 uses 10% of it
tilt 10 deg: total thrust 15.94 N (50% of max), horizontal accel 1.73 m/s2
tilt 20 deg: total thrust 16.70 N (52% of max), horizontal accel 3.57 m/s2
tilt 30 deg: total thrust 18.12 N (57% of max), horizontal accel 5.66 m/s2

This drone hovers at about half its maximum thrust, so it has plenty of headroom. Physically it could reach about 10,600 deg/s² of angular acceleration, but the default ATC_ACC_R_MAX uses only about 10% of that; the rest is reserve for the rate loop to fight gusts and correct errors. If a heavy payload made it hover at 80% of maximum thrust, the headroom would drop to less than half and the achievable angular acceleration with it. The lower half shows that a 30° tilt gives 5.66 m/s² of horizontal acceleration using only 57% of total thrust; this is the acceleration ceiling available to the position loop in Module 5.

Module lab

Lab: nested loops in SITL

  1. Start SITL and log step tilt commands in Stabilize or AltHold
  2. Look at the RATE and ATT messages, comparing desired and actual values in both loops
  3. Try three values of ATC_ANG_RLL_P within the allowed range and compare with Example 1
  4. Try the documented presets of ATC_ACC_R_MAX and compare rotation times with Example 2
  5. Weigh the training drone and measure its arm length, read maximum thrust from the motor and propeller data, and compute thrust headroom and angular acceleration with Example 3
  6. Restore all defaults and record which values suit the training drone

Common mistakes

Watch out

  • Tuning the outer loop before the inner loop
  • Raising gains to fix slowness when the real limit is the acceleration setting
  • Setting acceleration beyond the motors’ capability
  • Using parameter units from the wrong version, such as cdeg/s² versus deg/s²
  • Drawing conclusions from a model without confirming with real logs
  • Adding payload until the drone hovers near full thrust, leaving little thrust to produce moments

Summary

  • ArduPilot converts angle error to a rate with P and controls the rate with PID plus feedforward
  • An outer loop that is too strong for the inner loop overshoots and oscillates; tune the inner loop first
  • Limiting angular acceleration smooths commands; the minimum rotation time is
  • Parameter names and units change between firmware versions
  • Flight dynamics: and ; a multirotor redirects thrust by tilting () and makes moments from thrust differences, so it needs thrust headroom

Check your understanding

  1. With an angle gain of 4.5 and a 10° angle error, what rate is commanded?
  2. A 2 kg drone tilts 20° and holds altitude. What total thrust does it need, and what horizontal acceleration does it get ( = 9.81 m/s²)?
  3. What is the minimum time to rotate 45° at 900 deg/s²?
  4. Why tune the inner loop before the outer loop?
  5. What happens if the acceleration is set beyond the motors’ capability?
Answers
  1. deg/s
  2. N and m/s²
  3. s
  4. The outer loop commands the inner loop; if the inner loop cannot follow, adjusting the outer loop fixes the wrong thing
  5. The motors saturate, control worsens and the aircraft may oscillate

Key formulas

Outer (angle) loop commands a rate
Minimum rotation time under an acceleration limit
Rigid-body equations of motion
Tilting while holding altitude

Key references

  1. ArduPilot Dev Team. Copter attitude control. ArduPilot developer documentation. link
  2. ArduPilot Dev Team. (2026). ArduPilot source code, tag Copter-4.7.1 [Computer software]. GitHub. link
  3. ArduPilot Dev Team. Parameter list (Copter stable V4.7.1). ArduPilot Copter documentation. link
  4. PX4 Autopilot. Controller diagrams. PX4 user guide (main). link
  5. Beard, R. W., & McLain, T. W. (2012). Small unmanned aircraft: Theory and practice. Princeton University Press. link
  6. Quan, Q. (2017). Introduction to multicopter design and control. Springer Singapore. link
  7. Corke, P. (2023). Robotics, vision and control: Fundamental algorithms in Python. Springer. link

Further reading

Study the assigned knowledge units in advance, review media and take the module quiz

In class / field

Lecture, case discussion and in-class problem solving

Learning evidence: Quiz results and submitted exercises

Module quiz

This is a formative self-check, not a graded exam

Knowledge domain: Control, autopilot and navigation