Flight Dynamics: Forces, Attitude, and PID Control
Nothing about a quadcopter's motion is mysterious — it is four forces, a lever arm, and a control loop. Thrust pushes up, gravity pulls down, drag resists motion, and the remaining imbalance accelerates the aircraft. Every maneuver you have ever watched a drone perform reduces to tilting the thrust vector or unbalancing torque between propellers. This lesson derives those relationships, maps them onto the four control axes, and shows how a PID loop keeps the whole system stable when gusts and payload shifts try to knock it off course.
After working through this material you will be able to compute thrust and drag from first principles, explain exactly which motors speed up for each stick input, read and extend a PID controller, and recognize the difference between a stable, oscillating, and divergent tune.
The four forces on a hovering aircraft
Every object in flight is subject to four fundamental forces, and a drone is no exception. Thrust is produced by the propellers pushing air downward; by Newton's third law the air pushes the aircraft up. Gravity is simply mass times the acceleration due to gravity, pointing straight down toward the center of the Earth. Drag opposes the direction of motion through the air and grows with the square of velocity. Lift, on a fixed wing, comes from airfoil pressure differences — on a quadcopter it comes almost entirely from tilting the thrust vector so that part of it acts horizontally while the aircraft accelerates sideways.
In hover the situation is trivially balanced: total thrust equals weight, drag is near zero, and the aircraft sits still. The moment you command motion, the flight controller rolls or pitches the frame a few degrees, thrust acquires a horizontal component, and the drone accelerates. Drag eventually equals that horizontal force, and the aircraft reaches a steady cruise velocity. Understanding this loop — tilt, accelerate, drag balances — explains why drones feel so direct on the sticks and why they keep drifting if you release the stick at speed instead of counter-tilting.
| Force | Direction | Governing equation | Depends on |
|---|---|---|---|
| Thrust | Along propeller axis, up in hover | Thrust equals Cp × ρ × n² × D⁴ | Prop diameter, rpm, air density |
| Gravity | Straight down | Weight equals mass × 9.81 | Battery charge, payload |
| Drag | Opposite velocity | Drag equals ½ ρ v² Cd A | Speed squared, frontal area |
| Lift (from tilt) | Perpendicular to thrust axis | Component of thrust after tilt angle | Tilt angle, total thrust |
Air density ρ is 1.225 kg/m³ at sea level and drops roughly 12 percent by 1000 m of altitude — a real effect for mountain flights, where the same throttle setting produces measurably less thrust.
Computing thrust, weight, and drag
The core equations are simple enough to run on a companion computer during mission planning. The class below packages them with realistic defaults so you can size a build or sanity-check a datasheet claim in a few lines.
import math
class FlightPhysics:
"""Fundamental aerodynamics calculations for a quadcopter."""
AIR_DENSITY = 1.225 # kg/m^3 at sea level
GRAVITY = 9.81 # m/s^2
@classmethod
def thrust(cls, prop_diameter_m, rpm, cp=0.05, rho=None):
"""Thrust = Cp * rho * n^2 * D^4, with n in revolutions per second."""
rho = rho or cls.AIR_DENSITY
n = rpm / 60.0
return cp * rho * (n ** 2) * (prop_diameter_m ** 4)
@classmethod
def weight(cls, mass_kg):
return mass_kg * cls.GRAVITY
@classmethod
def drag(cls, velocity_ms, cd, frontal_area, rho=None):
rho = rho or cls.AIR_DENSITY
return 0.5 * rho * velocity_ms ** 2 * cd * frontal_area
@classmethod
def twr(cls, total_thrust_n, mass_kg):
"""Thrust-to-weight ratio; anything below 1 cannot leave the ground."""
return total_thrust_n / cls.weight(mass_kg)
diameter = 0.127 # 5-inch propeller
rpm = 20000 # typical loaded mid-throttle speed
per_motor = FlightPhysics.thrust(diameter, rpm)
total = per_motor * 4
mass = 0.5 # 500 g all-up weight
print(f"Thrust per motor: {per_motor / FlightPhysics.GRAVITY * 1000:.0f} g")
print(f"Total thrust: {total:.2f} N")
print(f"Weight: {FlightPhysics.weight(mass):.2f} N")
print(f"Thrust-to-weight: {FlightPhysics.twr(total, mass):.1f}:1")
A healthy general-purpose build lands between 4:1 and 6:1. Below 2:1 the aircraft hovers at nearly full throttle with no authority left for corrections, which is exactly how first builds end up wobbling into a wall.
Roll, pitch, yaw, and throttle through motor mixing
A quadcopter has no steering wheel and no rudder. It moves by redistributing thrust among its four motors, which requires the motors to spin in opposing pairs: diagonal motors rotate clockwise and the other diagonal rotates counterclockwise so their reaction torques cancel in hover. Varying speed within a pair creates torque imbalance and yaw; varying speed across pairs tilts the aircraft.
| Command | What changes | Effect on frame |
|---|---|---|
| Throttle up | All four motors equally | Vertical acceleration |
| Roll right | Left motors faster, right motors slower | Tilt right, accelerate right |
| Pitch forward | Rear motors faster, front motors slower | Tilt forward, accelerate forward |
| Yaw clockwise | Counter-clockwise pair faster | Rotate about vertical axis |
The mixer encodes these relationships as arithmetic. For an X-frame configuration the flight controller computes four output values — throttle plus or minus the roll, pitch, and yaw demands — and clamps each to the valid pulse range. Getting this sign convention right is the single most common source of "it flips over on arm" bugs, so verify it on the bench with props removed before ever arming with propellers mounted.
PID control: the invisible pilot
Attitude stability comes from a PID controller running once per IMU sample — typically 8 kHz in modern firmware. The proportional term reacts to the current error, the integral term eliminates slow drift by accumulating past error, and the derivative term anticipates by damping the rate at which error changes. Together they behave like a thermostat for position: aggressive when far from the setpoint, gentle as it closes in.
class PIDController:
"""Discrete PID controller with output clamping and anti-windup."""
def __init__(self, kp, ki, kd, limits=(-1000, 1000)):
self.kp, self.ki, self.kd = kp, ki, kd
self.limits = limits
self.integral = 0.0
self.prev_error = 0.0
def compute(self, setpoint, measurement, dt):
error = setpoint - measurement
p_term = self.kp * error
# Anti-windup: stop integrating once output is saturated.
self.integral += error * dt
self.integral = max(-100, min(100, self.integral))
i_term = self.ki * self.integral
derivative = (error - self.prev_error) / dt if dt > 0 else 0.0
d_term = self.kd * derivative
self.prev_error = error
output = p_term + i_term + d_term
return max(self.limits[0], min(self.limits[1], output))
alt_pid = PIDController(kp=2.0, ki=0.5, kd=0.3)
target, altitude, dt = 10.0, 0.0, 0.01
for step in range(60):
cmd = alt_pid.compute(target, altitude, dt)
accel = (cmd / 1000.0) * 9.81 - 9.81 # throttle fraction maps to climb
altitude += 0.5 * accel * dt * dt + 0.0
if step % 12 == 0:
print(f"t={step * dt:4.1f}s alt={altitude:5.2f} m err={target - altitude:5.2f} m")
Tuning follows a fixed order for a reason. Raise Kp alone until the frame oscillates continuously, back it off by half, then add Kd to damp the remaining bounce, and finally add a small Ki to erase steady-state hover drift. Reversing that order — Ki first — produces integral windup and lazy, overshooting responses that are painful to fly out.
Stability, resonance, and gimbal lock
Three regimes describe every tune. Stable means the frame returns to level after a disturbance in one or two small swings. Oscillating means the controller over-corrects and the aircraft buzzes at a fixed frequency — usually Kp too high or mechanical vibration leaking into the gyro. Divergent means oscillations grow without bound — usually Kd far too low or a failed motor — and it ends in a crash within a second.
Frame resonance is the hidden villain. Propellers pass energy into the frame at the blade-pass frequency, and if that lands near the structural resonance of the arms the gyro sees clean-but-wrong data. Soft-mounting the flight controller, balancing propellers, and raising the D-term low-pass filter cutoff are the standard remedies.
Gimbal lock deserves a separate note because it appears in navigation code rather than tuning. Representing attitude as Euler angles (roll, pitch, yaw) breaks down when pitch reaches ±90 degrees: roll and yaw become indistinguishable and the math divides by a cosine approaching zero. Firmware therefore stores attitude internally as a quaternion — four numbers with no singular configurations — and converts to Euler angles only for display. If your vision or planning code ever needs full attitude math, use quaternions from the start.
Hands-on: a 2D flight simulator
The fastest way to build intuition is to watch the equations run. This minimal simulator integrates thrust, gravity, and drag with explicit Euler steps and lets you test a crude altitude controller.
import math
class DroneSimulator2D:
def __init__(self):
self.x, self.y = 0.0, 5.0
self.vx, self.vy = 0.0, 0.0
self.mass, self.g = 1.0, 9.81
self.max_thrust, self.dt = 20.0, 0.01
def step(self, throttle, pitch):
thrust = throttle * self.max_thrust
ax = thrust * math.sin(pitch) / self.mass
ay = thrust * math.cos(pitch) / self.mass - self.g
self.vx += ax * self.dt
self.vy += ay * self.dt
self.x += self.vx * self.dt
self.y += self.vy * self.dt
if self.y <= 0:
self.y, self.vy = 0.0, 0.0
return self.x, self.y
def hover(self, setpoint=5.0, seconds=3.0):
pid = PIDController(kp=0.15, ki=0.02, kd=0.25, limits=(0.0, 1.0))
for i in range(int(seconds / self.dt)):
cmd = pid.compute(setpoint, self.y, self.dt)
throttle = 0.5 + cmd * 0.5
self.step(throttle, 0.0)
if i % 250 == 0:
print(f"alt={self.y:5.2f} m vy={self.vy:+.2f} m/s")
sim = DroneSimulator2D()
sim.hover()
Extend it by coupling the pitch angle to a horizontal position controller: two nested PID loops — outer loop commands pitch from position error, inner loop commands torque from attitude error — is exactly the cascade structure real flight firmware uses for position hold.
Common Mistakes
Assuming throttle maps linearly to altitude
Fix: Thrust scales with rpm squared, and battery voltage sags under load; altitude hold needs a closed loop, not a lookup table.
Tuning with Kd before Kp is settled
Fix: Derivative gain on a noisy gyro amplifies vibration; fix mechanical balance first, then tune P and D together.
Using Euler angles for full-attitude math near vertical
Fix: Switch to quaternions for representation; Euler angles are for display only.
Ignoring air density at altitude
Fix: Thrust falls about 12 percent by 1000 m; derate maximum hover throttle in mountain missions.
Best Practices
- Tune one axis at a time, starting with roll, then copy gains to pitch before touching yaw.
- Log blackbox data during every tune so oscillations can be diagnosed by frequency rather than by ear.
- Compute thrust-to-weight before the first hover; target at least 4:1 for predictable authority.
- Use cascaded controllers for position: outer loop for velocity, inner loop for attitude.
- Verify mixer signs on the bench with propellers removed before arming.
Key Takeaways
- Flight reduces to four forces — thrust, gravity, drag, and tilt-derived lift — with thrust proportional to rpm squared and propeller diameter to the fourth power.
- Quadcopter motion comes from motor mixing: diagonal pairs counter-rotate, cross-pair speed differences create roll and pitch, and within-pair differences create yaw.
- PID control runs per IMU sample; tune order is Kp, then Kd damping, then a small Ki for hover drift, with anti-windup clamping on the integral term.
- Stability has three regimes — stable, oscillating, divergent — and frame resonance from unbalanced propellers is the most common cause of spurious oscillation.
- For robust attitude math use quaternions internally; Euler angles singularities at vertical pitch make them unsuitable for control.