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.
| Representation | Advantages | Disadvantages | IMU Use Cases |
|---|---|---|---|
| Euler Angles | Intuitive, easy to understand | Gimbal lock, trigonometric singularities | Simple applications where full range of rotation is not required. |
| Rotation Matrices | No singularities, easy composition | 9 parameters, computationally expensive | Computer graphics, coordinate transformations |
| Axis-Angle | Compact (4 parameters), intuitive | Difficult to compose, not compact for storage | Physics engines, sometimes for user input |
| Quaternions | No gimbal lock, computationally efficient | Less 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.
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.
Quaternions in Aerospace
Quaternions were first implemented in the aerospace industry in the attitude control systems of spacecraft to prevent gimbal lock.
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.
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.
