Skip to main content
Sensors (Basel, Switzerland) logoLink to Sensors (Basel, Switzerland)
. 2019 May 23;19(10):2372. doi: 10.3390/s19102372

Quaternion-Based Robust Attitude Estimation Using an Adaptive Unscented Kalman Filter

Antônio C B Chiella 1, Bruno O S Teixeira 1, Guilherme A S Pereira 2,*
PMCID: PMC6566700  PMID: 31126032

Abstract

This paper presents the Quaternion-based Robust Adaptive Unscented Kalman Filter (QRAUKF) for attitude estimation. The proposed methodology modifies and extends the standard UKF equations to consistently accommodate the non-Euclidean algebra of unit quaternions and to add robustness to fast and slow variations in the measurement uncertainty. To deal with slow time-varying perturbations in the sensors, an adaptive strategy based on covariance matching that tunes the measurement covariance matrix online is used. Additionally, an outlier detector algorithm is adopted to identify abrupt changes in the UKF innovation, thus rejecting fast perturbations. Adaptation and outlier detection make the proposed algorithm robust to fast and slow perturbations such as external magnetic field interference and linear accelerations. Comparative experimental results that use an industrial manipulator robot as ground truth suggest that our method overcomes a trusted commercial solution and other widely used open source algorithms found in the literature.

Keywords: unit quaternion, unscented Kalman filter, MARG sensor, adaptive filtering

1. Introduction

With the rise of small flying vehicles, also known as drones, small and inexpensive attitude and heading reference systems (AHRS) have populated the market. For such systems, it is common to estimate the orientation by combining information from magnetic, rate and gravity (MARG) sensors, also known as inertial measurement unit (IMU), usually composed of micromechanical (MEMS) three-axis gyroscope and accelerometer and a three-axis magnetometer [1]. The standard approach for attitude estimation is to compute the three components of inertial orientation by integrating the gyroscope measurements, and use the gravity projection and heading angle estimated by the accelerometers and magnetometers to correct the angles computed with the gyro. Although theoretically simple, naive implementations of this approach may not be precise because magnetometer measurements are easily influenced by ferrous material in the vicinity, and accelerometers measure not only the gravitational direction but also its linear acceleration. In these cases, it is difficult to dissociate magnetic field perturbation and linear acceleration from both the magnetic field of the earth and gravity to compute the attitude accurately, which can lead to poor estimates [2,3]. Since accurate attitude estimation is a crucial task for a variety of applications, such as human motion tracking [4,5], augmented reality [6], satellite control [7] and navigation and control of aerial [8], and sub-aquatic vehicles [9], the main objective of this paper is to present a solution that deals with external in internal sensor disturbance and interference. This paper extends the results of our conference paper [10]. We provide a more detailed mathematical description of our method and provide a whole new set of experiments. We also added several new figures that illustrate the ability of our method to estimate attitude and also some characteristics of the sensors, such as bias.

It is usually very common and useful to represent attitude by a combination of three successive rotations, such as Euler angles. Although intuitive, Euler angles exhibit singularity in their kinematic description, a situation known as gimbal lock. Alternatively, unit quaternion and direct cosine representations avoid such singularities. Between the two, unit quaternion is preferred due to its minimal representation and computational efficiency [11]. However, the unit quaternion representation does not pertain to the Euclidean space, meaning that weighted sum and subtraction operations, common to most sensor fusion methodologies, may violate the unit norm constraint of the quaternion. This paper proposes a solution to this problem in situations where the uncertainty of the measurements may change over time.

There are many approaches to estimate attitude using the quaternion representation. Among the stochastic approaches, techniques based on the Kalman filter (KF) and its variations for non-linear systems are the most common [12,13]. To overcome the Euclidean systematization using the original KF, an indirect form of the KF, called multiplicative extended Kalman filter (MEKF) [14], was proposed. This approach is valid only for small estimation errors. For large errors, algorithms based on the unscented Kalman filter (UKF) as the unscented quaternion estimator (USQUE) [15] may yield better results. Since unit quaternions are constrained to the nonlinear Riemannian manifold, using its logarithm and exponential maps, as in Refs. [11,16], can better handle its properties. A more general formulation of UKF for unit quaternion can be found in Ref. [17]. However, these algorithms do not explore the time-varying measurement uncertainty. If, for example, external disturbance affects the measurement of the magnetic field, the filter estimate will be severely damaged.

The classical way of handling the temporal variation of uncertainty is through adaptive filters, in which the statistical parameters that characterize the uncertainty are jointly estimated with the system states. In this context, approaches based on the techniques referred to as covariance matching (CM) [18], interacting multiple models (IMM) [19] and covariance scaling (CS) [20], were investigated. Among these methods, the covariance matching approaches yield improved results in the estimation of the covariance matrix for Gaussian distribution, if compared to the CS approach. CM also presents a greater simplicity if compared to approaches based on multiple models. However, in the presence of outliers, its performance can be damaged. In this context, median-based approaches can be combined to mitigate the outlier influence [21,22]. It is important to point out that, like the KF, these adaptive approaches also belong to Euclidean systematization, thus requiring modifications to be used with unitary quaternions.

In Ref. [23], the authors present an adaptive UKF for attitude estimation. The adaptive part of the algorithm is based on a covariance scaling approach, which adapts the covariance matrix if a fault is detected by a chi-square test. The main shortcoming of this approach is that the chi-square test may fail for slow varying faults, keeping the covariance matrix unchanged. In addition, the attitude is parameterized by Euler angles, being vulnerable to gimbal-lock. Based on the algorithms shown in Refs. [15,23], an adaptive UKF for attitude represented in quaternions is presented in Ref. [24]. In Ref. [25], a inflated covariance method based on multiplicative EKF (MEKF) is proposed to compensate the undesired effects of magnetic distortion and body acceleration. In Ref. [26], the Hidden Markov Model (HMM) is combined with MEKF to estimate the observation covariance matrix, thus compensating the undesired effects of magnetic distortion and linear acceleration. In spite of demonstrated good performance with numerically simulated cases [25] and actual data [26], these algorithms suffer the same limitation of MEKF, which is restricted to small estimate errors.

