Cascaded Kalman Filtering-Based Attitude and Gyro Bias Estimation With Efficient Compensation of External Accelerations

We consider the problem of attitude estimation of rigid bodies in motion using low cost inertial measurement unit (IMU). An efficient scheme is proposed using two different Kalman filters by deriving their measurement models for precise attitude (pitch and roll) estimation in the presence of high and prolonged dynamic conditions and gyro bias. Both filters work in a coupled fashion where one of the filters provides accurate estimates of rigid body attitude and external acceleration using the accelerometer in conjunction with the gyroscope while the second filter is responsible to estimate the gyro bias, allowing the proposed scheme to be used in any application with minimal calibration. A new threshold based external acceleration detection module is also introduced to change the confidence level on external acceleration prediction to assist the estimation process. The proposed scheme is tested and compared with other existing estimators in the literature under different dynamical conditions and real-world experimental data sets in order to validate its effectiveness.


I. INTRODUCTION
The advent of micro electro mechanical systems (MEMS) technology has enabled the development of inertial measurement units (IMU) which due to their low cost, light weight and reduced power consumption, are being widely used in a variety of different applications which require attitude (pitch and roll) and/or heading (yaw) information such as human activity and gesture recognition using smart phones and watches [1]- [3], motion stabilization and control using drones and robots [4], [5], space and marine vehicle navigation [6], 3D motion tracking systems [7] and indoor localization [8], [9].
An IMU consists of a triad of accelerometer, gyroscope and magnetometer. While accelerometer and gyroscope measure the linear and angular motions respectively, the magnetometer measures local earth's magnetic field vector. The gyroscope and accelerometer are the most common choice for attitude estimation. It is due to the reason that the magnetometer measurements are very sensitive to the local environment The associate editor coordinating the review of this manuscript and approving it for publication was Lin Zhang . conditions and are prone to perturbations. While measuring the earth's magnetic field whose intensity varies from 25µT to 65µT with geographical location, the magnetometer measurements are perturbed due to electromagnetic devices (magnets, speakers etc.), man made structures (floors, walls etc.) or other ferromagnetic objects (belts,keys, etc.). As an example, a smart phone speaker has a field of about 200µT (4 times more than the earth's magnetic field). This behavior of magnetometers calls for special calibration techniques to be deployed before using their measurements [10]. Due to this reason, the magnetometers are mostly used for orientation estimation if heading information is needed.
The gyroscope and accelerometer also have their own pros and cons while estimating the attitude of a body; the gyroscope only offers short term stability due to its inherent bias, and the accelerometer suffers from the impact of external forces on the body. The gyroscope measures angular velocity which can be integrated over time to compute the attitude provided that the initial attitude is known. But this computed attitude drifts away from the true attitude very quickly due to accumulated gyro bias; drift errors can be as large as 100 • /hour [11]. A detailed comparison of different gyro prices and performance characteristics are presented in [12]. On the other hand, the accelerometer measures acceleration due to gravity and other external forces acting on the body. In the absence of any external acceleration, the attitude can easily be estimated by decomposing the gravity vector. However, the accelerometer measurements are almost always contaminated by the external acceleration of the body which is in motion, prohibiting their use for accurate attitude estimation.
Over the years, many different types of fusion filters have been proposed in order to overcome the shortcomings of these two sensors. These filters can be categorized into two main classes: deterministic complementary filters (CF) [13]- [15] and stochastic Kalman filters (KF) [16]- [23]. Where KF based techniques are based on the idea of explicit modeling of probabilistic states of the system, CF based techniques are more simple and computationally efficient as they are based on frequency analysis. However, it has been repeatedly shown that the efficiency of KF based techniques is better as compared to their CF counterparts [24]. Despite the availability of various techniques, an accurate and precise estimation of attitude information still remains a challenging problem due to two main problems: gyro bias and prolonged external accelerations. As an example, the performance of many techniques, e.g. [13], [14], [20], deteriorates rapidly in prolonged dynamic scenarios as they assume negligible external accelerations while estimating the attitude [25].
In such scenarios, other techniques which are specially designed for prolonged dynamic conditions, e.g. [15]- [18], [26], perform better due to their inherent capability to compensate for external accelerations. Most of these techniques deal with external acceleration problem by adjusting the gain of the filter accordingly with respect to low and high accelerations. In [27], the residuals in KF are used to estimate the external acceleration. The gain of KF is adjusted accordingly to reduce the effect of accelerometers measurement on attitude estimation. In [16], the authors have modeled external acceleration as a first order White noise process and modified the measurement noise covariance matrix of KF to reduce the impact of external accelerations. This approach performs better as compared to several other methods but is unable to cope with the prolonged external accelerations. This is due to following two reasons. First, the predicted external acceleration is equally distributed in all the axis even if there is external acceleration in a single axis. And second, the algorithm tries to predict external acceleration from the KF residuals. In the presence of gyro bias, the KF residuals contain erroneous information regarding external acceleration estimation. Hence, it becomes crucial for accurate attitude estimation during prolonged dynamic scenarios, to not only estimate gyro bias very accurately but also adjust the filter gain effectively for external accelerations compensation.
Recent attempts to address the gyro bias estimation have mostly relied on aid from other sensors such as global positioning system (GPS) [28], vision-aided systems [29] and map specific information [30]. Since, these methods use other expensive sensors and demand extra computational time which might be unsuitable in a low-cost battery powered environment. Apart from computational cost, these sensors also have their own limitations which make them suitable for certain environments only.
In this work, we propose a cascaded KF based attitude estimator which provides the correct estimates of attitude, external acceleration and gyro bias simultaneously using two different Kalman filters which work in a coupled fashion. The main contributions of this paper are listed as follows: • An efficient way to construct measurement noise covariance matrix is introduced in the Kalman filtering framework for attitude estimation to deal with prolonged external accelerations scenarios. In the presence and absence of external acceleration, filter gain needs to be adjusted accordingly so that the measurements coming from accelerometer can be used seamlessly for KF update step. By introducing a proper weight matrix during measurement noise covariance matrix computation, we control the amount of confidence on the current measurement which in turn controls the filter gain. Further, the coefficient of acceleration prediction filter is made adaptive with respect to external accelerations, to ensure fast convergence and better performance in prolonged dynamic conditions.
• In order to adjust the coefficient of acceleration prediction filter according to dynamic conditions, a novel external acceleration detector is developed which provides very accurate detection of external acceleration. We also demonstrate the effectiveness of this module as compared to other detectors such as simple norm based external acceleration detector.
• In addition to attitude estimating KF, an independent linear KF is proposed to estimate the bias of all three gyro, which requires only gyroscope and accelerometer measurements, without relying on other external sensors. The detailed derivation of measurement model is presented for gyro bias estimation for this KF. The paper is organized as follows: section II covers the complete derivation of the proposed cascaded filtering framework along with attitude formulation and sensor models. Section III describes the simulation environment and test conditions that have been used to assess the performance of the proposed filtering framework. In section IV, we evaluate the performance of the proposed framework using two different real world datasets. Conclusions are provided in section V.

II. PROPOSED CASCADED KF ALGORITHM
This section presents the overall design of cascaded KF for attitude and gyro bias estimation.

A. ATTITUDE REPRESENTATION
The direction cosine matrix (DCM) based attitude representation is used for state vector formulation of KF. The coordinate transformation between the sensor frame S and the inertial VOLUME 8, 2020 frame I for a 3×1 vector x is Using the conventional ZYX Euler angles, the rotation matrix from sensor to inertial frame I S R = R can be expressed as where c and s stand for cosine and sine trigonometric functions respectively. α, β and γ represents the yaw, pitch and roll angles respectively. Pitch and roll angles which constitute the attitude of the body can be found using the last row of rotation matrix R as where R ij represents (i, j) entry of matrix R.

B. SENSOR MODELS
At time instant t, the measurements from the gyroscope y G and the accelerometer y a can be modeled as where ω t are ideal angular rates, b G t represents gyro bias vector, g t is gravity vector and a t is external acceleration as observed by accelerometer. Sensor noise vectors n a and n g are considered to be uncorrelated and zero-mean White Gaussian. For attitude estimation, we can use the last row of matrix R as state vector. We define our state vector at time t as where the vector e is defined as e = 0 0 1 T . Also note that we can write the gravitational field vector g t as observed by the accelerometer as where g is the gravitational acceleration constant 9.81 m/s 2 .

C. KF FOR ATTITUDE ESTIMATION
A linear KF can be derived to provide attitude estimates as follows.

1) PROCESS MODEL
We assume the general equation for process model as where t−1 represents state transition matrix and w t−1 is the process noise vector which is assumed to be zero mean Gaussian as w t−1 ∼ N (0, Q t−1 ). At this point we assume that an estimate of gyro bias vector, denoted by b + G t , is available which can be used to correct gyro measurements as where y * G t represents corrected gyro measurements at time instance t. In next section, we develop an independent KF to provide b + G t . We derive the expressions for t−1 and Q t−1 as follows.
The rotation matrix at time t, denoted as R t , can be computed from rotation matrix at time t − 1, denoted as R t−1 , using integral of the vector differential equation as [31].
where t is sampling time interval and ω t−1 contains ideal angular rotation rates of the body at time t − 1. The symbol '∼' stands for cross product operator which when applied on As we only need to estimate the third row of the matrix R t which is our state vector, so we can directly use (12) instead of (10).
Using (4), (9) and some properties of cross product operator, we can write (12) as Though the process noise w t−1 appears to be state-dependent in (13), it does not violate any underlying assumption of the Kalman filter [12], [16], [32]. Comparing (13) with (8), we obtain The process noise covariance matrix Q t−1 is given by Here, G is the covariance matrix of gyro noise given by E n g n T g which is set equal to σ 2 g I 3 by assuming that the variance of gyro noise σ 2 g is same along all three axes.

