# Novel MARG-Sensor Orientation Estimation Algorithm Using Fast Kalman Filter

Authors: Siwen Guo; Jin Wu; Zuocai Wang; Jide Qian
Journal: Journal of Sensors
 (2017)

---

## Abstract

Orientation estimation from magnetic, angular rate, and gravity (MARG) sensor array is a key problem in mechatronic-related applications. This paper proposes a new method in which a quaternion-based Kalman filter scheme is designed. The quaternion kinematic equation is employed as the process model. With our previous contributions, we establish the measurement model of attitude quaternion from accelerometer and magnetometer, which is later proved to be the fastest (computationally) one among representative attitude determination algorithms of such sensor combination. Variance analysis is later given enabling the optimal updating of the proposed filter. The algorithm is implemented on real-world hardware where experiments are carried out to reveal the advantages of the proposed method with respect to conventional ones. The proposed approach is also validated on an unmanned aerial vehicle during a real flight. Results show that the proposed one is faster than any other Kalman-based ones and even faster than some complementary ones while the attitude estimation accuracy is maintained.


---

## Body

## 1. Introduction

In many robotic applications, the system needs to obtain the orientation parameters of some vital mechanical parts so that it can precisely control the actuators [1]. As is known, the orientation parameters consist of the roll, pitch, and yaw angles, namely, the frequently used Euler angles [2]. Usually, MARG sensors, that is, the gyroscope, accelerometer, and magnetometer, are employed to compute the orientation [3, 4]. Modern technological advances have allowed for the massive production of microelectromechanical-system (MEMS) inertial sensors, which are highly compactly integrated [5]. There are many other sensor combinations, for example, the gyro-accelerometer and gyro-magnetometer ones, which have been discussed in [6]. In the past decade, there has been many efforts around the sensor fusion techniques of MARG sensors.Attitude can often be acquired from integral of angular rates from gyroscope triads or least-square problem formed by vector observations [7, 8]. The first approach is related to the inertial navigation system (INS) in which inertial sensors are produced with tactical-grade quality. The second one is called Wahba’s problem when there are at least two vector observations [9]. For consumer electronics, MEMS gyroscope faces dilemma as there are too many uncertainties inside almost every process of the angular-rate sensing [10]. According to this, the angular-rate integral diverges very fast as time goes. Hence, to obtain stable and accurate attitude outputs, the gyroscope integral should be compensated using other strapdown sensors [11]. For instance, using accelerometer and magnetometer, it is able to determine the local gravity vector and geomagnetic heading, respectively [12].Early concerns about the MARG-sensor fusion are almost raised around 1990s when some researchers started to develop fusion algorithms based on complementary filters. Foxlin first used MARG sensors to monitor the attitude motion of human’s head [13]. One general framework of sensor fusion that combines the accelerometer and magnetometer as the electronic compass (eCompass) [14]. Marins et al. then tried to compute the attitude from eCompass using the Gauss-Newton algorithm (GNA) via quaternion representation [15]. This commitment was revisited by Madgwick et al. in 2011 showing that the gradient descent algorithm (GDA) could be another possible solution [6]. Besides, optimization methods like improved Gauss-Newton algorithm (IGNA, [16]) and Levenberg-Marquadt algorithm (LMA, [17]) are also applied for faster and more robust solutions. The above methods use optimization algorithms to compute attitude quaternion from the eCompass system. Mahony et al. tried different way where the attitude representation on special orthogonal groups is studied [18]. Using transformation of Wahba’s problem, Marantos et al. designed one efficient complementary filter with singular value decomposition (SVD) as well [19].The above ones focus on complementary filter design of attitude estimator. Complementary filters are flexible for application on common platforms but still have their drawbacks. The main concern is that the complementary gain is always empirically given for one time and would result in terrible estimates for another quite different performance. The second one is that some complementary gains degenerate to constants for the sake of convenience in engineering practice which significantly limits the estimation accuracy and convergence speed. To overcome such problem, Kalman filter is employed. The Kalman filter is an optimal estimator for real-time inputs in the sense of minimal mean-squared error (MMSE) [20]. Designed in this way, it owns the best estimation accuracy statistically. However, since Kalman filter is developed especially for linear system with uncorrelated white Gaussian noises (WGN), when nonlinearities are involved, the conventional filter would be no longer useful. In order to solve such problems, variants of Kalman filter like the extended Kalman filter (EKF, [21]) and unscented Kalman filter (UKF, [22]) are proposed and extensively investigated. For instance, when representing the direction cosine matrix (DCM) with quaternion, the quadratic items lead to nonlinearities. To overcome this, Sabatini designed an EKF to obtain accurate attitude outputs from MARG sensors [23]. The UKF approach is proposed by Crassidis and Markley revealing higher accuracy compared with existing filters [24]. It should be noted that, in such practices, extra computations like linearization, Cholesky factorization, and so forth increase the time consumption of the attitude estimation algorithm significantly.Therefore, we can see that it is necessary to find one method that is accurate statistically but fast even compared with complementary filters. In fact, in our previous research, the attitude determination from accelerometer is computed via linear quaternion transformations. In this paper, this motivates us to develop a novel quaternion measurement algorithm from accelerometer and magnetometer jointly. The algorithm serves as the observation model of the Kalman filter where the observation variance is systematically derived. Using the quaternion kinematic equation as the process model, the Kalman filter is established. Experiments are conducted to show the performance of the proposed filter with respect to representative methods. The results show that the filter is better for time consumption and maintains high attitude accuracy.This paper is structured as follows: Section2 introduces novel method for attitude determination from accelerometer and magnetometer. Section 3 consists of the design and implementation of the novel fast Kalman filter. Section 4 includes the experimental descriptions, results, and comparisons. Section 5 contains the concluding remarks.


