A New Perspective on Low-Cost MEMS-Based AHRS Determination

Attitude and heading reference system (AHRS) is the term used to describe a rigid body’s angular orientation in three-dimensional space. This paper describes an AHRS determination and control system developed for navigation systems by integrating gyroscopes, accelerometers, and magnetometers signals from low-cost MEMS-based sensors in a complementary adaptive Kalman filter. AHRS estimation based on the iterative Kalman filtering process is required to be initialized first. A new method for AHRS initialization is proposed to improve the accuracy of the initial attitude estimates. Attitude estimates derived from the initialization and iterative adaptive filtering processes are compared with the orientation obtained from a high-end reference system. The improvement in the accuracy of the initial orientation as significant as 45% is obtained from the proposed method as compared with other selected techniques. Additionally, the computational process is reduced by 96%.


Introduction
The determination of Attitude and Heading Reference System (AHRS) involves several fields like navigation, control, motion tracking [1][2][3], personal navigation [4,5], robotics [6], and virtual reality systems [7]. Several AHRS determination and control technologies in use need an external source to obtain orientation information [1]. Interference and shadowing are the main problems associated with these technologies. Compared with other technologies, the inertial system computes the attitude using self-contained sensors that only respond to inertial forces.
In inertial systems, the attitude is derived from the integration of rate gyroscope data in an inertial system. Rate gyroscopes are prone to bias and random drifts and this leads to unbounded attitude errors. Thus, successful implementation of an inertial system requires very expensive sensors that have exceptional long-term bias stability [8]. In the last decade, the rapid development of Micro-Electro-Mechanical System (MEMS) inertial sensors in precision, accuracy, size, weight, and cost make it ideal for developing a small-scale and lowcost AHRS determination and control system. However, inexpensive MEMS gyroscopes are low-performance, and using these gyroscopes may result in unbounded attitude errors. An AHRS determination and control system can be successfully implemented using such gyroscopes if there is a means for aiding the gyroscopes or resetting the attitude errors periodically [8].
One of the most successful applications for aiding the low-cost inertial sensors is the use of the Global Positioning System (GPS). GPS data are precise, and the errors are independent of time. This makes it ideal to calibrate the drift errors of low-cost gyroscopes. However, GPS has well-known limitations due to signal attenuation in indoor applications, so other technologies like the earth's magnetic and gravitational sensing [9] can help improving navigation systems.
(1) AHRS initialization process is applied under stationary conditions to determine the initial orientation. We developed a new method for AHRS initialization, named Hybrid Method to increase accuracy and precision. (2) An adaptive Extended Kalman filter (AEKF)-based iterative process is applied to perform the real-time estimation of attitude when the sensor is in motion. While gyroscope measurements are integrated to yield the attitude changes between successive body movements to maintain the high-frequency output of attitude, accelerometers and magnetometers provide a low frequency and noisy but drift-free calibration of attitude. The developed AEKF is adaptive to the effects of body acceleration and magnetic interferences, named the real-time calibration process.

Materials and Methods
In body frame (B), a sensor unit rotates and translates with respect to a navigation coordinate frame (N). The attitude of the sensor can be analytically represented by a direction cosine matrix C N B that transforms an arbitrary 3 × 1 vector A from its coordinate frame B (projection A B ) to the N frame (projection A N ), presented by Wahba's problem [11] as: when the body is in motion, its attitude relative to the reference N frame can be represented by a time-varying function of C N B (t). AHRS initialization is the process to determine the initial value of C N B0 . In this study, we consider a two-step process, a coarse alignment followed by fine alignment for AHRS initialization. In the following section, we introduce geomagnetic matching, Compass Heading, and our new method to achieve coarse alignment. In the end, fine alignment is designed to iteratively estimate the residual error in the heading estimation.

