Autopilot Heading Hold⚠ unverified
Aerospace / Controls · Compute a simple heading-hold autopilot command
Parameters
| Input | Symbol | Unit | Default | Description |
|---|---|---|---|---|
| kp | kp | — | 1.0 | Proportional ga |
| heading_error | headingerror | rad | 1.0 | Heading error |
| ki | ki | — | 1.0 | Integral ga |
| integral_error | integralerror | rad*s | 1.0 | Accumulated integral of the heading error |
| Output | Symbol | Unit | Description |
|---|---|---|---|
| result | cmd | rad | Commanded roll (or heading-correction) output, in radians (rad) |
The science & history
Understanding the Parameters
-
Heading hold commands bank, not rudder — a coordinated aircraft turns by banking: the horizontal component of lift pulls it around (Turn Radius). So a heading autopilot does not push rudder; it commands a roll angle proportional to how far off heading it is, and a lower-level roll loop holds that bank. Turn toward the target, roll level as the error vanishes.
-
Proportional term — turn toward the target — $k_p\,e_\psi$ banks the aircraft in proportion to the heading error: a large error commands a steep bank (a brisk turn), a small error a gentle one, rolling out smoothly as the aircraft approaches the selected heading. Proportional alone, though, can leave a small standing error.
-
Integral term — eliminate the standing error — $k_i\int e_\psi\,dt$ accumulates any persistent heading error and keeps adding bank until it is driven to exactly zero. This is what lets the autopilot hold the precise selected heading despite a steady crosswind, an out-of-trim condition, or asymmetric drag — the same offset-removing role the integral plays in any PID controller.
-
Why no derivative here — heading-hold is often implemented as PI because the aircraft's own roll and yaw damping (and the inner roll loop) already supply the damping a derivative term would add, and heading-rate signals can be noisy. The simplest useful heading autopilot is therefore proportional + integral.
-
Bank-angle limiting — real implementations cap the commanded bank (e.g. 25–30°) so a large heading change produces a standard-rate turn rather than an aggressive one; the raw PI command is limited before it reaches the roll loop. This calculator returns the unlimited command.
Derivation (Approaching a Proof)
Heading hold is a feedback loop whose job is to drive the heading error to zero. Define the error as selected minus actual heading:
$$e_\psi(t) = \psi_{\text{cmd}} - \psi(t).$$
Apply a PI control law — proportional plus integral action on this error (the PID law with $k_d = 0$):
$$\text{cmd}(t) = k_p\,e_\psi(t) + k_i\int_0^t e_\psi(\tau)\,d\tau. \qquad\blacksquare$$
Why PI suffices, term by term. The proportional term gives a bank command that produces a turn rate roughly proportional to the error, so the aircraft turns toward the target and the error shrinks. But proportional control of a system that must hold a value leaves a steady-state error whenever a constant disturbance (a crosswind pushing the track, a trim asymmetry) is present. The integrator's infinite DC gain forces that steady-state error to zero: it keeps accumulating until $e_\psi = 0$ exactly. Derivative action is usually unnecessary because the underlying airframe/roll-loop dynamics already provide damping, so the heading loop is kept as PI.
The command feeds an inner roll loop (hold the commanded bank) which in turn commands ailerons — a cascade of loops, of which this is the outer, heading-level one.
Dimensional check. $k_p\,e_\psi$: gain times radians. $k_i\int e_\psi\,dt$: gain times radian-seconds. For both to be a consistent bank command (radians), $k_p$ is dimensionless and $k_i$ carries $1/\text{s}$ — the gains absorb the units, and the registry labels them dimensionless ✓.
History and Development
-
From wing-leveler to heading hold. Early autopilots (Sperry's gyroscopic "gyropilot," 1912–1930s) began as wing-levelers and attitude holds; adding a heading reference and a PI law around it produced heading hold, a staple mode of every autopilot since.
-
The cascade architecture. Heading hold exemplifies the nested-loop (cascade) structure of flight control: an outer navigation/heading loop commands bank; an inner attitude loop holds bank; an innermost rate loop damps. Each loop is a simple law (often PI or PID); their nesting builds sophisticated autoflight from simple pieces.
-
Into the FMS. Modern autopilots fold heading hold into broader lateral modes — HDG SEL, LNAV (track a flight-plan path) — but the innermost logic that turns a heading error into a bank command remains this PI law, now bank-limited and gain-scheduled, feeding the roll channel.
Related Concepts: Pid Controller, Pid Output, Turn Radius, Roll Mode Time Constant, Damping Ratio, Settling Time 2%, Cross Track Error
Notes: A PI controller (Pid Controller without the D term) on heading error, commanding bank (an outer loop feeding an inner roll loop) — a coordinated aircraft turns by banking, not rudder. P turns toward the target; I removes the standing heading error (crosswind/trim bias). No D (airframe/roll-loop supply damping; heading-rate is noisy). Real ones bank-limit the command. Heading error in rad, integral in rad·s; gains carry the units; defaults ⇒ cmd $=2$.