3.5.5Guidance, Navigation & Control (GNC)

Gimbal lock — problem with Euler angles at θ = ±90°

1,815 words8 min readdifficulty · medium4 backlinks

WHAT is going on

WHY does the middle angle matter? The middle rotation is what tilts the last axis relative to the first. Push it to 90°90° and the last axis lies exactly along the first axis.


HOW to derive the lock from first principles

We don't memorize "lock at 90°" — we watch it happen in the matrices.

Elemental rotations (right-handed, active):

Rz(ψ)=(cψsψ0sψcψ0001),Ry(θ)=(cθ0sθ010sθ0cθ),Rx(ϕ)=(1000cϕsϕ0sϕcϕ)R_z(\psi)=\begin{pmatrix}c_\psi & -s_\psi & 0\\ s_\psi & c_\psi & 0\\ 0&0&1\end{pmatrix},\quad R_y(\theta)=\begin{pmatrix}c_\theta & 0 & s_\theta\\ 0&1&0\\ -s_\theta&0&c_\theta\end{pmatrix},\quad R_x(\phi)=\begin{pmatrix}1&0&0\\0&c_\phi&-s_\phi\\0&s_\phi&c_\phi\end{pmatrix}

where cα=cosα, sα=sinαc_\alpha=\cos\alpha,\ s_\alpha=\sin\alpha.

Step — set the pitch to the singular value θ=+90°\theta = +90°. Why this step? Because we suspect the singularity lives there; we test it directly. Then cθ=0, sθ=1c_\theta = 0,\ s_\theta = 1: Ry(90°)=(001010100)R_y(90°)=\begin{pmatrix}0&0&1\\0&1&0\\-1&0&0\end{pmatrix}

Step — multiply out Rz(ψ)Ry(90°)Rx(ϕ)R_z(\psi)R_y(90°)R_x(\phi). Why this step? We want to see if ψ\psi and ϕ\phi still act independently.

Doing the algebra, the full matrix collapses to:

R=(0sin(ϕψ)cos(ϕψ)0cos(ϕψ)sin(ϕψ)100)R = \begin{pmatrix} 0 & \sin(\phi-\psi) & \cos(\phi-\psi)\\ 0 & \cos(\phi-\psi) & -\sin(\phi-\psi)\\ -1 & 0 & 0 \end{pmatrix}

Step — read the result. Why this step? This is the punchline. Every entry depends on ψ\psi and ϕ\phi only through the combination (ϕψ)(\phi-\psi). So changing ψ\psi by +δ+\delta and ϕ\phi by +δ+\delta leaves RR unchanged. Two knobs, one effect.


HOW it wrecks the rates (the practical disaster)

Orientation isn't static — GNC integrates body angular rates (p,q,r)(p,q,r) into Euler angles. The kinematic relation is:

(ϕ˙θ˙ψ˙)=(1sinϕtanθcosϕtanθ0cosϕsinϕ0sinϕcosθcosϕcosθ)(pqr)\begin{pmatrix}\dot\phi\\\dot\theta\\\dot\psi\end{pmatrix} = \begin{pmatrix} 1 & \sin\phi\tan\theta & \cos\phi\tan\theta\\ 0 & \cos\phi & -\sin\phi\\ 0 & \dfrac{\sin\phi}{\cos\theta} & \dfrac{\cos\phi}{\cos\theta} \end{pmatrix} \begin{pmatrix}p\\q\\r\end{pmatrix}

WHY the blow-up: look at tanθ\tan\theta and 1/cosθ1/\cos\theta. As θ±90°\theta\to\pm90°, cosθ0\cos\theta\to0, so ϕ˙\dot\phi and ψ˙\dot\psi diverge to infinity. The math demands an infinite angle rate to represent a perfectly finite physical rotation — the coordinates are singular, not the physics.

Figure — Gimbal lock — problem with Euler angles at θ = ±90°

Worked examples


Steel-manned mistakes


The engineer's fix

  • Represent orientation with quaternions (or rotation matrices / axis-angle) internally.
  • Convert to Euler angles only for human display, and handle the θ=±90°\theta=\pm90° special case explicitly.
  • 80/20 takeaway: the physics is never singular; only the Euler chart is. Change charts.
Recall Feynman: explain to a 12-year-old

Imagine steering a toy plane with three dials: turn-left/right, nose-up/down, and barrel-roll. Now point the nose straight up at the ceiling. Now the "turn left/right" dial and the "barrel-roll" dial both just spin the plane like a top around the same up-down line — they do the exact same thing! You've lost one way of steering. The plane can still tumble any way it likes; it's your three dials that got confused. Astronauts fixed this by using a smarter set of "dials" called quaternions that never get stuck.