Geomagnetic Matching Technique in Coarse Alignment
Geomagnetic matching, one of the techniques often used in determine attitude [8,16], is based on solving Equation (1). While MEMS-based low-cost gyroscopes fail to sense the Sensors 2021, 21, 1383 3 of 12 earth's rotation, the earth's magnetic and gravitational acceleration vectors are independent and thus can be used in the AHRS initialization process.
Accelerometers in the static state can measure the components of gravity in B frame (g B ), and its N frame projection (g N ) is given by the standard gravity model [19]. Additionally, magnetometers sense the earth's magnetic vector in B frame (m B ) and its N frame projection can be obtained from international geomagnetic reference field models [20]. C N B0 can be obtained with g N = C N B0 g B , m N = C N B0 m B , and h N = C N B0 h B , where, h N = g N × m N , and h B = g B × m B , × is the cross-product between gravity and the earth's magnetic vector [8].

Compass Heading Technique in Coarse Alignment
Compass heading, another technique used to initialize the heading. The earth's magnetic field has a component in the local horizontal plane that is always pointing toward the magnetic north. If a triaxial magnetometer is placed in the horizontal plane, the heading can be calculated using the horizontal components of the earth's magnetic field. When the magnetometer is tilted, the tilt angles should be first compensated for before calculating the heading [21].
The tilt angles represented in by [21] give us roll (φ) and pitch (θ), calculated by: φ = tan −1 (y/z), and θ = tan −1 x/ y 2 + z 2 , where x, y, z are the components of gravity in B coordinate frame. The magnetometers data can be calculated in the horizontal plane by Xh = xcosθ + ysinφsinθ + zcosφsinθ and Yh = ycosφ − zsinφ, where x, y, z are readings of the triaxial magnetometer. In the end, heading angle ψ can be determined by ψ = tan −1 .
Using the equivalence relation between the direction cosine matrix and the Euler angle parameters, the attitude matrix C N B0 can be initialized in terms of ψ, φ, θ [21]:

Hybrid Method in Coarse Alignment
The new method for AHRS initialization proposed by this is study is developed based on the geomagnetic matching technique defined in Equation (1). (1) can be rearranged to A B = C B N A N , and attitude matrix C B N is represented in Equation (2).
If an arbitrary vector V is specified as the unit vectors along the X, Y, and Z axes of the coordinate frame N, the B frame projections of the unit vectors along N frame X, Y, and Z axes are expressed in terms of the elements of C N B as: can find the gravity vector g is aligned to the Z axis of the N frame and the earth's magnetic vector m lies in the X-Z plane depicted in Figure 1. The X, Y, and Z axes are mutually orthogonal; thus, the earth' magnetic vector is perpendicular to the Y-axis. Vectors along the Y-axis can therefore be computed from vector cross product between and . Realizing that and are the readings of the accelerometer and magnetometer when the body remains static during the initialization, the unit vector along the N frame Y-axis projected on B frame axes can be calculated by × , where, is the B frame projection of the unit gravity vector and is the unit earth's magnetic vector. So, can be computed by × . So can be initialized by × × × .

