Lie Theory: A Visual Introduction without the Maths
A starting point to understanding Lie theory and optimisation on curved spaces with intuitive demos.
Lie Theory in a Nutshell
A Lie group is a smooth
curved space
containing "things" representing transformations, for example, rotations or poses.
We can't do optimisation and maths directly on the curved space, so we temporarily work in a flat
"tangent space", then convert the result back to the curved space.
Many resources for Lie Theory immediately go deep into mathematical details. This one won't.
Functions and Optimisation
A function takes an input, does something, and returns an
output.
We often need to optimise: find the best input that minimises some constraint (a cost function).
Let's say we have a starting guess for the best input (which is often random). Other than randomly trying different inputs, how do we actually find the optimal input?
- Perturb: Nudge the input in each of its dimensions and plug in to the cost function.
- Gradient: calculate the gradient.
- Step: update your input by taking a small step against the gradient direction.
This is easy if your function operates on Euclidean space (vectors).
Let's say the input is a vector, (a 2D point)
(x_1, x_2).
If you perturb x_1 by a tiny \delta:
you get (x_1 + \delta,\, x_2), still a perfectly valid 2D point which you can feed into your function.
Drag the input x on the grid to see the cost function output change. On the right, the cost function is shown as a surface: height is f(x). Click through the optimisation steps to see how the optimal input is found.
Optimising over a rotation
That was easy because the input was a plain vector. What if the input is a rotation? Take the simplest case — 2D rotations, like a robot's heading or a steering angle.
A 2D rotation is usually written as a matrix:
It has four numbers, but they're not independent: the columns must be unit-length and perpendicular, and the determinant must be +1. There is only one real degree of freedom: the angle \theta.
Now try to perturb each element by \delta to estimate a gradient. The result has columns that are no longer orthonormal and a determinant that is no longer 1. It is not a rotation anymore, just a 2×2 grid of numbers, which we can't feed back into our cost function.
Perturb any matrix element of a rotation matrix by dragging it to add some \delta, and it stops being a rotation. Watch as the two basis vectors stop being perpendicular and unit length — the determinant is no longer 1.
Manifolds: the shape of "all valid inputs"
Not every matrix is a rotation. In 2D, only orthogonal matrices with determinant 1 are rotations. Together they form the SO(2) Lie group. Because every such matrix is determined by a single angle, θ, we can represent the SO(2) manifold (space) as a circle in 2D, with each point on the circle representing an element of the group.
Similarly, SO(3) is the set of all 3×3 orthogonal matrices with determinant 1. These 3D rotations form a three-dimensional curved manifold. This can't be drawn directly, so we'll use a sphere to represent it.
SO(2) and SO(3) are Lie groups: they are both manifolds and groups; elements of the group can be composed (combined) together, inverted, interpolated smoothly, and include an identity element (a "do-nothing" operation).
Two manifolds side by side: the SO(2) circle and the SO(3) sphere. Drag the point on either one — each point is a group element, and the cutaway shows the coordinate frame it represents. The group Identity is shown at ε.
Tangent Space, Exp and Log maps
When working with Lie groups, we want the best of both worlds: ensure the input is always on the manifold (always a valid rotation), but do any maths in an easy-to-work-with flat (Euclidean-like) space, known as the tangent space. Every point on the manifold has a tangent space at that point. (If the manifold is a ball, imagine the tangent plane at a point on the ball.)
The tangent space at the identity element ε is called the Lie Algebra.
Two mappings (functions) connect a Lie group (manifold) to its Lie algebra (tangent space at the identity element ε), and they are inverses of each other:
- The logarithmic map converts a Lie group element X → Lie algebra element \tau^{\wedge}:
\tau^{\wedge} = \log(X). - The exponential map converts a Lie algebra element \tau^{\wedge} → Lie group element X:
X = \exp(\tau^{\wedge}).
Don't worry about the superscript \wedge for now, we'll explain it in the next section.
In this demo, press log to lift a point into the Lie algebra (tangent space at the identity ε), and exp to retract (wrap) it back onto the Lie group (manifold).
Click the log and exp map buttons to see the relationship between points on the manifold and points in the tangent space.
The Cartesian Workspace as a Proxy Tangent Space
What we'd really like is to do the tangent-space maths in a nice Euclidean space \mathbb{R}^n — where everything is a vector that you can add, subtract, and differentiate freely.
But a tangent space isn't necessarily that. Its elements can be strange objects: an element of SO(2)'s tangent space is actually an imaginary number i\theta, despite the single degree of freedom \theta. A member of SO(3)'s tangent space is actually a 3×3 skew-symmetric matrix, even though there are only 3 degrees of freedom here.
Luckily, the tangent space of a Lie group with n degrees of freedom is isomorphic to
\mathbb{R}^n — a nice one-to-one mapping with a Euclidean space (\mathbb{R}^1 for SO(2), \mathbb{R}^3 for SO(3)).
Let's call this the Cartesian Workspace. Working here is equivalent to working in the tangent space, just a lot easier so we can think of it as a proxy to the tangent space.
Since we will always work with Cartesian Workspace vectors, we just need to introduce two operators:
- hat (\cdot)^\wedge: lifts a vector in \mathbb{R}^n in the Cartesian Workspace up to the Lie algebra.
- vee (\cdot)^\vee: brings a Lie algebra element back down to a vector in \mathbb{R}^n in the Cartesian Workspace. This is the inverse of the hat operator.
Edit the Cartesian Workspace vectors on the right to see how the Lie algebra elements change. The hat (\cdot)^\wedge operator lifts vectors up onto the Lie algebra, and the vee (\cdot)^\vee operator brings Lie algebra elements back down to the Cartesian Workspace.
The Importance of Lie Groups
Lie groups, tangent spaces, and the log and exp maps underpin a huge amount of robotics optimisation:
- Pose optimisation, bundle adjustment and SLAM: solve in the tangent space, retract each step onto the manifold so poses stay valid.
- IMU / motion integration: compose small rotations smoothly via the exp map.
- State estimation: EKF/UKF on manifolds represent state and uncertainty in the tangent space.
When dealing with uncertainty over Lie groups, a Gaussian distribution is defined in the tangent space around a mean Lie group element.
Summary
Robotics and Engineering often involve dealing with mathematical objects in curved spaces known as Lie groups. Optimisation on these spaces is tricky because the objects are constrained and can't be perturbed freely.
The whole idea is to journey across three spaces. We want to optimise on the Lie group
(the curved space of valid transformations) but can't do maths there directly.
So we hop via the log map to its Lie algebra, and
then, via the vee operator, to the plain Cartesian Workspace
\mathbb{R}^n, where ordinary vector maths just works.
Do the maths there, then travel back to the Lie group using the hat operator and exp map.
Can't do maths here
but it's unwieldy
easy to work with
Make sure to read A micro Lie theory for state estimation in robotics which was an inspiration for this work.
For an application of Lie theory in robotics, see DANCeRS: A Distributed Algorithm for Negotiating Consensus in Robot Swarms.