Understanding Quaternions in IMU Technology

Inertial Measurement Unit (IMU) is an electronic device, which is used to measure and report on specific force, angular rate, and orientation using a combination of accelerometers, gyroscopes, and sometimes magnetometers. The sensors are used in conjunction with each other to measure movement and orientation in three-dimensional space.

The Challenge of 3D Orientation

Representing 3D orientation is easy to say until you try to do it mathematically. The most intuitive approaches – Euler angles (roll, pitch, yaw) – have a problem called “gimbal lock” – two axes become aligned, and you get a degree of freedom.

Why Quaternions?

Quaternions (first discovered by William Rowan Hamilton in 1843 and then rediscovered in 1901) is a mathematical solution for describing rotations without gimbal lock. Efficient representations of rotations in 3 dimensions (one real and three imaginary) are used in four dimensions.

No Gimbal Lock

Unlike Euler angles, quaternions do not suffer from gimbal lock at all, by using quaternions to represent rotations in four dimensions and not three.

Computational Efficiency

Quaternions need fewer calculations than rotation matrices do, so they are better used for real time applications.

Smooth Interpolation

Quaternions allow for smooth interpolations between orientations (SLERP) which is needed for smooth animation and smooth motion tracking.

Numerical Stability

Quaternions are less susceptible to numerical error than other forms of representation of the rotations, particularly after a large number of operations.

How Quaternions Work with IMU Data

IMUs use quaternions to combine the information from the multiple sensors into a stable point of orientation. This process requires using a combination of gyroscope data (for rotation rates), accelerometer and magnetometer data (for absolute reference).

Sensor Data Acquisition

The IMU receives the raw data from the gyroscopes (angular velocity), accelerometers (linear acceleration) and the magnetometers (magnetic field direction).

Gyroscope Integration

The gyroscope data is integrated to estimate the changes in orientation and is represented as a derivative of a quaternion.

Complementary Filtering

Accelerometer and magnetometer data are used to correct the drift in the gyroscope only estimate based on algorithms such as Madgwick or Mahony filters.

Quaternion Normalization

The resulting quaternion is then normalized in order to preserve its length, so that it is a pure rotation.

Quaternion Applications to IMU Technology

Quaternions are now important in many applications where orientation tracking is needed in an accurate way. They have a number of mathematical properties that make them suitable for these technologies.

Virtual Reality

The reason for this is that VR headsets use IMUs that use quaternion math to track head orientation with low latency and without gimbal lock, which is essential for immersion.

Robotics

So quaternions are important in controlling robotic arms, drones, autonomous vehicles, etc.

Motion Capture

Professional motion capture systems capture the movements of the actors with IMU arrays and quaternion math to capture the actor movement for animation and biomechanics.

Aerospace

Quaternions are used for attitude control and stabilization of aircraft and spacecraft applications where reliability is very important.

Quaternion vs. Other Representations

Each of the rotation representations has pros and cons. This comparison gives an insight as to why quaternions are commonly used for IMU applications.

RepresentationAdvantagesDisadvantagesIMU Use Cases
Euler AnglesIntuitive, easy to understandGimbal lock, trigonometric singularitiesSimple applications where full range of rotation is not required.
Rotation MatricesNo singularities, easy composition9 parameters, computationally expensiveComputer graphics, coordinate transformations
Axis-AngleCompact (4 parameters), intuitiveDifficult to compose, not compact for storagePhysics engines, sometimes for user input
QuaternionsNo gimbal lock, computationally efficientLess intuitive, double coverage (q = -q)IMU orientation tracking, animation, robotics

The History of the Use of Quaternions In IMUs

Quaternion mathematics has gained a greater importance in the field of IMUs in recent years with the growing requirements for more accurate and efficient orientation tracking.

Early IMUs (1960s-1980s)

Euler Angle Dominance

Euler angles, with their conceptual simplicity, were used in most early inertial navigation systems even with the gimbal lock problems they suffer because of the conceptual simplicity of the approach.

Aerospace Adoption (1980s-1990s)

Quaternions in Aerospace

Quaternions were first implemented in the aerospace industry in the attitude control systems of spacecraft to prevent gimbal lock.

Consumer Electronics (2000s)

Mobile Revolution

The smartphone revolution led to the adoption of quaternions for MEMS IMUs to use in screen rotation and gaming and for AR applications.

Modern Applications (2010s-Present)

Widespread Implementation

Quaternion-based orientation tracking became available in all industries due to advanced sensor fusion algorithms (Madgwick, Mahony).

Conclusion

Quaternions offer a beautiful mathematical way of solving the difficult problem of tracking 3D orientation in IMUs. Quaternions have proven to be an effective orientation representation system, without causing gimbal lock, being computationally efficient and interpolating smoothly, and as a result they are now used in almost every application that needs to represent orientation (from consumer smartphones to aerospace systems). As IMU technology continues to advance, the need for an understanding of quaternion mathematics will only increase for those engineers and developers that are working with applications in motion tracking.

Related Articles

Latest Articles