Fine Alignment Process
Fine alignment process due to estimate the iterative orientation is implemented using Kalman filtering technique. The adaptive extended version of the Kalman filter (EKF) is developed in this study due to the high nonlinearity of the system. The state vector is defined to contain attitude and inertial sensor error, presented by = , where, is quaternion vector of attitude errors, is gyroscopes random errors, is acceleration errors, and is magnetic disturbances. The system model is a time-varying function of angular velocity and accelerations. When the initial value of attitude is obtained, 1st order approximation can be safely applied for remaining residual attitude errors. The attitude errors are defined by first rotating the body by an amount equal to the current attitude estimate [22]. By considering = ^⨂ , where, is the attitude quaternion, the combination of a vector component and a scalar component , and ⨂ indicates quaternion multiplication [23]; ^ is the estimated attitude; represents the small error in attitude, in view of quaternion definition, it is approximated as = ( , 1). For the high-frequency changes of attitude, we should consider ´= 0.5 ⨂ ← − 0.5 ← ⨂ where, ← = ( ← , 0), ← = ( ← , 0). ← and ← are the quaternion form of the angular velocity of the B frame and N frame, respectively; relative to the inertial (I) frame. ← is dominated by the earth's rotation rate, the translational movement of the body, and the earth's local curvature. In the AHRS determination, ← is negligible compared to the errors of low-cost gyroscopes; so, ´= 0.5 ⨂ ← − 0.5 ← ⨂ can be written as 0.5 ⨂ ← . Additionally, the propagation equation of the errors is derived after neglecting the 2nd order terms of , can be simplified as ´ = −0.5( ← ×) , where ( ← ×) is the skew-symmetric matrix of vector ← .
A measurement model is the analytical representation of the actual input to a Kalman filter.
In this study, we consider different inputs of accelerometer, gyroscope, and magnetometer data as the input to the Kalman filter. The general vector notation is used to represent the true gravity or magnetic vector [8].
= −2( ×) , that and The X, Y, and Z axes are mutually orthogonal; thus, the earth' magnetic vector m is perpendicular to the Y-axis. Vectors along the Y-axis can therefore be computed from vector cross product between g and m. Realizing that g B and m B are the readings of the accelerometer and magnetometer when the body remains static during the initialization, the unit vector along the N frame Y-axis projected on B frame axes can be calculated by