In contrast to KF-based approaches, which adopt a probabilistic determination of the modeled state, complementary filters (CF) are based on frequency analysis, being simplistic and usually computationally more efficient. In Ref. [27], the authors proposed an explicit complementary filter (ECF) for orientation estimation. Such a filter uses a proportional-integral (PI) controller to estimate the bias of the gyro. In Ref. [28], the authors present a computationally efficient gradient descent algorithm given measurements from a MARG sensor. The proposed algorithm has low computational cost and is able to reduce the effect of the magnetic disturbance. The problem of this algorithm is that the orientation estimated using accelerometers suffers the influence of magnetic disturbances due to the coupling in the gradient descent algorithm used. In Ref. [29], quaternion measurement is computed as the composition of two algebraic quaternions, mitigating the influence of magnetic distortion. Adaptive gains are used to reduce the estimation error during high dynamic motion. Instead of using adaptive factors, in Ref. [30], an air data sensor (ADS) is used to compensate for the linear acceleration disturbance in the MARG sensor. Although interesting, this solution requires a minimum system velocity, making its application limited.

In this scenario, we propose an adaptive algorithm based on UKF for attitude estimation using quaternion representation. In contrast to EKF, UKF-based approaches can better handle the high order nonlinear terms that can appear when the attitude error is large. The unit norm constraint of the quaternion is ensured by the use of a rotation vector parameterization. Differently from quaternion error approximation used on USQUE, this parameterization better handles the unit quaternion properties, such as the Riemannian metric [31]. The main difference between our work and classical approaches, such as MEKF and USQUE, is that it handles online the time-varying measurement uncertainty. For this, the covariance matching approach is used to update the observation covariance matrix online. Although CM can usually estimate well the measurement covariance matrix, the presence of outliers can damage the estimation. To minimize the effect of measurement outliers, we propose to combine the adaptive filter with a Hampel identifier, which compares the median deviation and the median absolute deviation (MAD) to identify an outlier. Our approach only uses the MARG sensor as an information source, and does not need extra information, such as ADS. Thus, the main contribution of this paper is the Quaternion-based Robust Adaptive Unscented Kalman Filter (QRAUKF) algorithm for attitude estimation. This algorithm is robust to fast and slow perturbations on both accelerometers and magnetometers and, to the best of authors’ knowledge, is the first one with such characteristics that precisely and consistently represent the attitude using quaternions. The proposed algorithm is tested with real experimental data collected from a MARG sensor. The performance of the proposed algorithm is confronted against the non-adaptive UKF, the open source algorithm based on complementary filter proposed in Ref. [32] and the commercial algorithm embedded in the MARG device used in our experiments, which was executed using a manipulator robot for validation purposes. A Matlab implementation of the algorithm is freely provided by the authors.

The rest of this paper is organized as follows. A problem formulation is presented in the next section. The theoretical basis for our contribution is in Section 3 and Section 4. The proposed algorithm is presented in Section 5 and is experimentally evaluated in Section 6. Finally, conclusions are presented in Section 7.

2. Problem Statement

This paper addresses the problem of attitude estimation of a rigid body moving in a three dimensional space. This problem basically consists in determining the three degrees-of-freedom orientation information of the body, independently of its current velocity and/or acceleration. Among the common representations for attitude, we chose to use unit quaternions, since it is a free-of-singularities and compact representation. To estimate the attitude, we assume that rigid body is attached to inertial and magnetic sensors, namely 3-axis accelerometer measuring acceleration in the three main body axis, ax,m, ay,m, and az,m; 3-axis magnetometer measuring the magnetic fields bx,m, by,m, and bz,m; and 3-axis gyroscope measuring the angular velocities ωx,m, ωy,m, and ωz,m. The accelerometers measure the gravity acceleration, which is indeed the part used for attitude estimation, along with all other accelerations to which the body is subjected, which act as perturbations for the movement. On the other hand, magnetometers measure the magnetic field of the earth, useful in the estimation process, and other unknown fields around the body. Measured accelerations and magnetic fields are contaminated with zero mean random noise. Angular velocity information, besides random noise, is also subjected to a time varying bias. Thus, our problem is to estimate the unit quaternion e=[e1,e2,e3,e4], given the vector of measurements [ax,m,ay,m,az,m,bx,m,by,m,bz,m,ωx,m,ωy,m,ωz,m], which is corrupted with noise and external disturbances, as mentioned before.

We solve the previous problem using a modified version of the Uncented Kalman Filter (UKF). A block diagram of our solution is shown in Figure 1. All blocks of this figure will be discussed in the following sections. We start by addressing attitude representation using unit quaternions and by presenting a new Unscented Transform (UT) for quaternions in the next section.

Figure 1.

Figure 1

The architecture of the quaternion-based robust adaptive Kalman filter. In the left, the MARG sensor provides the measurement information. The filtering algorithm uses the gyros measurement ωmR3 in the forecast step. The UT block is used to propagate the accelerometer amR3 and magnetometer bmR3 measurements through a nonlinear function, computing a unit quaternion, used as a pseudo-measurement in the robust noise estimation and data-assimilation steps.

3. Unit Quaternion Operations

Unit quaternions form a four-dimensional algebra over the real numbers and can be used to parametrize the rotation group SO(3). The set of unit quaternions, denoted by H1, form a group under multiplication operation but not under addition operation [17]. This group is topologically a 3-sphere, denoted by S3, embedded in the R4.

The unit quaternion can be represented as e=v,nH1, in which e=1. Here vR is the real part and nR3 is the imaginary part. Given a rotation θ and the unit vector w, the corresponding unit quaternion is e=cosθ2,sinθ2w. The inversion unit quaternion operation is equal to its conjugate, given by e1=e=v,n. The product ⊗ between quaternions is defined as eaebvavbnaTnb,vanb+vbna+na×nb, in which × denotes the cross product [33]. A vector vR3 can be rotated by a unit quaternion e, which is given by 0,u=e0,ve, where uR3 is the rotated vector [11].

3.1. Euclidean Tangent Space and Rotation Vector Parametrization

The group S3 is a Riemannian manifold, whose elements can be represented in a three-dimensional Euclidean tangent space TeS3. Many operations are defined in the Euclidean tangent space, such as the empirical mean and covariance. Furthermore, there are direct and inverse mappings between the manifold and its tangent space, S3TeS3, with exponential and logarithm functions, respectively.

