Reference Frames
In drone control, reference frames are essential for describing relative positions and orientations. Common examples include the drone's position relative to the ground, the camera's orientation relative to the drone, and the drone's velocity relative to the surrounding air.
Choosing an appropriate reference frame greatly simplifies many calculations. For example, aerodynamic forces and torques are most naturally expressed in a body-fixed reference frame, whereas gravitational acceleration is more conveniently represented in an inertial reference frame.
Rotation Matrices
When working with multiple reference frames, we need a mathematical way to describe the orientation of one frame relative to another. This is accomplished using rotation matrices, which provide a compact and consistent way to represent rotations in both two-dimensional (2D) and three-dimensional (3D) space.
2D
To describe a drone's position, we first define an inertial frame \({\color{var(--c1)}yz}\) (1).
- Fixed to the ground, which is assumed to neither accelerate nor rotate.
However, this frame alone is not sufficient to describe the drone's attitude (orientation). We must also introduce a body-fixed frame \({\color{var(--c3)}y'z'}\) (1).
- Fixed to the drone, accelerating and rotating together with it.
The drone's attitude is defined by the orientation of the body-fixed frame \({\color{var(--c3)}y'z'}\) relative to the inertial frame \({\color{var(--c1)}yz}\). This relationship can be represented mathematically by a \(2 \times 2\) matrix called the rotation matrix \(R\):
Although it contains four elements, this matrix can be completely described by a single parameter: the rotation angle \(\phi\).
Exercise 4.1
Consider a body-fixed frame \({\color{var(--c3)}y'z'}\) rotated by an angle \(\phi\) with respect to the inertial frame \({\color{var(--c1)}yz}\).
a) Write the rotation matrix as a function of the angle \(\phi\).
b) Compute \(R(\phi)\) for \(\phi=\frac{\pi}{2}\,\text{rad}\) and interpret the result.
As expected, after a \(90^\circ\) rotation, the \({\color{var(--c3)}y'}\) axis aligns with the \({\color{var(--c1)}z}\) axis, while the \({\color{var(--c3)}z'}\) axis points in the opposite direction of the \({\color{var(--c1)}y}\) axis.
c) Determine the angle \(\phi\) corresponding to the rotation matrix
\(R(\phi)=\begin{bmatrix}\frac{\sqrt{2}}{2}&\frac{\sqrt{2}}{2}\\-\frac{\sqrt{2}}{2}&\frac{\sqrt{2}}{2}\end{bmatrix}\).
3D
As in the two-dimensional case, the drone's attitude in three-dimensional space is defined by the orientation of the body-fixed frame \({\color{var(--c3)}x'y'z'}\) relative to the inertial frame \({\color{var(--c1)}xyz}\).
Since we are now working in three dimensions, the rotation matrix \(R\) becomes a \(3 \times 3\) matrix:
Leonhard Euler showed that any orientation in three-dimensional space can be represented by three successive rotations about predefined, mutually orthogonal axes (1). As a result, the nine elements of the rotation matrix can be expressed in terms of just three parameters: the Euler angles \(\phi\), \(\theta\), and \(\psi\).
- That is, the three axes are perpendicular to one another.
Exercise 4.2
Consider a body-fixed frame \({\color{var(--c3)}x'y'z'}\) rotated by an angle \(\phi\) about the \({\color{var(--c1)}x}\) axis with respect to the inertial frame \({\color{var(--c1)}xyz}\).
a) Write the rotation matrix as a function of the angle \(\phi\).
b) Compute \(R_x(\phi)\) for \(\phi=\pi\,\text{rad}\) and interpret the result.
The result is what we would expect. A \(180^\circ\) rotation about the \({\color{var(--c1)}x}\) axis reverses the \({\color{var(--c1)}y}\) and \({\color{var(--c1)}z}\) axes. Consequently, the \({\color{var(--c3)}y'}\) and \({\color{var(--c3)}z'}\) axes point in the opposite directions of \({\color{var(--c1)}y}\) and \({\color{var(--c1)}z}\), while the \({\color{var(--c3)}x'}\) axis remains aligned with \({\color{var(--c1)}x}\).
Exercise 4.3
Consider a body-fixed frame \({\color{var(--c3)}x'y'z'}\) rotated by an angle \(\theta\) about the \({\color{var(--c1)}y}\) axis with respect to the inertial frame \({\color{var(--c1)}xyz}\).
a) Write the rotation matrix as a function of the angle \(\theta\).
b) Compute \(R_y(\theta)\) for \(\theta=\frac{\pi}{2}\,\text{rad}\) and interpret the result.
This agrees with the geometric interpretation. After a \(90^\circ\) rotation about the \({\color{var(--c1)}y}\) axis, the \({\color{var(--c3)}x'}\) axis points in the opposite direction of \({\color{var(--c1)}z}\), while the \({\color{var(--c3)}z'}\) axis aligns with \({\color{var(--c1)}x}\). The \({\color{var(--c3)}y'}\) axis remains aligned with \({\color{var(--c1)}y}\).
Exercise 4.4
Consider a body-fixed frame \({\color{var(--c3)}x'y'z'}\) rotated by an angle \(\psi\) about the \({\color{var(--c1)}z}\) axis with respect to the inertial frame \({\color{var(--c1)}xyz}\).
a) Write the rotation matrix as a function of the angle \(\psi\).
b) Compute \(R_z(\psi)\) for \(\psi=2\pi\,\text{rad}\) and interpret the result.
This confirms the expected orientation of the axes. A full \(360^\circ\) rotation about the \({\color{var(--c1)}z}\) axis returns the body-fixed frame \({\color{var(--c3)}x'y'z'}\) to exactly the same orientation as the inertial frame \({\color{var(--c1)}xyz}\). In other words, all three axes coincide once again.
Properties
Rotation matrices satisfy several important properties:
- Each row and each column has unit norm (i.e., a length of 1).
- Rows and columns are mutually orthogonal (their dot product is zero).
- They are orthogonal matrices, meaning that their inverse is equal to their transpose: $$ R^{-1}=R^T $$
- Their determinant is equal to one: $$ \det(R)=1 $$
Exercise 4.5
Consider the rotation matrix \(R\) relating the body-fixed frame \({\color{var(--c3)}x'y'z'}\) to the inertial frame \({\color{var(--c1)}xyz}\):
Compute the inverse rotation matrix \(R^{-1}\), which relates the inertial frame \({\color{var(--c1)}xyz}\) to the body-fixed frame \({\color{var(--c3)}x'y'z'}\).
Solution
Euler Angles
Euler angles are a set of three successive rotations about distinct axes that transform the inertial frame \({\color{var(--c1)}xyz}\) into the body-fixed frame \({\color{var(--c3)}x'y'z'}\).
In this course, we will use what is called the yaw-pitch-roll sequence:
- \(\psi\): rotation about the \({\color{var(--c3)}z'}\) axis (yaw)
- \(\theta\): rotation about the \({\color{var(--c3)}y'}\) axis (pitch)
- \(\phi\): rotation about the \({\color{var(--c3)}x'}\) axis (roll)
The overall rotation matrix is obtained by multiplying(1) the three individual rotation matrices:
- Notice that the first rotation applied, \(R_z(\psi)\), appears on the right, whereas the last rotation, \(R_x(\phi)\), appears on the left. This is because matrix multiplication follows the reverse order of the applied transformations.
Exercise 4.6
Determine the overall rotation matrix \(R(\phi,\theta,\psi)\) relating the body-fixed frame \({\color{var(--c3)}x'y'z'}\) to the inertial frame \({\color{var(--c1)}xyz}\) as a function of the Euler angles \(\phi\), \(\theta\), and \(\psi\).
Hint: Use MATLAB's Symbolic Math Toolbox.
Solution
Singularities
A singularity is a configuration in which a mathematical representation becomes undefined or loses a degree of freedom. For Euler angles, this occurs when a single orientation can be represented by more than one combination of rotation angles.
In the yaw-pitch-roll convention, when the second rotation is equal to \(\theta=\frac{\pi}{2}~\text{rad}\), the axes of the first and third rotations become aligned, making it impossible to uniquely determine the yaw angle \(\psi\) and the roll angle \(\phi\). This phenomenon is commonly known as gimbal lock.
There is no single universally accepted Euler-angle convention. In fact, there are twelve possible rotation sequences(1), since each successive rotation must be performed about a different axis from the previous one, as summarized below:
- The yaw–pitch–roll convention adopted in this course is only one of them.
| Notation | 1st rotation axis | 2nd rotation axis | 3rd rotation axis |
|---|---|---|---|
| \( x\!-\!y\!-\!x \) | \( x' \) | \( y' \) | \( x' \) |
| \( x\!-\!y\!-\!z \) | \( z' \) | ||
| \( x\!-\!z\!-\!x \) | \( z' \) | \( x' \) | |
| \( x\!-\!z\!-\!y \) | \( y' \) | ||
| \( y\!-\!x\!-\!y \) | \( y' \) | \( x' \) | \( y' \) |
| \( y\!-\!x\!-\!z \) | \( z' \) | ||
| \( y\!-\!z\!-\!y \) | \( z' \) | \( y' \) | |
| \( y\!-\!z\!-\!x \) | \( x' \) | ||
| \( z\!-\!x\!-\!z \) | \( z' \) | \( x' \) | \( z' \) |
| \( z\!-\!x\!-\!y \) | \( y' \) | ||
| \( z\!-\!y\!-\!z \) | \( y' \) | \( z' \) | |
| \( z\!-\!y\!-\!x \) | \( x' \) |
Every rotation sequence has singularities, the only difference is the orientation at which they occur.
-
When the first and third rotation axes are the same(1), the singularity occurs when the second rotation is equal to \(0~\text{rad}\).
- These are known as proper Euler angles.
-
When the first and third rotation axes are different(1), the singularity occurs when the second rotation is equal to \(\frac{\pi}{2}~\text{rad}\).
- These are technically Tait–Bryan angles, although in practice they are often referred to simply as Euler angles.
Since a drone's nominal hovering attitude corresponds to a second rotation angle of approximately \(0~\text{rad}\), conventions in which the first and third rotation axes are different are preferred. This way, the singularity is far from the normal operating region, although it can still occur during aggressive maneuvers.
An alternative orientation representation that avoids singularities is the quaternion representation.