Rotations

Sources
  1. Euler Angle, Multi-Rotor Platform-based UAV Systems, 2020

Euler Angles

We can represent the rotation of a set of coordinates axes by angles $\phi$, $\theta$, and $\psi$, mathematically using a series of matrix-multiplications, as shown below. This rotation matrix is commonly referred to as DCM, or Direction Cosine Matrix.

$$ R_{\phi} = \begin{bmatrix} \phantom{-}1 & \phantom{-}0 & \phantom{-}0 \\ \phantom{-}0 & \phantom{-}\cos(\phi) & \phantom{-}\sin(\phi) \\ \phantom{-}0 & -\sin(\phi) & \phantom{-}\cos(\phi) \\ \end{bmatrix} \qquad R_{\theta} = \begin{bmatrix} \phantom{-}\cos(\theta) & \phantom{-}0 & -\sin(\theta) \\ \phantom{-}0 & \phantom{-}1 & \phantom{-}0 \\ \phantom{-}\sin(\theta) & \phantom{-}0 & \phantom{-}\cos(\theta) \\ \end{bmatrix} \qquad R_{\psi} = \begin{bmatrix} \phantom{-}\cos(\psi) & \phantom{-}\sin(\psi) & \phantom{-}0 \\ -\sin(\psi) & \phantom{-}\cos(\psi) & \phantom{-}0 \\ \phantom{-}0 & \phantom{-}0 & \phantom{-}1 \\ \end{bmatrix} $$ $$ R^L_G = R_{\phi} R_{\theta} R_{\psi} = \begin{bmatrix} c(\theta)c(\psi) & c(\theta) s(\psi) & -s(\theta) \\ s(\phi)s(\theta)c(\psi) - c(\phi)s(\psi) & s(\phi)s(\theta)s(\psi) + c(\phi)c(\psi) & s(\phi)c(\theta) \\ c(\phi)s(\theta)c(\psi) + s(\phi)s(\psi) & c(\phi)s(\theta)s(\psi) - s(\phi)s(\psi) & c(\phi)c(\theta) \\ \end{bmatrix} $$ Where $c$ and $s$ are the short-hand form of $\cos$ and $\sin$, respectively. The notation $R^L_G$ represents the rotation(R) from a Global(G) reference frame to a new Local(L) frame position. We can take the transpose of this rotation matrix to rotate from the Local(L) frame back to the Global(G) reference frame, as defined:

$$ R^G_L = (R^L_G)^T = R_{\psi}R_{\theta}R_{\phi} = \begin{bmatrix} c(\theta)c(\psi) & s(\phi)s(\theta)c(\psi) - c(\phi)s(\psi) & c(\phi)s(\theta)c(\psi) + s(\phi)s(\psi) \\ c(\theta) s(\psi) & s(\phi)s(\theta)s(\psi) + c(\phi)c(\psi) & c(\phi)s(\theta)s(\psi) - s(\phi)s(\psi) \\ -s(\theta) & s(\phi)c(\theta) & c(\phi)c(\theta) \\ \end{bmatrix} $$

In order to get meaningful information from our sensors we must establish a static coordinate system. In our case, we need to represent the position of our sensor as a set of orthogonal axes that rotate by angles $\phi$, $\theta$, and $\psi$, as our sensor is moved in the physical world. Therefore, we must determine a set of static reference axes. This can be accomplished using the NED-Coordinate system, where North(N), East(E), and Down(D), are static vectors in the physical world. We can use gravity to determine the Down axis, and the Earth’s magnetic field to determine the North axis. Using these axis, we can calculate the East axis using the cross product.