## 2. Novel Quaternion Determination Method from Accelerometer and Magnetometer

The attitude determination can be modeled with the following system:(1)Ab=CAr,Mb=CMr,where C is the DCM. Ab=(ax,ay,az)T and  Mb=(mx,my,mz)T are sensor outputs from accelerometer and magnetometer in the body frame b while Ar=(0,0,1)T and  Mr=(mN,0,mD)T are reference vectors of the two sensors in the reference frame r, respectively. C can be represented by quaternions and it can be decomposed in columns by [10] (2)C=C1,C2,C3,C1=P1q,C2=P2q,C3=P3q,P1=q0q1-q2q3-q3q2q1-q0q2q3q0q1,P2=q3q2q1q0q0-q1q2-q3-q1-q0q3q2,P3=-q2q3-q0q1q1q0q3q2q0-q1-q2q3,where q=(q0,q1,q2,q3)T is the unit attitude quaternion. In our previous literature [10], it is proved that(3)P1†=P1T,P2†=P2T,P3†=P3T,where † denotes the Moore-Penrose pseudoinverse. Now based on these, we introduce a novel attitude determination algorithm from accelerometer and magnetometer.The magnetometer equation can be rewritten as(4)Mb=CMr=C1,C2,C3mN0mD=mNC1+mDC3=mNP1+mDP3q.We also have(5)mNP1+mDP3mNP1+mDP3T=mN2P1P1T+mD2P3P3T+mNmDP1P3T+P3P1T.An interesting result is that(6)P1P3T+P3P1T=03×3 which leads to(7)mNP1+mDP3mNP1+mDP3T=mN2+mD2I3×3=I3×3. This generates(8)mNP1+mDP3†=mNP1+mDP3T.Hence it is obtained that(9)Mb=mNP1+mDP3q⟹q=mNP1+mDP3TMb.Expanding (9), we have (10)q=mDmzq0+myq1-mxq2+mNmxq0+mzq2-myq3mDmyq0-mzq1+mxq3+mNmxq1+myq2+mzq3mNmzq0+myq1-mxq2-mDmxq0+mzq2-myq3-mNmyq0-mzq1+mxq3+mDmxq1+myq2+mzq3which can be simplified as(11)q=Wmq,(12)Wm=mNmx+mDmzmDmymNmz-mDmx-mNmymDmymNmx-mDmzmNmymNmz+mDmxmNmz-mDmxmNmy-mNmx-mDmzmDmy-mNmymNmz+mDmxmDmy-mNmx+mDmzin which Wm is given in (12). Then it computed that(13)Wm2=mN2+mD2mx2+my2+mz2I4×4=I4×4. This shows that (11) can not be solved via direct iteration, recalling that, in our previous paper [10], we proved that the stable solution of(14)q=Wq is(15)qt=12Wt+I4×4qt-1 if and only if Wt2=I4×4. Here, t denotes the time epoch. Then we have(16)qm,t=12Wm,t+I4×4qt-1, where qm,t stands for the quaternion from magnetometer at the t time epoch.Combining the previous result of quaternion from accelerometer, that is,(17)qa,t=12Wa,t+I4×4qt-1, where(18)Wa=azay-ax0ay-az0ax-ax0-azay0axayaz with the above equation of magnetometer, we obtain Algorithm 1 for attitude determination algorithm from accelerometer and magnetometer.Algorithm 1:Attitude determination from accelerometer and magnetometer.
Initialize:
qt=0=(1,0,0,0)T
Initialization flag = false
Initialization accuracy:ε=ε0
while no abort command received do
(1) t=t+1
(2) Input sensor observations:  Ab,Mb
(3) Normalization:  Ab=Ab/Ab,Mb=Mb/Mb
(4) If  Initialization flag = false
k=0
Do
(a)k=k+1
(b)qinit,k=(1/4)Wa,t=1+I4×4Wm,t=1+I4×4qinit,k-1
(c)qinit,k=qinit,k/qinit,k
Whileqinit,k-qinit,k-1≥ε
qt=1=qinit,k
Initializationflag=true
Else
qt=(1/4)Wa,t+I4×4Wm,t+I4×4qt-1
(5) qt=qt/qt
end while


