03 Control Systems · #18 of 46

Capstone: Quadrotor Altitude

Four spinning blades, one number to hold, and gravity pulling the whole time

A quadcopter hovering in place looks effortless, a calm machine resting on nothing. It is the exact opposite. It is falling continuously, and a controller is catching it dozens of times a second by trimming four rotors against gravity. Stop the math for a heartbeat and it drops out of the sky.

This is the capstone for the control chapter, because a quadrotor is everything you've learned wired into one twitchy little aircraft. Holding altitude is the simplest job it has, and even that is pure PID: measure how high you are, compare it to where you want to be, and turn the gap into thrust. The catch is that gravity never stops pulling, so the loop never gets to rest.

NASA's Ingenuity helicopter standing on the reddish surface of Mars.
NASA's Ingenuity made the first powered, controlled flight on another world, a coaxial-rotor drone holding altitude in Martian air just 1 percent as thick as Earth's. · NASA/JPL-Caltech/ASU/Simeon Schmauss, CC BY 2.0

Fly it yourself

Below is a side-view quadrotor that bobs in real time as its controller fights to hold 1.0 m. The dashed line is the setpoint. Tune the three gains, hang a heavier payload on it, and slam it with a wind gust to see what survives.

Hover at 1.0 m, gust-resistant

altitude (live) 0.00 m
overshoot
gust dip
SSE
what to try
  • Drop Kd to zero. The drone oscillates around the setpoint with no damping: overshoot becomes the next undershoot, forever. This is the double-integrator failure mode P alone can't fix. Bring Kd back to ~3.
  • Crank Kp to 18 with Kd = 0. Same problem, but faster: the drone violently oscillates. P-gain determines speed; D-gain determines whether you survive the ride.
  • Trigger the wind gust mid-flight. A downward push lasting 0.3s. Without Ki, a steady wind would leave a permanent offset; the integrator kills it. Try Ki = 0 vs Ki = 3 with the gust active.
  • Hang a 2 kg payload (mass slider all the way right). The controller was tuned for 1 kg; suddenly the plant is twice as sluggish. Same lesson as Lesson 01: gains tuned for a nominal plant degrade as the real plant deviates.

Watch the drone, not just the trace. With sensible gains it rises, maybe overshoots once, and parks on the dashed line. Now sabotage it: drag Kd to zero and it bounces around the setpoint forever: every overshoot becomes the next undershoot, with nothing to damp the swing. That is the failure mode at the heart of this lesson, and proportional gain alone cannot fix it. You need the derivative term to act as a brake.

Three terms, three jobs, just like the first lesson in this chapter:

A quadcopter drone in flight against the sky.
A quadrotor holds altitude by trimming four rotor thrusts dozens of times a second, a control loop fighting gravity in real time. · BLM Oregon & Washington, Public domain

Why gravity makes the integrator earn its keep

In the PID lesson the integral term was the cleanup crew that mopped up small leftover errors. Here it is doing real, constant labor. Hover is not a state of "no force needed"; it is a state of "exactly enough upward thrust to cancel weight, applied nonstop." P and D both go quiet once the drone is sitting still on the setpoint, because the error and its rate are both zero. Something has to keep commanding that hover thrust, and that something is the integrator: it has accumulated exactly the constant push that balances m g.

Turn the payload slider up and you can feel this directly. The controller was tuned for a 1 kg craft; bolt on a heavy GoPro and the same gains suddenly drive a sluggish, heavier aircraft. It sags, then slowly climbs back as the integrator winds up to find the new, larger hover thrust. The control law didn't change; the world did.

The math: a double integrator and where the gust enters

Strip away the four rotors and altitude obeys Newton's second law: total thrust TT fights weight mgmg:

mh¨=Tmgm\,\ddot h = T - m g

This is a double integrator: thrust sets acceleration, you integrate once to get velocity, again to get altitude. Two integrators in series means two poles sitting at the origin: the marginal case. That is precisely why proportional gain alone cannot stabilize it: with no damping, P just trades position error for velocity and the drone oscillates forever. The derivative term supplies the missing damping.

Let the controller command the rotor thrust directly, u=Tu = T, with no gravity feedforward, so the loop itself has to discover how much thrust hover needs. Close it on the altitude error e=rhe = r - h with the three-term law:

u(t)=Kpe(t)+Ki0te(τ)dτ+Kde˙(t)u(t) = K_p\,e(t) + K_i \int_0^t e(\tau)\,d\tau + K_d\,\dot e(t)

so substituting T=uT = u into mh¨=Tmg+dm\ddot h = T - mg + d gives the plant the controller actually drives:

h¨=1mug+1md(t)\ddot h = \frac{1}{m}\,u - g + \frac{1}{m}\,d(t)

where d(t)d(t) is the wind-gust disturbance (a sharp downward shove for a fraction of a second) and g-g is the relentless constant pull underneath everything. The demo integrates this by forward-Euler at dt=0.01sdt = 0.01\,\text{s}. Two things fall out of the algebra. First, the payload slider scales the thrust and disturbance terms by 1/m1/m: double the mass and the same gains push half as hard, which is why a heavy craft turns sluggish. Second, and this is the whole reason a quadrotor is the chapter's capstone, at hover e0e \to 0, so KpeK_p e and Kde˙K_d \dot e both vanish, yet the plant still needs a steady u=mgu = mg just to hang in the air. Only the KieK_i \int e term can produce a nonzero output at zero error, so it is mathematically the only term that can hold that constant hover thrust. Switch it off and the drone settles wherever the leftover proportional error balances the weight, permanently below the line.

Key takeaways

A quadrotor is the whole chapter in miniature. Proportional for speed, derivative for the brake, integral for the patient bookkeeping that cancels gravity: three numbers cooperating dozens of times a second to keep a machine suspended on nothing.

It steered a battleship in 1922 and it holds your drone in the air today. The plant keeps changing; the loop does not.

full glossary →