Steady Hands
A drone must climb to 1 metre and stay there. Turn three knobs, P, I and D, and watch how it flies.
I push the drone up when it is too low. Try the P knob first: bigger means a stronger push. What happens when it gets too big?
Height over time
drone heighttarget (1 m) and the 2% bandwind gust
Overshoot
0%
Settles in
-
Final error
0
Challenges
Quick and neat: overshoot under 10% and settled in 1.5 seconds or less.
Gentle: zero overshoot (under 1%) and settled within 3 seconds.
Make it wobble: crank it until it overshoots by 40% or more.
Wind fighter: switch the gust on and end with an error under 0.02 m. You will need I!
What just happened?
- The controller looks at the error, the gap between where the drone is and where you want it.
- P pushes harder when the gap is big. Too much P and the drone overshoots and wobbles.
- D brakes when the drone moves fast, so it glides in gently.
- I keeps adding up leftover error, so a steady wind cannot hold the drone below its target.
- Tuning is a trade: faster usually means more overshoot, and you balance P, I and D.
For grown-ups: what's really going on
This is a PID controller on a second-order plant: m·ẍ = u − c·ẋ + d(t) with mass m = 1, drag c = 0.4, thrust limited to ±30 and a wind force d = −6 after 6 s. The control law is u = Kp·e + Ki·∫e dt − Kd·ẏ with e = setpoint − y, simulated for 12 s with a 10 ms Euler step.
- Overshoot = how far the peak goes above the target, in percent. Settling time = the last time the output leaves a ±2% band. Both are measured on the step before the gust.
- Without I, a constant disturbance leaves a steady-state error of about
d / Kp. The integral term drives it to zero. - Too much I causes integrator windup when thrust saturates, so we clamp the integral (anti-windup).
- The D term here acts on the measured velocity (not the error), which avoids a kick when the target jumps.
- For this plant the P+D part behaves like a spring-damper:
ωn = √Kpand dampingζ = (c + Kd) / (2√Kp). ζ near 1 means little overshoot.
Further reading: Åström and Murray, Feedback Systems, ch. 10 · Ziegler-Nichols tuning rules.