Exercises: Lie Groups & Manifold Optimization
Chapter 09: Lie Groups, Lie Algebras, and Optimization on Manifolds
Self-assessment guide: These exercises cover the mathematical foundations of rotation, rigid-body motion, and optimization on non-Euclidean spaces — the backbone of modern robotics state estimation. Complete them in order; later exercises build directly on earlier results.
Difficulty key: ⭐ Foundational | ⭐⭐ Intermediate | ⭐⭐⭐ Advanced | ⭐⭐⭐⭐ Challenge
Section A — Group Theory Foundations
A1. ⭐ Verify whether $(\mathbb{R}^{2 \times 2}, \cdot)$ — all $2 \times 2$ real matrices under multiplication — forms a group. Check each axiom:
1. Closure
2. Associativity
3. Identity element
4. Inverse element
Which axiom fails? What minimal restriction on the set fixes it?
Answer
**Closure:** Product of two $2 \times 2$ matrices is $2 \times 2$. ✓
**Associativity:** Matrix multiplication is associative for all matrices. ✓
**Identity:** $I_2 = \begin{pmatrix}1&0\\0&1\end{pmatrix}$ satisfies $AI = IA = A$. ✓
**Inverse:** **Fails.** The zero matrix $0_{2\times 2}$ has no inverse. More generally, any singular matrix ($\det A = 0$) has no inverse.
**Fix:** Restrict to $\text{GL}(2, \mathbb{R}) = \{A \in \mathbb{R}^{2\times 2} \mid \det A \neq 0\}$, the **general linear group**. Now every element has an inverse since $A^{-1} = \frac{1}{\det A}\text{adj}(A)$ exists. Closure holds because $\det(AB) = \det(A)\det(B) \neq 0$.
A2. ⭐ Consider the set of $2\times 2$ rotation matrices $\text{SO}(2)$. Every element has the form:
$$R(\theta) = \begin{pmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{pmatrix}$$
- Show that $R(\alpha) R(\beta) = R(\alpha + \beta)$.
- What is the identity element?
- What is $R(\theta)^{-1}$?
- Name another group that $\text{SO}(2)$ is isomorphic to.
Answer
**1. Composition:**
$$R(\alpha)R(\beta) = \begin{pmatrix}\cos\alpha & -\sin\alpha \\ \sin\alpha & \cos\alpha\end{pmatrix}\begin{pmatrix}\cos\beta & -\sin\beta \\ \sin\beta & \cos\beta\end{pmatrix}$$
$$= \begin{pmatrix}\cos\alpha\cos\beta - \sin\alpha\sin\beta & -\cos\alpha\sin\beta - \sin\alpha\cos\beta \\ \sin\alpha\cos\beta + \cos\alpha\sin\beta & -\sin\alpha\sin\beta + \cos\alpha\cos\beta\end{pmatrix} = \begin{pmatrix}\cos(\alpha+\beta) & -\sin(\alpha+\beta) \\ \sin(\alpha+\beta) & \cos(\alpha+\beta)\end{pmatrix} = R(\alpha+\beta)$$
Using the angle addition formulas for sine and cosine. ✓
**2. Identity:** $R(0) = I_2$, since $\cos 0 = 1$, $\sin 0 = 0$.
**3. Inverse:** $R(\theta)^{-1} = R(-\theta) = R(\theta)^T$. This follows from $R(\theta)R(-\theta) = R(0) = I$.
**4. Isomorphism:** $\text{SO}(2) \cong (\mathbb{R}/2\pi\mathbb{Z}, +)$ — the additive group of angles modulo $2\pi$. Also isomorphic to $U(1)$, the unit complex numbers under multiplication via $e^{i\theta} \mapsto R(\theta)$.
A3. ⭐⭐ Prove that $\text{O}(n) = \{Q \in \mathbb{R}^{n\times n} \mid Q^T Q = I\}$ is a subgroup of $\text{GL}(n, \mathbb{R})$.
Then prove that $\text{SO}(n) = \{Q \in \text{O}(n) \mid \det Q = +1\}$ is a subgroup of $\text{O}(n)$.
Answer
**$\text{O}(n) \leq \text{GL}(n)$:** Use the one-step subgroup test ($H \leq G$ iff $\forall a,b \in H: ab^{-1} \in H$).
- If $Q \in \text{O}(n)$, then $\det(Q^TQ) = (\det Q)^2 = 1$, so $\det Q = \pm 1 \neq 0$, hence $Q \in \text{GL}(n)$. ✓
- $I \in \text{O}(n)$ since $I^T I = I$. ✓ (non-empty)
- Let $A, B \in \text{O}(n)$. Then $B^{-1} = B^T$, and:
$$(AB^T)^T(AB^T) = (B^T)^T A^T A B^T = B (A^T A) B^T = B I B^T = B B^T = I$$
So $AB^{-1} = AB^T \in \text{O}(n)$. ✓ ∎
**$\text{SO}(n) \leq \text{O}(n)$:**
- $I \in \text{SO}(n)$ since $\det I = +1$. ✓
- Let $A, B \in \text{SO}(n)$. Then $\det(AB^{-1}) = \det(A)\det(B^{-1}) = (+1)(+1)^{-1} = +1$. ✓
- $AB^{-1} \in \text{O}(n)$ by the above, and $\det(AB^{-1}) = +1$, so $AB^{-1} \in \text{SO}(n)$. ✓ ∎
**Group hierarchy:** $\text{SO}(n) \leq \text{O}(n) \leq \text{GL}(n, \mathbb{R})$. Each is a normal subgroup of the next ($\text{SO}(n)$ has index 2 in $\text{O}(n)$).
A4. ⭐⭐ Let $\mathfrak{so}(3) = \{\Omega \in \mathbb{R}^{3\times 3} \mid \Omega^T = -\Omega\}$ be the set of $3\times 3$ skew-symmetric matrices.
- What is the dimension of $\mathfrak{so}(3)$? Exhibit a basis.
- Define the "hat" map $(\cdot)^\wedge : \mathbb{R}^3 \to \mathfrak{so}(3)$. Show it is a linear isomorphism.
- Show that $[\omega]_\times v = \omega \times v$ for any $\omega, v \in \mathbb{R}^3$.
Answer
**1. Dimension:** A $3\times 3$ skew-symmetric matrix has the form:
$$\Omega = \begin{pmatrix}0 & -\omega_3 & \omega_2 \\ \omega_3 & 0 & -\omega_1 \\ -\omega_2 & \omega_1 & 0\end{pmatrix}$$
with 3 free parameters $(\omega_1, \omega_2, \omega_3)$. So $\dim \mathfrak{so}(3) = 3$.
**Basis:**
$$e_1^\wedge = \begin{pmatrix}0&0&0\\0&0&-1\\0&1&0\end{pmatrix}, \quad e_2^\wedge = \begin{pmatrix}0&0&1\\0&0&0\\-1&0&0\end{pmatrix}, \quad e_3^\wedge = \begin{pmatrix}0&-1&0\\1&0&0\\0&0&0\end{pmatrix}$$
These are the generators of $\text{SO}(3)$.
**2. Hat map:** $\omega = (\omega_1, \omega_2, \omega_3)^T \mapsto [\omega]_\times = \omega^\wedge$ as above. It is linear: $(\alpha\omega + \beta\eta)^\wedge = \alpha\omega^\wedge + \beta\eta^\wedge$ (direct computation). Injective: $\omega^\wedge = 0 \implies \omega = 0$. Surjective: every skew-symmetric matrix has this form. Since $\dim \mathbb{R}^3 = \dim \mathfrak{so}(3) = 3$, it is a linear isomorphism. ✓
**3. Cross-product equivalence:**
$$[\omega]_\times v = \begin{pmatrix}0 & -\omega_3 & \omega_2 \\ \omega_3 & 0 & -\omega_1 \\ -\omega_2 & \omega_1 & 0\end{pmatrix}\begin{pmatrix}v_1\\v_2\\v_3\end{pmatrix} = \begin{pmatrix}-\omega_3 v_2 + \omega_2 v_3\\ \omega_3 v_1 - \omega_1 v_3\\ -\omega_2 v_1 + \omega_1 v_2\end{pmatrix} = \omega \times v \quad \checkmark$$
A5. ⭐⭐⭐ The matrix groups $\text{GL}(n)$, $\text{O}(n)$, $\text{SO}(n)$, $\text{SL}(n)$ all have manifold structure.
- $\text{GL}(n)$ is an open subset of $\mathbb{R}^{n \times n}$. What is its dimension?
- What constraint defines $\text{O}(n)$? How many independent constraints? What is $\dim \text{O}(n)$?
- What is $\dim \text{SO}(3)$? $\dim \text{SE}(3)$?
- Why can't we parametrize $\text{SO}(3)$ globally with 3 parameters without singularities?
Answer
**1.** $\text{GL}(n)$ is defined by $\det A \neq 0$, which is an open condition. $\dim \text{GL}(n) = n^2$.
**2.** $Q^T Q = I$ gives $\frac{n(n+1)}{2}$ independent scalar constraints (the product is symmetric, so the upper triangle gives the constraints). Thus:
$$\dim \text{O}(n) = n^2 - \frac{n(n+1)}{2} = \frac{n(n-1)}{2}$$
**3.**
- $\dim \text{SO}(3) = \frac{3 \cdot 2}{2} = 3$ (same as $\text{O}(3)$, since the $\det = +1$ constraint selects a connected component, not reducing dimension).
- $\dim \text{SE}(3) = \dim \text{SO}(3) + 3 = 6$ (3 rotation + 3 translation).
**4.** This is a topological obstruction. $\text{SO}(3)$ is diffeomorphic to $\mathbb{RP}^3$ (real projective 3-space), which is **compact** and **non-contractible**. Any smooth map $\mathbb{R}^3 \to \text{SO}(3)$ that is locally a diffeomorphism must have singularities — this is the **hairy ball theorem** generalization. Euler angles hit gimbal lock; no 3-parameter representation avoids this. Quaternions use 4 parameters with one constraint ($\|q\| = 1$).
Section B — SO(2) and SO(3)
B1. ⭐ Compute the following compositions in $\text{SO}(3)$. Use the axis-angle interpretation.
- $R_x(90°) R_y(90°)$ — rotation of 90° about $x$, then 90° about $y$.
- $R_y(90°) R_x(90°)$ — same rotations in reverse order.
- Are these equal? What does this say about $\text{SO}(3)$?
Answer
**1.** Using the elementary rotation matrices:
$$R_x(90°) = \begin{pmatrix}1&0&0\\0&0&-1\\0&1&0\end{pmatrix}, \quad R_y(90°) = \begin{pmatrix}0&0&1\\0&1&0\\-1&0&0\end{pmatrix}$$
$$R_x(90°)R_y(90°) = \begin{pmatrix}0&0&1\\1&0&0\\0&1&0\end{pmatrix}$$
This is a 120° rotation about the axis $\frac{1}{\sqrt{3}}(1,1,1)^T$ (cyclic permutation of axes).
**2.**
$$R_y(90°)R_x(90°) = \begin{pmatrix}0&1&0\\0&0&-1\\-1&0&0\end{pmatrix}$$
This is a 120° rotation about $\frac{1}{\sqrt{3}}(1,-1,-1)^T$.
**3.** They are **not equal**. $\text{SO}(3)$ is a **non-abelian** group — rotation order matters. This is in contrast to $\text{SO}(2)$, which is abelian ($R(\alpha)R(\beta) = R(\alpha+\beta) = R(\beta)R(\alpha)$).
B2. ⭐⭐ Derive Rodrigues' rotation formula. Given axis $\hat{n}$ ($\|\hat{n}\| = 1$) and angle $\theta$, show that:
$$R(\hat{n}, \theta) = I + \sin\theta\,[\hat{n}]_\times + (1-\cos\theta)\,[\hat{n}]_\times^2$$
Hint: Decompose any vector $v$ into components parallel and perpendicular to $\hat{n}$.
Answer
**Decomposition:** For any vector $v$:
- Parallel component: $v_\parallel = (\hat{n}^T v)\hat{n} = \hat{n}\hat{n}^T v$
- Perpendicular component: $v_\perp = v - v_\parallel = (I - \hat{n}\hat{n}^T) v$
Rotation only affects $v_\perp$. The rotated $v_\perp$ in the plane perpendicular to $\hat{n}$ is:
$$v_\perp' = \cos\theta\, v_\perp + \sin\theta\, (\hat{n} \times v_\perp)$$
The full rotated vector:
$$Rv = v_\parallel + v_\perp' = \hat{n}\hat{n}^T v + \cos\theta(I - \hat{n}\hat{n}^T)v + \sin\theta\,[\hat{n}]_\times v$$
$$= \cos\theta\, v + (1-\cos\theta)\hat{n}\hat{n}^T v + \sin\theta\,[\hat{n}]_\times v$$
Now use the identity $\hat{n}\hat{n}^T = I + [\hat{n}]_\times^2$ (verify: $[\hat{n}]_\times^2 = \hat{n}\hat{n}^T - I$ for $\|\hat{n}\|=1$):
$$Rv = \cos\theta\, v + (1-\cos\theta)(I + [\hat{n}]_\times^2) v + \sin\theta\,[\hat{n}]_\times v$$
$$= v + \sin\theta\,[\hat{n}]_\times v + (1-\cos\theta)\,[\hat{n}]_\times^2 v$$
Therefore:
$$\boxed{R(\hat{n}, \theta) = I + \sin\theta\,[\hat{n}]_\times + (1-\cos\theta)\,[\hat{n}]_\times^2}$$
B3. ⭐⭐ Unit quaternion $q = (w, x, y, z)$ with $\|q\| = 1$ represents a rotation. Given $q_1 = \frac{1}{\sqrt{2}}(1, 0, 0, 1)$ and $q_2 = \frac{1}{2}(1, 1, 1, 1)$:
- What rotation does $q_1$ represent? (Axis and angle.)
- Compute the quaternion product $q_1 \cdot q_2$.
- Verify that $\|q_1 \cdot q_2\| = 1$.
Answer
**1.** For $q = (w, x, y, z)$, the angle is $\theta = 2\arccos(w)$ and axis is $\hat{n} = \frac{1}{\sin(\theta/2)}(x, y, z)^T$.
For $q_1 = \frac{1}{\sqrt{2}}(1, 0, 0, 1)$: $w = \frac{1}{\sqrt{2}}$, so $\theta = 2\arccos\frac{1}{\sqrt{2}} = 2 \cdot 45° = 90°$.
Axis: $\hat{n} = \frac{1}{\sin 45°}(0, 0, 1)^T = \frac{1}{1/\sqrt{2}}(0,0,1)^T = (0,0,1)^T$. So $q_1$ represents a **90° rotation about $z$**.
**2. Quaternion product** (Hamilton product):
$$q_1 q_2 = (w_1 w_2 - x_1 x_2 - y_1 y_2 - z_1 z_2,\; w_1 x_2 + x_1 w_2 + y_1 z_2 - z_1 y_2,$$
$$w_1 y_2 - x_1 z_2 + y_1 w_2 + z_1 x_2,\; w_1 z_2 + x_1 y_2 - y_1 x_2 + z_1 w_2)$$
With $q_1 = \frac{1}{\sqrt{2}}(1,0,0,1)$ and $q_2 = \frac{1}{2}(1,1,1,1)$:
$$q_1 q_2 = \frac{1}{2\sqrt{2}}(1\cdot1 - 0 - 0 - 1\cdot1,\; 1\cdot1 + 0 + 0 - 1\cdot1,\; 1\cdot1 - 0 + 0 + 1\cdot1,\; 1\cdot1 + 0 - 0 + 1\cdot1)$$
$$= \frac{1}{2\sqrt{2}}(0,\; 0,\; 2,\; 2) = \frac{1}{\sqrt{2}}(0,\; 0,\; \frac{1}{\sqrt{2}},\; \frac{1}{\sqrt{2}}) = (0, 0, \frac{1}{2}, \frac{1}{2})$$
Wait, let's redo carefully: $\frac{1}{2\sqrt{2}}(0, 0, 2, 2) = (0, 0, \frac{2}{2\sqrt{2}}, \frac{2}{2\sqrt{2}}) = (0, 0, \frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}})$.
**3. Norm:** $\|q_1 q_2\| = \sqrt{0 + 0 + \frac{1}{2} + \frac{1}{2}} = 1$ ✓
This is a general property: the product of unit quaternions is always a unit quaternion.
B4. ⭐⭐⭐ Prove the double cover property: the map $\phi: S^3 \to \text{SO}(3)$ defined by $q \mapsto R(q)$ satisfies $\phi(q) = \phi(-q)$.
Then explain why this matters for interpolation in robotics. (OKS connection: OKS AMR heading representation.)
Answer
**Proof:** The rotation matrix from a quaternion $q = (w, x, y, z)$ is:
$$R(q) = \begin{pmatrix}1-2(y^2+z^2) & 2(xy-wz) & 2(xz+wy) \\ 2(xy+wz) & 1-2(x^2+z^2) & 2(yz-wx) \\ 2(xz-wy) & 2(yz+wx) & 1-2(x^2+y^2)\end{pmatrix}$$
Every entry is **quadratic** in $(w,x,y,z)$. Replacing $q$ with $-q$ (i.e., $w\to -w, x\to -x, y\to -y, z\to -z$) does not change any entry, since $(-w)(-z) = wz$, $(-y)^2 = y^2$, etc.
Therefore $R(q) = R(-q)$: two antipodal quaternions map to the same rotation. The map is exactly 2-to-1.
**Robotics implication:** When interpolating (SLERP) between quaternions $q_0$ and $q_1$, you must check the sign: if $q_0 \cdot q_1 < 0$, negate one quaternion first, otherwise SLERP will take the long path around $S^3$ (a 270° rotation instead of 90°). On the OKS AMR, heading is stored as a quaternion $(w, 0, 0, z)$ in the $z$-plane. Failing to handle the sign ambiguity can cause the robot to spin 270° instead of 90° during a turn command — a real bug class in AMR navigation.
B5. ⭐⭐⭐ Implement SLERP (Spherical Linear Interpolation) between two quaternions. Given $q_0, q_1$ and $t \in [0,1]$:
$$\text{SLERP}(q_0, q_1, t) = q_0 \frac{\sin((1-t)\Omega)}{\sin\Omega} + q_1 \frac{\sin(t\Omega)}{\sin\Omega}$$
where $\cos\Omega = q_0 \cdot q_1$.
- What happens when $\Omega \approx 0$? How should you handle it?
- Write Python code that handles all edge cases.
- Interpolate from $q_0 = (1,0,0,0)$ (identity) to $q_1 = (0,0,0,1)$ (180° about $z$) at $t = 0.5$. What rotation does the midpoint represent?
Answer
**1.** When $\Omega \approx 0$, $\sin\Omega \approx 0$ causing division by zero. For small $\Omega$, SLERP degenerates to LERP: $\text{SLERP} \approx (1-t)q_0 + t\,q_1$, then renormalize.
**2. Python implementation:**
import numpy as np
def slerp(q0, q1, t):
"""Spherical linear interpolation between unit quaternions."""
q0 = np.asarray(q0, dtype=float)
q1 = np.asarray(q1, dtype=float)
dot = np.dot(q0, q1)
# Handle double cover: ensure shortest path
if dot < 0:
q1 = -q1
dot = -dot
dot = np.clip(dot, -1.0, 1.0)
# For nearly identical quaternions, use linear interpolation
if dot > 0.9995:
result = q0 + t * (q1 - q0)
return result / np.linalg.norm(result)
omega = np.arccos(dot)
sin_omega = np.sin(omega)
s0 = np.sin((1 - t) * omega) / sin_omega
s1 = np.sin(t * omega) / sin_omega
return s0 * q0 + s1 * q1
**3.** $q_0 = (1,0,0,0)$, $q_1 = (0,0,0,1)$. $\cos\Omega = 0$, so $\Omega = \pi/2$.
$$\text{SLERP}(q_0, q_1, 0.5) = (1,0,0,0)\frac{\sin(\pi/4)}{\sin(\pi/2)} + (0,0,0,1)\frac{\sin(\pi/4)}{\sin(\pi/2)}$$
$$= \frac{1/\sqrt{2}}{1}(1,0,0,0) + \frac{1/\sqrt{2}}{1}(0,0,0,1) = \frac{1}{\sqrt{2}}(1,0,0,1)$$
This is a **90° rotation about $z$** — exactly the midpoint between 0° and 180°. ✓
Section C — Exponential and Logarithmic Maps
C1. ⭐ Compute $\exp(\theta\, e_3^\wedge)$ where $e_3 = (0,0,1)^T$, i.e., find $\exp\begin{pmatrix}0&-\theta&0\\\theta&0&0\\0&0&0\end{pmatrix}$ by direct series expansion.
Answer
Let $\Omega = \theta\,e_3^\wedge = \theta\begin{pmatrix}0&-1&0\\1&0&0\\0&0&0\end{pmatrix}$.
Observe the powers:
- $\Omega^2 = \theta^2\begin{pmatrix}-1&0&0\\0&-1&0\\0&0&0\end{pmatrix}$
- $\Omega^3 = \theta^3\begin{pmatrix}0&1&0\\-1&0&0\\0&0&0\end{pmatrix} = -\theta^2 \Omega$
- $\Omega^4 = \theta^4\begin{pmatrix}1&0&0\\0&1&0\\0&0&0\end{pmatrix} = -\theta^2 \Omega^2$
The pattern repeats with period 4 (up to sign and power of $\theta$). Grouping the series:
$$\exp(\Omega) = I + \Omega + \frac{\Omega^2}{2!} + \frac{\Omega^3}{3!} + \cdots$$
The $(1,1)$ entry: $1 - \frac{\theta^2}{2!} + \frac{\theta^4}{4!} - \cdots = \cos\theta$
The $(1,2)$ entry: $-\theta + \frac{\theta^3}{3!} - \cdots = -\sin\theta$
The $(3,3)$ entry: $1 + 0 + 0 + \cdots = 1$
$$\exp(\theta\, e_3^\wedge) = \begin{pmatrix}\cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1\end{pmatrix} = R_z(\theta)$$
This confirms: the exponential map sends Lie algebra elements to Lie group elements. Rotation about $z$ by angle $\theta$ corresponds to the algebra element $\theta\, e_3^\wedge$.
C2. ⭐⭐ The closed-form exponential map for $\text{SO}(3)$ is:
$$\exp(\omega^\wedge) = I + \frac{\sin\theta}{\theta}\omega^\wedge + \frac{1-\cos\theta}{\theta^2}(\omega^\wedge)^2$$
where $\theta = \|\omega\|$. Show that this is equivalent to Rodrigues' formula (Exercise B2).
Answer
Write $\omega = \theta\hat{n}$ where $\hat{n} = \omega/\|\omega\|$ is the unit axis and $\theta = \|\omega\|$.
Then $\omega^\wedge = \theta\,[\hat{n}]_\times$, and $(\omega^\wedge)^2 = \theta^2 [\hat{n}]_\times^2$.
Substituting:
$$\exp(\omega^\wedge) = I + \frac{\sin\theta}{\theta}(\theta\,[\hat{n}]_\times) + \frac{1-\cos\theta}{\theta^2}(\theta^2 [\hat{n}]_\times^2)$$
$$= I + \sin\theta\,[\hat{n}]_\times + (1-\cos\theta)\,[\hat{n}]_\times^2$$
This is exactly Rodrigues' formula from B2. ✓
**Key insight:** Rodrigues' formula **is** the exponential map for $\text{SO}(3)$, expressed in terms of the unit axis $\hat{n}$ and angle $\theta$. The Lie algebra parametrization $\omega \in \mathbb{R}^3$ is the **axis-angle** vector (axis direction encodes the rotation axis, magnitude encodes the angle).
C3. ⭐⭐⭐ Derive the logarithmic map for $\text{SO}(3)$: given $R \in \text{SO}(3)$, find $\omega$ such that $\exp(\omega^\wedge) = R$.
- Show that $\theta = \arccos\frac{\text{tr}(R) - 1}{2}$.
- Show that $[\hat{n}]_\times = \frac{R - R^T}{2\sin\theta}$ when $\theta \neq 0, \pi$.
- What special handling is needed for $\theta = 0$ and $\theta = \pi$?
Answer
**1. Angle extraction:** From Rodrigues: $R = I + \sin\theta\,[\hat{n}]_\times + (1-\cos\theta)[\hat{n}]_\times^2$.
Taking the trace: $\text{tr}(R) = 3 + 0 + (1-\cos\theta)\text{tr}([\hat{n}]_\times^2)$.
Since $\text{tr}([\hat{n}]_\times^2) = -2\|\hat{n}\|^2 = -2$:
$$\text{tr}(R) = 3 - 2(1-\cos\theta) = 1 + 2\cos\theta$$
$$\boxed{\theta = \arccos\frac{\text{tr}(R) - 1}{2}}$$
**2. Axis extraction:** The skew-symmetric part of $R$:
$$R - R^T = \sin\theta\,([\hat{n}]_\times - [\hat{n}]_\times^T) + (1-\cos\theta)([\hat{n}]_\times^2 - ([\hat{n}]_\times^2)^T)$$
Since $[\hat{n}]_\times$ is skew: $[\hat{n}]_\times^T = -[\hat{n}]_\times$, and $[\hat{n}]_\times^2$ is symmetric: $([\hat{n}]_\times^2)^T = [\hat{n}]_\times^2$.
$$R - R^T = 2\sin\theta\,[\hat{n}]_\times$$
$$\boxed{[\hat{n}]_\times = \frac{R - R^T}{2\sin\theta}}$$
**3. Special cases:**
- **$\theta = 0$:** $R = I$, so $\omega = 0$. Trivial.
- **$\theta = \pi$:** $\sin\theta = 0$, formula breaks. Here $R = I + 2[\hat{n}]_\times^2 = 2\hat{n}\hat{n}^T - I$. The axis $\hat{n}$ can be extracted from the eigenvector of $R$ with eigenvalue $+1$, or from the column of $R + I$ with largest norm (then normalize). Note: $\hat{n}$ has a sign ambiguity at $\theta = \pi$.
C4. ⭐⭐⭐ The Baker-Campbell-Hausdorff (BCH) formula gives the composition in the Lie algebra:
$$\log(\exp(A)\exp(B)) = A + B + \frac{1}{2}[A,B] + \frac{1}{12}([A,[A,B]] - [B,[A,B]]) + \cdots$$
where $[A,B] = AB - BA$ is the Lie bracket.
- For $\mathfrak{so}(3)$, show that $[\omega_1^\wedge, \omega_2^\wedge] = (\omega_1 \times \omega_2)^\wedge$.
- Why does the first-order approximation $\log(\exp(A)\exp(B)) \approx A + B$ fail for large rotations?
- (OKS connection) On an AMR fusing wheel odometry rotation $\delta\theta_{\text{odom}}$ with gyroscope $\delta\theta_{\text{gyro}}$ over a timestep, when is the first-order BCH acceptable?
Answer
**1.** Let $A = \omega_1^\wedge$, $B = \omega_2^\wedge$. Using the identity for skew-symmetric matrices:
$$[\omega_1^\wedge, \omega_2^\wedge] = \omega_1^\wedge \omega_2^\wedge - \omega_2^\wedge \omega_1^\wedge$$
For $3\times 3$ skew matrices, this equals $(\omega_1 \times \omega_2)^\wedge$. (This can be verified by expanding the matrix product component-wise.)
**Physical meaning:** The Lie bracket of two infinitesimal rotations is an infinitesimal rotation about the cross-product axis. This is why angular velocities compose via cross products.
**2.** First-order BCH says $R_1 R_2 \approx \exp((\omega_1 + \omega_2)^\wedge)$. This neglects the commutator $\frac{1}{2}[\omega_1^\wedge, \omega_2^\wedge]$. For large rotations, this commutator can be significant — e.g., two 90° rotations about different axes compose to something far from a simple sum (recall B1: the result was 120°, not $90° + 90° = 180°$).
**3.** For the OKS AMR at typical update rates (100–200 Hz), per-timestep rotations are $< 1°$ ($< 0.02$ rad). The commutator term is $O(\delta\theta^2) \approx O(10^{-4})$ rad, which is negligible compared to sensor noise ($\sim 10^{-2}$ rad). So first-order BCH is safe at high IMU rates but would fail for low-rate updates or aggressive maneuvers.
C5. ⭐⭐⭐⭐ Write a numerically stable Python function that computes both $\exp: \mathfrak{so}(3) \to \text{SO}(3)$ and $\log: \text{SO}(3) \to \mathfrak{so}(3)$, handling all edge cases ($\theta \approx 0$, $\theta \approx \pi$). Verify round-trip accuracy on 10,000 random rotations.
Answer
import numpy as np
def hat(omega):
"""R^3 -> so(3): vector to skew-symmetric matrix."""
return np.array([
[0, -omega[2], omega[1]],
[omega[2], 0, -omega[0]],
[-omega[1], omega[0], 0]
])
def vee(Omega):
"""so(3) -> R^3: skew-symmetric matrix to vector."""
return np.array([Omega[2,1], Omega[0,2], Omega[1,0]])
def so3_exp(omega):
"""Exponential map: R^3 -> SO(3)."""
theta = np.linalg.norm(omega)
if theta < 1e-10:
# First-order Taylor: exp(Ω) ≈ I + Ω
return np.eye(3) + hat(omega)
K = hat(omega) / theta # unit skew matrix
return (np.eye(3)
+ np.sin(theta) * K
+ (1 - np.cos(theta)) * K @ K)
def so3_log(R):
"""Logarithmic map: SO(3) -> R^3."""
cos_theta = np.clip((np.trace(R) - 1) / 2, -1.0, 1.0)
theta = np.arccos(cos_theta)
if theta < 1e-10:
# Near identity: log(R) ≈ R - I (skew part)
return vee(0.5 * (R - R.T))
if np.abs(theta - np.pi) < 1e-6:
# Near 180°: extract axis from R + I
M = R + np.eye(3)
# Pick column with largest norm
col_norms = np.linalg.norm(M, axis=0)
k = np.argmax(col_norms)
n_hat = M[:, k] / col_norms[k]
return theta * n_hat
# General case
skew = (R - R.T) / (2 * np.sin(theta))
return theta * vee(skew)
# Verification
errors = []
for _ in range(10000):
omega = np.random.randn(3) * np.pi * np.random.rand()
R = so3_exp(omega)
omega_recovered = so3_log(R)
R_recovered = so3_exp(omega_recovered)
errors.append(np.linalg.norm(R - R_recovered, 'fro'))
print(f"Max round-trip error: {max(errors):.2e}") # Should be < 1e-12
print(f"Mean round-trip error: {np.mean(errors):.2e}")
Expected output: max error $\sim 10^{-14}$, confirming numerical stability across all rotation magnitudes.
Section D — SE(2)/SE(3) and Jacobians
D1. ⭐ The group $\text{SE}(2)$ represents rigid-body motion in the plane. Its elements are:
$$T = \begin{pmatrix} R & t \\ 0 & 1 \end{pmatrix} \in \mathbb{R}^{3\times 3}, \quad R \in \text{SO}(2),\; t \in \mathbb{R}^2$$
- Compute $T_1 T_2$ for $T_1 = (R_1, t_1)$ and $T_2 = (R_2, t_2)$.
- What is $T^{-1}$?
- (OKS connection) An OKS AMR at pose $(x_1, y_1, \theta_1)$ observes a landmark at relative position $(\ell_x, \ell_y)$ in body frame. What is the landmark's world-frame position?
Answer
**1. Composition:**
$$T_1 T_2 = \begin{pmatrix}R_1 R_2 & R_1 t_2 + t_1 \\ 0 & 1\end{pmatrix}$$
The rotation composes multiplicatively; the translation is $t_1$ plus $t_2$ **rotated into frame 1**.
**2. Inverse:**
$$T^{-1} = \begin{pmatrix}R^T & -R^T t \\ 0 & 1\end{pmatrix}$$
Verify: $T T^{-1} = \begin{pmatrix}RR^T & -RR^Tt + t \\ 0 & 1\end{pmatrix} = \begin{pmatrix}I & 0 \\ 0 & 1\end{pmatrix}$. ✓
**3.** The world-frame position is:
$$p_w = T_{\text{robot}} \begin{pmatrix}\ell_x \\ \ell_y \\ 1\end{pmatrix} = \begin{pmatrix}\cos\theta_1 & -\sin\theta_1 & x_1 \\ \sin\theta_1 & \cos\theta_1 & y_1 \\ 0 & 0 & 1\end{pmatrix}\begin{pmatrix}\ell_x \\ \ell_y \\ 1\end{pmatrix}$$
$$= \begin{pmatrix}x_1 + \ell_x\cos\theta_1 - \ell_y\sin\theta_1 \\ y_1 + \ell_x\sin\theta_1 + \ell_y\cos\theta_1 \\ 1\end{pmatrix}$$
This is the standard body-to-world transformation used in every AMR localization system.
D2. ⭐⭐ The Lie algebra $\mathfrak{se}(3)$ represents twists (infinitesimal rigid motions). A twist $\xi = (\omega, v)^T \in \mathbb{R}^6$ maps to:
$$\xi^\wedge = \begin{pmatrix}\omega^\wedge & v \\ 0 & 0\end{pmatrix} \in \mathbb{R}^{4\times 4}$$
- What is the dimension of $\mathfrak{se}(3)$?
- Write out $\xi^\wedge$ explicitly for $\xi = (0, 0, \omega_z, v_x, v_y, 0)^T$. What kind of motion does this represent?
- (OKS connection) What twist corresponds to the OKS AMR driving straight forward at speed $v$ while turning at rate $\omega$?
Answer
**1.** $\dim \mathfrak{se}(3) = 6$: 3 for angular velocity $\omega$ + 3 for linear velocity $v$.
**2.** For $\xi = (0, 0, \omega_z, v_x, v_y, 0)^T$:
$$\xi^\wedge = \begin{pmatrix}0 & -\omega_z & 0 & v_x \\ \omega_z & 0 & 0 & v_y \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0\end{pmatrix}$$
This is **planar motion** — rotation about $z$ plus translation in the $xy$-plane. The full $\text{SE}(3)$ twist reduces to an $\text{SE}(2)$ twist when $\omega_x = \omega_y = v_z = 0$.
**3.** The OKS AMR moves in the ground plane. In body frame, forward is $+x$ (or $+y$ depending on convention). For forward speed $v$ and yaw rate $\omega$:
$$\xi_{\text{OKS}} = (0, 0, \omega, v, 0, 0)^T$$
This is a screw motion: pure rotation about a point offset from the robot (the instantaneous center of rotation, at distance $r = v/\omega$ from the robot center).
D3. ⭐⭐⭐ The left Jacobian of $\text{SO}(3)$ appears when differentiating the exponential map:
$$J_l(\omega) = \frac{\partial}{\partial \delta}\exp((\omega + \delta)^\wedge)\bigg|_{\delta=0}$$
Its closed form is:
$$J_l(\omega) = I + \frac{1-\cos\theta}{\theta^2}\omega^\wedge + \frac{\theta - \sin\theta}{\theta^3}(\omega^\wedge)^2$$
- Verify that $J_l(0) = I$.
- Show that the right Jacobian satisfies $J_r(\omega) = J_l(-\omega)$.
- Why do these Jacobians matter for optimization on $\text{SO}(3)$?
Answer
**1.** As $\theta = \|\omega\| \to 0$:
- $\frac{1-\cos\theta}{\theta^2} \to \frac{1}{2}$ (L'Hôpital or Taylor)
- $\frac{\theta-\sin\theta}{\theta^3} \to \frac{1}{6}$
But $\omega^\wedge \to 0$ and $(\omega^\wedge)^2 \to 0$, so all correction terms vanish: $J_l(0) = I$. ✓
Near identity, the exponential map behaves like the identity map — small rotations in the algebra correspond directly to small rotations in the group.
**2.** $J_r(\omega) = J_l(-\omega)$:
Replace $\omega$ with $-\omega$: $\theta$ stays the same ($\|-\omega\| = \|\omega\|$), $(-\omega)^\wedge = -\omega^\wedge$, $(-\omega^\wedge)^2 = (\omega^\wedge)^2$.
$$J_l(-\omega) = I - \frac{1-\cos\theta}{\theta^2}\omega^\wedge + \frac{\theta-\sin\theta}{\theta^3}(\omega^\wedge)^2 = J_r(\omega)$$
**3.** In optimization, we perturb a rotation $R$ by a small increment $\delta\phi \in \mathbb{R}^3$:
$$R' = R \cdot \exp(\delta\phi^\wedge) \quad \text{(right perturbation)}$$
or $R' = \exp(\delta\phi^\wedge) \cdot R$ (left perturbation). When computing Jacobians of residuals $r(R)$ w.r.t. $\delta\phi$, the chain rule picks up a factor of $J_l$ or $J_r$:
$$\frac{\partial \log(R_1^{-1} R_2)}{\partial \delta\phi} = J_r^{-1}(\log(R_1^{-1} R_2))$$
Without these Jacobians, the Gauss-Newton update direction would be incorrect, causing poor convergence or divergence in pose-graph SLAM.
D4. ⭐⭐⭐ The adjoint representation of $\text{SE}(3)$ is the $6\times 6$ matrix:
$$\text{Ad}_T = \begin{pmatrix}R & 0 \\ [t]_\times R & R\end{pmatrix}$$
for $T = (R, t) \in \text{SE}(3)$.
- Show that changing the perturbation side satisfies $T \exp(\xi^\wedge) = \exp((\text{Ad}_T \xi)^\wedge) T$.
- What is $\text{Ad}_T$ for a pure translation $T = (I, t)$?
- What is $\text{Ad}_T$ for a pure rotation $T = (R, 0)$?
Answer
**1.** This is the defining property of the adjoint. Starting from $T\exp(\xi^\wedge)$, we want to "move" the perturbation to the left:
$$T\exp(\xi^\wedge) = T\exp(\xi^\wedge)T^{-1} T = \exp(T\xi^\wedge T^{-1}) T$$
The adjoint maps the algebra element: $T \xi^\wedge T^{-1} = (\text{Ad}_T \xi)^\wedge$.
Explicitly for $T = (R,t)$ and $\xi = (\omega, v)$:
$$\text{Ad}_T \xi = \begin{pmatrix}R & 0 \\ [t]_\times R & R\end{pmatrix}\begin{pmatrix}\omega \\ v\end{pmatrix} = \begin{pmatrix}R\omega \\ [t]_\times R\omega + Rv\end{pmatrix}$$
The angular part is simply rotated. The linear part includes both the rotated velocity and the velocity induced by rotating about an offset point $t$.
**2.** Pure translation $T = (I, t)$:
$$\text{Ad}_{(I,t)} = \begin{pmatrix}I & 0 \\ [t]_\times & I\end{pmatrix}$$
Angular velocity unchanged; linear velocity gains a $[t]_\times \omega$ term (like $v = \omega \times t$).
**3.** Pure rotation $T = (R, 0)$:
$$\text{Ad}_{(R,0)} = \begin{pmatrix}R & 0 \\ 0 & R\end{pmatrix}$$
Both angular and linear velocity are rotated by $R$. This is a pure frame rotation.
D5. ⭐⭐⭐⭐ Derive the perturbation model for a point observation in $\text{SE}(3)$. A camera at pose $T = (R, t)$ observes a 3D point $p$. The observation function is:
$$h(T) = R^T(p - t)$$
Compute $\frac{\partial h}{\partial \delta\xi}$ using the left perturbation model $T' = \exp(\delta\xi^\wedge) T$.
Answer
The perturbed observation:
$$h(T') = h(\exp(\delta\xi^\wedge) T) = (R')^T(p - t')$$
where $R' = \exp(\delta\phi^\wedge)R$ and $t' = \exp(\delta\phi^\wedge)t + J_l(\delta\phi)\delta\rho$.
For small $\delta\xi = (\delta\phi, \delta\rho)^T$:
$$R'^T \approx R^T(I - \delta\phi^\wedge), \quad t' \approx t + \delta\phi^\wedge t + \delta\rho$$
Substituting:
$$h(T') \approx R^T(I - \delta\phi^\wedge)(p - t - [\delta\phi]_\times t - \delta\rho)$$
$$\approx R^T(p - t) - R^T[\delta\phi]_\times(p - t) - R^T\delta\rho$$
Using $[\delta\phi]_\times q = -[q]_\times \delta\phi$:
$$h(T') \approx h(T) + R^T[p - t]_\times \delta\phi - R^T \delta\rho$$
Therefore:
$$\frac{\partial h}{\partial \delta\xi} = \begin{pmatrix}R^T[p-t]_\times & -R^T\end{pmatrix} \in \mathbb{R}^{3\times 6}$$
This Jacobian is essential for visual SLAM, where each landmark observation contributes a row to the system Jacobian. The left perturbation model keeps the Jacobian in a consistent global frame.
Section E — Manifold Optimization
E1. ⭐ In Euclidean optimization, we update $x \gets x + \Delta x$. Explain why this fails for $R \in \text{SO}(3)$, and describe the retraction-based update:
$$R \gets R \cdot \exp(\delta\phi^\wedge)$$
Why does this stay on the manifold?
Answer
**Why additive update fails:** If $R \in \text{SO}(3)$ and $\Delta R \in \mathbb{R}^{3\times 3}$, then $R + \Delta R$ is generically **not** in $\text{SO}(3)$: it won't satisfy $R^T R = I$ or $\det R = 1$. The rotation matrices form a curved surface (manifold) in $\mathbb{R}^{3\times 3}$; straight-line steps leave the surface.
**Retraction-based update:** $\exp(\delta\phi^\wedge) \in \text{SO}(3)$ for any $\delta\phi \in \mathbb{R}^3$. Since $\text{SO}(3)$ is a group, $R \cdot \exp(\delta\phi^\wedge) \in \text{SO}(3)$. The update:
1. Computes a tangent-space perturbation $\delta\phi$ (e.g., from Gauss-Newton)
2. Maps it to the group via $\exp$
3. Composes with the current estimate
This is a **retraction** — a map from the tangent space back to the manifold. The exponential map is the canonical retraction for Lie groups. Alternative cheaper retractions exist (e.g., Cayley map), but $\exp$ is geometrically exact.
E2. ⭐⭐ Formulate a simple rotation averaging problem. Given $N$ noisy rotation measurements $\tilde{R}_i \approx R_{\text{true}}$, find:
$$R^* = \arg\min_{R \in \text{SO}(3)} \sum_{i=1}^N \|\log(R^{-1}\tilde{R}_i)\|^2$$
- Write the first-order optimality condition.
- Derive the Gauss-Newton update step using the right perturbation model.
- What is the geometric interpretation of this cost function?
Answer
**1. Residual:** $r_i(R) = \log(R^{-1}\tilde{R}_i)^\vee \in \mathbb{R}^3$ (the rotation error in the tangent space).
The cost is $f(R) = \sum_i \|r_i\|^2$.
**2. Right perturbation:** $R' = R\exp(\delta\phi^\wedge)$. Then:
$$r_i(R') = \log(\exp(-\delta\phi^\wedge)R^{-1}\tilde{R}_i)^\vee \approx r_i(R) - J_r^{-1}(r_i)\delta\phi$$
Using the BCH first-order approximation for small $\delta\phi$.
The Jacobian w.r.t. $\delta\phi$: $\frac{\partial r_i}{\partial \delta\phi} = -J_r^{-1}(r_i)$.
**Gauss-Newton:** Stack residuals $r = (r_1, \ldots, r_N)^T$ and Jacobians $J$:
$$\delta\phi^* = -(J^T J)^{-1} J^T r$$
Update: $R \gets R\exp((\delta\phi^*)^\wedge)$.
For small residuals ($R$ close to $\tilde{R}_i$), $J_r^{-1} \approx I$, and the update simplifies to the **Riemannian mean**:
$$\delta\phi \approx \frac{1}{N}\sum_i \log(R^{-1}\tilde{R}_i)^\vee$$
**3. Geometric interpretation:** The cost measures the sum of squared **geodesic distances** on $\text{SO}(3)$ from $R$ to each measurement $\tilde{R}_i$. The solution $R^*$ is the **Fréchet mean** — the rotation that minimizes total squared geodesic distance, the manifold analogue of the Euclidean centroid.
E3. ⭐⭐⭐ (OKS connection) Solve a small 2D pose-graph SLAM problem on $\text{SE}(2)$. Given:
- 3 robot poses: $T_0, T_1, T_2 \in \text{SE}(2)$
- Odometry constraints: $T_0^{-1}T_1 \approx \Delta_{01}$, $T_1^{-1}T_2 \approx \Delta_{12}$
- Loop closure: $T_0^{-1}T_2 \approx \Delta_{02}$
- $T_0$ is fixed (anchor/prior)
Set up the cost function and Jacobian structure. Describe (but don't fully solve) one Gauss-Newton iteration.
Answer
**State:** $x = (x_1, y_1, \theta_1, x_2, y_2, \theta_2)^T \in \mathbb{R}^6$ (pose 0 is fixed).
**Residuals:** For each edge $(i,j)$ with measurement $\Delta_{ij}$:
$$r_{ij} = \log(T_i^{-1} T_j \cdot \Delta_{ij}^{-1})^\vee \in \mathbb{R}^3$$
This is the difference between the predicted relative pose $T_i^{-1} T_j$ and the measured $\Delta_{ij}$, expressed in the tangent space.
**Cost:** $f(x) = \sum_{(i,j)} r_{ij}^T \Omega_{ij} r_{ij}$ where $\Omega_{ij}$ is the information matrix (inverse covariance) of each measurement.
**Jacobian structure** ($9 \times 6$ system, 3 edges × 3 residual each, 2 free poses × 3 DOF):
$$J = \begin{pmatrix}\frac{\partial r_{01}}{\partial x_1} & 0 \\ 0 & 0 \\ \frac{\partial r_{01}}{\partial x_1} & \frac{\partial r_{12}}{\partial x_2} \\ 0 & 0 \\ \frac{\partial r_{02}}{\partial x_1} & 0 \\ 0 & \frac{\partial r_{02}}{\partial x_2}\end{pmatrix}$$
Wait — let me write this correctly. With perturbation model $T_i' = T_i \exp(\delta\xi_i^\wedge)$:
- $r_{01}$ depends on $\delta\xi_1$ only (pose 0 fixed).
- $r_{12}$ depends on $\delta\xi_1$ and $\delta\xi_2$.
- $r_{02}$ depends on $\delta\xi_2$ only (pose 0 fixed).
The Jacobians are $3\times 3$ blocks:
$$J = \begin{pmatrix}J_{01,1} & 0 \\ J_{12,1} & J_{12,2} \\ 0 & J_{02,2}\end{pmatrix} \in \mathbb{R}^{9 \times 6}$$
**Gauss-Newton update:**
$$H\delta\xi = -b, \quad H = J^T\Omega J, \quad b = J^T\Omega r$$
where $\Omega = \text{blkdiag}(\Omega_{01}, \Omega_{12}, \Omega_{02})$.
Solve the $6\times 6$ system for $\delta\xi = (\delta\xi_1, \delta\xi_2)$, then update:
$$T_1 \gets T_1 \exp(\delta\xi_1^\wedge), \quad T_2 \gets T_2 \exp(\delta\xi_2^\wedge)$$
This is the core algorithm of every pose-graph SLAM solver (g2o, GTSAM, Ceres). The OKS AMR uses this structure for fusing wheel odometry and lidar scan-matching constraints.
E4. ⭐⭐⭐⭐ Compare the convergence behavior of manifold Gauss-Newton vs. naive Euler-angle parametrization near gimbal lock. Consider estimating a rotation near $R_{\text{true}} = R_y(89°)$:
- In Euler angle $(Z\text{-}Y\text{-}X)$ parametrization, what happens to the Jacobian near $\beta = 90°$?
- How does the Lie algebra perturbation model avoid this issue?
- Design a numerical experiment to demonstrate the difference. Describe the setup and expected results.
Answer
**1.** In $ZYX$ Euler angles $(\alpha, \beta, \gamma)$, the angular velocity maps via:
$$\omega = \begin{pmatrix}-\sin\beta & 0 & 1 \\ \sin\gamma\cos\beta & \cos\gamma & 0 \\ \cos\gamma\cos\beta & -\sin\gamma & 0\end{pmatrix}\begin{pmatrix}\dot\alpha \\ \dot\beta \\ \dot\gamma\end{pmatrix}$$
At $\beta = 90°$, $\cos\beta = 0$, and the matrix becomes rank-2. The Jacobian $\partial r / \partial(\alpha,\beta,\gamma)$ becomes rank-deficient. The Hessian $H = J^TJ$ is singular, and the Gauss-Newton system has no unique solution. Practically: the solver diverges or oscillates.
**2.** The Lie algebra perturbation $R' = R\exp(\delta\phi^\wedge)$ works in the tangent space at the current estimate. The Jacobian $\partial r / \partial \delta\phi$ is always full-rank (3×3 and invertible) as long as the problem is locally observable. There is no special configuration analogous to gimbal lock — every rotation has a well-defined tangent space of dimension 3.
**3. Experiment design:**
# Setup: estimate R from 100 noisy rotation measurements near R_y(89°)
# Method A: Gauss-Newton in Euler angles (α, β, γ)
# Method B: Gauss-Newton with SO(3) exponential map perturbation
#
# For each method:
# - Initialize at R_y(88°)
# - Run 50 iterations
# - Track cost and step size per iteration
#
# Expected results:
# - Method A: cost oscillates or diverges after ~5 iterations
# (Hessian condition number > 10^10 near β=89°)
# - Method B: converges in 3-5 iterations to correct solution
# (Hessian condition number ~ 10^1)
#
# Vary β from 0° to 89.99° and plot condition number of H
# to show gimbal lock is a parametrization artifact.
The key insight: gimbal lock is **not** a property of rotations — it is a singularity in the **parametrization**. The manifold $\text{SO}(3)$ is perfectly smooth everywhere.
E5. ⭐⭐⭐⭐ Prove that the Gauss-Newton method on $\text{SO}(3)$ with the exponential map retraction has local quadratic convergence under standard assumptions (small residuals, full-rank Jacobian).
Hint: Show that the retraction $R \cdot \exp(\delta\phi^\wedge)$ is a second-order approximation to the geodesic, and apply the standard Gauss-Newton convergence theory in the tangent space.
Answer
**Setup:** Let $f(R) = \frac{1}{2}\|r(R)\|^2$ where $r: \text{SO}(3) \to \mathbb{R}^m$ is a smooth residual function. We use the right perturbation model.
**Step 1: Retraction quality.** The exponential map is a **second-order retraction**, meaning:
$$\text{dist}(R\exp(\delta\phi^\wedge),\; \gamma_R(\delta\phi)) = O(\|\delta\phi\|^3)$$
where $\gamma_R$ is the geodesic from $R$ in direction $\delta\phi$. This is because $\exp$ is the Riemannian exponential for the bi-invariant metric on $\text{SO}(3)$.
**Step 2: Local model.** In the tangent space $T_R\text{SO}(3) \cong \mathbb{R}^3$, define:
$$\hat{r}(\delta\phi) = r(R\exp(\delta\phi^\wedge)) = r(R) + J\delta\phi + O(\|\delta\phi\|^2)$$
where $J = \frac{\partial r}{\partial \delta\phi}\big|_{\delta\phi=0}$.
**Step 3: GN update.** The Gauss-Newton step $\delta\phi^* = -(J^TJ)^{-1}J^T r$ minimizes $\|\hat{r}_{\text{lin}}\|^2$. Standard GN theory in $\mathbb{R}^3$ gives:
$$\|\delta\phi^{k+1}\| \leq C \|\delta\phi^k\|^2$$
when the residual at the solution is small ($\|r(R^*)\| \approx 0$) and $J$ is full rank.
**Step 4: Manifold transfer.** Because the exponential retraction is second-order, the error introduced by mapping back to the manifold is $O(\|\delta\phi\|^3)$, which does not degrade the quadratic rate. Therefore:
$$d(R^{k+1}, R^*) \leq C' \cdot d(R^k, R^*)^2$$
where $d(\cdot, \cdot)$ is the geodesic distance.
**Conclusion:** Manifold Gauss-Newton inherits the local quadratic convergence of Euclidean GN, provided:
1. The retraction is second-order (exponential map qualifies)
2. Residuals at the optimum are small
3. The Jacobian is full rank
This result extends to $\text{SE}(3)$ and other Lie groups, and is the theoretical foundation for solvers like GTSAM and g2o.
Section F — Applications and Integration
F1. ⭐⭐ (OKS connection) The OKS AMR navigation estimator fuses wheel encoders (providing $\Delta\text{SE}(2)$ increments) with an IMU gyroscope (providing angular rate $\omega_z$). The discrete-time state update is:
$$T_{k+1} = T_k \cdot \exp(\xi_k^\wedge \cdot \Delta t)$$
where $\xi_k = (0, 0, \omega_z, v_x, 0, 0)^T$.
- Expand $\exp(\xi_k^\wedge \Delta t)$ for the $\text{SE}(2)$ case.
- What is the exact closed-form solution for the circular arc (constant $v_x, \omega_z$)?
- Show that the straight-line case ($\omega_z = 0$) falls out as a limit.
Answer
**1.** For planar motion, the $\text{SE}(2)$ exponential map with $\phi = \omega_z \Delta t$ and $\rho = (v_x \Delta t, 0)^T$:
$$\exp(\xi^\wedge \Delta t) = \begin{pmatrix}R(\phi) & V\rho \\ 0 & 1\end{pmatrix}$$
where $V = \frac{1}{\phi}\begin{pmatrix}\sin\phi & -(1-\cos\phi) \\ 1-\cos\phi & \sin\phi\end{pmatrix}$.
**2. Closed form:** With $\phi = \omega_z \Delta t$ and $d = v_x \Delta t$:
$$\Delta T = \begin{pmatrix}\cos\phi & -\sin\phi & \frac{d}{\phi}\sin\phi \\ \sin\phi & \cos\phi & \frac{d}{\phi}(1-\cos\phi) \\ 0 & 0 & 1\end{pmatrix}$$
This is the exact circular arc: the robot traces an arc of radius $r = v_x/\omega_z$ through angle $\phi$.
**3. Limit $\omega_z \to 0$:** As $\phi \to 0$:
- $\frac{\sin\phi}{\phi} \to 1$, $\frac{1-\cos\phi}{\phi} \to 0$
- $R(\phi) \to I$
$$\Delta T \to \begin{pmatrix}1 & 0 & d \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{pmatrix}$$
Pure forward translation by $d = v_x \Delta t$. The circular arc degenerates to a straight line, as expected. ✓
This is why the exponential map formulation is superior to naive Euler integration ($x += v\cos\theta\,\Delta t$, $y += v\sin\theta\,\Delta t$): the exact arc model has zero integration error for constant velocity, regardless of timestep.
F2. ⭐⭐⭐ Hand-eye calibration finds the unknown rigid transform $X \in \text{SE}(3)$ satisfying $AX = XB$ where $A, B$ are known motions. Given $n$ pairs $(A_i, B_i)$:
- Show that the rotation part decouples: $R_A R_X = R_X R_B$.
- Using axis-angle representations $\alpha_i = \log(R_{A_i})^\vee$ and $\beta_i = \log(R_{B_i})^\vee$, show that the rotation satisfies:
$$R_X(\beta_i - \alpha_i) = -[\alpha_i + \beta_i]_\times \cdot ?$$
Hmm, let's use a cleaner approach. Show that for each pair, $(\alpha_i + \beta_i)$ must lie in a known relationship determined by $R_X$.
- How many motion pairs are needed for a unique solution?
Answer
**1. Decoupling:** From $AX = XB$ in homogeneous form:
$$\begin{pmatrix}R_A & t_A \\ 0 & 1\end{pmatrix}\begin{pmatrix}R_X & t_X \\ 0 & 1\end{pmatrix} = \begin{pmatrix}R_X & t_X \\ 0 & 1\end{pmatrix}\begin{pmatrix}R_B & t_B \\ 0 & 1\end{pmatrix}$$
Rotation block: $R_A R_X = R_X R_B$, hence $R_X = R_A R_X R_B^{-1}$ — depends only on rotations. ✓
Translation block: $R_A t_X + t_A = R_X t_B + t_X$, i.e., $(R_A - I)t_X = R_X t_B - t_A$. This is linear in $t_X$ once $R_X$ is known.
**2. Axis-angle formulation (Tsai-Lenz approach):** From $R_A R_X = R_X R_B$, using the modified Rodrigues vectors $a_i = 2\sin(\alpha_i/2)\hat{n}_{A_i}$ and similarly for $b_i$, we obtain the linear system:
$$[\hat{a}_i + \hat{b}_i]_\times \hat{n}_X = a_i - b_i$$
where $\hat{n}_X$ is the axis of $R_X$. Each pair $(A_i, B_i)$ gives 3 equations (but rank 2). This is a linear system that can be solved by stacking multiple pairs.
**3. Minimum pairs:** Each pair provides 2 independent rotation constraints (rank of $[a+b]_\times$ is 2). We need 3 independent constraints for $R_X$ (3 DOF), so **at least 2 pairs** with non-parallel rotation axes. For $t_X$ (3 more DOF), we need $R_A - I$ to have sufficient rank, requiring at least 2 pairs with non-trivial rotation. In practice, **3+ pairs** with diverse motion directions are needed for a robust solution.
F3. ⭐⭐⭐ Design a trajectory interpolation scheme on $\text{SE}(3)$. Given keyframe poses $T_0, T_1, \ldots, T_N$ at times $t_0 < t_1 < \cdots < t_N$:
- Define SLERP interpolation between two poses $T_a, T_b$.
- Extend to cubic B-spline interpolation in the Lie algebra.
- Why is Lie algebra interpolation better than interpolating Euler angles + position separately?
Answer
**1. SE(3) SLERP:** Between $T_a$ and $T_b$ at parameter $s \in [0,1]$:
$$T(s) = T_a \cdot \exp(s \cdot \log(T_a^{-1} T_b))$$
This interpolates along the geodesic on $\text{SE}(3)$. The relative transform $\Delta = T_a^{-1} T_b$ is mapped to the Lie algebra, scaled by $s$, and applied incrementally.
**2. Cubic B-spline on $\text{SE}(3)$:** Given control poses $T_{i-1}, T_i, T_{i+1}, T_{i+2}$, the cumulative B-spline formulation:
$$T(s) = T_i \cdot \prod_{j=1}^{3} \exp(\tilde{B}_j(s) \cdot \Omega_{i+j-1})$$
where $\Omega_k = \log(T_{k-1}^{-1} T_k)$ are the inter-control-point increments in the Lie algebra, and $\tilde{B}_j(s)$ are cumulative cubic B-spline basis functions.
This produces $C^2$-continuous poses on $\text{SE}(3)$ — smooth position, velocity, and acceleration — which is critical for motion planning.
**3. Advantages over Euler angle interpolation:**
- **No gimbal lock:** Lie algebra interpolation is singularity-free.
- **Coupled rotation-translation:** The screw interpolation naturally couples rotation and translation (e.g., a helical motion stays helical), while separate interpolation can produce unnatural paths where the robot translates then rotates.
- **Geometric consistency:** SLERP on $\text{SO}(3)$ produces constant angular velocity; linear interpolation of Euler angles does not.
- **Frame invariance:** The Lie group interpolation result is independent of the choice of reference frame. Euler angle interpolation depends on the decomposition order ($ZYX$ vs $XYZ$ etc.).
F4. ⭐⭐⭐⭐ IMU preintegration on $\text{SO}(3)$. An IMU provides angular velocity $\omega_k$ at each timestep $\Delta t$. The preintegrated rotation between keyframes $i$ and $j$ is:
$$\Delta R_{ij} = \prod_{k=i}^{j-1} \exp((\omega_k - b_g)\Delta t \cdot \mathbf{1}^\wedge)$$
where $b_g$ is the gyroscope bias.
- Why preintegrate instead of integrating directly into the world frame?
- Derive the first-order bias correction: if the bias estimate changes from $\bar{b}_g$ to $\bar{b}_g + \delta b_g$, show that:
$$\Delta R_{ij}(\bar{b}_g + \delta b_g) \approx \Delta R_{ij}(\bar{b}_g) \cdot \exp\left(\frac{\partial \Delta R_{ij}}{\partial b_g}\delta b_g\right)$$
- What is the Jacobian $\frac{\partial \Delta R_{ij}}{\partial b_g}$?
Answer
**1. Why preintegrate?** Direct integration puts the IMU measurements into the world frame, which depends on the (unknown, being-optimized) poses $T_i$ and $T_j$. Every time the optimizer updates these poses, the entire IMU integration must be redone.
Preintegration computes the relative motion $\Delta R_{ij}$ in the **body frame**, which is independent of world-frame poses. When the optimizer updates $T_i$, only the residual computation changes — the preintegrated measurement is fixed. This avoids $O(N_{\text{imu}})$ re-integration per optimization iteration.
**2. First-order bias correction:**
The preintegrated rotation at the nominal bias $\bar{b}_g$:
$$\Delta R_{ij}(\bar{b}_g) = \prod_{k=i}^{j-1}\exp((\omega_k - \bar{b}_g)^\wedge \Delta t)$$
Perturbing the bias by $\delta b_g$, each factor becomes:
$$\exp((\omega_k - \bar{b}_g - \delta b_g)^\wedge \Delta t) = \exp((\omega_k - \bar{b}_g)^\wedge \Delta t) \cdot \exp(-J_r^k \delta b_g \Delta t)$$
using the BCH approximation for small $\delta b_g$. Accumulating through the product and using first-order BCH repeatedly:
$$\Delta R_{ij}(\bar{b}_g + \delta b_g) \approx \Delta R_{ij}(\bar{b}_g) \cdot \exp\left(-\left(\sum_{k=i}^{j-1} \Delta R_{kj}^T J_r^k \Delta t\right)\delta b_g\right)$$
**3. Bias Jacobian:**
$$\frac{\partial \Delta R_{ij}}{\partial b_g} = -\sum_{k=i}^{j-1} \Delta R_{(k+1)j}^T J_r((\omega_k - \bar{b}_g)\Delta t) \Delta t$$
This can be computed incrementally during the forward integration pass:
$$\frac{\partial \Delta R_{ij}}{\partial b_g} \gets \exp(-(\omega_{j-1}-\bar{b}_g)^\wedge\Delta t)^T \frac{\partial \Delta R_{i(j-1)}}{\partial b_g} - J_r^{j-1}\Delta t$$
This is exactly the approach used in GTSAM's `PreintegratedImuMeasurements` and in ORB-SLAM3's IMU initialization.
F5. ⭐⭐⭐⭐ (OKS connection) Design a mini visual-inertial odometry (VIO) pipeline for the OKS AMR. The robot has:
- A forward-facing camera (10 Hz)
- An IMU (200 Hz)
- Wheel encoders (50 Hz)
Describe the state vector, the Lie group structure of each component, the residual types, and the factor graph. Your answer should address:
- What is the state at each keyframe?
- What factors connect consecutive keyframes?
- How do wheel encoder and IMU constraints differ in their Lie group formulation?
- What is the computational complexity of one optimization step?
Answer
**1. Keyframe state** (at time $t_k$):
$$\mathcal{X}_k = \{T_k \in \text{SE}(3),\; v_k \in \mathbb{R}^3,\; b_k^g \in \mathbb{R}^3,\; b_k^a \in \mathbb{R}^3\}$$
- $T_k$: 6-DOF pose (Lie group $\text{SE}(3)$, perturbation in $\mathbb{R}^6$)
- $v_k$: velocity in world frame ($\mathbb{R}^3$, Euclidean)
- $b_k^g, b_k^a$: gyro and accelerometer biases ($\mathbb{R}^3$ each, Euclidean with random walk prior)
Total DOF per keyframe: $6 + 3 + 3 + 3 = 15$.
Plus a set of 3D landmarks $\{l_j \in \mathbb{R}^3\}$.
**2. Factors between keyframes $k$ and $k+1$:**
| Factor | Type | Residual dimension | Lie group |
|--------|------|-------------------|-----------|
| IMU preintegration | $\Delta R, \Delta v, \Delta p$ vs preintegrated | 9 | $\text{SO}(3) \times \mathbb{R}^6$ |
| Wheel odometry | $T_k^{-1}T_{k+1}$ vs encoder $\Delta$ | 3 (SE(2) only) | $\text{SE}(2) \subset \text{SE}(3)$ |
| Visual reprojection | $\pi(T_k^{-1} l_j)$ vs pixel | 2 per feature | — |
| Bias random walk | $b_{k+1} - b_k \sim \mathcal{N}(0, \Sigma_b \Delta t)$ | 6 | Euclidean |
**3. Wheel vs IMU formulation:**
- **Wheel encoders** provide planar $\text{SE}(2)$ constraints (forward velocity + yaw rate). The residual is:
$$r_{\text{wheel}} = \log_{\text{SE}(2)}(\Delta_{\text{enc}}^{-1} \cdot \Pi_{xy}(T_k^{-1} T_{k+1}))$$
where $\Pi_{xy}$ projects to the ground plane. This constrains only 3 DOF ($x, y, \theta$).
- **IMU preintegration** provides full $\text{SO}(3)$ rotation + $\mathbb{R}^3$ velocity + $\mathbb{R}^3$ position constraints with bias correction (see F4). The rotation residual lives on $\text{SO}(3)$:
$$r_R = \log(\Delta R_{ij}^T R_i^T R_j)$$
The IMU constrains all 6 pose DOF plus velocity.
**4. Computational complexity:**
With $K$ keyframes, $L$ landmarks, and $M$ total observations:
- Jacobian computation: $O(M)$ — one Jacobian per factor
- Hessian assembly: $O(M \cdot d^2)$ where $d$ is the state dimension per node
- Schur complement to eliminate landmarks: $O(K^2 L)$ per iteration
- Reduced system solve: $O(K^3 \cdot 15^3)$ — dense for sliding window, or $O(K \cdot 15^2)$ for banded structure
For a sliding window of $K = 10$ keyframes with $L = 200$ landmarks:
- Reduced system: $150 \times 150$ — trivially solvable
- Each GN iteration: $\sim 1\text{ms}$ on modern hardware
This is the architecture used by VINS-Mono, OKVIS, and similar VIO systems. For the OKS AMR, the wheel encoder factor provides a strong prior on planar motion, making the system more robust in feature-poor warehouse environments than pure visual-inertial systems.
Summary
| Section |
Topic |
Exercises |
Key Concepts |
| A |
Group Theory Foundations |
A1–A5 |
Axioms, subgroups, dimension counting, hat map |
| B |
SO(2) and SO(3) |
B1–B5 |
Rodrigues, quaternions, SLERP, double cover |
| C |
Exponential/Logarithmic Maps |
C1–C5 |
exp/log derivation, BCH, numerical stability |
| D |
SE(2)/SE(3) and Jacobians |
D1–D5 |
Twists, left/right Jacobians, adjoint, perturbation |
| E |
Manifold Optimization |
E1–E5 |
Retraction, rotation averaging, pose-graph SLAM, convergence |
| F |
Applications |
F1–F5 |
IMU preintegration, hand-eye calibration, VIO pipeline |
Difficulty distribution: ⭐ ×6 (A1, A2, B1, C1, D1, E1) | ⭐⭐ ×8 (A3, A4, B2, B3, C2, D2, E2, F1) | ⭐⭐⭐ ×10 (A5, B4, B5, C3, C4, D3, D4, E3, F2, F3) | ⭐⭐⭐⭐ ×6 (C5, D5, E4, E5, F4, F5)
OKS robotics exercises: B4 (heading double cover), D1 (body-to-world transform), E3 (pose-graph SLAM), F1 (odometry integration), F5 (VIO pipeline design).