2) MEASUREMENT MODEL
The measurement model is based on accelerometer measurements and is formulated in a way to correct the estimation error, introduced during the time propagation using the process model. The general equation of measurement model is given as where z t is the measurement vector, H is the system matrix mapping state vector to measurements and v t is the measurement noise vector which is assumed to be Gaussian with zero mean and having covariance matrix By adopting a model based approach for external acceleration, we derive the expressions for H, v t and M t below.
In order to deal with external acceleration issue, we can model it as a first-order low-pass filtered White noise process as where c a and ε t represent the cutoff frequency and time-varying error of this model respectively. Let a − t denote the predicted acceleration at time t according to (18), and a + t−1 be the estimated external acceleration at time t −1, then, we can write By inserting (19) and (20) into (5), we obtain Now, by comparing (21) and (17), we obtain the measurement vector z t , the observation matrix H, and the measurement noise v t as Since n a is not correlated with ε t , we can write the measurement noise covariance matrix M t as where A is set equal to σ 2 A I 3 by assuming that the variance of accelerometer measurement noise σ 2 A is same along all of its axes.

3) DESIGN OF M t
The measurement noise covariance matrix M t plays perhaps the most important role in accurately compensating the external acceleration effect during attitude estimation. If there is a very large external acceleration, then the accelerometer measurements are less reliable and hence Kalman gain must be adjusted in a way to weight the prediction model more which is based on gyro measurements. Increasing the measurement noise covariance matrix diagonal entries allows to make these adjustments. Similarly, if external acceleration is almost absent, then, the diagonal entries of M t must be decreased to give more weight to accelerometer measurement during the KF update process. Below, we address the issue of designing this matrix so that we can deal with external acceleration issue in a more robust and seamless way.
Since, the second term in (25) is fixed to σ 2 A I 3 and the analytical expression for the first term cannot be obtained as we don't know a t , however, we can approximate this first term as follows. Using (20), the expression for acc can be approximated as The usual trend in designing this matrix is to ignore the first term and use the model to approximate the second term. However, the problem with this approach is when external acceleration appears suddenly then acc takes a lot of time to converge to a sufficient value for proper KF gain adjustment.
Here, we argue to deal with the appearance of such a sudden bursts of external acceleration by not ignoring this term rather to approximate it from the available information. We can use (5) to approximate the first term as Similarly, using the model in (19), we can write the second term as so that At this point, we obtain a diagonal acc having same entries on the diagonals which means the measurement noise covariance of each accelerometer is equally weighted in all the scenarios of external acceleration. However, this is not an efficient approach as if there is external acceleration in any single axis then the measurement noise covariance of only that accelerometer must be adjusted for compensation. Keeping this in mind, we introduce a diagonal weight matrix W in (29) as where T . There is still one remaining issue with (30) which needs to be addressed. At the end of dynamic scenario i.e. when the acceleration suddenly drops to zero, although the term y A t 2 − 9.8 would become negligible but the other term i.e. a + t−1 2 will still have quite large value. This needs to be suppressed right at the instance which marks the end of dynamic scenario. Towards this end, we propose to make the coefficient c a adaptive subjected to the detection of external acceleration. Let α t i be a binary variable which takes a value 1 if there is an external acceleration at time instant t i otherwise it takes value 0. Then, based on the value of α t i , we can adapt the value of c a in a way that as soon as we detect the absence of external acceleration, we VOLUME 8, 2020 decrease c a to ensure faster convergence. For this purpose, we halve its current value. In this way, we obtain In this way, as soon as we detect the absence of external acceleration, acc will be adjusted instantly leading to improved tracking performance. Below, we deal with the problem of instantaneous detection of external acceleration.

4) EXTERNAL ACCELERATION DETECTION
The external acceleration detection relies on a threshold based binary classifier which takes a set of features extracted from instantaneous norm of accelerometer measurements as input, and outputs an indicator variable α t i which shows the presence or absence of external acceleration at time instance t i .
In the first step, we compute and store the norm of accelerometer measurements as y i = y A t i 2 . Then, using the time series y i values over a window of length L, we can compute different features. We have selected the following features which provide robust and instantaneous detection of external acceleration.
• Mean: Please note that one of the common approach for designing the threshold based external acceleration detectors is to switch between gyroscope and accelerometer during high and low dynamic conditions. The main problem in switching based architecture is chattering and false detection. As it is clearly stated in [21], [33] that the external acceleration status predictor can predict false due to outliers. Another set of approaches present in the literature, adaptively adjust the measurement covariance matrix in the line with the magnitude of the detected acceleration. In such a case, the measurements are not completely ignored rather their weight is reduced during update process. Our approach also lies in this category with different formulation for the covariance matrix. In our proposed method for acceleration detection, we change the confidence on the predicted external acceleration by changing the coefficient c a . This enables us to not only adjust the covariance matrix accordingly, but also to make the tracking process fast and more efficient as it is evident from the results in section III-C (Fig. 3).

