Rigid body
State: position p, velocity v (world), attitude quaternion q, body rates ω. Integrated with RK4 at 400 Hz.
m v̇ = R(q)[ Fdrag,b + (0,0,ΣTi) ] − m g ẑ
I ω̇ = τ − ω × Iω − ω × hrotors
q̇ = ½ q ⊗ (0,ω) I = diag(Ixx, Ixx, Izz)
Rotors and mixer
Ti = kT ωi² Qi = kQ ωi² = cQ Ti kT ∝ ρ
ω̇i = (ωcmd − ωi)/τm (τm = 30 ms motor lag)
τx = Σ yiTi τy = −Σ xiTi τz = −Σ siQi − JrΣ siω̇i
The four commands (thrust, roll, pitch, yaw torque) are mapped to rotor thrusts with the pseudo-inverse of the 4×n mixing matrix; if a rotor would leave [Tmin, Tmax] the yaw demand is given up first, then roll/pitch authority is reduced (priority: thrust > roll/pitch > yaw), and integrators are frozen (anti-windup). Max rotor speed falls with pack voltage (ωmax ∝ V).
Cascaded control
a = Kp(pref−p) + Kd(vref−v) + Ki∫e, Kp = ωn², Kd = 2ζωn
f = m(a + g ẑ) − Fdrag(v) T = f·zb, zb,des = f/|f|
eR = ½ (RdᵀR − RᵀRd)∨ ωdes = −Katt eR
α = Kp(ωdes−ω) + Ki∫(ωdes−ω) − Kdω̇ τ = Iα + ω×Iω
Geometric attitude error after Lee, Leok & McClamroch (2010); the position/attitude structure follows Mellinger & Kumar (2011). For small angles and a fast inner loop, the horizontal channel reduces to ẍ = Kp(xref−x) − Kdẋ, the double integrator used in check 3.
Ground effect
TIGE/TOGE = 1 / (1 − (R/4z)²) (Cheeseman & Bennett 1955, constant rotor power)
Applied per rotor using its own height, so a tilted aircraft feels a rolling moment near the floor. The classic form is an empirical single-rotor law; multirotor overlap and wall effects are ignored, and it is clamped for z < R/2.
Power, battery and endurance
hover: Pideal = T3/2/√(2ρA) P = Pideal/FM (FM = 0.65 figure of merit)
forward flight: vi = vh²/√(V∥² + (V⊥+vi)²) (Glauert)
Protor = κT(vi+V⊥) + cpT3/2/√(2ρA)(1+4.65μ²), cp = 1/FM − κ
Pelec = ΣProtor/ηm + Pavionics
Vpack = ns·OCV(SoC) − I Rint, P = V I ⇒ I = (OCV − √(OCV² − 4RP))/2R
tend = 0.8 Epack / Phover
The P(V) curve is the trimmed level-flight solution (thrust tilts to balance quadratic drag). The best-endurance speed minimises P(V); the best-range speed minimises P(V)/V (tangent from the origin). At altitude ρ falls, so hover power rises as ρ−1/2 and the rotors must spin faster.
Wind
Steady wind + first-order Gauss–Markov turbulence (time constant 2 s, vertical component 0.6×), a stand-in for Dryden turbulence (Beard & McLain), and a 1−cos discrete gust. The airframe drag uses the air-relative velocity.
One motor out
A quad has four unknowns for four demands, so losing a rotor removes a degree of freedom: this controller gives up yaw (the nose spins, limited only by aerodynamic yaw damping) and tries to hold position. A hexacopter with the pseudo-inverse keeps all four controls: with rotor k gone the opposite rotor must drop to zero thrust, which is exactly the boundary of the feasible set, so there is no margin for further disturbance. Real quad survivors use special reduced-attitude controllers (Mueller & D'Andrea 2014); this lab uses the ordinary one on purpose.
What is simplified
No blade flapping, no rotor-hub forces, no vortex-ring-state model in descent (induced velocity is clamped), constant air density with height for a given density-altitude slider, no propeller inflow lag, identical motors, perfect state estimation (no sensor noise or delay). Frame inertia and drag areas are generic. The aircraft is a generic civilian survey / aid-logistics platform and the parcel mass is only ballast; this is a flight-physics teaching model.
Self-checks in this page
Hover thrust and power vs formula, ground effect vs Cheeseman–Bennett, the 6-DOF step response vs the linearised double integrator, energy bookkeeping, best-endurance speed vs the analytic minimum, torque-free precession, and endurance vs E/P. All run the same engine headless.
References: Lee, Leok & McClamroch, CDC 2010; Mellinger & Kumar, ICRA 2011; Cheeseman & Bennett, ARC R&M 3021 (1955); Leishman, Principles of Helicopter Aerodynamics; Beard & McLain, Small Unmanned Aircraft; Mueller & D'Andrea, ICRA 2014. 3D models and terrain built procedurally in Blender 5.2 with baked textures.