Fine Alignment Process
Fine alignment process due to estimate the iterative orientation is implemented using Kalman filtering technique. The adaptive extended version of the Kalman filter (EKF) is developed in this study due to the high nonlinearity of the system. The state vector is defined to contain attitude and inertial sensor error, presented by where, q e is quaternion vector of attitude errors, b B ω is gyroscopes random errors, b B a is acceleration errors, and d B m is magnetic disturbances. The system model is a time-varying function of angular velocity and accelerations. When the initial value of attitude is obtained, 1st order approximation can be safely applied for remaining residual attitude errors. The attitude errors are defined by first rotating the body by an amount equal to the current attitude estimate [22]. By considering q =q q e , where, q is the attitude quaternion, the combination of a vector component q and a scalar component q 0 , and indicates quaternion multiplication [23];q is the estimated attitude; q e represents the small error in attitude, in view of quaternion definition, it is approximated as q e = (q e , 1).
For the high-frequency changes of attitude, we should and ω N I←N are the quaternion form of the angular velocity of the B frame and N frame, respectively; relative to the inertial (I) frame.
ω N I←N is dominated by the earth's rotation rate, the translational movement of the body, and the earth's local curvature. In the AHRS determination, ω N I←N is negligible compared to the errors of low-cost gyroscopes; so,q = 0.5q W B I←B − 0.5W N I←N q can be written as 0.5q W B I←B . Additionally, the propagation equation of the errors is derived after neglecting the 2nd order terms of q e , can be simplified asq e = −0.5 ω B I←B × q e , where (ω B I←B ×) is the skew-symmetric matrix of vector ω B I←B . A measurement model is the analytical representation of the actual input to a Kalman filter.
In this study, we consider different inputs of accelerometer, gyroscope, and magnetometer data as the input to the Kalman filter. The general vector notation A is used to Sensors 2021, 21, 1383 5 of 12 represent the true gravity or magnetic vector [8]. δA N = −2 A N × q e , that A N and δA N represent vector A is projected on N frame, and the error of A N , respectively. According to [8], we can consider δA N = A N −Ĉ N B A B , where,Ĉ N B and A B are the estimated attitude and the true gravity or magnetic vectors, respectively.
Ref. [8] presents that the general linear measurement model can be considered as , applying the accelerometer, gyroscope and magnetometer raw measurements. So, the measurement models are defined as: where A N a , A N m and A N g are the data of the triaxial accelerometer, magnetometer, and gyroscope, b B a , d B m and d B g are the acceleration errors and magnetic disturbance, and gravity errors.
Regarding the sensor model, this study investigated three stochastic models that are developed to account for the gyroscope random drifts, body acceleration, and magnetic disturbances. Employing Allan variance to analyze the stochastic errors of the low-cost gyroscopes used in this study [24,25], a log-log plot of Allan standard deviation σ(τ) versus cluster times τ is shown in Figure 2.
celerometer, gyroscope and magnetometer raw measurements. So, the measurement models are defined as: where , and are the data of the triaxial accelerometer, magnetometer, and gyroscope, , and are the acceleration errors and magnetic disturbance, and gravity errors.
Regarding the sensor model, this study investigated three stochastic models that are developed to account for the gyroscope random drifts, body acceleration, and magnetic disturbances. Employing Allan variance to analyze the stochastic errors of the low-cost gyroscopes used in this study [24,25], a log-log plot of Allan standard deviation ( ) versus cluster times is shown in Figure 2.
The results indicate that the dominant noise type appears in the ( ) ⁄ plot with slope of -1/2, which represents the random walk noise term. The gyroscope stochastic error is thus approximated as a random walk process, presented by ´ = , where, is a vector representing the stochastic errors of a triaxial gyroscope; is a vector of Gaussian white noise with the noise density . The acceleration errors caused by body motion are modeled by a 1st-order Markov random process [ 3], presented by ´ + , where is a vector representing the triaxial acceleration errors; is a diagonal matrix, of which the three diagonal entries are the time constants for the acceleration errors along each axis of the sensor device; is a vector of Gaussian white noise whose density . To extract the stochastic noises in IMU, we put the sensor in static mode for about 4 h. When the experiment is performed in an environment where there are no significant external magnetic fields, the magnetic disturbances can be estimated as a 1st-order Gauss-Markov process, ´ + , where is a random magnetic disturbances vector; is a diagonal matrix, and its three diagonal elements represent the time constants for the magnetic disturbances along each axis; is Gaussian white noise vector with density . The results indicate that the dominant noise type appears in the σ(τ)/τ plot with slope of −1/2, which represents the random walk noise term. The gyroscope stochastic error is thus approximated as a random walk process, presented byb B ω = n B ω , where, b B ω is a vector representing the stochastic errors of a triaxial gyroscope; n B ω is a vector of Gaussian white noise with the noise density σ ω . The acceleration errors caused by body motion are modeled by a 1st-order Markov random process [3], presented byb B a τ a b B a + n B a , where b B a is a vector representing the triaxial acceleration errors; τ a is a diagonal matrix, of which the three diagonal entries are the time constants for the acceleration errors along each axis of the sensor device; n B a is a vector of Gaussian white noise whose density σ a . To extract the stochastic noises in IMU, we put the sensor in static mode for about 4 h. When the experiment is performed in an environment where there are no significant external magnetic fields, the magnetic disturbances can be estimated as a 1st-order Gauss-Markov process,d B m τ m d B m + n B m , where d B m is a random magnetic disturbances vector; τ m is a diagonal matrix, and its three diagonal elements represent the time constants for the magnetic disturbances along each axis; n B m is Gaussian white noise vector with density σ m .

Experimental Results and Discussion
The experiments evaluate the AHRS initialization by different techniques and investigate the accuracy and stability of the AHRS determination and control system in different scenarios. We use MEMS-based inertial sensor unit nIMU, which contains triaxial gyroscope, accelerometer, and magnetometer. Additionally, we utilize an accurate optical motion capturing system Vicon as a true reference.