Flashcards

What is gimbal lock in one sentence?
The loss of one rotational degree of freedom in an Euler-angle representation when the middle (pitch) angle reaches ±90°\pm90°, causing the first and third rotation axes to align.
At which Euler angle does ZYX gimbal lock occur?
When pitch θ=±90°\theta=\pm90°.
Why do Euler rates blow up near lock?
The kinematic map contains tanθ\tan\theta and 1/cosθ1/\cos\theta; as θ±90°\theta\to\pm90°, cosθ0\cos\theta\to0 so ϕ˙,ψ˙\dot\phi,\dot\psi\to\infty.
At θ=+90°\theta=+90° the rotation matrix depends on yaw/roll only through what combination?
Only through (ϕψ)(\phi-\psi) (and (ϕ+ψ)(\phi+\psi) at θ=90°\theta=-90°).
Is gimbal lock a physical limitation of the rigid body?
No — the body rotates freely; only the coordinate chart (and analog gimbals implementing it) loses a DOF.
Standard engineering fix for gimbal lock?
Use quaternions (or rotation matrices) internally; Euler angles only for display.
Do quaternions suffer gimbal lock?
No; they form a smooth global cover of SO(3)SO(3) with no singular orientations (only a harmless qqq\equiv-q sign ambiguity).
Why is avoiding exactly θ=90°\theta=90° insufficient?
The 1/cosθ1/\cos\theta term makes a whole neighborhood numerically unstable, not just the single point.

Connections

  • Euler angles — the representation that fails
  • Quaternions — the singularity-free fix
  • Rotation matrices SO(3) — the group being parametrized
  • Angular velocity kinematics — source of the 1/cosθ1/\cos\theta rate blow-up
  • Attitude determination and control — where this bites in GNC
  • Apollo Guidance Computer — historic gimbal-lock avoidance ("don't fly into the gimbal lock zone")
  • Singularities of coordinate charts — the deeper differential-geometry reason

Concept Map

built from

tilts to 90 deg

coincide

causes

set to 90 deg

collapses to

two knobs one effect

integrated via

contains

singular at theta 90

motivates

avoided by

Euler angles yaw pitch roll

Middle rotation pitch theta

Yaw axis and roll axis

Gimbal lock

Degree of freedom lost

Matrix R at theta 90

Only phi minus psi matters

Euler rate kinematics

tan theta and 1 over cos theta

Rates blow up to infinity

Use quaternions instead

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, Euler angles ka matlab hai kisi bhi orientation ko teen rotations mein todna: yaw (Z ke around), phir pitch (naye Y ke around), phir roll (naye X ke around). Problem tab aati hai jab pitch angle θ\theta exactly ±90°\pm90° ho jaata hai. Us waqt jo aakhri axis (nose/roll axis) hai woh bilkul pehli axis (world vertical/yaw axis) ke upar aa jaati hai. Matlab ab yaw ghumao ya roll ghumao — dono se object same hi direction mein ghoomta hai. Ek poora degree of freedom gaayab! Isko bolte hain gimbal lock.

Sabse important baat: yeh koi mechanical jam nahi hai. Aircraft ya satellite khud toh kisi bhi taraf freely ghoom sakta hai — sirf humare coordinate system (Euler angles) confuse ho gaya. Matrix nikaalo toh dikhta hai ki θ=90°\theta=90° pe sab kuch sirf (ϕψ)(\phi-\psi) pe depend karta hai, yaani do knob ka ek hi kaam.

Practical disaster rates mein aata hai. Jab hum body angular rates (p,q,r)(p,q,r) se Euler angles integrate karte hain, formula mein tanθ\tan\theta aur 1/cosθ1/\cos\theta terms hote hain. θ90°\theta\to90° pe cosθ0\cos\theta\to0, toh ϕ˙\dot\phi aur ψ˙\dot\psi infinity ki taraf bhaag jaate hain. Chhoti si sensor noise bhi huge yaw error bana deti hai — GNC integrator phat jaata hai.

Fix simple hai: andar ka saara maths quaternions ya rotation matrices se karo, jinme koi singular orientation nahi hoti. Euler angles sirf display ke liye use karo, aur ±90°\pm90° case ko alag se handle karo. Yaad rakho — "Pitch to the peak, the poles leak." Yeh GNC ka classic 80/20 concept hai, Apollo mission tak isko dodge karna padta tha.

Go deeper — visual, from zero

Test yourself — Guidance, Navigation & Control (GNC)

Connections