Reference frames and transformations

Contents

Motivation

Say you want to design a localization system for a ground robot equipped with wheel encoders, an IMU, and a Lidar. The goal of the navigation system is to estimate the robot's pose (i.e., displacement and orientation) resolved in the world frame (i.e., as seen by an observer in the world looking at the robot). To do that, the navigation system would need to resolve the sensor measurements (e.g., lidar measurements) in the robot frame. In other words, the system should transform the measurements from the sensor frame to the robot frame. This requires using transformations, which can be parametrized as transformation matrices, which in turn are a relation between two coordinate systems.

 A robot equipped with multiple sensors.
A robot equipped with multiple sensors.

This blog serves as a very lightweight intro to the notion of reference frames and transformations that link frames and displacements together.

Reference frames

I've been talking about reference frames and transforms without giving them a proper introduction. So, I'll try to give a clearer intro to these concepts, and I'll use visuals to help me with this intro. Refer to [1][2] for more info on frames and transforms.

A reference frame, denoted F\mathcal{F}, is a set of orthogonal physical unit vectors. The frame can be attached to a rigid body such that it rotates with the rigid body. However, the reference frame does not have a notion of "position" or "displacement", which could be a confusing concept, especially that it's common to refer to a frame's "origin" (e.g., ROS' tf library). What's usually meant to be communicated is "the displacement of some point aa with respect to another point bb, resolved in frame Fa\mathcal{F}_{a}".

For example, the vector from point ww to point pp is represented using a physical vector rpw\underrightarrow{r}^{pw}.

 Physical vector in the physical space.
Physical vector in the physical space.

To make sense of the physical vector rpw\underrightarrow{r}^{pw}, a reference frame needs to be defined in which the physical vector can be resolved. Let's define an arbitrary frame Fa\mathcal{F}_{a} and resolve the physical vector. The physical vector rpw\underrightarrow{r}^{pw} resolved in frame Fa\mathcal{F}_{a} is denoted by rapw\mathbf{r}^{pw}_{a}, as seen below.

 Physical vector resolved in an arbitrary frame.
Physical vector resolved in an arbitrary frame.

As mentioned previously a frame does not have a position. For example, let's define another frame Fa\mathcal{F}_{a'} that is aligned (i.e., the arrows are in the same direction) with frame Fa\mathcal{F}_{a} but is visualized as if it was displaced. Then the vector rpw\underrightarrow{r}^{pw} resolved in frame Fa\mathcal{F}_{a'}, rapw\mathbf{r}^{pw}_{a'} has the same value as rapw\mathbf{r}^{pw}_{a}.

 A frame does not have a notion of position.
A frame does not have a notion of position.

However, if the two frames are misaligned (i.e., the vectors are pointing in different directions), then the resolved values (i.e., the coordinates are different). For example, defining a frame Fb\mathcal{F}_{b} that has its x-axis aligned with the physical vector rpw\underrightarrow{r}^{pw} will have different coordinates than rapw\mathbf{r}^{pw}_{a}.

 The resolved vector coordinates are different if the two frames are misaligned.
The resolved vector coordinates are different if the two frames are misaligned.

The frames Fa\mathcal{F}_{a} and Fb\mathcal{F}_{b} are related to one another through a rotation matrix, also known as a direction cosine matrix (DCM)[3]. The rotation matrix Cab\mathbf{C}_{ab} consists of the vectors of the frame Fb\mathcal{F}_{b} resolved in the frame Fa\mathcal{F}_{a}. For the given example above, the matrix is given by

Cab=[cos(θba)sin(θba)sin(θba)cos(θba)], \mathbf{C}_{ab} = \begin{bmatrix} \cos(\theta_{ba}) & -\sin(\theta_{ba})\\ \sin(\theta_{ba}) & \cos(\theta_{ba}) \end{bmatrix},

where θba\theta_{ba} is the angle from frame Fa\mathcal{F}_{a} to frame Fb\mathcal{F}_{b}. For the example above, the angle is θba=tan1(1/2)\theta_{ba} = \tan^{-1}(1 / 2).

The rotation matrix is useful because it can be used to relate the coordinates of a physical vector resolved in different frames. For example,

rapw=Cabrbpw. \mathbf{r}^{pw}_{a} = \mathbf{C}_{ab} \mathbf{r}^{pw}_{b}.

Transformations

The rotation matrices are useful to relate vector coordinates resolved in different frames. However, sometimes we're interested in more than just resolving the vector in a different frame. Specifically, we're sometimes interested in having the displacement be with respect to another point, resolved in a different frame.

For example, say we have the coordinates rapw\mathbf{r}^{pw}_{a}.

Furthermore, say we're interested in having the coordinates of rbpz\mathbf{r}^{pz}_{b}. That is, the displacement of the point pp with respect to point zz, resolved in frame Fb\mathcal{F}_{b} (i.e., the green arrow in the gray blow).

Then, what is the relation between rapw\mathbf{r}^{pw}_{a} and rbpz\mathbf{r}^{pz}_{b}?

The relationship is given by

rapw=Cabrbpz+razw, \mathbf{r}^{pw}_{a} = \mathbf{C}_{ab} \mathbf{r}^{pz}_{b} + \mathbf{r}^{zw}_{a},

which can be written compactly as

[rapw1]=[Cabrazw01]Tabzw[rbpz1], \begin{bmatrix} \mathbf{r}^{pw}_{a} \\ 1 \end{bmatrix} = \underbrace{ \begin{bmatrix} \mathbf{C}_{ab} & \mathbf{r}^{zw}_{a} \\ \mathbf{0} & 1 \end{bmatrix} }_{\mathbf{T}^{zw}_{ab}} \begin{bmatrix} \mathbf{r}^{pz}_{b} \\ 1 \end{bmatrix},

where Tabzw\mathbf{T}^{zw}_{ab} is known as a transformation matrix, and [r1]T\begin{bmatrix}\mathbf{r} & 1\end{bmatrix}^{\mathsf{T}} is known as a homogenous coordinate. The notation is summarized in the following figure.

Applications

Transformation matrices, and transformations in general are quite important in many fields that use kinematics such as aerospace, robotics, vehicles, and many others. The reason they are important is because there are often multiple important frames on a robot.

For example, sensor data (e.g., lidar) are resolved in the sensor frame. However, robotic systems, such as the navigation system, would require the sensor data be resolved in the body frame. As such, the transformation matrices between these frames are important for such a system.

 A robot is usually equipped with multiple frames. Usually each sensor has its own frame.
A robot is usually equipped with multiple frames. Usually each sensor has its own frame.

These transformation matrices are often estimated using calibration processes, often referred to as extrinsic calibration.

Concluding remarks

This blog was intended to be a light-weight introduction to the applications of reference frames and transformation matrices. Transformations are an important part of any robotic system with multiple frames, so it's important to have a good understanding of it. This blog lacks the depth for deep understanding of these concepts. As such, I've provided some references for further readings for the interested readers.

Further readings

The rotation matrices and transformation matrices fall under a special mathematical structure known as a matrix Lie group. Specifically, the rotation matrices fall under the special orthogonal group, whereas the transformation matrices fall under the special Euclidean group. A very good introduction to Lie groups for robotics is presented by Sola[4].

For a more thorough and a more solid intro to reference frames, Lie groups, and robotics in general, Barfoot's book is quite something[3].

References

[1] Representing Robot Pose: The good, the bad, and the ugly
[2] Reducing the uncertainty about the uncertainties, part 2: Frames and manifolds
[3] State Estimation for Robotics
[4] A micro Lie theory for state estimation in robotics