AHRS Initialization
AHRS initialization consists of coarse alignment and fine alignment. Coarse alignment approximately obtains the initial orientation. As the heading results derived from coarse alignment may be significantly affected by magnetic disturbances, fine alignment is employed to compensate for the heading errors. So, the EKF-based attitude estimation process is used for the initialization under stationary conditions.
The testing unit is placed on the top of a turning table in eight different setups and the data are recorded at 100 Hz for a duration of 10 s. The three-coarse alignment process using three different techniques is evaluated by comparing the Euler angle parameters of the attitude. Three methods present the same accuracy and precision in estimating heading (ψ) orientation shown in Table 1. Regarding the accuracy, three methods almost identically show significant errors compared with the references. The errors have a mean value of 178.1 • and vary between 161.9 • and 188.5 • . The reason causing the heading errors is the existence of magnetic disturbances. In this table, pitch (θ) and roll (φ) angles, when compared with the approach based on the compass heading or hybrid method techniques, the geomagnetic matching presents significant errors in the pitch and roll angles among some scenarios. The maximum differences between compass heading and the references are 1.5 • and 0.8 • ; whereas the differences are 7.0 • and 5.6 • , in pitch and roll, respectively, for geomagnetic matching. Regarding the pitch angles, although 50% of scenarios have an estimation error less than 1.0 • using the geomagnetic matching method, some trails show significant errors bigger than 6.0 • .
The reason for significant errors in estimating pitch and roll attitude using the geomagnetic matching technique is that the gravity measurements are exclusively used to compute the pitch and roll angles in the approaches based on compass heading and hybrid method techniques. Since the accelerometer is stationary during the initialization process, it only measures gravity and thus provides a good estimation of pitch and roll angles.
The adaptive EKF used for fine alignment is applied at the end of the coarse alignment. It is operated under static conditions for a duration of 10 s. The result of the coarse alignment is used to initialize the system.
In the proposed adaptive EKF, magnetic disturbances are estimated as a random vector and be tuned by modifying the parameters of the time constant matrix. It can be observed from Figures 3 and 4, regarding the Bland-Altman plot between the reference and the adaptive EKF, that the fine alignment first starts from the Euler angles derived from coarse alignment. After a few iterations of filtering, the heading angles convergence is quick; however, it varies on the scenarios. In the proposed adaptive EKF, magnetic disturbances are estimated as a random vector and be tuned by modifying the parameters of the time constant matrix. It can be observed from Figures 3 and 4, regarding the Bland-Altman plot between the reference and the adaptive EKF, that the fine alignment first starts from the Euler angles derived from In the proposed adaptive EKF, magnetic disturbances are estimated as a random vector and be tuned by modifying the parameters of the time constant matrix. It can be observed from Figures 3 and 4, regarding the Bland-Altman plot between the reference and the adaptive EKF, that the fine alignment first starts from the Euler angles derived from coarse alignment. After a few iterations of filtering, the heading angles convergence is quick; however, it varies on the scenarios.   In Table 2, compared with the heading results derived from coarse alignment shown in Table 1, the heading angles converge to the reference in all the scenarios after the fin alignment process. This demonstrates the effectiveness of the fine alignment EKF in estimating and compensating the magnetic disturbances. The accuracy of the headings is reached at an average error of 2.9°. Regarding the pitch and roll angles, the pitch angle presents an average error of 0.5° compared with the references; the roll angles have an average error of 0.5°. In conclusion, the proposed adaptive EKF presents a significant improvement in the heading attitude by compensating magnetic disturbances.

AHRS Estimation in a Long-Term Test
The adaptive EKF used by the fine alignment process is also employed in the attitude estimation. After the completion of a fine alignment, the adaptive EKF automatically works in the dynamic estimation of attitude.
Tests are performed to validate the performance of the proposed EKF under a dynamic scenario. The attitude in this study is determined by three methods: (1) dead-reckoning, i.e., the angular velocity from gyroscopes is integrated into standalone mode, namely INS; (2) attitude iterative estimation by EKF that considers only accelerometers and gyroscopes for integration, namely EKF(Acc+Gyr), (3) attitude iterative estimation by EKF that considers accelerometers, gyroscopes and magnetometers for integration without coarse and fine alignments, namely EKF1(Acc+Gyr+Mag), (4) attitude iterative estimation by EKF that considers accelerometers, gyroscopes and magnetometers for integration with initialization coarse and fine alignments, namely EKF2(Acc+Gyr+Mag) discussed in Section 3; (5) Vicon optical system used as the reference. The attitude results represented by Euler angles are given in Figure 5. In Table 2, compared with the heading results derived from coarse alignment shown in Table 1, the heading angles converge to the reference in all the scenarios after the fin alignment process. This demonstrates the effectiveness of the fine alignment EKF in estimating and compensating the magnetic disturbances. The accuracy of the headings is reached at an average error of 2.9 • . Regarding the pitch and roll angles, the pitch angle presents an average error of 0.5 • compared with the references; the roll angles have an average error of 0.5 • . In conclusion, the proposed adaptive EKF presents a significant improvement in the heading attitude by compensating magnetic disturbances.

AHRS Estimation in a Long-Term Test
The adaptive EKF used by the fine alignment process is also employed in the attitude estimation. After the completion of a fine alignment, the adaptive EKF automatically works in the dynamic estimation of attitude.
Tests are performed to validate the performance of the proposed EKF under a dynamic scenario. The attitude in this study is determined by three methods: (1) dead-reckoning, i.e., the angular velocity from gyroscopes is integrated into standalone mode, namely INS; (2) attitude iterative estimation by EKF that considers only accelerometers and gyroscopes for integration, namely EKF(Acc+Gyr), (3) attitude iterative estimation by EKF that considers accelerometers, gyroscopes and magnetometers for integration without coarse and fine alignments, namely EKF1(Acc+Gyr+Mag), (4) attitude iterative estimation by EKF that considers accelerometers, gyroscopes and magnetometers for integration with initialization coarse and fine alignments, namely EKF2(Acc+Gyr+Mag) discussed in Section 3; (5) Vicon As can be seen in the figure, the drift in the attitude solution derived from INS without considering any additional method for calculation is significant. The heading, pitch and roll angles rapidly diverge from the reference. This figure also presents that while EKF(Acc+Gyr), EKF1(Acc+Gyr+Mag), and EKF2 (Acc+Gyr+Mag) outperform INS solution due to their partial usage of IMU data or initialization methods (coarse and fine alignments), they cannot reach the reference performance.
Compared with the previous solutions, the attitude EKF2 presents a good estimation of the attitude. Figure 6, which considers the first 300 s of the test, shows that the heading angles converge to the heading reference at 187° after the fine alignment and the transition from fine alignment to the attitude estimation process is automatic. The initial transients generated from the fine alignment are depicted in Figure 7, where it is seen that the heading is converged in less than one second. The average error in the heading angles is 2.5° compared with the reference. One can also realize that as the iteration proceeds, the attitude errors are reduced gradually. For example, the average error during the time 0∼150 s is less than 1.0°; whereas it is 2.0° during 140∼270 s. As can be seen in the figure, the drift in the attitude solution derived from INS without considering any additional method for calculation is significant. The heading, pitch and roll angles rapidly diverge from the reference. This figure also presents that while EKF(Acc+Gyr), EKF1(Acc+Gyr+Mag), and EKF2 (Acc+Gyr+Mag) outperform INS solution due to their partial usage of IMU data or initialization methods (coarse and fine alignments), they cannot reach the reference performance.
Compared with the previous solutions, the attitude EKF2 presents a good estimation of the attitude. Figure 6, which considers the first 300 s of the test, shows that the heading angles converge to the heading reference at 187 • after the fine alignment and the transition from fine alignment to the attitude estimation process is automatic. The initial transients generated from the fine alignment are depicted in Figure 7, where it is seen that the heading is converged in less than one second. The average error in the heading angles is 2.5 • compared with the reference. One can also realize that as the iteration proceeds, the attitude errors are reduced gradually. For example, the average error during the time 0~150 s is less than 1.0 • ; whereas it is 2.0 • during 140~270 s. The max error (6°) in the heading is caused by the errors in the gravity measurements used in Kalman filtering and the cross-axis sensitivity of the inertial sensors. A small error in the gravity measurements has a significant impact on the heading. The errors in the heading are coupled into pitch and roll because of the sensor cross-axis sensitivity. This ment process, the attitude EKF2 reaches the same accuracy in estimating pitch and roll under dynamic conditions. The errors caused by the rotations introduced during the testing are not exactly about the sensor axes; as a result, the rotation along one axis is projected into the other two axes. Moreover, the EKF2-derived attitude is noisier compared to the reference because the EKF2 is tuned to have a wide bandwidth and thus a quick dynamic response.  The max error (6 • ) in the heading is caused by the errors in the gravity measurements used in Kalman filtering and the cross-axis sensitivity of the inertial sensors. A small error in the gravity measurements has a significant impact on the heading. The errors in the heading are coupled into pitch and roll because of the sensor cross-axis sensitivity. This increases the errors in the gravity measurements due to the deteriorated pitch and roll solutions.
The Bland-Altman plot of pitch and roll angles obtained from the attitude EKF2 presented in Figure 8 shows the average errors of 0.7 • in both. Compared with the fine alignment process, the attitude EKF2 reaches the same accuracy in estimating pitch and roll under dynamic conditions. The errors caused by the rotations introduced during the testing are not exactly about the sensor axes; as a result, the rotation along one axis is projected into the other two axes. Moreover, the EKF2-derived attitude is noisier compared to the reference because the EKF2 is tuned to have a wide bandwidth and thus a quick dynamic response. In conclusion, the attitude EKF2 presents a stable and accurate estimation of the attitude referring to the reference. This demonstrates the feasibility of applying such an EKF2 in estimating attitude when using the low-cost inertial sensors.

Conclusions
This paper developed and validated an AHRS estimation algorithm in navigation and tracking systems using low-cost and small-scale MEMS-based inertial sensors. The attitude estimation process incorporates the mechanism for adapting the EKF in the presence of sensor acceleration and magnetic disturbances. In the experiment, improvement in the accuracy of the initial orientation as significant as 45% is obtained from the new method as compared with other techniques. While the performance of this method is superior to the other techniques, the errors in the derived initial orientation are sometimes as much as 8°. These errors affect the subsequent attitude estimation process and may result in the deterioration of the attitude estimates. So, future work will investigate the impact of the initial errors on the attitude estimates. This will help indicate the sources of In conclusion, the attitude EKF2 presents a stable and accurate estimation of the attitude referring to the reference. This demonstrates the feasibility of applying such an EKF2 in estimating attitude when using the low-cost inertial sensors.

Conclusions
This paper developed and validated an AHRS estimation algorithm in navigation and tracking systems using low-cost and small-scale MEMS-based inertial sensors. The attitude estimation process incorporates the mechanism for adapting the EKF in the presence of sensor acceleration and magnetic disturbances. In the experiment, improvement in the accuracy of the initial orientation as significant as 45% is obtained from the new method as compared with other techniques. While the performance of this method is superior to the other techniques, the errors in the derived initial orientation are sometimes as much as 8 • . These errors affect the subsequent attitude estimation process and may result in the deterioration of the attitude estimates. So, future work will investigate the impact of the initial errors on the attitude estimates. This will help indicate the sources of the initial errors and interpret the errors in the attitude estimation process, which in turn will improve the accuracy of the estimated orientation.
Author Contributions: R.J.L. conceptualized and directed the project, Methodology, validation, and secured funding. N.N. drove back-end code development, testing, and documentation; lead the integration, and was the primary author on this paper. All authors have read and agreed to the published version of the manuscript.