D. KF FOR GYRO BIAS ESTIMATION
In (9), we assumed the availability of gyro bias vector estimate b + G t . In this section, we develop an independent linear KF to provide this estimate using accelerometer measurements.

1) PROCESS MODEL
The process model of gyro bias vector is based on first order Gauss-Markov process as where the state transition matrix is selected as = diag(c b ) with c b being a dimensionless constant which defines the bandwidth of the process, and the process noise vector w b t is assumed to be Gaussian with zero mean i.e. w b t ∼ N (0, σ b I 3 )

2) MEASUREMENT MODEL
The general equation for measurement model is assumed to be of the form where H b is state to measurement system matrix and v b t is the measurement noise vector which is assumed to Starting from a time instance t o , we can write the expression for R t using (10) as which can be further simplified as follows.
where H.O.T. contains all those terms which involve power of t larger than 1. Since, t is usually very small, we can neglect H.O.T. for mathematical convenience, to obtain Using (4), we can further simplify as Now, by introducing J t,t o = I 3 + t t−1 t=t oỹ G t andη = t t−1 t=t oñ G , and by assuming that the value of gyro bias vector does not change significantly from t o to t, we can write (35) as where L b = t−to t . We can combine (36) with (5) and (7) to obtain Assuming the absence of external acceleration at time instance t o , we can readily approximate y A to ≈ gR T t o e, where y A to is the accelerometer measurement at time t o . Using external acceleration detection module, we can search for the latest time instant t o where external acceleration was zero, by keeping L b the minimum value for the window interval. With this assumption, we obtain Rearranging, ignoring approximation error, using a + t = y A t −gx + t in place of a t and the property of cross product operatorb T a =ãb, we obtain By comparing it with (34), we obtain The measurement noise covariance matrix M b t can be written as Since, the term η cannot be evaluated analytically, we drop it for simplicity. Please note that this term can also be dropped due to the reason that if L b is quite large,η contains averaged value ofñ G which is assumed to be zero mean. Hence, its value will be very small which has also been observed during testing scenarios. However, we introduce a term α t I 3 to the expression of M b t with the rationale that as soon as external acceleration is detected, we need to adjust the KF gain such that it gives less weight to accelerometer measurements for gyro bias estimation. Hence, the final form of M b t is E. OVERALL SCHEME Once we have been able to identify the process and measurement models for both filters, linear Kalman filters are implemented to execute the overall scheme which is depicted in Fig. 1. The procedure for KF execution is also described in the same diagram, where the superscript − stands for a priori and + indicates a posteriori estimate. The matrices P t and P b t are state error covariance matrices, and K and K b are Kalman gain matrices for their respective Kalman filters.

III. SIMULATION RESULTS AND DISCUSSION
In order to test the performance of the proposed method under different dynamic scenarios, we performed a number of simulations. The simulations for IMU system were developed in MATLAB environment where the sensor signals were generated at a sampling rate of 100 Hz. The noise variance for gyroscope was set as 0.03 dps/ √ Hz and for accelerometer it was set equal to 0.2mg/

√
Hz to match the low cost MEMS IMU characteristics. External acceleration and gyro bias were added to each axis of sensors to simulate different scenarios. Details of various test conditions are described in Table 1.

A. REFERENCE METHODS
There are mainly two types of filters in attitude estimation problem, Kalman filters and Complimentary filters.  For performance comparison, we have selected 8 different methods from both representations which include: The attitude is estimated using only accelerometer without dealing with external accelerations.

2) METHOD 2 (GYROSCOPE ONLY)
This method rely only on gyroscope for attitude estimation. This can be done by setting the covariance matrix of measurement noise to infinity.

3) METHOD 3 (MAHONY'S FILTER) [13]
This method use nonlinear gain to fuse gyroscope and accelerometer signals in quaternion domain. K p and K i are two gains

4) METHOD 4 (MADGWICK'S FILTER) [14]
This method uses a gradient decent based approach to estimate orientation. Madgwick suggested to formulate orientation estimation problem as minimization problem and to solve it iteratively using steepest decent.
q e,t 5) METHOD 5 (LEE'S FILTER) [16] The measurement noise covariance(M t ) is adaptively increased during dynamic conditions.The external acceleration is modeled as first order low pass filtered white noise process, The M t is a function of predicted external acceleration, and.
where acc = 3 −1 c 2 a ||a t−1 || 2 I 3 and a t is estimated from a-posteriori state estimate using a t = y a,t − gx + t 6) METHOD 6 (FOURATI'S FILTER) [15] Fourati's alogirthm is similar to a switch gain filter that combine Gradient Decent based Complimentary filter and Marquardt approach for bio logging.

7) METHOD 7 (SWITCH GAIN FILTER) [18]
The attitude is estimated using gyroscope and accelerometer both.A switching gain topology is adapted to switch between gyroscope and accelerometer based on external acceleration.
where A is threshold applied on the norm of accelerometer and n is the number of times this should happen to trigger the dynamic condition.

8) METHOD 8 (CASCADED FILTER) [17]
This method uses adaptive gain Kalman Filter for attitude estimation and gyro bias is estimated using another Kalman Filter. Gyroscope bias modeled as first order random walk process, which is estimated from the corrected orientation vector and raw orientation vector constructed from bias contaminated gyroscope. As expected, all the algorithms perform good except gyro only method whose RMSE increases significantly due to accumulation of gyro bias over time. In next test i.e. T3, apart from gyro bias drift of 70 o /hr, we also introduce a mild external acceleration but only in single axis (X axis) of accelerometer. Different types of external accelerations i.e. constant, linearly increasing and rapidly changing were added in each axis alternatively keeping external acceleration zero in the remaining two axes. Here, we start to observe the performance degradation in several algorithms (pitch estimation) due to presence of both gyro bias and external acceleration. Roll estimation is also deteriorated but it remains comparable to test T2 case. All the filters surpass the performance of accelerometer only method when there is no external acceleration in the desired axis. Except our proposed filter and Mahoney's Filter, all other filters were not able to perform as good as accelerometer only. The gain in complimentary filters (Fourati's, Madgwicks) effects equally to both axes while fusing gyro and accelerometer. Lee's filter and Cascaded filter also performed poorly as compared to accelerometer. The reason behind their poor performance is the assumption taken while estimating covariance of acceleration model error as they assume that the covariance matrix should be approximated to have external acceleration equally distributed in all axes. If acceleration appears in one axis, it is assumed to be equally distributed in all axes which results in loss of information from remaining axes and hence the performance is deteriorated. However, the proposed filter remains unaffected of these accelerations and performed better as compared to accelerometer and all other filters due to its careful design of measurement covariance matrix which not only manages to take care of single axis vs multiple axes external acceleration compensation but also takes into account gyro bias degradation by explicitly estimating and removing it from gyro measurements during estimation process.
In test T4, we add external acceleration in all axis along with gyro bias. The performance of all other algorithms is deteriorated as compared to the proposed filter. It further exposes the inability of Lee's filter and Cascaded filter to incorporate unequal accelerations in all axes. Fourati's method was able to perform better than other filters but was unable to cope with moderately long external accelerations and suffers from incorrect switching between gains. The proposed method was able to maintain sub-degree estimation accuracy by changing the confidence level on the predicted accelerations during estimation.
In test T5, we combine different dynamic conditions and simulate a realistic scenario which incorporates both constant initial bias (−150 o /hr in x-gyro, 150 o /hr in y-gyro, and −80 o /hr in z-gyro) and random walk for gyro bias and external accelerations of varying magnitudes and durations. Test T5 is divided in five different regions. In first region, (0-100 s), no external acceleration was present. In second region (100-140 s), external acceleration was added in one axis only. In region three (140-180 s), we add rapidly changing acceleration in x-axis, and slowly varying y-axis accelerations. In region four (200-420 s), both rapidly changing as well slowly varying external accelerations were added in all axes. For this test, the profile of gyro bias and external accelerations are shown in Fig. 2 along with the attitude estimation results of different methods which are considered in this paper. Only the proposed filter was able to give sub-degree accuracy due to its efficient handling of both gyro bias and severe external acceleration even at time instants (e.g. 250-275 s) where there was external acceleration in all axes of accelerometer. RMSE as described in table 2 shows huge performance gain of the proposed algorithm as compared to other algorithms.

C. EXTERNAL ACCELERATION DETECTION AND ESTIMATION
One of the main contribution of this work is its proposed way of handling the external accelerations. Using accelerometer measurements, we first detect the presence or absence of external acceleration at any given time instance by extracting a number of useful features to be used by a binary classifier VOLUME 8, 2020 subsequently. The quality of acceleration detection affects the quality of attitude estimation through measurement noise covariance matrix (see (30)) and gyro bias estimation (see (45)). In order to elaborate the detection process, we perform a simulation where external acceleration is added in x-axis while the body goes under different rotation sequences. In comparison to our method, we use Lee's method which is well recognized method in the literature to deal with external acceleration. Fig. 3 shows the norm of accelerometer measurements along with extracted features, true acceleration profile in x-axis and the value of coefficient c a adapted as per dynamic conditions, given by (32) in the proposed algorithm. As a comparison, Lee's method is run with two different values of c a . As it can be observed from Fig. 3, the proposed method automatically and instantly adjusts the value of coefficient c a to compensate for external acceleration while Lee's method leaves the tuning of this critical parameter in user's hand which becomes a tedious task. Lee's method also struggles on both ends of external acceleration event i.e. on the start of external acceleration and also on the end of external acceleration, and takes some time to settle to a value. On the other hand, the switching in the proposed method is instantaneous due to explicit and instantaneous detection of external acceleration event.
Once we have an estimate of attitude, we can find external acceleration easily using a + t = y A t −gx + t . Table 3 shows RMSE in estimation of external acceleration of different methods for test T5 which clearly indicates that the proposed method outperforms all other methods in terms of accuracy. Estimation of external acceleration is also shown in Fig.(5). This can be attributed to the sub-degree accuracy obtained during attitude estimation by the proposed method.

D. GYRO BIAS ESTIMATION
Accurate estimation of attitude information by the proposed method can also be attributed to its treatment of gyro bias as gyroscope measurements are not reliable in long term due to its inherent bias and drift error. The second Kalman filter in the proposed cascaded Kalman filter method, takes care  of gyro bias estimation using accelerometer measurements as described in section II-D. The quality of gyro bias estimates directly affects the quality of final attitude estimates. In order to show the validity of the proposed method to accurately track and estimate gyro bias, we first perform a simulation test with only gyro bias being present in the measurements while external acceleration is forced to be zero. During the simulation, gyro bias of 120 o /hr, -120 o /hr and -70 o /hr along with random walk drifts are introduced in X,Y and Z-axis gyroscope measurements respectively. Fig. 4 shows the estimation results of the proposed filter in comparison to the reference value of the gyro bias for all axes. Clearly, the proposed algorithm is able to accurately track the gyro bias for whole duration of the simulation. Now, we turn our attention to the estimation of gyro bias in the presence of external acceleration. For this purpose, we show the estimation results for Test T5 where similar type of biases were introduced in the gyroscope measurements. Fig. 6 plots the estimation results of the proposed method in comparison to the reference bias. Although the estimation performance of the proposed algorithm is affected by prolonged external acceleration (e.g. 100-180 s), overall, the proposed algorithm is able to maintain good estimation accuracy. RMSE in estimation of gyro bias for this test was found to be 9.87 o /hr for x-axis, 12 o /hr for y-axis and 15 o /hr for z-axis gyro.

E. YAW ESTIMATION
Yaw angle can either from magnetometer or from both gyroscope and magnetometer. Measuring yaw angle using only VOLUME 8, 2020  gyro is not feasible due to gyro bias. Accelerometer is not capable of measuring yaw angle but it can be used to estimate z-axis gyro bias to restrict the drift in yaw angle. A comparison of yaw estimation using bias corrected gyro measurements using the proposed filter is shown in Fig. 7. It can be clearly seen that the proposed method outperforms gyro only method in yaw estimation.
On the other hand, the magnetometer measurements can also be used for yaw estimation. The measurement model for magnetometer is given as where h is earth reference magnetic filed and n m is noise in the measurement. The yaw angle can be computed using [34] γ = atan y m,z .sinα − y m,y .cosα y m,x .cosβ + y m,y .sinβ.sinα + y m,z .sinβ.cosα It can be seen in above equation that the magnetometer can not estimate yaw angle alone, as it requires roll and pitch angle to estimate yaw. Accurate estimation of the pitch and roll angles are necessary in order to obtain an accurate yaw angle from a magnetometer. Any error in the attitude will automatically induce an error in the yaw estimate. Table 4 summarizes RMSE results during Test T5, for different methods when their estimated attitude is used in (53) to compute the yaw angle.

