Quaternion Averaging
Quaternion Averaging
Why not just average the numbers?
- The arithmetic mean of unit quaternions isn't a unit quaternion.
- Double cover: and are the same rotation but average to 0.
- Even after normalising, it's not the rotation that minimises the squared rotation errors.
Gradient-descent (intrinsic) mean
Find that minimises . Kraft's iteration:
q̄ ← initial guess (e.g. previous estimate propagated by ω·dt)
repeat:
e_i = log(q_i ⊗ q̄⁻¹) for every sigma point (error rotation vectors)
ē = mean(e_i)
q̄ ← exp(ē) ⊗ q̄
until ‖ē‖ < tol (or max iterations)
At convergence, the final are exactly the orientation part of the error vectors used for the covariance — no extra work needed.
flowchart LR
A["guess q̄"] --> B["e_i = log(q_i ⊗ q̄⁻¹)"]
B --> C["ē = mean e_i"]
C --> D["q̄ ← exp(ē) ⊗ q̄"]
D -->|"‖ē‖ ≥ tol"| B
D -->|"‖ē‖ < tol"| E["done: q̄, {e_i}"]
Convergence: sigma points are close together (a few degrees), so it's nearly linear and converges in 2–4 iterations from a good guess. A good guess matters: the original started from the first sigma point (already offset by a whole σ) and had no iteration cap. → bug #7
Alternative: eigenvector method (Markley 2007)
Closed form, sign-invariant (since ), minimises a chordal rather than geodesic distance. Nearly identical for tightly clustered points. Handy for a quick sanity check:
M = (w[:, None, None] * qs[:, :, None] * qs[:, None, :]).sum(0)
q_bar = np.linalg.eigh(M)[1][:, -1]
Next: Quaternion UKF (Kraft)