Modeling Vehicle Dynamics – Euler Angles

This post is the 1st in a series on modeling and simulation of a quadcopter’s vehicle dynamics. The full series will include all of the following posts:

  1. Modeling Vehicle Dynamics – Euler Angles
  2. Modeling Vehicle Dynamics – Quadcopter Equations of Motion
  3. Modeling Vehicle Dynamics – 6DOF Nonlinear Simulation


Six Degrees of Freedom (6DOF)

For this first part in developing the vehicle dynamics we’ll set the stage by describing the space in which we can express these dynamics. For a rigid body in a 3-D world we can describe the location of all points on the vehicle with 6 coordinates. The first 3 should be obvious: these are the (x, y, z) coordinates which represent the distance of the object’s center of mass from some origin in the 3-D world. Starting out, we will assume a flat-Earth model, meaning our world the vehicle can move around in is assumed to be above flat ground, in a rectilinear coordinate system, and the gravity is constant. With constant gravity the center of mass will also be equivalent to the center of gravity (cg), so we will treat these terms as interchangeable.

If we are in a 3-D world, how can there be 6 degrees of freedom? Well, we may know the location of the vehicle’s cg, but we don’t know where the rest of the components of the vehicle are around that cg. Here is where the “rigid body” assumption comes in. The idea of a rigid body is that every point on the vehicle has a fixed location relative to the cg. The opposite of this would be a flexible body, where different points on the body are free to flex and vibrate and introduce additional dynamics to the system. The final 3 coordinates represent the orientation of the vehicle represented by three angles: (\phi,\theta,\psi). If we know all 6 coordinates then we can determine the location of the cg from (x, y, z) and then from the orientation, or vehicle attitude as it’s also called, of (\phi, \theta, \psi), and we can determine the location of the rest of the vehicle in relation to the cg.

A rigid body is assumed to have a constant relationship between all its points of mass. A flexible body model may be necessary for vehicles which have long, thin structures.

Representing Orientation

The 3 position vector components (x, y, z) I think are easy enough to understand. This coordinate frame could be aligned with North, East, and vertical height and the values of the components would be some distance in each of those directions. But 3 coordinates that describe the attitude of a vehicle is not as intuitive to grasp. There are multiple means of representing orientation, but the two most common are Euler angles and quaternions. Euler angles are the simplest to understand as well as gain insight in to the system while analyzing its motion, and is the method we will use to derive our vehicle’s equations of motion. However they do have a limitation as for certain orientations an ambiguity arises where the three coordinates do not define a unique orientation. This singularity is referred to as gimbal-lock and can be mitigated by using quaternions instead. Often times simulations and controllers for vehicles will do their calculations in quaternions, but convert back to Euler angles for output because of their ease of use. I will discuss quaternions in more detail in a later post, but for now you can accept that Euler angles are sufficient to describe all the orientations of the vehicle we expect it to fly in.

Before we go into Euler angles we will first introduce the idea of multiple reference frames. For our model, there will be two reference frames (coordinate systems) we will care about:

  1. Inertial reference frame
    This is fixed to the Earth and the coordinates could be based in cardinal directions (North, East), or arbitrary directions within a room floorplan. The main point is that it doesn’t move (due to our flat-Earth assumption). For now we will define the inertial frame with the coordinates (x, y, z).
  2. Body-fixed reference frame
    Remember how we stated earlier that with a rigid body all components of the vehicle are fixed in relation to the cg? Well let’s define a coordinate system with its origin at the cg, and now we have a convenient way to describe how far away the propellers are, and in what direction they face with respect to the cg. We will define the body-fixed reference frame with the coordinates (b_1, b_2, b_3) and align them with the structure such that b1 and b2 are aligned with symmetric axes of the body and b3 is in the vertical direction (parallel to the propeller motor axes) as shown here:


Now that we have two reference frames, we need a way to switch between them. If we can establish a general relationship that allows us to transform from one set of coordinates to the other, then we can do calculations in whichever is most convenient. Then we can transform that solution to the other reference frame when needed. This is the same concept of rectangular and polar coordinates you may have encountered in grade school algebra classes: you can describe the same location in both, and use mathematical relationships to switch back and forth between them. But you learn to use both because each has different advantages for different situations. Our end goal is to use the two coordinates to separate out translational and rotational motion. We’ll keep track of the orientation of the vehicle by rotating the body-fixed frame about the vehicle cg and keep track of the vehicle’s location by translating the cg with respect to the inertial frame. The translation representation is simply the vector distance of the body frame from the inertial. To represent the orientation, however, we’ll need to use Euler angles.

Euler Angles

The idea of Euler angles is that one can represent any final orientation of a reference frame via a set of 3 sequential rotations about specific axes. Let’s try do an example rotation about different axes to get a feel for how this works. To get used to the matrix notation we will use to describe the rotations, let us first start with the trivial case where both coordinate frames have the same orientation.

Here we are representing the coordinate frames with unit vectors [x, y, z] and [b1, b2, b3]. A convenient way to transform one vector to another is through matrix multiplication. When all 3 components are parallel to each other, it can be seen in the figure above that the transformation matrix is simply the identity matrix.

Now, what if we rotate the body frame about one of its axes by a specific amount? We’ll see that the axis it rotates about remains parallel to the corresponding inertial axis. We can describe the other body frame axes with trigonometry as a function of the inertial components and the angle of rotation. These equations can be condensed again into a matrix multiplication expression as shown below, looking at each axis individually.

