Lie Groups: SO(3), SE(3) and the Exponential Map

A gyro says the drone turns at a steady rate. Add each small turn to the rotation matrix and, after 12 steps, the matrix is no longer a rotation: its determinant is 1.43. Step the Euler angles and the attitude ends 16.2° off. Compose each turn with the exponential map and it lands on the truth, 0.00° off.

Pick an updater, set the step size, and press Play. Watch the purple estimate chase the pink truth. Then we build, piece by piece, groups, the tangent space, exp and log, twists, left and right perturbations and their Jacobians.

You need Lecture 1 (rotation matrices, the skew matrix, Rodrigues' formula), matrix times vector and a little Python. We build the rest from zero.

Lecture 2 of 14 in our follow-along of MIT 16.485, Visual Navigation for Autonomous Vehicles (VNAV, taught by Luca Carlone). Every idea is re-taught here in our own words and devices. Previous: Lecture 1, 3D geometry. Next: Lecture 3, control.

Integrate a gyro three ways

10°

Illustrative motion: a steady body rate ω = (0, 1, 0.5) rad/s, a pitch-up with some yaw, held until the drone has turned 120°. Euler angles in yaw-pitch-roll order. Exact maths. Drag sideways on the scene to orbit.

Chapter 0

Rotations Do Not Add

Add a small turn to a rotation matrix ten times and watch the frame grow

An estimator holds the drone's attitude as a rotation matrix R. Every few milliseconds, a gyro or an optimiser says "turn by this small amount". For a position, you add the correction. Can you add one to R?

Try it. Write a turn of 0.3 rad about z as the skew matrix from Lecture 1, and add it to the identity I. The columns of the sum have length 1.044, and its determinant is 1.09. That is not a rotation. It stretches every vector by about 4%.

Repeat one small turn

Seen from above. The dashed circle holds every place a rotated x arrow can end. Pick add or compose, then raise the number of updates and watch where the tip goes.

0.30 rad
10

Exact maths, turns about z only, seen from above.

Work the number. One addition gives a determinant of 1.09. Ten additions give 1.09 to the tenth power, 2.37: the "rotation" more than doubles every volume. Composing with the matching rotation, R exp(δ∧), keeps the determinant at exactly 1 after any number of steps.

The rotations form a curved set. In the device, every valid x arrow ends on the circle. An addition moves along a straight line and leaves the circle. The exponential map, the tool of this lesson, bends the step so that it stays on.

Symptom: the map an attitude filter builds slowly inflates or shears.

Measure: log det R after every update. A rotation gives 1.000000.

Fix: update with R exp(δ∧), never with R + δ∧.

The road

  1. Groups: SO(3) is a group you can bend, a Lie group.
  2. Tangent space: so(3), the hat and vee maps, and the gyro's rate.
  3. exp: Rodrigues' formula from a power series, and small angles (the hero's third button).
  4. log: from a rotation back to a vector, and the two danger zones.
  5. SE(3): twists, and why the turn bends the shift.
  6. Left or right: two places to put a correction, and the adjoint.
  7. Jacobians: how exp responds when its input moves.
  8. BCH: composing two turns, to first order.
  9. Showcase: steer to a goal attitude three ways (the hero's first two buttons fail here too).
  10. Field guide: the maps side by side, the conventions, code and the credit.
You add the skew matrix of a 0.3 rad turn about z to the identity. What is the determinant of the sum?

Chapter 1

SO(3) Is a Group You Can Bend

Check the group rules, then zoom in until the curved set looks flat

Rotations have their own way to combine: multiplication. A group is a set with one way to combine two members that obeys four rules. The result stays in the set (closure). Brackets do not matter (associativity). One member does nothing (identity). Every member has an undo (inverse).

SO(3) with matrix multiplication obeys all four. The identity I does nothing, and R⊤ undoes R. But order matters: Lecture 1 showed that Rz(90°) Rx(90°) and Rx(90°) Rz(90°) differ. A group like that is non-commutative.

Why does a product of two rotations stay a rotation? Call them R1 and R2.

Say it aloud

R-one R-two, transposed, times R-one R-two, equals R-two-transpose R-one-transpose R-one R-two, which equals I.

(R1R2)⊤(R1R2)
the product, transposed, times the product the test from Lecture 1: every column dotted with every column.
R2⊤ R1⊤
R-two-transpose R-one-transpose the transpose of a product reverses the order.
R1 R2
R-one R-two the product itself. The inner pair R1⊤R1 meets in the middle.
I
I the 3 by 3 identity.
In plain words

Transpose the product, and the order flips. The middle pair R-one-transpose R-one is I, so it drops out. What is left, R-two-transpose R-two, is I too. The determinants multiply, 1 times 1, so the product is in SO(3).

With numbers

Rz(90°) Rx(90°) has columns (0, 1, 0), (0, 0, 1) and (1, 0, 0). Each has length 1, and the determinant is +1. The sum Rz(90°) + Rx(90°) has columns of length 1.41 and determinant 2. Multiplying stays in the set; adding leaves it.

A manifold is a curved set that looks flat when you zoom in close, like the Earth seen from a field. SO(3) sits inside the 9 numbers of a 3 by 3 matrix, and its 6 rules leave 3 dimensions. SE(3), a turn plus a shift, has 6.

A Lie group (say "lee") is both: a group whose members form a smooth manifold. So we can compose, undo and take derivatives.

Zoom in until the circle looks flat

The dashed circle is SO(2), the turns in a plane. The warm line touches it at the identity. Step along the line, then turn on zoom: the circle looks straighter the closer you look.

0.10

Exact maths on the unit circle. SO(3) is the same story in 3 dimensions.

Work the number. Step 0.1 along the line from (1, 0). The point (1, 0.1) sits 0.005 outside the circle. At a step of 0.01, the gap is 0.00005. Ten times smaller a step gives a hundred times smaller gap, so near the identity the flat line is a good map.

Symptom: a solver converges for small corrections but fails for large ones.

Measure: plot the gap between R + δ∧ and the nearest rotation against the step. It grows with the square of the step.

Fix: trust the flat picture only near the current point, and curve each step back with exp.

Which group rule does SO(3) NOT obey under matrix multiplication?

Chapter 2

The Tangent Space: so(3), Hat and Vee

Turn three numbers into a skew matrix and watch it act as a cross product

Which ways can a rotation move from the identity? Take a smooth path of rotations R(t) with R(0) = I. Every point obeys R(t)⊤R(t) = I. Differentiate at t = 0 and you get Ṙ(0)⊤ + Ṙ(0) = 0. So the velocity Ṙ(0) is a skew-symmetric matrix: its transpose is its negative.

Those velocities form the Lie algebra so(3), the flat tangent space at the identity. A skew matrix has three free numbers, so so(3) has 3 dimensions, the same as SO(3). The hat map writes a 3-vector as its skew matrix. The vee map reads the three numbers back.

How do three numbers fill a skew matrix? Call the vector φ (phi), with parts φ1, φ2 and φ3.

Say it aloud

Phi-hat is the matrix with rows zero, minus phi-3, phi-2; then phi-3, zero, minus phi-1; then minus phi-2, phi-1, zero. Phi-hat times v equals phi cross v.

φ∧
phi-hat the skew matrix of φ, a member of so(3).
[ … ]
the matrix zeros on the diagonal; each number appears once above and once below it, with opposite signs.
v
v any 3-vector, here a point on the drone.
φ × v
phi cross v the cross product: square to both, by the right-hand rule.
In plain words

Put φ3 at row 2, column 1 and −φ3 at row 1, column 2. Do the same for φ1 and φ2. Multiplying by phi-hat is then the cross product with φ. Vee reads entries (3,2), (1,3) and (2,1).

With numbers

φ = (1, 2, 3) gives rows (0, −3, 2), (3, 0, −1) and (−2, 1, 0). With v = (1, 0, 0), phi-hat times v is (0, 3, −2), and φ × v is (0, 3, −2) too.

Turn three numbers into a skew matrix

The warm arrow is φ. The pink point v sits at (1, 0, 0). The purple arrow is phi-hat times v: the velocity v gets if the drone spins about φ. It is always square to both.

1.0
2.0
3.0

Exact maths. We scale the arrows to fit. Drag sideways to orbit.

The hat map also says how an attitude moves. Call the gyro's turn rate, in the body frame, ωB (omega-B), and let R be RWB.

Say it aloud

R-dot equals R times omega-B-hat, which equals omega-W-hat times R, where omega-W equals R times omega-B.

Ṙ
R-dot how fast each entry of R changes, per second.
R
R RWB: body numbers in, world numbers out.
ωB
omega-B the turn rate in the body frame, what the gyro reads, in rad/s.
ωW
omega-W the same turn rate, written in world numbers.
In plain words

The gyro's rate ωB is in body numbers, so its hat goes on the right of R. Rotate it by R to get ωW, and its hat goes on the left.

With numbers

Yaw 90°, so R = Rz(90°). The gyro reads a roll rate ωB = (0.5, 0, 0) rad/s. Then ωW = R ωB = (0, 0.5, 0): the nose points along world y, so a roll is a spin about world y.

Symptom: integrated attitude is right while the drone faces east and wrong once it turns.

Measure: on one logged pose at 90° yaw, compare R ω∧ with ω∧ R for the gyro reading.

Fix: the gyro reads body rates, so put its hat on the right: R ωB∧.

Why must a velocity of SO(3) at the identity be a skew-symmetric matrix?

Chapter 3

The Exponential Map: Rodrigues From a Series

Add terms of a power series and watch them close onto a rotation

Hold a velocity φ∧ steady for one second. Where do you end? For a number, a steady rate a gives ea. For a matrix, the matrix exponential is the same series: exp(A) = I + A + A²/2! + A³/3! + … For a skew matrix this series has a closed form.

Write φ = θu, with the angle θ = |φ| and a unit axis u. Lecture 1's skew matrix obeys (u∧)³ = −u∧, because (u∧)² = uu⊤ − I and u∧u = 0. So the powers cycle: u∧, (u∧)², −u∧, −(u∧)², and so on.

Group the series by those two matrices. The odd terms carry θ − θ³/3! + θ5/5! − …, the sine series. The even terms carry θ²/2! − θ4/4! + …, the series of 1 − cos θ. That is Rodrigues' formula, now derived, not assumed.

Say it aloud

Exp of phi-hat equals I, plus sine theta over theta times phi-hat, plus one minus cos theta over theta squared, times phi-hat squared.

exp(φ∧)
exp of phi-hat the rotation reached by spinning at φ for one second: a member of SO(3).
I
I the identity: where the spin starts.
(sin θ)/θ
sine theta over theta the weight of the first-order part. θ is the length of φ, the angle in radians.
φ∧
phi-hat the skew matrix of φ, and its square.
(1 − cos θ)/θ²
one minus cos theta over theta squared the weight of the second-order part. It tends to one half as θ goes to 0.
In plain words

Find the angle θ as the length of φ. Build phi-hat and its square. Weight them by the two coefficients and add them to I.

With numbers

φ = (0, 0, π/2): θ = 1.571, sin θ/θ = 0.637 and (1 − cos θ)/θ² = 0.405. Phi-hat squared has −2.467 in the top-left 2 by 2 corner. Result: rows (0, −1, 0), (1, 0, 0), (0, 0, 1), the 90° yaw Rz(90°).

Close the series onto a rotation

The pink frame is exp(φ∧) from Rodrigues' formula. The purple frame is the series cut after N terms. Lower N or raise the angle and the purple arrows stretch away from pink.

90°
3

Exact maths. "N terms" means the powers 0 to N. Drag sideways to orbit.

Work the number. At 90°, the series cut after the cube term misses one entry by 0.23, and its determinant is 0.91. Ten terms bring the miss down to 0.0000035. Rodrigues' formula is exact in one step.

Small angles need care. In floating point, 1 − cos θ for θ = 10−8 rounds to 0, so the second coefficient comes out 0, not 0.5. At θ = 10−6 it is 0.50004, wrong in the fifth digit. Below about 10−4 rad, use the Taylor forms: sin θ/θ ≈ 1 − θ²/6 and (1 − cos θ)/θ² ≈ 1/2 − θ²/24.

Symptom: a 1 kHz gyro integration freezes or jitters when the drone hovers still.

Measure: print the two coefficients at θ = 10−8. The second should read 0.5.

Fix: switch to the Taylor forms below θ = 10−4, and never divide by θ = 0.

Which fact collapses the exponential series of a skew matrix into two terms?

Chapter 4

The Logarithm Map: Back to a Vector

Turn past 180° and watch the log answer the short way round

Now the reverse question. Given a rotation R, which vector φ makes it? That is the logarithm map. Optimisers need it to measure how far apart two attitudes are.

Take the trace of Rodrigues' formula, the sum of its diagonal. The phi-hat term adds 0 and the squared term adds −2θ², so the trace is 1 + 2 cos θ. The skew part gives the axis: R − R⊤ = 2 sin θ u∧.

Say it aloud

Theta equals the arc-cosine of trace R minus one, over two. Phi equals theta over two sine theta, times the vee of R minus R-transpose.

θ
theta the angle of the turn, between 0 and π rad.
arccos
arc-cosine the angle whose cosine is the given number.
tr R
trace R the sum of R's three diagonal entries, from −1 to 3.
(R − R⊤)∨
vee of R minus R-transpose the three numbers of R's skew part: 2 sin θ times the axis u.
φ
phi the rotation vector: angle times axis.
In plain words

Add the diagonal of R, subtract 1 and halve it: that is cos θ. Take R − R-transpose, read its three numbers with vee, and scale them by θ/(2 sin θ).

With numbers

With made-up φ = (0.3, −0.2, 0.6): R has trace 2.530, so cos θ = 0.765 and θ = 0.700 rad. Half the vee of R − R⊤ is (0.276, −0.184, 0.552). Scale by θ/sin θ = 1.087: back to (0.300, −0.200, 0.600).

Turn past 180°

Left: the warm arc is the turn you ask for, about +z. Right: the line holds every answer the log can give, from −180° to +180°. Push the angle past 180° and watch the purple answer jump to the other end.

200°

Exact maths, with the robust log described below.

The log always returns an angle between 0 and π. Ask for 200° about +z and it returns 160° about −z: the same rotation, the short way round.

The formula has two danger zones. Near θ = 0, arccos is flat: for θ = 10−7 rad it returns 0.99 × 10−7, 1% off. Use θ = atan2(|w|, (tr R − 1)/2), with w half the vee of R − R⊤, and θ/sin θ ≈ 1 + θ²/6. Near θ = π, both sin θ and R − R⊤ go to 0: at 179.9°, θ/(2 sin θ) is 900. There, read the axis from the symmetric part, (R + R⊤)/2 − cos θ I = (1 − cos θ) uu⊤.

The log also gives a distance. The length of log(RA⊤ RB) is the geodesic distance, the angle between two attitudes.

Rz(45°) to Rz(90°): geodesic 0.785 rad; chordal |RA − RB| = 2√2 sin(θ/2) = 1.082

Symptom: a heading residual jumps from +179° to −179° and the solver kicks the drone round.

Measure: log residual angles per step; look for jumps near π.

Fix: compute residuals as log(Rest⊤ R), which is always the short way, and use the symmetric-part branch near π.

R = Rz(180°) has diagonal (−1, −1, 1). What angle does the log map return, and why is the axis formula a problem here?

Chapter 5

Twists: The Exponential Map on SE(3)

Drive and turn at once, and see the turn bend the shift

A pose has a turn and a shift, and SE(3) is a Lie group too. Its tangent space se(3) holds twists: six numbers ξ = (φ, ρ) (xi equals phi, rho). φ is a turn rate and ρ a forward speed, held for one second. On this page the rotation part comes first.

Drive at 1 m/s while you yaw at 90°/s, for one second. You do not end 1 m ahead. You trace a quarter circle, so the turn bends the shift. The exponential map on SE(3) adds exactly that bend.

Say it aloud

Exp of xi-hat is the 4 by 4 matrix with exp of phi-hat in the corner and J-l of phi times rho as the shift. J-l of phi equals I, plus one minus cos theta over theta squared times phi-hat, plus theta minus sine theta over theta cubed times phi-hat squared.

exp(ξ∧)
exp of xi-hat the pose T after holding the twist ξ for one second. ξ∧ holds φ∧ in its corner and ρ in its last column.
exp(φ∧)
exp of phi-hat the rotation block: Chapter 3's Rodrigues formula.
Jl(φ)
J-l of phi the left Jacobian of SO(3): it sums the forward motion as the heading turns. It is I when φ = 0.
ρ
rho the linear part of the twist, in m/s along the body's own axes at the start.
In plain words

The rotation block is the SO(3) exp of φ. The shift is not ρ: multiply ρ by J-l of phi, which bends it along the arc the drone drives.

With numbers

φ = (0, 0, π/2) and ρ = (1, 0, 0). Jl has 0.637 on the diagonal of its top-left block, −0.637 above it and +0.637 below. The shift is t = Jlρ = (0.637, 0.637, 0) m: the end of a quarter circle of radius 2/π = 0.637 m.

Drive and turn for one second

Seen from above. The teal arc is the path a steady twist drives. The teal drone is exp(ξ∧). The red ring is where t = ρ would put it. Turn the rate to 0 and the two meet.

1.0 m/s
90°/s

Exact maths, planar twist (yaw only) for one second.

Work the number. Setting t = ρ puts the drone at (1, 0, 0), 0.73 m from where it ends. A half turn with ρ = 2 m/s ends at (0, 1.27, 0): the far side of a circle of diameter 1.27 m, not 2 m ahead.

Symptom: odometry built from twists overshoots on every turn.

Measure: on a turning step, compare |t| with |ρ|. For a quarter turn, |t| should be 0.90 times |ρ|.

Fix: shift by Jl(φ) ρ, or call a tested SE(3) exp.

A twist has φ = 0 and ρ = (1, 0, 0). What pose does exp give?

Chapter 6

Left or Right: Perturbations and the Adjoint

Apply one correction on each side of R and convert between them

A small correction δ (delta) can go on either side of R. The right perturbation R exp(δ∧) turns about the drone's own axes: δ is in the body frame. The left perturbation exp(δ∧) R turns about the world's axes. The same δ gives different results.

Yaw the drone 90° and take δ = (0.2, 0, 0), 0.2 rad about x. On the right, that x is the drone's nose: the drone rolls, and the nose stays along world y. On the left, x is world x, which now points out of the drone's right side: the nose tips up to (0, 0.980, 0.199). The two results differ by 16.2°.

How do we move a body correction to the left side? Call the rotation R and the body correction δ.

Say it aloud

R times exp of delta-hat equals exp of the hat of R delta, times R.

R
R the attitude RWB.
exp(δ∧)
exp of delta-hat a small turn by δ, written in body numbers, applied on the right.
exp((Rδ)∧)
exp of the hat of R delta the same turn written in world numbers, applied on the left. Rδ is the adjoint of R acting on δ: AdR = R.
In plain words

To move a body correction to the left, rotate its vector by R. The reason: R δ∧ R⊤ = (Rδ)∧, and the series of exp keeps that through every power.

With numbers

R = Rz(90°) and δ = (0.2, 0, 0): Rδ = (0, 0.2, 0). Rolling 0.2 rad about the nose on the right equals turning 0.2 rad about world y on the left.

Put the correction on either side

The faint teal drone is R. The warm arrow is the axis the correction turns about. The yellow dashed frame is the right-perturbed result; purple is the result of your choice.

90°
0.20 rad

Exact maths. Drag sideways to orbit.

For poses, the adjoint is a 6 by 6 matrix. With the twist ordered (φ, ρ), it is:

AdT = [R, 0; t∧R, R] drone at t = (5, 0, 0), yaw 90°: body twist (0, 0, 0.1, 0, 0, 0) becomes world twist (0, 0, 0.1, 0, −0.5, 0)

The world twist keeps the spin and adds −0.5 m/s: the velocity that the spin gives a point at the world origin.

Symptom: analytic Jacobians pass the check at yaw 0 and fail at other headings.

Measure: finite-difference once with R exp(δ∧) and once with exp(δ∧) R. See which one your Jacobian matches.

Fix: pick one side for the whole solver (this series and Lecture 10 use the right) and convert with the adjoint.

The drone yaws 90°. A correction δ = (0.2, 0, 0) is meant in the body frame, but your code applies corrections on the left. What must you pass?

Chapter 7

The Jacobians of exp

Nudge the input of exp and measure how much the naive guess misses

An optimiser asks: if I nudge the vector φ by a small δ, how does the rotation exp(φ∧) move? The naive guess, exp(φ∧) exp(δ∧), is wrong unless φ and δ share an axis, because turns do not commute.

The fix is a 3 by 3 matrix. It turns a change in φ into the matching small turn of the rotation. If the turn goes on the right, the matrix is the right Jacobian Jr(φ). On the left, it is the left Jacobian Jl(φ) from Chapter 5.

Say it aloud

Exp of the hat of phi plus delta is about exp of phi-hat, times exp of the hat of J-r of phi times delta. J-r of phi equals I, minus one minus cos theta over theta squared times phi-hat, plus theta minus sine theta over theta cubed times phi-hat squared.

exp((φ + δ)∧)
exp of phi plus delta the rotation after the input vector moves by δ.
exp(φ∧)
exp of phi-hat the rotation before the nudge.
Jr(φ)
J-r of phi the right Jacobian: Jl with the sign of the phi-hat term flipped, so Jr(φ) = Jl(−φ).
δ
delta the small change of the vector φ, in radians.
In plain words

Map δ through J-r of phi, then turn by the result on the right. On the left, use Jl(φ), which equals R Jr(φ). Both tend to I as θ goes to 0.

With numbers

φ = (0, 0, π/2) and δ = (0.05, 0, 0). Jrδ = (0.032, −0.032, 0). The naive exp(φ∧) exp(δ∧) misses exp((φ + δ)∧) by 2.10°. With Jr the miss is 0.017°, a second-order leftover.

Measure the miss

The horizontal axis is the size of the nudge δ about x. The red curve is the naive guess; the purple curve uses Jr. Set the angle of φ to 0 and the two curves meet.

90°
0.05 rad

Exact maths: each miss is the angle of log(guess⊤ exp((φ + δ)∧)).

The inverse goes the other way. When the estimate moves by a small δ on the right, its log moves by Jr−1(φ) δ:

log(exp(φ∧) exp(δ∧)) ≈ φ + Jr−1(φ) δ the residual Jacobian that Lecture 10 uses

Symptom: Gauss-Newton converges slowly or zigzags when the rotations are large.

Measure: compare your analytic Jacobian with finite differences at θ = 90°.

Fix: include Jr or its inverse. The identity is right only near θ = 0.

When does exp(φ∧) exp(δ∧) equal exp((φ + δ)∧) exactly?

Chapter 8

BCH: Composing Two Turns

Compose two turns and see how much a plain sum misses

Two turns, a then b, compose to one turn c: exp(c∧) = exp(a∧) exp(b∧). For numbers, c = a + b. For turns, the Baker-Campbell-Hausdorff (BCH) formula adds correction terms. It builds them from the commutator a∧b∧ − b∧a∧, which in so(3) is the hat of a × b.

What is c to first order beyond the sum? Call the two turn vectors a and b.

Say it aloud

The log of exp a-hat times exp b-hat is about a plus b, plus one half a cross b.

log(exp(a∧) exp(b∧))
the log of the composed turn c, the single rotation vector of the product. Read right to left: b acts on a vector first.
a + b
a plus b the plain sum: right only if the turns commute.
½ a × b
one half a cross b the first correction. It is second order: the product of the two sizes.
In plain words

Add the two vectors. Then add half their cross product. What is left is third order: products of three of the turns' sizes.

With numbers

a = (0, 0, 0.5) rad and b = (0, 0.4, 0) rad. The true c is (−0.100, 0.392, 0.493). a + b = (0, 0.4, 0.5) misses it by 0.101 rad (5.8°). Adding half the cross product, (−0.1, 0, 0), cuts the miss to 0.011 rad (0.6°).

Compose two turns

Left: the warm arrows are a and b, the pink arrow is the true c, purple are the two guesses. Right: each guess's miss, in degrees. Shrink both turns and watch the misses fall at different speeds.

0.50 rad
0.40 rad

Exact maths. The left panel draws vectors twice their size so short ones show. Drag sideways to orbit.

The correction shrinks with the product of the sizes. At 5° per turn, a + b misses by 0.22°, and the BCH sum by 0.0045°. At 1°, the misses are 0.0087° and 0.000036°. So a solver that takes small steps can treat composition as addition, and one that takes big steps cannot.

When one turn is small, BCH has an exact first-order form: the inverse Jacobian of Chapter 7. With b = δ small, c ≈ a + Jr−1(a) δ.

Symptom: an IMU integrator that sums rotation vectors drifts during fast turns.

Measure: compare the summed vector with the log of the composed rotations over one second.

Fix: compose with exp and products. Use BCH to reason about the error, not to replace the product.

When is exp(a∧) exp(b∧) ≈ exp((a + b)∧) a good approximation?

Chapter 9

Showcase: Steer to a Goal Attitude

Race three solvers to a goal near 90° pitch and watch one stall

Now put it together. The drone must find a goal attitude Rgoal. It sees three known directions, so it can score any guess R. Call each direction in the body frame bi and in the world wi. The score, or cost, is half the sum over i of |R bi − wi|².

Three solvers take the same step size from the same level start. The on-manifold solver takes the slope with respect to a right perturbation and steps with exp. The Euler solver takes the slope with respect to yaw, pitch and roll. The additive solver steps the 9 matrix entries.

The on-manifold step needs the slope of the cost for a small body turn. Call the step size α (alpha) and the slope at step k gk.

Say it aloud

R-k-plus-one equals R-k times exp of minus alpha g-k-hat, where g-k equals minus the sum over i of b-i cross R-k-transpose w-i.

Rk+1
R-k-plus-one the attitude after the step.
Rk
R-k the attitude at step k; Rk⊤ brings world numbers into the body.
α
alpha the step size, 0.25 here.
gk
g-k the slope of the cost for a small body turn, a 3-vector.
Σi
the sum over i one term for each of the three directions.
bi
b-i direction i as the drone sees it, in body numbers.
wi
w-i the same direction in world numbers, from the map.
In plain words

Bring each world direction w-i into the body with R-k-transpose. Cross b-i with it, add over i and change the sign: that is g-k. Step against g-k by α, on the right, with exp.

With numbers

Goal yaw 50°, pitch 80°, roll −40°; level start, 112° away. After 30 steps the on-manifold error is below 0.0001°. Euler is stuck at 0.61°, and still at 0.48° after 60 steps. The additive solver's first step has determinant 0.48: a squashed frame, not an attitude.

Race three solvers to the goal

Left: the pink frame is the goal, purple is the chosen solver's attitude. Right: each solver's error in degrees, on a log scale, step by step. Press Run, then move the goal pitch toward 90°.

80°

Illustrative problem: three orthogonal directions, goal yaw 50° and roll −40°, step size 0.25, 30 steps. We measure the additive solver's error after projecting it to the nearest rotation. Exact maths.

Why does Euler stall? Near 90° pitch, the yaw axis and the roll axis nearly line up. The three angle directions then cover one world direction badly: its share of each step shrinks to 1 − sin θ. At 80° that is 0.015, so steps along it are about 66 times smaller.

Symptom: an attitude solver converges in 5 steps in level flight and takes hundreds when the drone points up.

Measure: log the pitch and 1/cos θ next to the iteration count.

Fix: optimise on the manifold with R exp(δ∧). Keep Euler angles for display.

A drone's attitude is R and the solver returns a body-frame step δ. Which update keeps R in SO(3) with no gimbal lock?

Chapter 10

Field Guide

Keep the maps, the conventions and the code side by side

Rotations form a Lie group: you compose them, never add them. The tangent space so(3) holds skew matrices. Hat and vee write them with three numbers. exp curves a tangent vector onto the group by Rodrigues' formula, and log brings it back the short way. SE(3) does the same with twists, where Jl bends the shift. A correction goes on the right (body) or the left (world), and the adjoint converts. Jr and Jl say how exp responds to a change of its input, and BCH says how two turns compose.

ObjectLives inNumbersMap to the nextWatch out
Rotation vector φR33hat: φ to φ∧φ and φ + 2πu are the same turn
Skew matrix φ∧so(3), tangent at I9 stored, 3 freeexp: RodriguesTaylor forms below 10−4 rad
Rotation RSO(3)9 stored, 3 freelog: trace and skew partatan2 near 0, symmetric part near π
Twist ξ = (φ, ρ)se(3)6exp: [exp(φ∧), Jlρ; 0, 1]t is Jlρ, not ρ
Pose TSE(3)16 stored, 6 freeAdT = [R, 0; t∧R, R]the block order follows the twist order

The conventions on this page

The core, as code

python
import numpy as np
from scipy.spatial.transform import Rotation

def hat(p):  return np.array([[0, -p[2], p[1]], [p[2], 0, -p[0]], [-p[1], p[0], 0]])
def vee(M):  return np.array([M[2, 1], M[0, 2], M[1, 0]])

def exp_so3(p):
    th = np.linalg.norm(p); P = hat(p)
    if th < 1e-4: A, B = 1 - th**2/6, 0.5 - th**2/24        # Taylor forms
    else:         A, B = np.sin(th)/th, (1 - np.cos(th))/th**2
    return np.eye(3) + A*P + B*P@P

def log_so3(R):
    c = (np.trace(R) - 1)/2; w = vee(R - R.T)/2; s = np.linalg.norm(w)
    th = np.arctan2(s, c)                                  # robust in [0, pi]
    if th < 1e-4: return w*(1 + th**2/6)
    if np.pi - th < 1e-3:                                # near pi: axis from the symmetric part
        B = ((R + R.T)/2 - c*np.eye(3))/(1 - c); k = np.argmax(np.diag(B))
        u = B[:, k]/np.sqrt(B[k, k]); return th*(u if u @ w >= 0 else -u)
    return th/s*w

def J_l(p):
    th = np.linalg.norm(p); P = hat(p)
    if th < 1e-4: return np.eye(3) + P/2 + P@P/6
    return np.eye(3) + (1 - np.cos(th))/th**2*P + (th - np.sin(th))/th**3*P@P
def J_r(p): return J_l(-p)

def exp_se3(xi):                                         # xi = (phi, rho), rotation first
    T = np.eye(4); T[:3, :3] = exp_so3(xi[:3]); T[:3, 3] = J_l(xi[:3]) @ xi[3:]; return T

phi = np.array([0.3, -0.2, 0.6])
assert np.allclose(exp_so3(phi), Rotation.from_rotvec(phi).as_matrix())
assert np.allclose(log_so3(exp_so3(phi)), phi)
print(exp_se3(np.r_[0, 0, np.pi/2, 1, 0, 0])[:3, 3])           # [0.6366 0.6366 0.]
d = np.array([1e-6, 0, 0])                                   # finite-difference check of J_r
fd = log_so3(exp_so3(phi).T @ exp_so3(phi + d))
assert np.allclose(fd, J_r(phi) @ d, atol=1e-11)

Where it sits

Every estimator in this series keeps a pose in SE(3) and corrects it with R exp(δ∧). Lecture 10, optimisation on manifolds, builds Gauss-Newton on these maps. Lecture 11, visual-inertial odometry, integrates the gyro with exp. Lecture 13, SLAM and factor graphs, measures every relative pose with log.

Keep going

The takeaway. Never add to a rotation. Compose with R exp(δ∧), measure with log, and carry Jr or the adjoint whenever a correction changes sides or size.

Now press Present or Teach. Explain from memory why R + δ∧ fails and derive Rodrigues from the series. Recover φ with log, bend a twist with Jl, and move a correction across R with the adjoint. Then go back to the hero and say why each wrong button misses the truth by the amount it does.

Credit

VNAV Lecture 2: Lie Groups, SO(3), SE(3) and the Exponential Map
MIT 16.485 VNAV · Previous: 3D geometry · Next: control · Back to Gleams