Let e=v,n be a unit quaternion and r=θw be a rotation vector representing a rotation θ about the unit axis w. The unit quaternion to rotation vector mapping, called logarithm mapping, is given by [17]:

r=2arccosvnn,ifn0andv0,2arccosvnn,ifn0andv<0,03×1,ifn=0, (1)

where the quaternion antipodal ambiguity e=e is treated by checking the signal of v.

The inverse mapping, called exponential mapping, is [17]:

e=cosr2,sinr2rr,ifr0,(1,03×1),ifr=0. (2)

For brevity, logarithm (1) and exponential (2) mappings are written as e=R2Q(r) and r=Q2R(e), respectively.

3.2. Sum, Subtraction, and Weighted Mean Operations

We define now the operations of sum, subtraction, and weighted mean for unit quaternion states. The difference between ea and ebH1 is defined as

eaebQ2Reaeb. (3)

Similarly, for the Euclidean vectors ξa and ξbRn, this operation is giving by ξaξb.

The sum of a unit quaternion eaH1 and a rotation vector rR3, is defined as

earR2Qrea. (4)

In Euclidean space, this operation is ξa+ξb.

Lastly, the weighted mean operation for a set of unit quaternions E={ei}, i1nw, is defined as

e^WME,W, (5)

where W={wi} is a set of corresponding weights. The quaternion mean e^H1 can be computed in a closed form by [34]

Mi=1nwwieieiT, (6)

where MR4×4, and the quaternion mean is the eigenvector of M corresponding to the maximum eigenvalue. Iterative algorithms can also be used, as the gradient descent algorithm presented in Refs. [10,11].

3.3. Quaternion Unscented Transform

The unscented transform (UT) is the main core of UKF. The UT approximates the mean y^Rm and its covariance PyyRm×m of a random variable y obtained from the nonlinear transformation y=h(x1,x2,c), where x1Rn1 and x2Rn2 are random variables with mean x^1 e x^2 and covariance matrices Px1x1R(n11)×(n11) and Px2x2Rn2×n2, respectively, and c a known deterministic variable. In addition, the random variable x1 is composed by a unit quaternion part x1,H and a unconstrained Euclidean part x1,E; thus x1x1,HTx1,ETT.

Now, we define the augmented state vector x˘Rn˘ as

x˘x1Tx2TT, (7)

where n˘=n1+n2, as well as the augmented covariance matrix Px˘x˘R(n˘1)×(n˘1)

Px˘x˘=Px1x10(n11)×n20n2×(n11)Px2x2. (8)

The UT is based on a set of deterministically chosen samples known as sigma points (SP). The sigma points XjRn˘1 and the associated weights wj, j=1,,2(n˘1) can be chosen asx

X=x˘^11×2(n˘1)n˘1Px˘x˘12Px˘x˘12, (9)
wj=12(n˘1), (10)

where Xj is the jth column of matrix XR(n˘1)×2(n˘1), (·)12 is the Cholesky square root operation, and 11×2(n˘1)R1×2(n˘1) is a row vector with elements equal to one. Notice that the columns of the covariance matrix Px˘x˘ can be seen as a perturbation variable, where the unit quaternion part is parameterized as a rotation vector, which means that the covariance matrix is defined in the tangent space, hence the n˘1 dimension. The SP (9) can be partitioned as

Xx1Xx2X, (11)

where Xx1R(n11)×2(n˘1) and Xx2Rn2×2(n˘1).

Then each sigma point Xj is propagated through h:

Yj=hXjx1,Xjx2,c, (12)

where Yj=Yj,HTYj,ETTRny is the jth column of the matrix YRny×2(n˘1).

From (12), we obtain y^, Pyy and Px1y as

y^=WMY,w, (13)
Pyy=j=12(n˘1)wjYjy^Yjy^T, (14)
Px1y=j=12(n˘1)wjXjx1x^1Yjy^T. (15)

At this point it is important to mention that Equations (9) and (13)–(15) differ from the one in the standard UT transform because they consider the quaternion operations previously defined in this section.

From now on, for notation simplicity, we define the quaternion unscented transformation as the function UT(·) comprising the set of Equations (9)–(15) as:

y^,Pyy,Pxy=UTx˘^,Px˘x˘,c,h. (16)

where x˘^ and Px˘x˘ are given by Equations (7) and (8), respectively.

4. Mathematic Modeling

This section describes the discrete time dynamic model used by the filtering algorithm presented in this paper.

4.1. Kinematic Model of Attitude

Assuming that angular rates ωkR3, measured by a 3-axis gyros from the input vector uk of the dynamic system, the discrete-time attitude model is given by [15]

vecek=Ak1vecek1, (17)

where vec·:H1R4 is an operator that takes the four coefficients of the unit quaternion and stacks them in a 4-vector, k denotes the discrete time, and

Ak1cT2ωI4×4+T2sT2ωΩ(ω),Ω(ω)0ωxωyωzωx0ωzωyωyωz0ωxωzωyωx0.

We assume that uk=ωkR3 is corrupted with random noise and bias terms, modeled as um,k=uk+βk+qu,k, in which “m” denotes a measured variable, um,k=ωxm ωym ωzmTR3 are angular rates measured by a 3-axis gyros, βk=βωx βωy βωzTR3 are bias terms, and qu,kN[0]3×1,QuR3 is the input random noise. To directly use the measured inputs in (17), bias terms and random noise are estimated and subtracted from the measurement. Then,

uk=um,kβkqu,k. (18)

A more general model for gyrometers is um,k=I3×3+Suk+βk+qu,k, where SR3×3 denotes the matrix of scale factors and misalignment. This model is more appropriate for in-lab calibration [2]. Thus, in this paper, we assume that scale factors and misalignment have already been determined and compensated, and only the biases are estimated [35].

Due to bias, which may vary in time, the attitude estimated based on gyros measurements may suffer a temporal drift. To minimize this problem, bias terms βk are modeled as a random walk process,

βk=βk1+qβ,k1, (19)

where qβN[0]3×1,QβR3 and are jointly estimated with the other system states, yielding a joint state vector xkvecekβkTTR7.

Equations (17) and (19) compose the process model, which can be compactly presented as

xk=fxk1,qk1,uk1,k1, (20)

where f denotes a nonlinear function of previous state xk1, with input uk1, and process noise qk1qu,k1Tqβ,k1TT.

4.2. Observation Model

The observation model relates the components of state vector xk with the output measurement vector ykH1, defined as ykem. Measurements are corrupted by random errors and modeled as em=ekrk, where rkN[0]3×1,RkR3 is the measurement noise parameterized as a rotation vector. Therefore, the observation model may be written as

yk=hxk,rk,k. (21)

In this paper, the measured acceleration am,k=axayazTR3 and magnetic field bm,k=bxbybzTR3 are used to compute the unit quaternion emH1. Assuming normalized measurements such that am,k=1 and bm,k=1, the unit quaternion representing the body attitude can be computed as [13,29]:

em(am,bm)=eaccemag, (22)

where em(am,bm) is the conjugate of em(am,bm) and

eacc=λ1,ay2λ1ax2λ10T,az0ay2λ2,λ20ax2λ2T,az<0, (23)
emag=λ32Γ,00λ32ΓT,lx0ly2λ4,00λ42ΓT,lx<0, (24)

where λ1=(az+1)/2, λ2=(1az)/2, Γ=lx2+ly2, λ3=Γ+lxΓ, λ4=ΓlxΓ and lm,k=lxlylzT such that 0,lm,k=eacc0,bm,keacc.

Because these equations are nonlinear, the unscented transform, given in Equation (16), is used to propagate the measured acceleration error ra,kN[0]3×1,RaR3 and magnetic field error rb,kN[0]3×1,RbR3 through Equations (22)–(24). Then,

yk,Rk,=UTamTbmTT,diag(Ra,Rb),0,hab, (25)

where diag(A,B) forms a block diagonal matrix with matrices A and B, and hab(am,bm)H1 is given by Equation (22).

5. State Estimators

We assume that our dynamic system is modeled by the nonlinear Equations (20) and (21) in which, k1, the known data are the measured output yk and input uk1. It is also assumed that process noise qk1Rnq and measurement noise rkRnr are mutually independent with covariance matrices Qk1Rnq×nq and RkRnr×nr, respectively. The state estimation problem aims at providing approximations for the mean x^k=E[xk] and covariance Pkxx=E[xkx^kxkx^kT] that characterize the a posteriori probability density function (PDF) ρ(xk|y1:k).

Due to the nonlinear characteristics of the model, our proposition is to use as the basis to our approach the unscented Kalman filter (UKF) [36]. In the standard form of the UKF, two problems arise when it is used to estimate attitude: (i) the UKF pertains to Euclidean systematization, therefore containing sum and weighting operations, which are not defined for unit quaternions; (ii) the output measured noise rk can have time-varying statistical properties, which can, in the worst case, lead to diverging estimates. Regarding (i), most of the issues are solved if the modified unscented transform presented in Section 3.3 is applied in the place of the standard one, as shown in Section 5.1. The solution of (ii) is our core contribution. We consider two events that may change the statistical properties of measured noise: a dynamic event, such as linear accelerations that mask the gravity vector projection measured by accelerometers; and a external influence, such as a ferromagnetic element that disturbs the Earth’s magnetic field measured by the magnetometers. The rejection of these perturbations is addressed in Section 5.2 and Section 5.3.

5.1. Quaternion-Based UKF

The UKF algorithm presented in this section is based on the ones shown in Refs. [11,17], which are slightly modified to encompass direct unit quaternion measurements and multiplicative noise in the process. Henceforth, the notation x^k|k1 indicates an estimate of xk at time k based on information available up to and including time k1. Likewise, x^k indicates an estimate of xk at time k based on information available up to and including time k. Let the process noise be partitioned as qk1q1,k1Tq2,k1TTRnq with covariance matrix Qk1diagQ1,k1,Q2,k1Rnq×nq, where q1,k1Rnqnx+1 is the noise nonlinearly related to the state vector and q2,k1Rnx1 is the linear partition of noise. To improve the numerical stability of the filter, additive noise is considered for all states [37].

Given these definitions, the modified quaternion-based unscented Kalman filter (QUKF) forecast step is given by

x^k|k1,P˜k|k1xx,=UTx˘^k1,Pk1x˘x˘,uk1,f, (26)
Pk|k1xx=P˜k|k1xx+Q2,k1, (27)
y^k|k1,P˜k|k1yy,Pk|k1xy=UTx^k|k1,Pk|k1xx,0,h, (28)
Pk|k1yy=P˜k|k1yy+Rk, (29)
νk=yky^k|k1, (30)

where νk is the innovation. The augmented state vector x˘k1Rn˘ and the corresponding covariance matrix Pk1x˘x˘Rn˘×n˘ are respectively given by

x˘k1xk1Tq1,k1TT,Pk1x˘x˘Pk1xx0(nx1)×(nqnx+1)0(nqnx+1)×(nx1)Q1,k1,

with n˘=nq+1.

The state estimate and error covariance matrix are updated using information from yk in the data-assimilation step, given by:

Kk=Pk|k1xyPk|k1yy1, (31)
x^k=x^k|k1Kνk, (32)
Pkxx=Pk|k1xxKkPk|k1yyKkT. (33)

5.2. Adaptive Covariance Matrix

The uncertainty of measurements in the UKF is represented by covariance matrix Rk, which is usually constant. However, the measurement uncertainties can be time-varying. We then propose the use of innovation νk to adjust the measurement covariance matrix online through the covariance matching (CM) approach [18].

Based on the assumption that the observation covariance matrix Rk is constant during a sliding sampling window with finite length N, the basic idea of CM is to make the innovation νk consistent with its covariance E[νkνkT]Pk|k1yy. Notice that the innovation pertains to the three-dimensional Euclidean tangent space. Thus, the covariance of νk is estimated as based on the last N innovation samples as

E[νkνkT]1Nj=kN+1kνjνjT. (34)

Notice that, the UKF (see Equation (29)) approximates the covariance by E[νkνkT]P˜k|k1yy+Rk, where P˜k|k1yyj=12(n1)wjy˜j,k|k1y˜j,k|k1T. Then, Rk can be estimated by

R^k=1Nj=kN+1kνjνjTP˜k|k1yy. (35)

To avoid negative values due the subtraction operation in Equation (35), negative values in R^k are replaced by their correspondent value in the nominal covariance matrix R0.

5.3. Outlier Rejection

Outliers are spurious data that contaminate the statistical distribution. The contaminated measurements deviate significantly from the normal observations, which directly reflects in the innovation value νk, and, consequently, in the covariance estimated by CM.

The Hampel identifier [38] is an outlier identification method that is reported as extremely effective in practice [39]. Based on this approach, our contribution is to compute a gain λRnr×nr to be used as a multiplier that reduces the outlier influence in the estimation of the covariance matrix and also on the Kalman gain. This gain is a diagonal matrix, wherein each the diagonal is defined as

λj,iimin1,nσsi|νj,imed{νj,i}|, (36)

where si=1.4826med{|νj,imed{νj,i}|} is the median absolute deviation (MAD), nσ is the number of standard deviations (confidence region) by which the innovation sample must differ from the local median, med is the median operator, {·} is a moving window with size N, jkN+1k is an index for each element of the moving window, and i is the index of each element of the innovation vector.

5.4. Quaternion-Based Robust Adaptive Unscented Kalman Filter

By combining Equations (35) and (36) with the QUKF Equations (26)–(33), we then obtain a three step algorithm that we call quaternion-based robust adaptive unscented Kalman filter (QRAUKF). The first step is the forecast step, which is given by Equations (26)–(28) and (30). The second step is the robust noise estimation given by Equation (36), the estimate covariance

R^k=max1Nj=kN+1kλjνjλjνjTP˜k|k1yy,R0 (37)

and (29). The third and last step is the data-assimilation step, which is given by Equations (31) and (33), and

x^k=x^k|k1Kλkνk. (38)

6. Experimental Results and Discussion

