Skip to the content
FixTheRobot Explore Robotics / UAV / Module 1 / M1-T6

UAV Systems Engineering · Module 1

M1-T6: Roll, pitch, yaw and thrust generation

Four motors, four numbers: derive the mixer that turns thrust and torques into motor commands, and see what breaks when a motor runs out of range.

  • Lesson 6 of 12
  • UAV Fundamentals and System Architecture
  • Established engineering
  • About 7 minutes to read

The controller thinks in thrust and torques; the motors only know thrust. The mixer is the small linear map between the two, and it is also where saturation, the most common cause of lost control authority, first shows up.

Learning objectives

After this lesson, you should be able to:

  • Explain how each of thrust, roll, pitch and yaw is produced by differential motor thrust.
  • Derive the X-quadrotor mixer and its inverse from the geometry.
  • Compute motor commands for a requested wrench and detect infeasible requests.
  • Describe a priority scheme for handling saturation.

Conceptual explanation

All four motors point up. If they produce equal thrust, the vehicle only climbs or descends. Roll comes from more thrust on one side than the other, pitch from more thrust at the front than at the rear, and yaw from the reaction torque of the propellers: two spin clockwise and two counter-clockwise, and speeding up one pair produces a net torque about zz because each propeller’s drag torque pushes back on the airframe.

X quadrotor motor layoutTop view of an X quadrotor with body x forward and y left. Motor 1 front-right and 2 rear-left spin counter-clockwise; motor 3 front-left and 4 rear-right spin clockwise. Differing thrust between motors produces roll, pitch and yaw torque. 1 FRCCW2 RLCCW3 FLCW4 RRCW x forwardy (FRD: right) Roll τx:right side vs left side Pitch τy:front vs rear Yaw τz:CCW pair vs CW pair
XX configuration with the PX4 motor numbering. Check the geometry file of your own airframe for exact numbering and spin directions.
Animation in four phases of how an X quadrotor makes thrust, roll, pitch and yaw. Thrust: all four motors increase together and the vehicle climbs. Roll: the two left motors speed up and the two right motors slow down, so the left side rises. Pitch: the two rear motors speed up and the two front motors slow down, so the nose drops. Yaw: the two clockwise motors speed up and the two counter-clockwise motors slow down, so the reaction torque turns the body counter-clockwise. Bars beside each motor show its thrust.
The four commands in turn (looping, about eight seconds; a schematic drawn for this course, not a simulation). Each phase changes the motor thrusts by the mixer pattern shown, around the hover thrust f0, using this lesson’s motor numbering and signs (body xx forward, yy left, zz up). Bar heights are the motor thrusts; the pictures on the right show the resulting motion.

The mapping from motor thrusts ff to the generalised force (T, τx, τy, τz)(T,\,\tau _{x},\,\tau _{y},\,\tau _{z}) is linear. The mixer is its inverse: given the wrench the controller asks for, it returns the four thrusts.

Engineering intuition

Roll and pitch are cheap: they use leverage, a thrust difference acting at the arm length. Yaw is expensive: it uses the propeller drag torque, which is a small fraction (k≈1–2 cm)(k\approx 1\text{–}2\,\mathrm{cm}) of the thrust times a lever arm, so a yaw command needs a large thrust difference for a small torque. That is why yaw is slow on a quadrotor and why, when motors saturate, yaw is sacrificed first: losing yaw control is far less dangerous than losing roll or pitch.

Mathematical formulation

Body frame xx forward, yy left, zz up. Motors sit at (±dd, ±dd, 0) with d=L/2d=L/\sqrt{2} for a motor-to-motor distance LL. Each motor produces thrust fif_{i} along +z and a drag torque k fik\,f_{i} about zz, opposing its rotation.

Wrench from motor thrusts
T=f1+f2+f3+f4τx=d (−f1+f2+f3−f4)τy=d (−f1+f2−f3+f4)τz=−k (f1+f2−f3−f4)\begin{aligned} T &= f_1 + f_2 + f_3 + f_4\\ \tau_x &= d\,(-f_1 + f_2 + f_3 - f_4)\\ \tau_y &= d\,(-f_1 + f_2 - f_3 + f_4)\\ \tau_z &= -k\,(f_1 + f_2 - f_3 - f_4) \end{aligned}
Motors 1 and 2 turn counter-clockwise, motors 3 and 4 clockwise.
TT
total thrust (N).
τx\tau _{x}, τy\tau _{y}, τz\tau _{z}
roll, pitch and yaw torque about the body axes (NN·mm).
dd
perpendicular lever arm of each motor, d=L/2(m)d=L/\sqrt{2}(m).
kk
ratio of propeller drag torque to thrust (m); depends on the propeller.