## 3. Kalman Filter Design

In our design, the quaternion kinematic equation is employed as the process model. The gyroscope’s bias is not concerned in the current form. The gyroscope’s bias and biases of the accelerometer and magnetometer for observation model are cancelled before the filter update. Using the attitude determination algorithm proposed in the last section as the observation model, we model the system by(19)dqdt=12Ω×q,qmeasure,t=qacc,mag,t,where(20)Ω×=0-ωx-ωy-ωzωx0ωz-ωyωy-ωz0ωxωzωy-ωx0 in which ω=(ωx,ωy,ωz)T denotes the angular rate from gyroscope. The discretized system is then given by(21)qt=I4×4+Δt2Ω×qt-1,qmeasure,t=qacc,mag,t.As there are stochastic noises inside the sensor outputs, both the process and observation models contain noise items; hence the system should be rewritten as(22)qt=I4×4+Δt2Ω×qt-1+ξt,qmeasure,t=qacc,mag,t+υt,where Δt is the time span between time epoch t and t-1. The process noise’s variance is given by(23)Σξt=Δt22ΞtΣgyroΞtT,where Σgyro stands for the variance of angular rates’ covariance, which is usually given by Σgyro=diag[σωx2,σωy2,σωz2], while σωi denotes the standard deviation of i-axis’ angular rate. Ξt is given by(24)Ξt=q1q2q3-q0-q3-q2q2-q0-q1-q2q1-q0. The measurement quaternion is computed using(25)qt=14Wa,t+I4×4Wm,t+I4×4qt-1.The observation noise is induced by accelerometer and magnetometer’s noises and we can see that, according to matrix multiplication, the accelerometer vector and magnetometer vector have been mixed. In this way, there are quadratic nonlinearities inside the propagation of variance. Hence, for the observation model, the variance is given by the first-order approximation. The measurement quaternion’s variance is approximated by(26)Συt=JΣacc,magJTin which(27)J=∂qacc,mag,t∂AbT,MbT=∂q0∂ax∂q0∂ay∂q0∂az∂q0∂mx∂q0∂my∂q0∂mz∂q1∂ax∂q1∂ay∂q1∂az∂q1∂mx∂q1∂my∂q1∂mz∂q2∂ax∂q2∂ay∂q2∂az∂q2∂mx∂q2∂my∂q2∂mz∂q3∂ax∂q3∂ay∂q3∂az∂q3∂mx∂q3∂my∂q3∂mzwhose details are given in the Appendix 5. Σacc,mag is given by(28)Σacc,mag=diagΣacc,Σmag,where Σacc,Σmag are covariances of accelerometer and magnetometer, respectively. Then we can use the following algorithm to obtain MMSE estimation of attitude via Kalman filter: (1)
State prediction:qt-=I4×4+(Δt/2)Ω×qt-1.(2)
Covariance prediction:Σqt-=I4×4+(Δt/2)Ω×Σqt-1I4×4+(Δt/2)Ω×T+Σξt.(3)
Kalman gain:Gt=Σqt-Σqt-+Συt-1.(4)
State correction:qt=qt-+Gkqacc,mag,t-qt-.(5)
Covariance update:Σqt=I4×4-GkΣqt-. It can be seen that the overall calculation steps are time efficient and flexible.