The transformation matrix is referred to as a Direction Cosine Matrix (DCM) or Rotation Matrix which we will represent as R. These matrices are orthonormal (comprised of orthogonal unit vectors) and therefore have the property that RT = R-1.

Now imagine that we perform those 3 rotations sequentially in the order of rotating about b3, then b2, then b1. The body frame will end up looking something like this:

Notice how the second and third rotations are about axes which have already been rotated. This is why the order of Euler angles must be consistent. There are many sequences you can choose from and different disciplines have different standards. However once a sequence of the three angle rotations is chosen you must always transform them in that order, otherwise you may not get the correct final orientation. For our modeling we will follow the standard commonly used in the aircraft industry which uses Body 3-2-1 angles, as illustrated above.

Now we’ll take advantage of the convenience of our matrix notation. A more rigorous explanation of the Euler angles would define each angle rotation as an intermediate reference frame. So for the \psi, \phi, \theta rotation shown above you would have 4 total reference frames. But for our modeling right now we are only really interested in the inertial frame and final body-fixed frame after all 3 Euler angle rotations. The usefulness of matrix transformations is they can be concatenated so we can simplify the 3 rotation matrices to a single matrix which transforms inertial frame coordinates to body frame coordinates. Notice below that the [x, y, z] vector is first premultiplied by the \psi rotation, then that is premultiplied by the \theta rotation, and finally that result is premultiplied by the \phi rotation matrix.

\begin{bmatrix} b_1 \\ b_2 \\ b_3 \end{bmatrix} =    \begin{bmatrix} 1 & 0 & 0 \\ 0 & cos(\phi) & sin(\phi) \\ 0 & -sin(\phi) & cos(\phi) \end{bmatrix}    \begin{bmatrix} cos(\theta) & 0 & -sin(\theta) \\ 0 & 1 & 0 \\ sin(\theta) & 0 & cos(\theta) \end{bmatrix}    \begin{bmatrix} cos(\psi) & sin(\psi) & 0 \\ -sin(\psi) & cos(\psi) & 0 \\ 0 & 0 & 1 \end{bmatrix}    \begin{bmatrix} x\\y\\z \end{bmatrix}

\begin{bmatrix} b_1 \\ b_2 \\ b_3 \end{bmatrix} =    \begin{bmatrix} cos(\theta)cos(\psi) & cos(\theta)sin(\psi) & -sin(\theta) \\    -cos(\phi)sin(\psi)+sin(\phi)sin(\theta)cos(\psi) & cos(\phi)cos(\psi)+sin(\phi)sin(\theta)sin(\psi) & sin(\phi)cos(\theta) \\    sin(\phi)sin(\psi)+cos(\phi)sin(\theta)cos(\psi) & -sin(\phi)cos(\psi)+cos(\phi)sin(\theta)sin(\psi) & cos(\phi)cos(\theta) \end{bmatrix}    \begin{bmatrix} x\\y\\z \end{bmatrix}

To simplify our notation, I will use a variable \textbf{C}_{i}^{j} to refer to these coordinate transformations, where the transformation is from a reference frame i to a different reference frame j. Therefore, the above matrix would be expressed as a transformation from the inertial frame, n (as in navigation), to the body frame, designated b:

\begin{bmatrix} b_1 \\ b_2 \\ b_3 \end{bmatrix} =  \textbf{C}_{n}^{b} \begin{bmatrix} x\\y\\z \end{bmatrix}

Now, if we want to perform a rotation in the reverse direction, from body-fixed frame coordinates to inertial coordinates, we need to use the inverse of the matrix. But instead of calculating the inverse of the matrix we can take advantage of the orthogonal property we identified earlier: that the transpose of a rotation matrix is equal to the inverse. Therefore, the reverse rotation is simply:

\begin{bmatrix} x\\y\\z \end{bmatrix} =  \textbf{C}_{b}^{n} \begin{bmatrix} b_1 \\ b_2 \\ b_3 \end{bmatrix} = {[\textbf{C}_{n}^{b}]}^{T} \begin{bmatrix} b_1 \\ b_2 \\ b_3 \end{bmatrix}

\begin{bmatrix} x\\y\\z \end{bmatrix} =  \begin{bmatrix} cos(\theta)cos(\psi) & -cos(\phi)sin(\psi)+sin(\phi)sin(\theta)cos(\psi) & sin(\phi)sin(\psi)+cos(\phi)sin(\theta)cos(\psi)\\  cos(\theta)sin(\psi) &  cos(\phi)cos(\psi)+sin(\phi)sin(\theta)sin(\psi) & -sin(\phi)cos(\psi)+cos(\phi)sin(\theta)sin(\psi) \\  -sin(\theta)  & sin(\phi)cos(\theta)   & cos(\phi)cos(\theta) \end{bmatrix}  \begin{bmatrix} b_1 \\ b_2 \\ b_3 \end{bmatrix}


We have now defined our inertial and body reference frames and how to transform coordinates in one frame into the other. Next we will look at how we can describe vehicle motion in these frames.


For more detailed derivations of these concepts, the following books are great references:

[1] Nelson, Robert C., Flight Stability and Automatic Control

[2] Stevens, Brian L. and Lewis, Frank L., Aircraft Control and Simulation

One thought on “Modeling Vehicle Dynamics – Euler Angles

  1. You have a natural ability to define and explain a problem. I have read so many books and articles, but in my opinion your explanation is more meaningful, comparatively speaking.

Leave a comment or ask a question: