- Introduced by
- Aviation heritage
- Year
- 1940s
- Type
- System
- Family
- Attitude Estimation
What does it do?
An Attitude Heading Reference System (AHRS) is an inertial subsystem that estimates and outputs the three-dimensional orientation (attitude) and heading of a vehicle or platform.
It combines measurements from accelerometers, gyroscopes and, often, magnetometers through a sensor-fusion filter, typically a Kalman filter or a complementary filter, to reduce gyroscope drift in the attitude estimate. Unlike a full inertial navigation system, an AHRS outputs attitude and heading only, with no position or velocity estimate, and it is common in aviation, marine navigation and autonomous systems.
The intuition behind the method
Gyroscopes measure rotation rates directly and respond quickly, but integrating their output accumulates bias and noise, so the attitude estimate drifts over time. Accelerometers sense the direction of gravity, which gives a long-term reference for pitch and roll, but they are noisy and, during manoeuvres, also sense the vehicle's own acceleration. Because gravity is vertical, accelerometers cannot observe heading (rotation about the vertical axis). A magnetometer provides a heading reference relative to the Earth's magnetic field, but local magnetic distortion corrupts it. An AHRS fuses all three: the gyroscope supplies fast response between corrections, while the accelerometer and magnetometer correct its slow drift.
History
Mechanical gyroscopic attitude references were developed for aircraft in the first half of the twentieth century. Electronic AHRS units followed as solid-state inertial sensors became available. MEMS gyroscopes, accelerometers and magnetometers then made compact, low-power units practical; the 2004 edition of Titterton and Weston includes chapters on MEMS technology. Low-cost attitude estimators, such as the gradient-descent filter of Madgwick et al. (2011), offer low computational cost for fusing these sensors. The Mahony filter is a further estimator of this kind.
When to use it
Choose an AHRS when the application needs continuous, real-time attitude and heading from onboard sensors, for example flight control, autopilot stabilisation, a marine heading reference or UAV control. It is appropriate when gyroscope-only integration drifts too much over the operating time, or when an accelerometer or magnetometer alone is too noisy or ambiguous to give a usable tilt or heading. Because it relies only on inertial and magnetic sensing, it does not depend on external visibility, so it can operate where vision-based attitude estimation is unavailable. Do not choose an AHRS when position or velocity is required, since it does not estimate them; that calls for a navigation system with additional aiding sources. Avoid relying on its heading output in locations with strong local magnetic disturbances unless the magnetometer has been compensated for them.
Limitations and considerations
- Magnetometer disturbance: local magnetic anomalies from steel structures, electrical wiring or vehicle electronics bias the heading, so the magnetometer must be calibrated and its correction weighted down when the field is disturbed.
- Acceleration: during manoeuvres the accelerometer measures gravity plus the vehicle's own acceleration, which corrupts the tilt estimate; the filter needs a motion model or reduced accelerometer weight to limit pitch and roll errors.
- Euler-angle singularity: at 90-degree pitch the roll and yaw axes align (gimbal lock), so internal computation should use quaternions.
- Initialisation: attitude is normally initialised with the platform held still or in known motion; dynamic initialisation is harder and cannot be handled by a static procedure.
- Modelling assumptions: the platform is treated as a rigid body, and the sensor bias and noise models are assumed to be characterised; errors outside these models are not compensated.
- Local-field assumptions: during quasi-static motion the accelerometer is assumed to sense mainly gravity, and the magnetic field is assumed to be locally uniform; these assumptions fail during manoeuvres and near magnetic anomalies.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Fuses slow but stable reference sensors (accelerometer and magnetometer) with a fast gyroscope, so the attitude estimate stays responsive while its long-term drift is corrected.
- Output can be produced at the sensor sample rate; the output rate is set by the implementation and can match the sensor rate, so it can feed control loops.
- Uses only onboard inertial and magnetic sensors, so it needs no external radio or visual references for attitude.
- The filter gains set how strongly each correction acts, letting the designer trade responsiveness against noise sensitivity, as discussed under pitfalls.
Applications
- Aircraft autopilot and flight control: maintains aircraft attitude and heading; provides input to autopilot algorithms.
- Unmanned aerial vehicle (UAV) stabilization: enables quadcopter and fixed-wing UAV flight control.
- Marine navigation and stabilization: ship heading reference for autopilot and navigation; input to anti-roll stabilization.
- Mobile robot and wheeled vehicle guidance: provides heading and pitch/roll for terrain navigation.
- Smartphone and wearable augmented reality: enables orientation tracking for AR displays and gesture recognition.
How it works
How it works
Collect high-rate measurements from a 9-degree-of-freedom (9-DOF) inertial measurement unit (IMU): a 3-axis accelerometer, a 3-axis gyroscope and a 3-axis magnetometer. The sample rate is chosen to suit the control loop and the sensor bandwidth.
Calibrate sensor biases, scale factors and axis misalignment using static or known-motion procedures, and compensate for magnetometer hard-iron and soft-iron distortion. Timestamp all measurements accurately, since timing errors translate directly into attitude errors during rotation.
Combine the vector measurements from the accelerometer and magnetometer with the gyroscope's rate measurements in an observer-based filter, either a complementary filter or a Kalman filter, to estimate attitude as a quaternion. Propagate the attitude with quaternion kinematics, which use a quaternion product with the body-frame angular-rate vector, and renormalise the quaternion after each integration step. Convert the result to Euler angles (roll, pitch, yaw) or a direction cosine matrix for output.
Formula
\vec{q}(t+dt) = \vec{q}(t) + \frac{1}{2}\vec{\omega} \times \vec{q}(t) \cdot dtMaintain the attitude state (quaternion or direction cosine matrix) and, in a Kalman formulation, its covariance. Propagate the state by integrating gyroscope rates, then correct it with accelerometer and magnetometer observations, weighted by their noise characteristics and a dynamics model.
Output attitude (pitch, roll and yaw, or the quaternion) and heading, distinguishing magnetic heading from true heading; true heading requires a magnetic declination correction for the location. Report confidence or accuracy indicators where available, and flag magnetic disturbance or sensor faults. A disturbed or faulty estimate is typically indicated by a large residual (innovation) between an accelerometer or magnetometer observation and the state prediction, by a magnetometer field magnitude or dip angle that departs from the expected local values from a known reference model, or by a heading that disagrees with the gyroscope-propagated heading over a short interval.
Common pitfalls
- Uncalibrated magnetometer: hard-iron and soft-iron distortion can cause large heading errors, so the magnetometer should be calibrated in the operational installation rather than on the bench.
- Filter tuning: too fast a correction gain lets accelerometer and magnetometer noise appear as heading jitter, while too slow a gain lets gyroscope drift persist. Gains usually require empirical tuning or an adaptive scheme.
- Magnetic versus true heading: magnetic declination depends on location, so reporting magnetic heading as true heading produces a systematic error. State which heading the application needs.
- Accelerometer as a tilt reference during fast manoeuvres: the accelerometer no longer senses only gravity, so using it unweighted for pitch and roll gives a wrong attitude. The filter must reduce or gate its correction during such motion.
Frequently asked questions
What is gimbal lock and how do I avoid it?
Gimbal lock occurs when pitch reaches 90 degrees (for example, the nose pointing straight up or down). At this singularity the roll and yaw axes align and one degree of freedom is lost in the Euler-angle representation. Use quaternions for internal calculations and convert to Euler angles only for display, since quaternions have no such singularity.
How do I initialize AHRS attitude during dynamic motion?
Initialization is usually done with the platform held still, which lets the accelerometer sense gravity and the magnetometer sense the field direction. Dynamic initialization is harder, because the accelerometer then also senses the vehicle's acceleration; it needs a motion model that assumes known manoeuvres or low acceleration, or a reduced accelerometer weight. The required settling time depends on sensor noise, bias stability and the accuracy requirement, and must be determined from characterisation of the installed sensors. Some systems use GPS velocity to detect the motion mode and select the initialization method.
What is the difference between complementary filter and Kalman filter for AHRS?
A complementary filter is heuristic and simpler to tune: it high-pass filters the gyroscope rate and low-pass filters the accelerometer and compass readings. A Kalman filter tracks uncertainty explicitly and weights each sensor by its noise characteristics, which generally gives better performance under changing noise, but it is more computationally demanding. The standard Kalman filter assumes linear dynamics, whereas attitude kinematics are nonlinear, so AHRS implementations typically use an extended or other nonlinear variant. For many applications a complementary filter is sufficient.
How do I detect and correct magnetic disturbance in an AHRS?
Monitor magnetometer readings for anomalies, such as a change in field magnitude or a deviation from the expected field, and compare the compass heading with the inertial estimate; a large disagreement signals disturbance. Mitigation options include applying hard-iron and soft-iron calibration and reducing the compass weight in the filter. A heading derived from GPS velocity can be used during the disturbance only when the platform moves above a minimum speed and GPS is available; at low speed, indoors or at standstill it is not valid, and the system must rely on gyroscope propagation, accepting that heading error grows over time.
Related methods
Sources
Savage, P. G. (2007). Strapdown Inertial Integration Technology (2nd ed.). Strapdown Associates.
Open publication referenceTitterton, D. H., & Weston, J. L. (2004). Strapdown Inertial Navigation Technology (2nd ed.). Institution of Engineering and Technology.
Open DOI referenceMadgwick, S. O. H., Harrison, A. J. L., & Vaidyanathan, R. (2011). Estimation of IMU and MARG orientation using a gradient descent algorithm. IEEE International Conference on Rehabilitation Robotics (ICORR), 1–7.
Open publication reference