### 3.1. Discussion of the Kalman Filter

In previous descriptions, we have noted that the Kalman filter can not be applied to systems with correlation noises. As given in (25), the quaternion noise not only relates to accelerometer and magnetometer’s outputs but also relates to the covariance of the optimal quaternion computed last time. However, according to real-time applications, the measurement from accelerometer and magnetometer at time t has very tiny correlation with last time’s quaternion. Hence it is almost independent with predicted quaternions as well. Therefore, here it is possible to use Kalman filter for attitude estimation.


## 3.1. Discussion of the Kalman Filter

In previous descriptions, we have noted that the Kalman filter can not be applied to systems with correlation noises. As given in (25), the quaternion noise not only relates to accelerometer and magnetometer’s outputs but also relates to the covariance of the optimal quaternion computed last time. However, according to real-time applications, the measurement from accelerometer and magnetometer at time t has very tiny correlation with last time’s quaternion. Hence it is almost independent with predicted quaternions as well. Therefore, here it is possible to use Kalman filter for attitude estimation.


## 4. Experiments and Results

In this section, we conduct several experiments using the MicroStrain 3DM-GX3-25 attitude and heading reference system (AHRS). The hardware is shown in Figure1. The AHRS is 9 degrees of freedom (9DOF) which contains 3-axis precision gyroscope, accelerometer, and magnetometer. According to the official datasheet of the AHRS, the inside attitude estimation program is formed by EKF providing users with highly reliable attitude estimation. Besides, the specially designed data transmission protocol allows for the logging of raw sensor data. In the following experiments, the data sampling frequency is set to 500 Hz and the motion is randomly generated using human’s hand. The raw inertial data and the reference attitude angles are measured and collected via the USB data wire. To visually display the attitude estimation performance, we also design one upper monitor software program showing the attitude motion from the AHRS and proposed method (see Figure 2).Figure 1
The MicroStrain 3DM-GX3-25 AHRS for experimental validation.Figure 2
Designed upper monitor for visual display of attitude estimation.


### 4.1. Experiment 1: Comparisons with Commercial AHRS

In this experiment, we compare the attitude estimates from the proposed filter and AHRS so that the absolute accuracy of our method can be verified. The variances of gyroscope, accelerometer, and magnetometer are computed via statistical data when the AHRS is still on the table. The parameters areΣgyro=diag(0.0011,0.0009,0.0013), Σacc=diag(0.01,0.098,0.011), and Σmag=diag(0.014,0.012,0.020). The recorded raw sensor data is shown in Figure 3. Using our proposed Kalman filter, the estimated quaternions are converted to Euler angles and are plotted with reference angles together in Figure 4.Figure 3
Raw sensor data of angular rate, acceleration, and magnetic field.Figure 4
Estimated Euler angles and reference angles.We can see that the proposed filter outputs accurate attitude estimates which coincide with the reference angles very well. The MSEs of roll, pitch, and yaw angles with respect to the reference are 0.0134°, 0.0286°, and 0.335°, respectively, which show that the proposed algorithm is accurate.To verify the observation model and its variance, the measurement quaternion and its3σ bounds are demonstrated in Figure 5. The standard deviation of the quaternion is computed by taking the square roots of the diagonal elements of the covariance matrix. In the presented materials, we would find out that the measurement quaternions are continuous. The measurement quaternion’s standard deviation bounds fit the measurement quaternion very well. Hence, the first-order approximation of the measurement quaternion is experimentally verified to be adequate to describe the noise characteristics.Figure 5
Measurement quaternion and its standard deviation bounds.Experiment1 shows that the proposed filter can estimate attitude angles of quite the same accuracy with commercial EKF-based AHRS. However, compared with EKF, there is no doubt that the flexible design of the proposed filter allows for the huge decrease of time consumption. This is going to be shown in the next subsection.


### 4.2. Experiment 2: Comparisons with Representative Complementary Filters

Using the hardware presented in Figure1, we acquire another sample of motion’s data. The raw data is processed here with the proposed filter and representative complementary ones including the LMA-Complementary Observer (LMA-CO) by Fourati et al. [17] and Wahba’s Complementary Filter (WCF) by Marantos et al. [19] The factor of LMA in LMA-CO is set to 0.01 according to related literature while its complementary gain is set to 0.01 denoting the motion’s change rate. The parameters of WCF follow the original author’s determination that are given by wa=0.9,wm=0.8,c1=0.7,c2=0.3,c3a=8500.0,c3m=5500.0. And for the sake of justice, the adaptive mode of WCF is not enabled. The computed Euler angles are drawn in Figure 6.Figure 6
Estimated Euler angles from the proposed filter, LMA-CO, and WCF.We can see that the differences between LMA-CO and the proposed filter are quite small while that between WCF and the proposed filter seems to be relatively larger. Throughout computations of MSEs with respect to reference angles, the results are shown in Table1.Table 1
MSEs of attitude angles.
Algorithm
Roll
Pitch
Yaw
LMA-CO
0.1514°
0.1052°
0.7143°
WCF
1.2833°
1.0069°
0.5688°
Proposed method
0.0893°
0.0726°
0.1346°This shows that the proposed filter is more accurate than the two representative methods. In engineering practice, the time consumption of one certain algorithm is another critical character. The comparison of time consumption of these algorithms is tested and plotted in Figure7.Figure 7
Tested time consumption of different algorithms.Compared with LMA-CO and WCF, we may find out that the proposed filter owns the least time consumption. This is because LMA-CO uses more complicated LMA and WCF adopts SVD for attitude estimation. The proposed filter, however, has only one computationally-complex process, that is, the inversion operation. This shows that the proposed filter is faster than these representative complementary filters.


### 4.3. Experiment 3: Comparisons with Representative Kalman Filter

In this subsection, we also evaluate the results from a recent representative Kalman filter, that is, the Algebraic QUAternion Kalman Filter (AQUA-KF) by Valenti et al. [25]. Related variances of sensors are the same as that of the proposed filter. Using the data sample from the last subsection, the estimation results are computed and shown in Figure 8.Figure 8
Estimated Euler angles from the proposed filter and AQUA-KF.We can see that the AQUA-KF seems to have some minor differences with the proposed filter. For AQUA-KF, the MSEs of roll, pitch, and yaw angles with respect to reference angles are 2.24°, 1.56°, and 3.67°. The details of the proposed filter on this data sample have been shown in Table1. We can directly see that the proposed filter is more accurate than the AQUA-KF.Moreover, we also evaluate the time consumption performance of the two filters. The tested time consumption results are shown in Figure9 revealing that the AQUA-KF is evidently slower than the proposed one. This is because the AQUA-KF obtains observation model via the AQUA algorithm which needs more judgement and matrix operations.Figure 9
Time consumption results of the proposed filter and AQUA-KF.


### 4.4. Experiment 4: Test Results on an Unmanned Aerial Vehicle

In this experiment, the proposed approach is validated on an unmanned aerial vehicle. The designed platform is composed of an MEMS inertial sensor array, a vision-inertial AHRS, a micro controller, USB debugger, and a transmitter (see Figure10). Using the monitoring software we designed, it is possible to log the raw data and calculate orientation visually. The MEMS inertial sensor array contains high-end 3-axis gyroscope, accelerometer, and magnetometer.Figure 10
Mounted test platform with inertial sensor array, vision-inertial AHRS, micro controller, transmitter, and so forth.The vision-inertial AHRS is made by YunHeng Tech. Inc., Chengdu, China, giving high-resolution and precision attitude outputs according to local vision and inertial measurements. The XBee S3B Pro transmitter is used for wireless data transmission. The raw sensor outputs and referenced information are processed with the micro controller, an STM32F407VG board with 168 MHz clock speed, and abundant interfaces for data interaction. The sensor biases are cancelled before the flight was done according to the method by Zhang [26]. During a real flight in Chengdu, Sichuan Province, China, the raw measurements of accelerometer, gyroscope, and magnetometer are collected. Meanwhile, the vision-inertial AHRS provides us with the reference angles for comparison. The whole project is implemented using C++ programming language on the IAR Embedded WorkBench IDE. The raw inertial data during the flight test is logged via the upper monitor and is plotted in Figure 11. Using this sample, the estimated Euler angles are calculated, which are compared with the outputs from the onboard vision-inertial AHRS (see Figure 12). We can see from the results that the roll and pitch angles fit the reference ones very well while the yaw does not show the same accuracy. This is because when the motors on the drone are armed, the local magnetic field is significantly disturbed, leading to the biases of the magnetometer’s measurement. Such phenomenon can actually be avoided by adopting the magnetic-field modeling presented by Zhou et al. [27]. The roll and pitch’s performances show that the proposed filter is able to accomplish attitude estimation tasks in real-flight tests.Figure 11
Raw inertial sensor data of the flight test.Figure 12
Estimated and reference Euler angles during the flight test.Besides, from Figure13, we can also find out that the variance information can well describe the characteristics of the estimation uncertainties, which helps the quality monitoring in a degree.Figure 13
The variance of estimated quaternions and their 3σ bounds.


## 4.1. Experiment 1: Comparisons with Commercial AHRS

In this experiment, we compare the attitude estimates from the proposed filter and AHRS so that the absolute accuracy of our method can be verified. The variances of gyroscope, accelerometer, and magnetometer are computed via statistical data when the AHRS is still on the table. The parameters areΣgyro=diag(0.0011,0.0009,0.0013), Σacc=diag(0.01,0.098,0.011), and Σmag=diag(0.014,0.012,0.020). The recorded raw sensor data is shown in Figure 3. Using our proposed Kalman filter, the estimated quaternions are converted to Euler angles and are plotted with reference angles together in Figure 4.Figure 3
Raw sensor data of angular rate, acceleration, and magnetic field.Figure 4
Estimated Euler angles and reference angles.We can see that the proposed filter outputs accurate attitude estimates which coincide with the reference angles very well. The MSEs of roll, pitch, and yaw angles with respect to the reference are 0.0134°, 0.0286°, and 0.335°, respectively, which show that the proposed algorithm is accurate.To verify the observation model and its variance, the measurement quaternion and its3σ bounds are demonstrated in Figure 5. The standard deviation of the quaternion is computed by taking the square roots of the diagonal elements of the covariance matrix. In the presented materials, we would find out that the measurement quaternions are continuous. The measurement quaternion’s standard deviation bounds fit the measurement quaternion very well. Hence, the first-order approximation of the measurement quaternion is experimentally verified to be adequate to describe the noise characteristics.Figure 5
Measurement quaternion and its standard deviation bounds.Experiment1 shows that the proposed filter can estimate attitude angles of quite the same accuracy with commercial EKF-based AHRS. However, compared with EKF, there is no doubt that the flexible design of the proposed filter allows for the huge decrease of time consumption. This is going to be shown in the next subsection.


## 4.2. Experiment 2: Comparisons with Representative Complementary Filters

Using the hardware presented in Figure1, we acquire another sample of motion’s data. The raw data is processed here with the proposed filter and representative complementary ones including the LMA-Complementary Observer (LMA-CO) by Fourati et al. [17] and Wahba’s Complementary Filter (WCF) by Marantos et al. [19] The factor of LMA in LMA-CO is set to 0.01 according to related literature while its complementary gain is set to 0.01 denoting the motion’s change rate. The parameters of WCF follow the original author’s determination that are given by wa=0.9,wm=0.8,c1=0.7,c2=0.3,c3a=8500.0,c3m=5500.0. And for the sake of justice, the adaptive mode of WCF is not enabled. The computed Euler angles are drawn in Figure 6.Figure 6
Estimated Euler angles from the proposed filter, LMA-CO, and WCF.We can see that the differences between LMA-CO and the proposed filter are quite small while that between WCF and the proposed filter seems to be relatively larger. Throughout computations of MSEs with respect to reference angles, the results are shown in Table1.Table 1
MSEs of attitude angles.
Algorithm
Roll
Pitch
Yaw
LMA-CO
0.1514°
0.1052°
0.7143°
WCF
1.2833°
1.0069°
0.5688°
Proposed method
0.0893°
0.0726°
0.1346°This shows that the proposed filter is more accurate than the two representative methods. In engineering practice, the time consumption of one certain algorithm is another critical character. The comparison of time consumption of these algorithms is tested and plotted in Figure7.Figure 7
Tested time consumption of different algorithms.Compared with LMA-CO and WCF, we may find out that the proposed filter owns the least time consumption. This is because LMA-CO uses more complicated LMA and WCF adopts SVD for attitude estimation. The proposed filter, however, has only one computationally-complex process, that is, the inversion operation. This shows that the proposed filter is faster than these representative complementary filters.


## 4.3. Experiment 3: Comparisons with Representative Kalman Filter

In this subsection, we also evaluate the results from a recent representative Kalman filter, that is, the Algebraic QUAternion Kalman Filter (AQUA-KF) by Valenti et al. [25]. Related variances of sensors are the same as that of the proposed filter. Using the data sample from the last subsection, the estimation results are computed and shown in Figure 8.Figure 8
Estimated Euler angles from the proposed filter and AQUA-KF.We can see that the AQUA-KF seems to have some minor differences with the proposed filter. For AQUA-KF, the MSEs of roll, pitch, and yaw angles with respect to reference angles are 2.24°, 1.56°, and 3.67°. The details of the proposed filter on this data sample have been shown in Table1. We can directly see that the proposed filter is more accurate than the AQUA-KF.Moreover, we also evaluate the time consumption performance of the two filters. The tested time consumption results are shown in Figure9 revealing that the AQUA-KF is evidently slower than the proposed one. This is because the AQUA-KF obtains observation model via the AQUA algorithm which needs more judgement and matrix operations.Figure 9
Time consumption results of the proposed filter and AQUA-KF.


## 4.4. Experiment 4: Test Results on an Unmanned Aerial Vehicle

In this experiment, the proposed approach is validated on an unmanned aerial vehicle. The designed platform is composed of an MEMS inertial sensor array, a vision-inertial AHRS, a micro controller, USB debugger, and a transmitter (see Figure10). Using the monitoring software we designed, it is possible to log the raw data and calculate orientation visually. The MEMS inertial sensor array contains high-end 3-axis gyroscope, accelerometer, and magnetometer.Figure 10
Mounted test platform with inertial sensor array, vision-inertial AHRS, micro controller, transmitter, and so forth.The vision-inertial AHRS is made by YunHeng Tech. Inc., Chengdu, China, giving high-resolution and precision attitude outputs according to local vision and inertial measurements. The XBee S3B Pro transmitter is used for wireless data transmission. The raw sensor outputs and referenced information are processed with the micro controller, an STM32F407VG board with 168 MHz clock speed, and abundant interfaces for data interaction. The sensor biases are cancelled before the flight was done according to the method by Zhang [26]. During a real flight in Chengdu, Sichuan Province, China, the raw measurements of accelerometer, gyroscope, and magnetometer are collected. Meanwhile, the vision-inertial AHRS provides us with the reference angles for comparison. The whole project is implemented using C++ programming language on the IAR Embedded WorkBench IDE. The raw inertial data during the flight test is logged via the upper monitor and is plotted in Figure 11. Using this sample, the estimated Euler angles are calculated, which are compared with the outputs from the onboard vision-inertial AHRS (see Figure 12). We can see from the results that the roll and pitch angles fit the reference ones very well while the yaw does not show the same accuracy. This is because when the motors on the drone are armed, the local magnetic field is significantly disturbed, leading to the biases of the magnetometer’s measurement. Such phenomenon can actually be avoided by adopting the magnetic-field modeling presented by Zhou et al. [27]. The roll and pitch’s performances show that the proposed filter is able to accomplish attitude estimation tasks in real-flight tests.Figure 11
Raw inertial sensor data of the flight test.Figure 12
Estimated and reference Euler angles during the flight test.Besides, from Figure13, we can also find out that the variance information can well describe the characteristics of the estimation uncertainties, which helps the quality monitoring in a degree.Figure 13
The variance of estimated quaternions and their 3σ bounds.


## 5. Conclusion

Orientation estimation from MARG sensors is revisited in this paper. Using our previous research contributions, we establish one observation model for determining attitude quaternions from accelerometer and magnetometer with linear quaternion transformations. Adopting the quaternion kinematic equation as the process model, we form a novel Kalman filter with minimum state dimension. The variance analysis of the observation model is systematically derived. Since the observation procedure employs merely several simple matrix multiplications, the computational speed is quite faster. Experiments on real-world hardware are carried out showing the correctness of the measurement quaternion and observation variance. Throughout comparisons of the attitude estimation results between the proposed filter and commercial AHRS, other representative filters, we not only prove that the proposed filter is accurate, but also show that the proposed filter is faster than these representative ones including complementary filters and other Kalman filters. The source code has been uploaded tohttps://github.com/zarathustr/FKF and the audience can evaluate the algorithm by downloading it. We hope that this research would benefit related attitude estimation applications in the future.



---

*Source: 8542153-2017-09-24.xml*