2.1. Principles of AHRS
The sensors comprising an Orientation and Heading Reference System (AHRS) include MEMS-based triaxial gyroscopes, MEMS-based triaxial accelerometers, and triaxial magnetometers. Within the AHRS, the initial step involves reading angular velocity, acceleration, and magnetic field strength data from each axis of the sensor units. This angular velocity data is subsequently processed to obtain changes in orientation. By combining this with the previous orientation of the vehicle, a new predicted Euler angles is derived.
However, errors such as gyroscopic bias, scale factor error, cross-axis coupling error, and noise inherent in the gyroscopes can cause the integrated orientation results to drift from the true values over time. Therefore, data fusion techniques are commonly employed to calculate Euler angles using accelerometer and magnetometer measurements, which compensate for the gyroscope-derived Euler angles and suppress gyroscopic drift.
The Euler angles derived from the gyroscopes can also provide boundary conditions for the accelerometer and magnetometer-derived Euler angles, particularly under high dynamic conditions or magnetic interference. The workflow of AHRS is illustrated in
Figure 1.
2.2. Sensor Data Fusion
In this paper, the navigation frame is defined as the East-North-Up (O-ENU) frame. The X-axis of the body frame points to the right in the horizontal plane of the vehicle, the Y-axis points forward in the horizontal plane, and the Z-axis points vertically upward from the horizontal plane of the vehicle, as shown in
Figure 2. To prevent singularities and reduce the overall computational load of the algorithm, quaternion-based orientation update method is adopted. The quaternion describing this orientation,
, is given by Equation (1).
The solving process of the traditional gradient descent method is as follows: first, the relationship between the angular velocity and quaternion derivative is calculated through numerical integration to determine the vehicle’s orientation. Then, the measurements from the magnetometer and accelerometer are taken as observation vectors, and the orientation is estimated using the gradient descent method. Finally, the orientation quaternion obtained from gyroscope integration and the orientation quaternion derived from the observation vectors are combined in a complementary filter to accurately estimate the vehicle’s orientation.
The angular rate measured by the gyroscope is denoted as
, which can be expressed in the form of Equation (2). Since MEMS gyroscopes are used in this paper, the Earth’s rotation rate
and the coupling angular velocity between the navigation frame and the earth frame
are relatively small, so the measured angular rate can be approximated as
. The relationship between the gyroscope-measured angular rate and the quaternion derivative
can be represented by Equations (3) and (4).
Under the assumption of a known initial orientation, the orientation of the body frame relative to the navigation frame at time
t can be obtained by integrating the quaternion derivative equation, as shown in Equations (5) and (6):
In the above equations, is the prior estimate quaternion of the orientation of the body frame relative to the navigation frame obtained from gyroscope data at time t, is the derivative of the orientation quaternion measured by the gyroscope at time t, is the angular rate measured by the gyroscope at time t, is the gyroscope sampling period, and is the posterior estimate of the orientation at the previous time step.
Using the Earth’s gravity vector and the geomagnetic vector as observation vectors, the value of the gradient
can be calculated. When the Earth’s gravity vector is used as an observation vector, its magnitude is
, and its direction is opposite to the navigation frame’s z-axis. Normalizing the accelerometer measurement
, we can obtain Equations (7) and (8).
When using the geomagnetic vector as an observation vector, the geomagnetic vector can be considered to have components on a horizontal axis and a vertical axis, with a magnitude of
. Normalizing the magnetometer measurement
, we can obtain Equations (9) and (10).
The geomagnetic vector measured at time
t,
, can be obtained by rotating the normalized magnetometer measurement
using the posterior estimate of the orientation from the previous time step
, as shown in Equation (11). If the measured geomagnetic vector is incorrectly inclined, it can be corrected to the same inclination plane, as shown in Equation (12).
At this point, using the Earth’s gravity vector as an observation vector can suppress the divergence of the pitch and roll angles. To avoid the remaining yaw angle divergence, it is necessary to use both the Earth’s gravity vector and the geomagnetic vector as observation vectors. In this case, the objective function and the Jacobian matrix are given by Equations (13) and (14).
According to the gradient calculation formula, at this point,
is given by Equation (15).
Based on the gradient descent method, the gradient descent estimate at time
t,
, can be calculated from the posterior estimate of the orientation at the previous time step
through a single iteration, as shown in Equation (16).
By fusing the orientation quaternions
and
obtained from Equations (6) and (16) respectively, the posterior estimate of the orientation quaternion at the current time
t is derived. The fusion is performed as shown in Equation (17), where
is the weight applied to the orientation quaternion.
The optimal value of
is defined to ensure that the weighted divergence of
equals the weighted convergence of
. This is defined by Equation (18), where
β is the divergence rate of
, representing the magnitude of the quaternion derivative corresponding to the gyroscope measurement error.
Given that
β is generally large, Equation (16) has an approximate expression as shown in Equation (19).
Substituting Equations (6) and (19) into Equation (17) yields Equations (20) and (21).
Figure 3 illustrates the block diagram of the implementation of the filtering algorithm.