Writing this as [T, τ]=A f[T,\,\tau ]=A\,f, the four rows are orthogonal, so A is invertible and:

The mixer (inverse of A)
f1=T4−τx4d−τy4d−τz4kf2=T4+τx4d+τy4d−τz4kf3=T4+τx4d−τy4d+τz4kf4=T4−τx4d+τy4d+τz4k\begin{aligned} f_1 &= \frac{T}{4} - \frac{\tau_x}{4d} - \frac{\tau_y}{4d} - \frac{\tau_z}{4k}\\ f_2 &= \frac{T}{4} + \frac{\tau_x}{4d} + \frac{\tau_y}{4d} - \frac{\tau_z}{4k}\\ f_3 &= \frac{T}{4} + \frac{\tau_x}{4d} - \frac{\tau_y}{4d} + \frac{\tau_z}{4k}\\ f_4 &= \frac{T}{4} - \frac{\tau_x}{4d} + \frac{\tau_y}{4d} + \frac{\tau_z}{4k} \end{aligned}

Saturation

Each fif_{i} must satisfy 0≤fi≤fmax⁡0\le f_{i}\le f_{\max}. If a requested wrench violates this, the mixer cannot deliver it. A common priority scheme: first reduce the yaw torque to zero; if still infeasible, shift thrust so no motor is below zero (sacrificing altitude hold); finally scale the roll and pitch torques. Autopilots implement variants of this; consult your autopilot’s control-allocation documentation for what it does.

Architecture and data flow

The mixer sits between the rate controller and the ESCs: rate controller → (T, τ)(T,\,\tau ) → mixer → normalised motor outputs → ESC → motors. Anything the mixer cannot satisfy is a saturation event that the controller should know about, so that its integrators stop winding up (anti-windup).

Real-world UAV applications

  • Control allocation for quadrotors, hexarotors and octorotors (the matrix A has more columns; the inverse becomes a pseudo-inverse).
  • Motor-out fault tolerance: remove a column and re-allocate with reduced yaw authority.
  • Sizing: the maximum roll torque with all other axes at hover tells you the attitude bandwidth the airframe can deliver.
  • Diagnosing a vehicle that flips at takeoff (a swapped motor or reversed propeller).

Implementation example

This runs as shown. It builds A from the geometry, inverts it, mixes a request, and checks that a feasible request round-trips while an extreme yaw request saturates.

import numpy as np
L, k, fmax = 0.25, 0.016, 12.0          # arm (m), drag/thrust ratio (m), max thrust per motor (N): illustrative
d = L / np.sqrt(2)
#          f1 FR  f2 RL  f3 FL  f4 RR      rows: T, tau_x, tau_y, tau_z
A = np.array([[1,     1,    1,    1],
              [-d,    d,    d,   -d],
              [-d,    d,   -d,    d],
              [-k,   -k,    k,    k]])
Ainv = np.linalg.inv(A)

def mix(T, tx, ty, tz):
    return Ainv @ np.array([T, tx, ty, tz])

def mix_with_priority(T, tx, ty, tz):
    f = mix(T, tx, ty, tz)
    if f.min() < 0 or f.max() > fmax:           # 1) give up yaw first
        f = mix(T, tx, ty, 0.0)
    if f.min() < 0 or f.max() > fmax:           # 2) shift collective thrust into range if the spread allows it
        spread = f.max() - f.min()
        if spread <= fmax:
            f = f + max(0.0, -f.min()) - max(0.0, f.max() + max(0.0, -f.min()) - fmax)
        else:                                   # 3) scale the roll/pitch request down
            f = f.mean() + (f - f.mean()) * fmax / spread
    return np.clip(f, 0, fmax)

f = mix(14.7, 0.2, -0.1, 0.05)
assert np.allclose(A @ f, [14.7, 0.2, -0.1, 0.05])      # round trip
print("motors:", np.round(f, 2))

