Multirotor Drones: Chapter 0
1. Prerequisites
-
Basic Mathematics
- trigonometry
- linear algebra (vectors, matrices and basic matrix operations)
-
Kinematics
- coordinate transformations and rotation matrices
-
Dynamics
Analysis of forces and their effects on motion, crucial for modeling and simulating drone behavior. -
PID Control
Basics of Control Theory. Stability, Controllability etc. -
Model Predictive Control (MPC)
In the last chapter we will use mpc to control the drone. Previous knowledge is needed. -
Sensors and Sensing
Understanding the role of sensors like IMUs, GPS, and cameras in perceiving the environment and providing feedback for control. Have an idea about sensor fusion algorithms, especially the Kalman Filter.
2. General Motivation
Since the 2000’s market for consumer quadcopters grows in a high speed. While the first available drones were difficult to control and tend to crash, nowadays the average multicopter on the market is highly performant, offers a great stability and is easy to control.
This module about multicopters aims to provide you with the tools to model, simulate and control a multirotor drone. For the sake of simplicity all the steps will be shown on a quadcopter but are extendable to other multirotor drone configurations. At the end of the module there is a big simulation exercise where you will need to control a drone to fly through gates as fast as possible. For this we will introduce the mathematical language for drone modeling to then later model a drone, derive the dynamics of a drone and finally present control strategies.
This page will establish the different reference frames needed to describe the position of a drone in 3D space and give a short refresher on how rotations in the 3d space are described mathematically.
Chapter 0 : Mathematical tools for modelling and control of UAV’s
Coordinate System
In order to control a drone we need to describe the position and orientation of the drone relative to a fixed frame. In this module we use the ENU convention which is standard in robotics.
The world-fixed frame or also inertial frame is a coordinate frame fixed at an arbitrary point on the ground (i.e. ground station or take-off point) and has the x-axis pointing East, the y-axis pointing North and the z-axis pointing up.
For the rest of this module we will refer to this frame as the world frame and denote $\mathcal{W}$ or ${W}$ with its axes $\mathbf{x}_W$, $\mathbf{y}_W$, and $\mathbf{z}_W$.
The body frame $\mathcal{B}$ or ${B}$ is a right-handed coordinate system fixed on the drone, typically located at its center of mass. Using the FLU convention it has the x-axis pointing forward to the nose/head, y-axis to the left and the z-axis pointing upwards. We denote them with $\mathbf{x}_B$, $\mathbf{y}_B$, and $\mathbf{z}_B$.
Illustration of reference frames used in this module. The body frame is fixed on the drone while the world frame is fixed on the ground.
For rotations of the drones we use the following convention:
- Roll angle $\phi$ describes a rotation around the $\mathbf{x}_B$ axis.
- Pitch angle $\theta$ describes a rotation around the $\mathbf{y}_B$ axis.
- Yaw angle $\psi$ describes a rotation around the $\mathbf{z}_B$ axis.
The positive direction of the angles are defined using the right-hand-rule.
Attitude Representation
The attitude is the orientation of the drone in the 3D space. We describe the orientation of the body frame $\mathcal{B}$ relative to the world frame $\mathcal{W}$ using a rotation. Below we will briefly describe three methods to do so for a drone: rotation matrices, Euler angles and quaternions.
Rotation Matrices
Rotation matrices provide the most fundamental and mathematically rigorous way to describe the orientation of a rigid body in a different frame. They are explained in more detail in the fundamental chapter about kinematics.
A Rotation Matrix $R\in \mathbb{R}^{3 \times 3}$ is a transformation that, when multiplied by a vector expressed in the body frame, yields the coordinates of that same vector expressed in the world frame. We will denote it by $R_\mathcal{B}^\mathcal{W}$.
If for instance $\mathbf{p}_B$ is a point measured in the body frame and $\mathbf{p}_W$ is the same point expressed in the world frame, the transformation is:
To construct the rotation matrix $R_\mathcal{B}^\mathcal{W}$ you simply express the basis vectors of the body frame ( $\mathbf{x}_B$, $\mathbf{y}_B$, $\mathbf{z}_B$) which then correspond to the columns of the rotation matrix:
Drawbacks: While rotation matrices are mathematically complete, easy to use and simple to understand they have one big draw back which is the redundancy. They need 9 parameters to represent only three degrees of freedom which makes them computationally expensive.
Euler Angles
A more intuitive and compact way to express a rotation is with the euler angles. This representation uses three sequential rotations around the principal axes: roll, pitch and yaw.
The order in which these three rotations are applied matters. Rotating 90° in roll and then 90° in pitch results in a different final orientation than pitch and then roll. In robotics the standard convention is the $RPY$ sequence:
- Rotate around the $\mathbf{x_1}$-axis (roll, $\psi$)
- Rotate around the intermediate $\mathbf{y_2}$-axis (pitch, $\theta$)
- Rotate around the final $\mathbf{z_3}$-axis (yaw, $\psi$)
Euler angles describe a sequence of rotations around the three principal axes. First the yaw-rotation around the z-axis, then a pitch rotation around th y-axis and finally a roll rotation around the x-axis are applied.
The total rotation matrix $R_\mathcal{B}^\mathcal{W}$ is the product of the three individual elementary rotations:
$$ R_{tot} = R_\mathcal{B}^\mathcal{W} = R_\psi R_\theta R_\phi $$
where the elementary rotations are:
Singularities:
When using Euler angles you encounter singularities: some attitudes do not have an unique Euler angle representation. For a pitch angle of $\theta = \pm \pi/2$ there are infinite many RPY angles representing the same attitude. Mathematically the following product produces the same rotation matrix for any choice of $\delta$:
This phenomena is called Gimbal lock. Furthermore it is proven that no 3 parameter representation can be free of singularities. They occur whenever the second Euler angle aligns the first and third rotation axes causing the loss of a degree of freedom.
Unit Quaternions
To overcome singularities of euler angles and the redundancy of rotation matrices, a fourth parameter is sufficient. Unit quaternions integrate the idea to rotate an angle $\alpha$ around an arbitrary axis $\mathcal{v}$.
A quaternion $\mathbf{q}$ extends complex numbers into four dimensions. It consists of a scalar part $q_w$ (sometimes denoted $q_0$) and a vector part $\mathbf{q}_v = [q_x, q_y, q_z]^T$:
$$ \mathbf{q} = q_x i + q_y j + q_z k + q_w= \begin{bmatrix} \mathbf{q}_v \\ q_w \end{bmatrix} $$
The basis elements $i, j, k$ satisfy the fundamental Hamilton’s rule: $i^2 = j^2 = k^2 = ijk = -1$.
If a point rotates by an angle $\alpha$ around a unit axis unit vector $\mathbf{v} = [v_x, v_y, v_z]^T$, the corresponding quaternion is:
$$ \mathbf{q} = \begin{bmatrix} \mathbf{v} \sin(\alpha/2) \\ \cos(\alpha/2) \end{bmatrix} = \begin{bmatrix} v_x \sin(\alpha/2) \\ v_y \sin(\alpha/2) \\ v_z \sin(\alpha/2) \\ \cos(\alpha/2) \end{bmatrix} $$
Rotating a Vector To rotate a vector $\mathbf{p}_B$ (point in body frame) to $\mathbf{p}_W$ (world frame) using quaternions, we first treat the vector $\mathbf{p}$ as a “pure quaternion” (where the scalar part is 0).
The rotation is performed using the Hamilton product (denoted by $\otimes$) and the conjugate $\mathbf{q}^*$:
Where the conjugate is $\mathbf{q}^* = [-\mathbf{q}_v, q_w]^T$.
The Hamilton Product:
The Hamilton product of two quaternions $\mathbf{q}$ and $\mathbf{p}$ is determined by the distributive law and the fundamental rules of the basis elements:
By expanding the product $\mathbf{q} \otimes \mathbf{p} = (q_w + q_x i + q_y j + q_z k)(p_w + p_x i + p_y j + p_z k)$, we obtain:
Compact Vector Form:
A more concise way to express this product is using the scalar and vector parts. Given $\mathbf{q} = [\mathbf{q}_v, q_w]^T$ and $\mathbf{p} = [\mathbf{p}_v, p_w]^T$:
This vector form is particularly useful for implementation in code.
Composition of Rotations
Unlike Euler angles, composing rotations with quaternions is straightforward and computationally efficient. If we have a rotation $\mathbf{q}_1$ followed by a rotation $\mathbf{q}_2$, the total rotation is simply the product of the two quaternions:
Drawbacks:
- Double Cover: The quaternions $\mathbf{q}$ and $-\mathbf{q}$ represent the exact same rotation. This can cause control issues if the controller tries to take the “long way around” to get to the negative quaternion.
- Visualization: Unlike Euler angles ($30^\circ$ roll), quaternions are not human-readable. You cannot look at $[0.707, 0, 0.707, 0]$ and immediately visualize the orientation without calculation.
Due to these two points we will continue to use rotation matrices for the rest of this module. Quaternions remain nevertheless a powerful mathematical tool.
Are more compact and mathematically more interesting way of representing these transformations are with the use of
Exercises
Exercise 1: Prove that the following expression is indeed independent of $\delta$:
Solutions
Exercise 1: Let us proceed by inspection and compute the product $R_z(\delta) R_y(\pi/2)$. Recalling that $\psi, \theta, \phi$ correspond to rotations around $z, y, x$:
$$ R_z(\delta) R_y(\pi/2) = \begin{bmatrix} \cos(\delta) & -\sin(\delta) & 0 \\ \sin(\delta) & \cos(\delta) & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ -1 & 0 & 0 \end{bmatrix} = \begin{bmatrix} 0 & -\sin(\delta) & \cos(\delta) \\ 0 & \cos(\delta) & \sin(\delta) \\ -1 & 0 & 0 \end{bmatrix} $$
Now doing the overall multiplication with the third matrix $R_x(\alpha + \delta)$:
Using the trigonometric difference identities $\sin(A-B)$ and $\cos(A-B)$, where $A=(\delta+\alpha)$ and $B=\delta$:
$$ \begin{bmatrix} 0 & \sin((\delta + \alpha) - \delta) & \cos((\delta + \alpha) - \delta) \\ 0 & \cos((\delta + \alpha) - \delta) & -\sin((\delta + \alpha) - \delta) \\ -1 & 0 & 0 \end{bmatrix} = \begin{bmatrix} 0 & \sin(\alpha) & \cos(\alpha) \\ 0 & \cos(\alpha) & -\sin(\alpha) \\ -1 & 0 & 0 \end{bmatrix} $$
The result is independent from $\delta$, proving the claim.
Exercise 2:
Imagine a mapping drone flying horizontally over a field to map crops. A 3D camera is rigidly mounted on the drone’s body to point straight down. We detect a Point of Interest (POI) in the camera’s frame ($\mathcal{C}$) and want to find its global position in the World Frame ($\mathcal{W}$) to create a map of the field.
Camera Reference Frame Definition ($\mathcal{C}$):
The camera frame is a standard right-handed frame fixed at the camera’s optical center:
- $\mathbf{x}_{\mathcal{C}}$: Points to the image sensor’s right.
- $\mathbf{y}_{\mathcal{C}}$: Points to the image sensor’s bottom.
- $\mathbf{z}_{\mathcal{C}}$: Is perpendicular to the image sensor’s plane pointing forward .
Refer to the drawing below.
Drawing of the camera positioned on the drone.
Given Information:
- POI position in Camera Frame: .
- Camera position in Body Frame: (Offset from the drone’s center of mass to the camera’s origin). Refer to the drawing and take $a=b=0.1m$.
- Drone position in World Frame:
- Drone orientation (Yaw) in World Frame:
Task: Find the total position of the POI in the World Frame, $\mathbf{p}_{\mathcal{W}, POI}$, as a function of the given parameters.
Hints
Hint 1
Start by understanding the transformation chain. The total transformation involves three steps:
- Rotate the point from the Camera frame to the Body frame using $R_{\mathcal{C}}^{\mathcal{B}}$.
- Add the offset $\mathbf{p}_{B, C}$ to account for the camera’s position relative to the drone’s center of mass.
- Rotate the result from the Body frame to the World frame using $R_{\mathcal{B}}^{\mathcal{W}}$ and add the drone’s position $\mathbf{p}_{\mathcal{W}, \mathcal{B}}$ in the World frame.
Hint 2
To calculate $R_{\mathcal{C}}^{\mathcal{B}}$, express the basis vectors of the Camera frame $\mathbf{x}_C, \mathbf{y}_C, \mathbf{z}_C$ in terms of the Body frame. Use the given definitions of the Camera frame axes relative to the Body frame.
Hint 3
For $R_{\mathcal{B}}^{\mathcal{W}}$, since $\phi = 0$ and $\theta = 0$, the rotation matrix simplifies to a pure yaw rotation around the Z-axis: Substitute the given yaw angle $\psi$ to compute the matrix.
Solution
We have:
This gives us the POI expressed in the Body frame:
For $\psi=30°$ we get:
Leading to the final result:
Other prerequisites
Link to other foundations that are needed such as mpc, optimization and
Additional Resources
Credits:
This course page was created by Lisa Romana Schneider, MSc in Robotics at EPFL, and funded by IEEE RAS and EPFL.
This course page is partly based on the Aerial Robotics class taught by Prof. Dario Floreano at EPFL (Ecole Polytéchnique Fédérale de Lausanne).
Additional Resources:
Introduction to Multicopter Design and Control (Quan Quan)- Textbook offering a systematic overview over multicopters from basic design guidelines to high-level control.