F. COMPUTATIONAL LOAD
In order to evaluate the computation load of the proposed algorithm and compare it with the reference methods considered in this paper, we evaluated the running time of each algorithm for 20 different runs of Test T5 on a computer with specifications Intel Core i-7, 4GB RAM using MATLAB version R2019a. Table 5 summarizes the results in terms of average simulation time taken by each algorithm for execution of Test T5. It can be noted that the proposed algorithm takes slightly higher but not so significant computation time than rest of the algorithms due to the presence of two KFs.

IV. EXPERIMENTAL RESULTS
The performance of the proposed method has been verified using two different datasets; Micro Aerial Vehicles (MAV) dataset provided by [35] and Smart Phone data set provided by [25].

A. EXPERIMENT A
First dataset we have used consists of visual-inertial dataset which has been collected on-board an MAV, containing synchronized stereo images, IMU measurements, and accurate ground truth values. Although, there are two types of datasets available but we have used only the one which contains 6D pose ground truth from a Vicon motion capture system. More details about the environment where data was collected, sensor setup, reference Vicon system, data format, description, calibration and synchronization can be found in [35]. Fig. 8 shows attitude estimation results for all the algorithms considered in this paper including the proposed algorithm, using one sample dataset from MAV. A close observation reveals that the proposed filtering framework is able to estimate the attitude with enhanced accuracy as compared to the rest of the filters. In order to quantify the accuracy of all the algorithms, we averaged the estimation results on MAV dataset in Table 6 where it can be observed that the proposed filter outperforms other methods in terms of accuracy of attitude estimation.

B. EXPERIMENT B
In order to further validate the enhanced performance of the proposed method for attitude estimation, we consider another dataset which is obtained by conducting different experiments with several smartphones (including LG Nexus 5, iPhone 5, iPhone 4s). Internal IMU sensors of these devices are really cheap which provide data at reasonably good 50032 VOLUME 8, 2020   sampling rates. Experiments were conducted in a room of 10m × 10m where a reference system from Qualisys was used to generate the ground truth. More details about data collection, alignment and synchronization can be found in [25]. In the dataset, five different types of hand-held device motions were identified and the data was recorded for each type of motion. These motions, associated acceleration during these motions, and dataset records are described in Table 7. For this experiment, we provide precision error for attitude estimation in a different metric called mean absolute error (MAE) as done by [25]. Fig. 9 plots attitude estimation results for all the algorithms considered in this paper using one sample dataset from Smart Phone Dataset repository. As can be seen from Fig. 9, Gyro Only method is worse here due to accumulated gyro bias over the time. Other methods do well while the proposed method consistently tracks the true attitude and performs well. In order to quantify the amount of attitude estimation error for Smart Phone Dataset, we run all the algorithms on complete repository and measure average MAE. Table 8 shows average MAE in attitude estimation for different algorithms using different hand-held motion profiles. These results demonstrate that the proposed algorithm outperforms other algorithms during all motion profiles consistently. As the external acceleration becomes severe from one motion profile to other, the performance of all methods degrades. However, since the proposed method has been designed to efficiently compensate for external acceleration, VOLUME 8, 2020  the degradation in its performance is low as compared to all other methods.

V. CONCLUSION
In this paper, we proposed a cascaded Kalman filtering framework to estimate the attitude of a rigid body using low-cost IMU data which is possibly corrupted by gyroscope bias and external accelerations. The proposed method uses two different but coupled Kalman filters to estimate attitude and gyro bias separately. An efficient method is proposed to design the measurement noise co-variance matrix which controls the compensation of accelerations once detected. For acceleration detection, a robust learning based approach is designed and implemented. For gyro bias estimation, a novel KF is designed to provide gyro bias estimates. The performance gain of the proposed scheme has been compared against different methods using extensive simulations and two standard real world datasets. The proposed framework showed enhanced performance under different dynamic conditions consistently.