f_raw = mix(14.7, 0.0, 0.0, 1.0)                        # a large yaw request
print("raw yaw request:", np.round(f_raw, 1), "-> infeasible" if (f_raw.min() < 0 or f_raw.max() > fmax) else "")
assert f_raw.min() < 0 or f_raw.max() > fmax
f_ok = mix_with_priority(14.7, 0.0, 0.0, 1.0)
print("with priority:", np.round(f_ok, 2))
assert f_ok.min() >= 0 and f_ok.max() <= fmax and abs(f_ok.sum() - 14.7) < 1e-9
Mixer, round-trip check and a priority scheme that sacrifices yaw first.

Common engineering mistakes

Wrong spin direction or motor numbering

A reversed propeller flips the sign of τz\tau _{z} and of the thrust it produces. Verify with a props-off motor test on every build.

Assuming the mixer is perfectly linear in throttle

Thrust is roughly proportional to the square of rotor speed; real systems linearise thrust-to-command with a calibrated curve.

Ignoring saturation in the controller

Integrators wind up while the mixer clips, then the vehicle overshoots wildly on recovery. Feed saturation back to anti-windup.

Equal weights for yaw and roll/pitch

Yaw must be the first thing sacrificed, not the last.

Failure modes

Failure modes, symptoms and causes
Failure modeHow it shows upLikely cause
Takeoff flipVehicle rolls or pitches violently when thrust is appliedSwapped motor wires, reversed propeller, or wrong mixer sign
Yaw drift in hoverConstant slow rotationMotor or propeller mismatch, mis-trimmed yaw torque
Loss of attitude control under aggressive commandsOscillation that grows when the command is largeMotor saturation without anti-windup or priority
Low-throttle instabilityWobble at minimum throttleMotors clipped at their lower limit so negative thrust corrections cannot be applied

Debugging approach

  1. With propellers removed, command each axis in turn and check which motors speed up (and in which direction they spin).
  2. Plot motor outputs and mark saturation in the log: they should not touch limits in normal flight.
  3. Verify A f=[T, τ]A\,f=[T,\,\tau ] numerically for the airframe geometry you actually built.
  4. Compare vehicle response to a small roll step with the model; a wrong sign or a gain error shows up immediately.

Practical exercises

  1. Derive the mixer for a plus (+) configuration with motors on the axes at distance L/2.
  2. Compute the largest yaw torque possible at hover thrust for L=0.25 mL=0.25\,\mathrm{m}, k=0.016 mk=0.016\,\mathrm{m}, fmax⁡=12 Nf_{\max}=12\,\mathrm{N}, T=14.7 NT=14.7\,\mathrm{N}.
  3. Extend the mixer to a hexarotor and compute the pseudo-inverse.
  4. Remove motor 1 (failure) from the quadrotor mixer and show which axes can still be controlled.

Interview questions

Write an answer in your own words, then reveal the model answer. Nothing is sent anywhere.

Question 1

Why do two motors spin each way?

Model answer

Each propeller exerts a reaction torque on the airframe about the vertical axis. Equal numbers of clockwise and counter-clockwise propellers cancel these at equal speeds, and speeding up one pair gives a controlled yaw torque.

Question 2

Which axis is sacrificed first on saturation, and why?

Model answer

Yaw. It is the weakest and slowest axis and its loss is the least dangerous, whereas losing roll or pitch authority leads to a crash.

Question 3

What does the mixer do mathematically?

Model answer

It inverts the linear map from four motor thrusts to total thrust and three torques. With four motors the map is square and invertible; with more motors it is solved with a pseudo-inverse or an optimisation.

References and further reading

Primary papers, official documentation and standards. Each claim above that is specific to a tool or version points here.

What’s next

Mark this lesson

Saved in this browser and synced to your account when you are signed in.

Practice this lesson

M1-L1: Build a simulated quadrotor model

Integrate the 6-DoF model, apply a mixer and hold hover with attitude PID.

Practice this lesson

M1-L3: Understand motor mixing

Map thrust and torque commands to four motor outputs and check saturation.

Next lesson

M1-T7: Flight controllers, ESCs, motors and propellers

Size a propulsion system from thrust-to-weight ratio, and explain the role of each element in the actuator chain.