If you are an engineer, developing guidance and navigation solutions for drones, autonomous cars, industrial and delivery robots, construction equipment, and other systems that need to move in three dimensions, you need to know about IMUs (inertial measurement units) and how to integrate them into your designs.

Being able to accurately determine the dynamic roll and pitch angle of a platform is essential for a variety of applications. One classic example is the vertical gyro or attitude indicator in an aircraft, which provides a horizon reference to a pilot flying in the clouds.

More recently, many dynamic tilt applications have emerged in drones, robotics, and autonomous vehicle systems. This article will introduce the basic physics and math to estimate roll and pitch under dynamic conditions using an IMU.

The first and most basic way to measure tilt is to consider a liquid level measurement such as a carpenter’s level. Essentially, this is just a simple acceleration measurement of Earth’s gravity.

Under static conditions, the three-axis accelerometer in an IMU can directly measure this response.   The static accuracy of such measurement is generally most impacted by the overall accelerometer bias accuracy including temperature effects.

> FIGURE 1. A liquid level measurement is a simple static gravitational acceleration.

The complete math for a static roll and pitch measurement is shown below. This math is implemented in a simple application called a Leveler. You can download and install this code on an Aceinna OpenIMU from source or upload it to an OpenIMU using the Aceinna developer website and the compiled code.

Summary of equations for static tilt with an IMU

> FIGURE 2. Summary of equations for static tilt with an IMU.

The problem is that the accelerometer responds to both the platform’s tilt and its linear acceleration, as shown below. Moreover, it is impossible to distinguish between the two using an accelerometer by itself.

Acceleration based tilt measurement errors in dynamic conditions

> FIGURE 3. Acceleration based tilt measurement errors in dynamic conditions.

Luckily, an IMU also has a three-axis rate gyro inside it that responds to the angular rate of change on each of the three axes. A simple yaw-rate example is shown below. The good news about the angular rate gyro is that it does not directly respond to linear acceleration or linear motion. The bad news is that the process of converting angular rate to angle involves integration, which will drift over time due to the bias and noise of the gyro. In addition, the gyro has no true measurement of level and hence is unable to determine absolute level like a bubble level or acceleration-based measurement of gravity.

Acceleration based tilt measurement errors in dynamic conditions

> FIGURE 4. Angular rate gyro measures the angular rate of change.

Of course, the next step is to combine the two forms of measurement into one solution. The accelerometers are used as a long-term reference for static level i.e., vertical. The data are fused with the gyro measurements of attitude change for an overall accurate drift-free dynamic response.

This classic sensor fusion of vertical + gyro underlies the origin of the aircraft term Vertical Gyro. A great way to implement this measurement in practice is to use a quaternion update to propagate angular rate to attitude alongside a Kalman Filter. This math is outlined below.

Summary of Kalman Filter equations for dynamic attitude with an IMU

> FIGURE 5. Summary of Kalman Filter equations for dynamic attitude with an IMU.

As with the static leveler code, the OpenIMU platform provides a high-performance tuned implementation of the above math. Just install the Extension for Visual Studio Code using the link below, then click “Custom IMU Examples”. The dynamic tilt application is called “VG_AHRS” and additionally includes a dynamically stabilized heading measurement using the onboard magnetometer as well as hard/soft iron compensation.

Mike Horton

Mike Horton is the CTO of Aceinna where he is responsible for corporate technology strategy and inertial-navigation related technology development.  Prior to Aceinna, Mike Horton founded Crossbow Technology, a leader in MEMS-based inertial navigation systems and wireless sensor networks, with his advisor the late Dr. Richard Newton while at UC Berkeley.  Crossbow Technology grew to $23M in revenue prior to being sold in two transactions (Moog, Inc and MEMSIC) totaling $50M.  In addition to his role at Aceinna, Mike is active as an angel investor with two Silicon Valley based angel groups - Band of Angels and Sand Hill Angels.  He also actively mentors young entrepreneurs in the UC Berkeley research community.  Mike holds over 15 patents and holds a BSEE and MSEE from UC Berkeley.  

For more information on the Aceinna, visit marketplace.visualstudio.com and watch https://www.youtube.com/watch?v=EnPzCbfCS3s.