In this section we compare the performance of the proposed QRAUKF algorithm to the QUKF, the complementary filter (CF) proposed in Ref. [32], and the commercial algorithm embedded in the MicroStrain 3DM-GX1® IMU. We implemented QRAUKF using Matlab (Our code is available at https://bitbucket.org/coroufmg/raukf_cm).

Actual data was collected at 40 Hz from the IMU, which was mounted on the end effector of a Comau Smart Six® manipulator, used to perform controlled movements and to provide accurate orientation information. Figure 2 illustrates our setup.

Figure 2.

Figure 2

Experimental setup using the MicroStrain 3DM-GX1® IMU and the Comau Smart Six® robot.

To set QUKF and QRAUKF, we have assumed that the covariance matrix Q1,k1R3×3 is diagonal with elements related to the angular rates measured by the gyros. This matrix was estimated as σω=0.45840.37240.4927Tdeg/s. The additive noise of process was represented by the diagonal matrix Q2,k1R6×6. This matrix is related to the attitude, parametrized as a rotation vector, and the bias terms of the gyros. The standard deviations were empirically set as σv=57.3×10203×1deg and σβ=57.3×1093×1deg/s, for attitude and bias terms, respectively. The measured acceleration and magnetic field are propagated through the nonlinear function represented by Equations (22)–(24). Standard deviations of accelerometer and magnetometer are σa=0.03610.04550.0330Tm/s2 and σm=0.00110.000980.00098T Gauss [G], respectively. The nominal covariance matrix of measurements Rk is computed by the UT. The sliding window size of RAUKF was empirically set to be N=20 samples, which represents a period of 0.5s during which the noise covariance is assumed to be constant, and the confidence region nσ=3 standard deviations. CF has two parameters, the gain that quantifies the gyro measurement noise, set as β=0.007, and the gain that quantifies the bias terms, set as ζ=0.01. These values follows the authors recommendations [32]. The standard deviations σω, σa, and σm were estimated from experimental data. For this, we have used a window of approximately 20s. During this calibration process, the MARG sensor was kept stationary (steady-state behavior). The tuning parameters were estimated before performing the main state estimation experiments, during which they remain unaltered. Observe that the measurement covariance matrix Rk is updated online, in contrast with the process covariance matrices Q1,k1 and Q2,k1, that also remain unaltered. Although we used a simplistic parameter estimation approach, the parameterization seems to be appropriate, even for different experiments.

Five disturbance scenarios were evaluated: (i) abrupt and (ii) slow varying magnetic disturbances; (iii) linear accelerations; (iv) individual axis rotation about the origin; and (v) simultaneous axes rotations about the origin. The last two experiments, scenarios (iv)–(v), suffer linear accelerations due to the lever arm between the end effector of robot and IMU (Videos showing the experiments are found at: https://goo.gl/mtFSqG).

6.1. Magnetic Field Distortion

Heading estimation is performed by monitoring the Earth’s magnetic field with the magnetometer. Due to the proximity of ferrous or magnetic materials, the magnetic field can be locally distorted, which causes inaccurate estimates of heading angle. In our first experiment, the magnetic brakes of the robot manipulator are turned on and off a few times, thus causing an abrupt variation in the magnetic field that is perceived by the magnetometers. Due to the shaking caused by the release of the brakes, some spikes of acceleration also appear. Figure 3 shows the acceleration and magnetic field measurements, and the attitude estimation error for each axis. The disturbance periods are highlighted. Observe that the QUKF is more sensitive to outliers in the acceleration and magnetic field measurements, converging quickly to wrong estimates induced by inaccurate measurements. This behavior is expected, once QUKF does not have any treatment for abnormal measurements. In contrast, QRAUKF, CF, and 3DM-GX1 algorithms reject the outliers. Table 1 shows the Root Mean Square Error (RMSE) for this experiment in the column called “Abrupt magnetic”. Observe that QRAUKF performs better than other algorithms, with the smaller RMSE. In contrast, QUKF yields the largest RMSE indices.

Figure 3.

Figure 3

Results for abrupt magnetic disturbances experiment, scenario (i). In the left column, linear acceleration am and magnetic field bm measurements, in the right column, the attitude error.

Table 1.

Root Mean Square Error (RMSE) in degrees for disturbance scenarios (i) and (ii). The lowest RMSE results are highlighted in bold.

Abrupt Magnetic Slow Magnetic 1 Slow Magnetic 2
Algorithm ϕ˜ θ˜ ψ˜ ϕ˜ θ˜ ψ˜ ϕ˜ θ˜ ψ˜
QRAUKF 0.05 0.04 0.07 0.07 0.09 1.84 0.40 0.19 3.11
QUKF 0.05 0.05 0.20 0.98 0.51 13.0 1.66 0.27 12.52
CF 0.07 0.06 0.14 9.22 11.00 28.90 3.20 0.86 8.97
3DM-GX1 0.16 0.18 0.09 0.12 0.09 11.28 0.35 0.27 9.8

In a second experiment, the magnetic field was artificially and slowly disturbed with a magnetic material. Figure 4 shows the acceleration and magnetic field measurements, and the attitude error for each axis. This kind of perturbation is usually difficult to detect and can damage the estimation. Notice that QRAUKF is less sensitive to the slow varying abnormal measurement. CF yields the worst results as shown by RMSE in Table 1, in the column called “Slow magnetic 1”. Figure 5 shows the bias estimation in y and z-directions. Observe that the abnormal behavior of the magnetic field affects the bias estimates of angular rate in all directions for QUKF and CF, which in turns does not happen with QRAUKF.

Figure 4.

Figure 4

Results for slow magnetic disturbances experiment (second experiment), scenario (ii). In the left column, linear acceleration am and magnetic field bm measurements, in the right column, the attitude error.

Figure 5.

Figure 5

Bias estimate of angular rate ωy and ωz, respectively, measured by the gyros for second experiment, scenario (ii).

In a third experiment, the magnetic field was also artificially and slowly disturbed with magnetic material. Although similar to the previous experiment, in this one the magnetic field is continually disturbed during 30 s. Figure 6 shows the measurements and attitude estimation error for each axis. In addition to magnetic disturbance, during the experiment we accidentally touched the manipulator with the magnet and observed that the accelerometers and gyros also measure abrupt changes just before 10 s and 20 s. Figure 7 shows angular rate measurements for this experiment. All algorithms, except QUKF, are robust to outliers in acceleration and magnetic field measurements, however, as can be seen by the error results, all algorithms have large peak errors ϕ˜ and θ˜. These large errors are caused by the outliers in the angular rate measurements, that are not handled by the algorithms. In spite of these outliers, notice that QRAUKF shows the best result, as can be seen in Table 1, column “Slow magnetic 2”.

Figure 6.

Figure 6

Results for slow magnetic disturbances experiment (third experiment), scenario (ii). In the left column, linear acceleration am and magnetic field bm measurements, in the right column, the attitude error.

Figure 7.

Figure 7

Angular rate ωy and ωz, respectively, measured by the gyros for the third experiment, scenario (ii).

6.2. Linear Acceleration Disturbance

Roll ϕ and pitch θ angles are computed by the projection of the gravity vector, which is measured by the accelerometer. However, the accelerometer measures the linear body acceleration together with the gravity vector, which masks the gravity vector observation. Thus, the linear acceleration disturbs the observation of ϕ, θ, and consequently the heading angle ψ.

To test the behavior of the algorithms against the perturbation of linear velocities, the manipulator executed independent translational movements in each axis. Figure 8a shows the accelerometer measurements. We observed that even when the movements are being executed separately in each axis, linear accelerations appear in all axes. This is probably due to a small angle in the link joining the IMU and the robot end effector. Figure 8b–d shows the attitude error. Table 2 shows the values of RMS for this and other experiments. Notice that the QUKF provides the worst results. In contrast, QRAUKF yields the best RMSE indexes and the smallest peak-error for heading angle. We also observe that after 30 s, the attitude error for QRAUKF grows due to the longer time exposed to linear acceleration perturbation. In fact, the QRAUKF estimates tend to converge to the value induced by the perturbed measurement after a period of time.

Figure 8.

Figure 8

Results for linear acceleration disturbance experiment, scenario (iii). (a) shows the measured linear accelerations am; (bd) show the estimation error for ϕ, θ and ψ angles, respectively.

Table 2.

Root Mean Square Error (RMSE) in degrees for disturbance scenarios (iii), (iv), and (v). The lowest RMSE results are highlighted in bold.

Linear Acceleration Individual Rotations Simultaneous Rotations
Algorithm ϕ˜ θ˜ ψ˜ ϕ˜ θ˜ ψ˜ ϕ˜ θ˜ ψ˜
QRAUKF 0.28 0.87 0.16 1.08 1.31 0.91 2.88 1.94 1.37
QUKF 4.0 3.78 2.36 1.97 1.73 2.23 2.76 2.08 4.20
CF 1.87 1.60 0.53 1.17 1.61 1.17 2.97 2.54 2.03
3DM-GX1 0.37 0.99 0.39 1.08 1.34 1.37 2.88 2.17 2.06

6.3. Rotations about the Origin

In our last two experiments, presented in Figure 9 and Figure 10, rotations about the origin in each axis separately and simultaneously were performed. In these cases, estimates are influenced by linear accelerations that appear due to a lever arm between the IMU and the robot end effector. Figure 9a and Figure 10a show the actual movement performed by the manipulator. Again, the proposed algorithm yields the best results, as shown by Table 2. Notice by Figure 9 that QRAUKF and 3DM-GX1 algorithm have similar errors, however, QRUKF converges faster to measurement after the perturbation finishes. The poor performance of KF and CF is due to bias estimates that are influenced by linear acceleration.

Figure 9.

Figure 9

Results for individual axis rotation about the origin, scenario (iv). (a) shows actual orientation for individual axis movements; (bd) show the estimation error for ϕ, θ and ψ angles, respectively.

Figure 10.

Figure 10

Results for simultaneous axes rotation about the origin, scenario (v). (a) shows actual orientation for simultaneous axes movements; (bd) show the estimation error for ϕ, θ and ψ angles, respectively.

7. Conclusions

In this paper, a quaternion-based robust adaptive unscented Kalman filter for orientation estimation was presented. The algorithm ensures the unit norm of quaternion in all algorithm steps without forcing a normalization. The logarithmic map of unit quaternions is used to parametrize the error quaternion. This parameterization allows us to perform operations in Euclidean space and then use existing approaches to adapt the measurement covariance matrix and detect outliers. Due to the nonlinear nature of this transformation, unscented transform is used to compute the measured quaternion.

The proposed algorithm was compared to a nonadaptive version of UKF, a complementary filter, and commercial algorithm embedded in the IMU. Some experiments were performed to verify the performance of the algorithms in situations where distorted magnetic field and linear accelerations exist. The proposed algorithm shows the best RMSE results in all situations tested, and the smallest peak-error for linear acceleration disturbance. In addition, the proposed algorithm accurately estimates the gyros bias terms. Although in this paper we only show attitude estimation, the proposed methodology can be used along the standard UKF equations to estimate the full state vector of vehicles. The same ideas for disturbance rejection can also be extended for other vehicle states, once the sum and subtraction operations defined in Section 3.2 are the usual operations for Euclidean states.

Author Contributions

A.C.B.C. was the main developer of the proposed methodology. He also performed experiments, analyzed the results and wrote most of this manuscript. B.O.S.T. and G.A.S.P. co-supervised the entire work. They directly contributed with the methodology, planning of experiments, analysis of results and writing of the manuscript.

Funding

This work was partially supported by FAPEMIG/Brazil, grant TEC-APQ-00850-15 and CNPq/Brazil, grant 465755/2014-3 (National Institute of Science and Technology). A. Chiella holds a scholarship from CAPES/Brazil. B. Teixeira and G. Pereira hold research fellowships from CNPq/Brazil.

Conflicts of Interest

The authors declare no conflict of interest.

References

  • 1.Jang J.S., Liccardo D. Small UAV automation using MEMS. IEEE Aerosp. Electron. Syst. Mag. 2007;22:30–34. doi: 10.1109/MAES.2007.365332. [DOI] [Google Scholar]
  • 2.Groves P.D. Principles of GNSS, Inertial, and Multisensor Integrated Navigation Systems. Artech House; Norwood, MA, USA: 2013. [Google Scholar]
  • 3.Yadav N., Bleakley C. Accurate orientation estimation using AHRS under conditions of magnetic distortion. Sensors. 2014;14:20008–20024. doi: 10.3390/s141120008. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Vartiainen P., Bragge T., Arokoski J.P., Karjalainen P.A. Nonlinear State-Space Modeling of Human Motion Using 2-D Marker Observations. IEEE Trans. Biomed. Eng. 2014;61:2167–2178. doi: 10.1109/TBME.2014.2318354. [DOI] [PubMed] [Google Scholar]
  • 5.Ding Y., Gao T., Wu Y., Zhu S. The research of a new data glove based on MARG sensor and magnetic localization technology; Proceedings of the AIP Conference Proceedings; Xi’an, China. 20–21 January 2018; p. 040098. [Google Scholar]
  • 6.Michel T., Genevès P., Fourati H., Layaïda N. On attitude estimation with smartphones; Proceedings of the IEEE International Conference on Pervasive Computing and Communications; Kona, HI, USA. 13–17 March 2017; pp. 267–275. [DOI] [Google Scholar]
  • 7.Gui H., de Ruiter A.H. Quaternion Invariant Extended Kalman Filtering for Spacecraft Attitude Estimation. J. Guid. Control Dyn. 2017;41:863–878. doi: 10.2514/1.G003177. [DOI] [Google Scholar]
  • 8.Pereira G.A.S., Iscold P., Torres L.A.B. Airplane attitude estimation using computer vision: Simple method and actual experiments. Electron. Lett. 2008;44:1303–1304. doi: 10.1049/el:20081184. [DOI] [Google Scholar]
  • 9.Costanzi R., Fanelli F., Monni N., Ridolfi A., Allotta B. An Attitude Estimation Algorithm for Mobile Robots Under Unknown Magnetic Disturbances. IEEE/ASME Trans. Mechatron. 2016;21:1900–1911. doi: 10.1109/TMECH.2016.2559941. [DOI] [Google Scholar]
  • 10.Chiella A.C.B., Teixeira B.O.S., Pereira G.A.S. Robust attitude estimation using an adaptive unscented Kalman filter (forthcoming); Proceedings of the 2019 IEEE International Conference on Robotics and Automation (ICRA); Montreal, QC, Canada. 20–24 May 2019; pp. 7748–7754. [Google Scholar]
  • 11.Sipos B.J. Application of the manifold-constrained unscented Kalman filter; Proceedings of the 2008 IEEE/ION Position, Location and Navigation Symposium; Monterey, CA, USA. 5–8 May 2008; pp. 30–43. [DOI] [Google Scholar]
  • 12.Yuan X., Yu S., Zhang S., Wang G., Liu S. Quaternion-based unscented Kalman filter for accurate indoor heading estimation using wearable multi-sensor system. Sensors. 2015;15:10872–10890. doi: 10.3390/s150510872. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Valenti R.G., Dryanovski I., Xiao J. A linear Kalman filter for MARG orientation estimation using the algebraic quaternion algorithm. IEEE Trans. Instrum. Meas. 2016;65:467–481. doi: 10.1109/TIM.2015.2498998. [DOI] [Google Scholar]
  • 14.Lefferts E.J., Markley F.L., Shuster M.D. Kalman filtering for spacecraft attitude estimation. J. Guid. Control Dyn. 1982;5:417–429. doi: 10.2514/3.56190. [DOI] [Google Scholar]
  • 15.Crassidis J.L., Markley F.L. Unscented filtering for spacecraft attitude estimation. J. Guidance Control Dyn. 2003;26:536–542. doi: 10.2514/2.5102. [DOI] [Google Scholar]
  • 16.Hertzberg C., Wagner R., Frese U., Schröder L. Integrating generic sensor fusion algorithms with sound state representations through encapsulation of manifolds. Inf. Fusion. 2013;14:57–77. doi: 10.1016/j.inffus.2011.08.003. [DOI] [Google Scholar]
  • 17.Menegaz H.T., Ishihara J.Y. Unscented and square-root unscented Kalman filters for quaternionic systems. Int. J. Robust Nonlinear Control. 2018:1–28. doi: 10.1002/rnc.4249. [DOI] [Google Scholar]
  • 18.Mehra R. Approaches to adaptive filtering. IEEE Trans. Autom. Control. 1972;17:693–698. doi: 10.1109/TAC.1972.1100100. [DOI] [Google Scholar]
  • 19.Li X.R., Bar-Shalom Y. A recursive multiple model approach to noise identification. IEEE Trans. Aerosp. Electron. Syst. 1994;30:671–684. doi: 10.1109/7.303738. [DOI] [Google Scholar]
  • 20.Hide C., Moore T., Smith M. Adaptive Kalman filtering algorithms for integrating GPS and low cost INS; Proceedings of the Position Location and Navigation Symposium; Monterey, CA, USA. 26–29 April 2004; pp. 227–233. [Google Scholar]
  • 21.Moghaddamjoo A., Kirlin R.L. Robust adaptive Kalman filtering with unknown inputs. IEEE Trans. Acoust. Speech Signal Process. 1989;37:1166–1175. doi: 10.1109/29.31265. [DOI] [Google Scholar]
  • 22.Pearson R.K., Neuvo Y., Astola J., Gabbouj M. Generalized Hampel Filters. EURASIP J. Adv. Signal Process. 2016;2016:87. doi: 10.1186/s13634-016-0383-6. [DOI] [Google Scholar]
  • 23.Soken H.E., Hajiyev C. Pico satellite attitude estimation via robust unscented Kalman filter in the presence of measurement faults. ISA Trans. 2010;49:249–256. doi: 10.1016/j.isatra.2010.04.001. [DOI] [PubMed] [Google Scholar]
  • 24.Lee D., Vukovich G., Lee R. Robust Adaptive Unscented Kalman Filter for Spacecraft Attitude Estimation Using Quaternion Measurements. J. Aerosp. Eng. 2017;30:04017009. doi: 10.1061/(ASCE)AS.1943-5525.0000718. [DOI] [Google Scholar]
  • 25.Ghobadi M., Singla P., Esfahani E.T. Robust Attitude Estimation from Uncertain Observations of Inertial Sensors Using Covariance Inflated Multiplicative Extended Kalman Filter. IEEE Trans. Instrum. Meas. 2018;67:209–217. doi: 10.1109/TIM.2017.2761230. [DOI] [Google Scholar]
  • 26.Tong X., Li Z., Han G., Liu N., Su Y., Ning J., Yang F. Adaptive EKF Based on HMM Recognizer for Attitude Estimation Using MEMS MARG Sensors. IEEE Sens. J. 2018;18:3299–3310. doi: 10.1109/JSEN.2017.2787578. [DOI] [Google Scholar]
  • 27.Euston M., Coote P., Mahony R., Kim J., Hamel T. A complementary filter for attitude estimation of a fixed-wing UAV; Proceedings of the 2008 IEEE/RSJ International Conference on Intelligent Robots and Systems; Nice, France. 22–26 September 2008; pp. 340–345. [DOI] [Google Scholar]
  • 28.Madgwick S.O.H., Harrison A.J.L., Vaidyanathan R. Estimation of IMU and MARG orientation using a gradient descent algorithm; Proceedings of the IEEE International Conference on Rehabilitation Robotics; Zurich, Switzerland. 27 June–1 July 2011; pp. 1–7. [DOI] [PubMed] [Google Scholar]
  • 29.Valenti R.G., Dryanovski I., Xiao J. Keeping a good attitude: A quaternion-based orientation filter for IMUs and MARGs. Sensors. 2015;15:19302–19330. doi: 10.3390/s150819302. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 30.Wang L., Fu L., Hu X. A nonlinear complementary filter approach for MAV 3D-attitude estimation with low-cost MARG/ADS; Proceedings of the 2016 IEEE/ION Position, Location and Navigation Symposium (PLANS); Savannah, GA, USA. 11–14 April 2016; pp. 42–47. [DOI] [Google Scholar]
  • 31.Menegaz H.M.T., Ishihara J.Y., Kussaba H.T.M. Unscented Kalman Filters for Riemannian State-Space Systems. IEEE Trans. Autom. Control. 2019;64:1487–1502. doi: 10.1109/TAC.2018.2846684. [DOI] [Google Scholar]
  • 32.Madgwick S.O. An Efficient Orientation Filter for Inertial and Inertial/Magnetic Sensor Arrays. University of Bristol; Bristol, UK: 2010. Technical Report. [Google Scholar]
  • 33.Kim S., Haschke R., Ritter H. Gaussian mixture model for 3-Dof orientations. Robot. Auton. Syst. 2017;87:28–37. doi: 10.1016/j.robot.2016.10.002. [DOI] [Google Scholar]
  • 34.Markley F.L., Cheng Y., Crassidis J.L., Oshman Y. Averaging quaternions. J. Guid. Control Dyn. 2007;30:1193–1197. doi: 10.2514/1.28949. [DOI] [Google Scholar]
  • 35.Markley F.L., Crassidis J.L. Fundamentals of Spacecraft Attitude Determination and Control. Volume 33 Springer; New York, NY, USA: 2014. [Google Scholar]
  • 36.Julier S.J., Uhlmann J.K. Unscented filtering and nonlinear estimation. Proc. IEEE. 2004;92:401–422. doi: 10.1109/JPROC.2003.823141. [DOI] [Google Scholar]
  • 37.Xiong K., Zhang H., Chan C. Performance evaluation of UKF-based nonlinear filtering. Automatica. 2006;42:261–270. doi: 10.1016/j.automatica.2005.10.004. [DOI] [Google Scholar]
  • 38.Davies L., Gather U. The Identification of Multiple Outliers. J. Am. Stat. Assoc. 1993;88:782–792. doi: 10.1080/01621459.1993.10476339. [DOI] [Google Scholar]
  • 39.Pearson R.K. Outliers in process modeling and identification. IEEE Trans. Control Syst. Technol. 2002;10:55–63. doi: 10.1109/87.974338. [DOI] [Google Scholar]

Articles from Sensors (Basel, Switzerland) are provided here courtesy of Multidisciplinary Digital Publishing Institute (MDPI)

RESOURCES