# A DCM Based Attitude Estimation Algorithm for Low-Cost MEMS IMUs

Authors: Heikki Hyyti; Arto Visala
Journal: International Journal of Navigation and Observation
 (2015)

---

## Abstract

An attitude estimation algorithm is developed using an adaptive extended Kalman filter for low-cost microelectromechanical-system (MEMS) triaxial accelerometers and gyroscopes, that is, inertial measurement units (IMUs). Although these MEMS sensors are relatively cheap, they give more inaccurate measurements than conventional high-quality gyroscopes and accelerometers. To be able to use these low-cost MEMS sensors with precision in all situations, a novel attitude estimation algorithm is proposed for fusing triaxial gyroscope and accelerometer measurements. An extended Kalman filter is implemented to estimate attitude in direction cosine matrix (DCM) formation and to calibrate gyroscope biases online. We use a variable measurement covariance for acceleration measurements to ensure robustness against temporary nongravitational accelerations, which usually induce errors when estimating attitude with ordinary algorithms. The proposed algorithm enables accurate gyroscope online calibration by using only a triaxial gyroscope and accelerometer. It outperforms comparable state-of-the-art algorithms in those cases when there are either biases in the gyroscope measurements or large temporary nongravitational accelerations present. A low-cost, temperature-based calibration method is also discussed for initially calibrating gyroscope and acceleration sensors. An open source implementation of the algorithm is also available.


---

## Body

## 1. Introduction

Inertial measurement units (IMUs) are widely used in attitude estimation in mobile robotics, aeronautics, and navigation. An IMU consists of a triaxial accelerometer and a triaxial gyroscope and it is used for measuring accelerations and angular velocities in three orthogonal directions. The attitude, which is a 3D orientation of the IMU with respect to the Earth coordinate system, can be estimated by combining integrated angular velocities and acceleration measurements. Microelectromechanical-system (MEMS) IMUs are small, light, and low-cost solutions for attitude estimation. They are widely used in mobile robotics, such as unmanned aerial vehicles (UAVs) [1]. MEMS IMUs are also used in combination with other sensors, such as global navigation satellite systems (GNSS) [2, 3], light detection and ranging (LIDAR) sensors, or cameras in various applications. In addition, MEMS IMUs are commonly included in modern mobile phones [4].Unfortunately, the use of low-cost MEMS IMUs introduces several challenges compared to high-precision measurement devices. Low-cost MEMSs are noisy and their measurements usually include various errors. These errors consist of an unknown zero level, that is, bias error, and unknown scale factor, that is, gain error [5]. Moreover, the gain and the bias tend to drift over time and are affected by temperature change. Therefore, sensor calibration has become one of the most challenging issues in inertial navigation [6].Other problems with IMUs are related to the standard design of the sensor fusion algorithms. Usually, the roll and pitch angles are estimated using the measured angle of the Earth’s gravitation force as reference to the integrated angle obtained from angular velocity measurements. This works perfectly if no other forces than gravity exist in the system. Unfortunately, this is rarely the case. In practical use, when an IMU is attached to a moving platform or object, these accelerations are unavoidable. In various cases, as in the estimation of either a human body [7] or a mobile phone [4] position, or in a legged robot [8], these accelerations can become significantly large. Therefore, their presence should be taken into account.Another problem with standard IMU implementations concerns heading angle estimation. The Earth’s gravitation field gives no information about this. Therefore, the integration of triaxial accelerometers and gyroscopes cannot provide an absolute heading angle. This is commonly overcome using an extra sensor, usually a triaxial magnetometer [2, 9–16] or satellite navigation [3, 5, 17–20]. Triaxial magnetometers offer a good solution if the magnetic field measurement can be trusted. In practice, this is usually not the case at least in robotics, since robots are usually made of magnetic metal, have high current electronics and motor drives, and may travel within locations that are surrounded by power lines, magnets, and magnetic metals. Moreover, because the magnetic sensor observes the sum field caused by all magnets and electrically induced magnetic fields, the Earth’s magnetic field cannot be easily separated. Furthermore, satellite navigation can be of little help, as it does not work well inside buildings or caves or under dense forest foliage.The ability to reliably estimate attitude with a minimal number of sensors would also increase the robustness of the system in two ways. Firstly, as fewer sensors would be needed, there would be less risk of sensor failures. Secondly, it would be beneficial to run an IMU algorithm on the background as a backup method, even when other measurements are available. In addition, these results could be compared between the different algorithms to detect failures and possibly compensate for those faults.Our proposed method solves presented challenges by firstly formulating a calibration method as a function of measured temperature for gains and biases and secondly using an extended Kalman filter to estimate the bias in gyroscope measurements online. We have purposely omitted magnetometer and other possible measurements from our filter, and we estimate only absolute pitch and roll angles, thus keeping the main focus on the gyroscope bias estimation. Although the heading estimate (yaw angle) can be computed from the results of the proposed filter, it is not an absolute heading. Instead, it is an integrated bias-corrected angular velocity aroundz-axis. The absolute yaw could be estimated in a separate filter using any extra measurements. By doing this, we can increase the robustness of the proposed sensor fusion algorithm and enhance gyroscope bias estimation. If the magnetometer or other sensors would fail catastrophically, only the heading estimate would fail, leaving pitch and roll estimates unaffected. This can offer significant advantages for robotic applications such as flying UAVs or other robots.In contrast to other proposed solutions [21–24], introduced in more detail in the next chapter, we implement an extended Kalman filter to tune the bias estimates when such information is available. Furthermore, we do not rely on constant gains for updating bias. Instead, we use an extended Kalman filter to employ available information in system and measurement covariances in order to tune the gains for updating bias and attitude estimates. Later, in Experiments and Results, we also show in practice that even in the worst case scenario, the filter remains stable.In addition to the calibration and robust estimation of gyroscope biases, we adapt our measurement covariances to increase the quality of the filter against changing dynamic conditions. IMU algorithms usually use the direction of gravity (through measured accelerations) to reduce accumulating errors in integrated angular velocities during attitude estimation. This causes unwanted errors in the attitude estimate when nongravitational accelerations or contact forces are present. We also use a variable-measurement-covariance method to reduce errors in the attitude estimation caused by rapid and temporary nongravitational accelerations. It is affordable to do, as in the DCM representation of rotation; the bottom row of rotation matrix represents the direction of gravitational force. As a result, our implementation of the extended Kalman filter is able to use only six states for estimating the attitude, gyroscope biases, and the gravity vector.In Experiments and Results, we show that our solution is significantly more accurate than the compared algorithms in those situations in which either temporary accelerations are present or significant gyroscope biases exist. With fully calibrated bias-free data without nongravitational accelerations, our algorithm performs as well as the compared algorithms, since our gyroscope bias estimates do not disturb attitude estimation.Our work provides a complete solution that integrates low-cost MEMS IMU, temperature calibration, online bias estimator, and a robust extended Kalman filter which is able to handle large temporary accelerations and changes in sampling rate. We verify our algorithm using multiple different tests and we also obtain accurate reference measurements using the KUKA LWR 4+ robot arm and comparisons to other freely available state-of-the-art algorithms. The used calibration and measurement data for our tests and the proposed algorithm (in MATLAB and C++) are published as open source athttps://github.com/hhyyti/dcm-imu.


## 2. Related Work

Numerous attitude estimation algorithms have become available. Most of these consist of various Kalman filter solutions [2, 3, 5, 12, 13, 16, 25], usually extended Kalman filters (EKF) [7, 9, 10, 15, 17, 18, 20, 26], and some unscented Kalman filters (UKF) [14, 19, 27], though some non-Kalman filter solutions also exist [1, 4, 11, 21, 28–30] as well as some geometric methods [31–34]. In addition, Chao et al. [35] have carried out a comparative study of low-cost IMU filters. Existing algorithms often rely on data obtained from military-grade IMUs, which are usually subject to export restrictions and high cost that limit commercial applications [29]. Several authors have reported that cheaper commercial grade IMUs commonly include non-Gaussian noise in their gyroscope and accelerometer measurements, often leading to instability in connecting classical Kalman and extended Kalman filter algorithms [29, 30]. The same has been noted in an extensive survey of nonlinear attitude estimation methods by Crassidis et al. [36]. They also state that EKF is not as good a solution as other filtering schemes. The survey was published a few years prior to most of the papers presenting DCM based methods [3, 9, 12, 21], and their possibilities were therefore not considered in their review.Low-cost MEMSs are usually subject to time-dependent errors, such as drifting gyroscope biases. Therefore, all IMU algorithms for low-cost sensors should have an online bias estimator. Unfortunately, few of the previously published algorithms developed for only triaxial accelerometers and gyroscopes have included online bias estimates for gyroscopes. In many algorithms, other measurements are needed in addition to gyroscopes and accelerometers in order to estimate gyroscope biases. The most commonly used sensors are triaxial magnetometers [2, 9–16, 25] and satellite navigation [3, 5, 17–20]. In addition to our work, few filters [21–24, 30] have been able to estimate gyroscope biases without extra sensors in addition to the triaxial accelerometer and gyroscope.The development of a filter that uses only accelerometer and gyroscope measurements is difficult and can lead to an observability problem. This problem arises when a single vector measurement, such as the gravity through acceleration measurements, gives only information to correct estimates of attitude angles, as well as the related biases, which could rotate that vector. The single vector measurement provides no information about the rotation around that vector. Hamel and Mahony [30] have discussed the problem of orientation and gyroscope bias estimation using passive complementary filter. They have also proposed a solution to estimate biases even in the single vector case. Subsequently, Mahony et al. [21] derived a nonlinear observer, termed the explicit complementary filter, which similarly requires only accelerometer and gyro measurements. In another theoretical study [37], they discussed observability and stability issues that arise especially while using single vector measurements. Finally, they proved that, in these single vector cases, the derivation leads to asymptotically stable observers if they assume persistent excitation of rigid-body motion.Similar ideas have been later used in the work by Khosravian and Namvar [38], who proposed a nonlinear observer using a magnetometer as a single vector measurement. In addition to their work, Hua et al. [23] have implemented a nonlinear attitude estimator that allows the compensation of gyroscope biases of a low-cost IMU using an antiwindup integration technique. They also show valuable aspects of a practical implementation of a filter. Finally, the observability problem for systems, in which the measurement of system input is corrupted by an unknown constant bias, is tackled in [39].The observability problem can also be avoided. Ruizenaar et al. [22] solve the problem by adding a second IMU to the system. They propose a filter that uses two sets of triaxial accelerometers and gyroscopes attached in a predefined orientation with respect to each other in order to overcome the observability problem. After their work, Wu et al. [24] overcome the same problem by actively rotating their IMU device. Rather than having two separate measurement devices or an instrumented rotating mechanism, a simpler, cheaper solution to this problem could be obtained, if we could overcome the problem algorithmically.Currently, the most commonly used (at least among hobbyists with low-cost MEMS) and freely available IMU algorithms are Madgwick’s [11] and Mahony’s [21] non-Kalman filter methods. Both of these methods are computationally simpler than any Kalman filter implementation. Open-source implementations by Madgwick are used to compare these two state-of-the-art implementations to our work. These implementations are freely available for C and MATLAB at http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/. The explicit complementary filter by Mahony et al. is used as a primary attitude estimation system on several MAV vehicles worldwide [21]. However, neither of these Madgwick’s implementations was able to estimate biases using only accelerometer and gyroscope measurements. Nevertheless, we used these, as other implementations were not available at the time of writing.Mahony’s and Baldwin’s IMU algorithm [21, 29] is based on an idea roughly similar to our solution. In contrast to our EKF solution, they derive their direct and complementary filters using tools from differential geometry on the Lie group S
O
(
3
). This solution is based on the Special Orthogonal group S
O
(
3
), which is the underlying Lie group structure for space of rotation matrices. Our solution is in principle defined similarly to theirexplicit complementary filter with bias correction; however, instead of their constant gains for measurement update and bias estimator, we use EKF to tune these gains.Madgwick’s implementation [11, 28] is a quaternion implementation of Mahony’s observer [21], and it uses a gradient descent algorithm in the orientation estimation. Madgwick’s implementation [11] also uses simple algebraic modifications [21] to ensure separation of the roll and pitch estimation error from the yaw estimation. This addition helps to deal with unreliable magnetic field measurements. Madgwick’s solution is computationally efficient because only one iteration of the gradient descent algorithm is performed for each measurement. Therefore, the filter is better suited for high measurement frequencies. If used sampling rate is larger than 50 Hz, the remaining error is negligible [11]. In our tests, we used a significantly larger rate of 150 Hz (the maximum we could record using Microstrain Inertia-Link).The effects of dynamic motion and nongravitational accelerations have previously been taken into account in [14–16, 18, 27]. Most of this previous work compares the magnitude of accelerometer measurements to the expected magnitude of Earth’s gravitation field [15, 18, 27]. It is not a perfect approach, as exactly the same magnitude of accelerometer measurements can occur in multiple configurations (e.g., free fall and an acceleration of 1 g in any direction). A more exact approach to do this would be using a separate estimate for nongravitational accelerations as in [14]. Although they use three separate filter states for estimating linear acceleration components, this unnecessarily increases the computational load of the filter. One solution would be making an adaptation in the covariance for acceleration measurements using the magnitude of the difference between an estimated gravity vector and a measured acceleration [16]. We implemented this method for our DCM-type representation of orientation. In our representation of rotation, it is efficient to use an estimated gravity vector, as it is included in our state estimates representing the rotation.If there were extra measurements for the velocity, for example, from satellite navigation sensors, then the nongravitational acceleration could be added to the filter as a state to be estimated. This would make it possible to avoid our proposed method to tune the measurement covariance of accelerometers and to improve the accuracy of the proposed filter, as it would no longer be vulnerable to nontemporary or constant accelerations. Many velocity aided attitude estimation methods are dependent on measurement of linear velocity in addition to gyro and accelerometer measurements in order to reliably compensate for nongravitational accelerations [31–34]. Instead of using velocity measurements, we use only a low-cost triaxial set of an accelerometer and a gyroscope.


## 3. Methods

### 3.1. DCM Based Partial Attitude Estimation

Our proposed partial attitude estimation builds upon the work by Phuong et al. [12]. It is based on the relation between the estimated direction of gravity and measured accelerations. The direction of gravity is estimated by integrating measured angular velocities using a partial direction cosine matrix (DCM). The results are translated into Euler angles in the Z
Y
X convention [40], which have the following relation to the DCM:(1)
C
b
n
=
θ
c
ψ
c
-
ϕ
c
ψ
s
+
ϕ
s
θ
s
ψ
c
ϕ
s
ψ
s
+
ϕ
c
θ
s
ψ
c
θ
c
ψ
s
ϕ
c
ψ
c
+
ϕ
s
θ
s
ψ
s
-
ϕ
s
ψ
c
+
ϕ
c
θ
s
ψ
s
-
θ
s
ϕ
s
θ
c
ϕ
c
θ
c
.The notation “s” in (1) refers to sine and “c” to cosine, φ to roll, θ to pitch, and ψ to yaw in Euler angles. The direction cosine matrix C
b
n, that is, the rotation matrix, defines rotation from the body-fixed frame (b) to the navigation frame (n). It is integrated from initial DCM using an angular velocity tensor [
ω
b

×

] formed from triaxial gyroscope measurements in the body-fixed frame according to [41](2)
C
˙
b
n
=
C
b
n
ω
b
×
,where(3)
ω
b
×
=
0
-
ω
z
b
ω
y
b
ω
z
b
0
-
ω
x
b
-
ω
y
b
ω
x
b
0
.Normally, in DCM-type filters, the whole DCM matrix would be updated; however, in this partial-attitude-estimation case, only the bottom row of the matrix in (1) is estimated for the proposed filter. These bottom-row elements are collected into a row vector C
3
b
n which can be updated using (4)
C
˙
3
b
n
=
C
˙
31
b
n
C
˙
32
b
n
C
˙
33
b
n
=
0
-
C
33
b
n
C
32
b
n
C
33
b
n
0
-
C
31
b
n
-
C
32
b
n
C
31
b
n
0
︸
C
3
×
ω
x
b
ω
y
b
ω
z
b
︸
u
,which is derived from (1), (2), and (3) [12]. In (4), ω
i
b, i
∈
x
,
y
,
z are measured angular velocities and C
3
i
b
n, i
∈
1,2
,
3 are bottom-row elements of the DCM, which are used as an estimate of the partial attitude. Later in this paper, these three bottom-row elements are called DCM states, which form a DCM vector C
3
b
n. [
C
3

×

] is defined as a rotation operator which rotates the current DCM vector according to the measured angular velocities.The observation model is constructed using accelerometer measurements, which are compared to the current estimate of the direction of gravity by [12](5)
f
b
=
f
x
b
f
y
b
f
z
b
=
C
T
b
n
0
0
g
=
C
31
b
n
C
32
b
n
C
33
b
n
g
,where f
i
b, i
∈
x
,
y
,
z are accelerometer measurements (forming a measurement vector f
b) in the body-fixed frame (
b
) and g is the magnitude of the Earth’s gravitation field. This simple model assumes that the gravity is aligned parallel to the z-axis and that there is no other acceleration than gravity. Later in this paper, this assumption is relaxed with the application of a variable measurement covariance in the extended Kalman filter algorithm.


### 3.2. Adaptive Extended Kalman Filter with Gyroscope Bias Estimation and Variable Covariances

An extended Kalman filter (EKF) is a linearized approximation of an optimal nonlinear filter, similar to the original Kalman filter [42]. Usually, the state and measurements are predicted with the original nonlinear functions, and the covariances are predicted and updated with a linearized mapping. In this case, the measurement model is linear, and the state update is nonlinear. Some attitude estimation algorithms based on previously presented Kalman filters [3, 5, 12, 13, 25] use a simpler linear model; however, in our work, we use a nonlinear state-transition model for a purely nonlinear problem.We enhance the commonly used standard EKF algorithm through a few additions. First, the filter is adapted to changing measurements by using a variable time-dependent state-prediction and acceleration-dependent measurement covariances. Second, the filter is simplified and made computationally more feasible by using gyroscope measurements as control inputs in the EKF. Third, the magnitude of the DCM vector is constrained to be always exactly one. Finally, the filter is formulated for a variable sampling interval to tolerate jitter or changes in sampling rate.The filter principle is shown as a simplified block diagram in Figure1. The accelerometer measurements are used as a measurement for the EKF, and gyroscope measurements are used as control inputs in the prediction subsection. Later on, the EKF is used to fuse these measurements in the update subsection. In Figure 1, x refers to the EKF state vector defined in (6), x
^ is an unnormalized predicted state, z is a measurement, u is a control input, and y
~
k is a measurement residual. The colored blocks in the figure are updated or estimated online. The accelerometer measurement is drawn using different subblocks for gravitational, g, and nongravitational accelerations, a, because nongravitational acceleration is estimated using the predicted state in the EKF, thus allowing these two to be separated.Figure 1
A simplified block diagram of the DCM IMU filter. The covariance computation has been hidden to simplify the work flow of the EKF filter. The colored blocks are adjusted online.The state-transition model to update angular velocities to DCM states (4) and the measurement model to incorporate accelerations (5) are formulated into an extended Kalman filter that has six states: three for orientation (the DCM vector, C
3
b
n) and three for gyroscope biases (the bias vector, b
ω
b):(6)
x
=
C
3
b
n
b
ω
b
=
C
31
b
n
C
32
b
n
C
33
b
n
b
x
ω
b
b
y
ω
b
b
z
ω
b
T
.The state-space model for the proposed system is the following:(7)
x
k
+
1
=
f
k
x
k
,
u
k
+
Γ
k
w
k
,
y
k
=
Η
x
k
+
v
k
,
c
x
k
=
1
constraint
,
E
w
k
=
E
v
k
=
0
,
E
w
k
w
k
T
=
Q
k
,
E
v
k
v
k
T
=
R
k
,
x
0
=
0
0
1
0
0
0
T
.In (7), f
k
x
k
,
u
k is the discrete nonlinear state-transition function at time index k. The state-transition function is presented in (8) (see Appendix for the derivation). The function uses the state vector x
k in (6) and gyroscope measurements as control input u
k. The measurement y
k in (7) is derived with a linear and static observation model H presented in (9). In (8), [
C
3

×

] is a rotation operator defined in (4), and Δ
t is a sampling interval which can vary in this formulation of extended Kalman filter. In (9), g is the magnitude of the gravity(8)
f
k
x
k
,
u
k
=
I
3
-
Δ
t
C
3
×
k
0
3
×
3
I
3
x
k
+
Δ
t
C
3
×
k
0
3
×
3
u
k
,
(9)
H
=
g
I
3
0
3
×
3
.In (7), v
k and w
k represent a zero mean Gaussian white noise, and Γ
k
=
Δ
t is a simplified time-dependent model for the state-prediction noise. This simplified model is derived assuming a Wiener white noise process in angular velocity measurements (used as control inputs) which are integrated into the DCM state and bias estimates over time in each prediction step [43]. Therefore, we can formulate a state-prediction model to have a linear relationship to time step size. This time-dependent modification of the process noise covariance allows the filter to behave more robustly to changing sampling interval. When this is applied to a covariance model, we simplify and assume that there is no cross-correlation between states, thus yielding the following equation for process noise covariance Q
k
-
1:(10)
Q
k
=
Γ
σ
C
3
2
I
3
0
3
×
3
0
3
×
3
σ
b
ω
2
I
3
Γ
T
=
Δ
t
2
σ
C
3
2
I
3
0
3
×
3
0
3
×
3
σ
b
ω
2
I
3
.In (10), there are two parameters. First, σ
C
3
2 is the DCM-state-prediction variance which is mainly driven by the control inputu (angular velocities), and thus the value of the parameter can be approximated as the variance of noise of gyroscope measurements. Second, σ
b
ω
2 is the bias-state-prediction variance. In this work, it is assumed that since gyroscope biases drift very slowly, setting a tiny value for the prediction variance of corresponding bias states is reasonable (see experimental parameters in Table 1). This forces the filter to trust its own bias estimate much more than its attitude estimate, and bias estimates change only slightly during each measurement update. Our work omits the optimal estimation of these experimental parameters as acceptable parameters can be found manually.Table 1
Experimental parameters for IMU algorithms.
Symbol
Quantity
Value
g
The acceleration of gravity (around Helsinki, Finland)
9.8189 m/s2
Δ
t
Sampling interval
~1/150 s
σ
C
3
,
0
2
Initial variance of the DCM state
12 (rad/s)2
(σ
b
,
0
ω)2
Initial variance of bias states
0.12 (rad/s)2
σ
C
3
2
DCM-state-prediction variance
0.12 (rad/s)2
(σ
b
ω)2
Bias-state-prediction variance
0.00012 (rad/s)2
σ
f
2
Variance of accelerometer measurement
0.52 (m/s2)2
σ
a
2
Variance of estimated acceleration
102 (m/s2)2
β
A tuning parameter of Madgwick’s filter
0.1
K
p
A tuning parameter of Mahony’s filter
0.5The measurement covarianceR
k in (7) is adjusted according to the acceleration measurement as follows:(11)
R
k
=
a
k
b
σ
a
2
+
σ
f
2
I
3
,which is a robust covariance for acceleration measurements based on the work by Li and Wang [16]. The proposed measurement covariance R
k is built upon two parts: first, a constant part which represents a variance of a measurement noise for a triaxial accelerometer σ
f
2 and second, a variable part which represents a constant variance of estimated acceleration σ
a
2 scaled using the magnitude of the estimated nongravitational acceleration a
k
b, which is the difference between the measured acceleration and the estimated gravity. These nongravitational accelerations are estimated using a relation between a predicted DCM vector C
^
3
,
k
b
n (the first part of the predicted state vector in the EKF) and the current accelerometer measurement f
k
b deriving from (5): (12)
a
k
b
=
f
k
b
-
g
C
^
3
,
k
b
n
.The proposed measurement covariance adaptation is more effective than the standard approach, since it modifies the algorithm to become more robust against rapid accelerations. However, if measurement errors are correlated (i.e., there exists a long-term or constant nongravitational acceleration), the assumption underlying the proposed model would no longer hold. Therefore, this solution is only limited to cases where nongravitational accelerationa
k
b in (12) can be assumed to be temporary.For simplicity, since the sampling time of accelerometer is assumed to be constant, these parameters (measurement variancesσ
f
2 and σ
a
2) should be tuned to include the effect of the used sampling time. Time-dependent modifications could be added similar to that for Q in (10). However, it is not necessarily needed, as measurement updates can be avoided if a measurement is lost, and the physical sampling time in practice usually remains constant, although the sampling interval might change or measurements might be lost. For a practical implementation, parameter σ
a
2 (the gain for estimated gravitational acceleration) should be set to a much larger value than σ
f
2 (measurement noise). This makes the adaptation to changing acceleration values significant compared to measurement noise. For the values used, see experimental parameters in Table 1.The constraint,c, in (7) keeps the DCM vector C
3
,
k
b
n used in the first three states as a unit vector. The constraint is defined according to (13)
c
x
k
=
C
3
,
k
b
n
=
1
.Many different nonlinear filters could be used to solve the proposed estimation problem, for example, Gaussian filters like extended and unscented Kalman filters [44]. We selected an extended Kalman filter [43] as we wanted to minimize computational load of the filter. We used the projection method by Julier and LaViola Jr. [45] to handle the constraint in (7). The derivation and practical implementation of the proposed EKF and the constraint projection are explained in Appendix.


### 3.3. Computation of Euler Angles from Filter States

To compare our results to other filters and to use the estimate, the estimated attitude should be able to be translated into an Euler angle representation. As the proposed attitude filter only estimates the partial attitude, corresponding to two out of the three Euler angles present in the bottom row of the rotation matrix in (1), the transformation of filter states to Euler angle representation is not trivial. While the yaw angle should be integrated separately, pitch θ and roll φ angles can be estimated using the following equations that can be derived from (1):(14)
θ
k
=
arcsin
⁡
-
C
31
,
k
,
ϕ
k
=
atan
2
⁡
C
32
,
k
,
C
33
,
k
,where a
t
a
n
2 is an inverse tangent function with two arguments to distinguish angles in all four quadrants [46] and C
3
i
,
k is the ith element of the DCM vector at time index k.Yaw angle,ψ, can be integrated from bias-corrected angular velocities with (1) and (2) using previously computed roll, pitch, and yaw angles as a starting point. The yaw can be resolved from the full DCM matrix C using the following equation: (15)
ψ
k
=
atan
⁡
2
C
21
,
k
,
C
11
,
k
,where C
i
j
,
k is the i
,
jth index of the DCM matrix at time index k. Note that indices 2,1 and 1,1 are not estimated in the proposed filter. In (15), since the upper rows of the matrix are needed, the whole rotation matrix needs to be computed outside the filter if the yaw angle estimate is required.


### 3.4. Temperature Calibration Method

MEMS gyroscopes and accelerometers usually show at least some bias error, though some gain error might be present as well. To be able to reduce the effect of these errors and to achieve the best performance of the IMU, it is important to calibrate the system before feeding the data into any attitude estimation algorithm. The gains and biases of the MEMS gyroscope and accelerometer vary over time, a large part of which can be explained by temperature changes in the physical instrument. Our observations (Figures11 and 12) indicate that while working near room temperatures, a linear model for temperature is sufficiently accurate to model most of the changes in bias and gain terms using low-cost MEMS accelerometers and gyroscopes.As our proposed IMU uses accelerometers to calibrate gyroscope biases online, accelerometer calibration is essential for reaching accurate measurements. Therefore, temperature-dependent calibration is needed at least for the accelerometers in order to estimate temperature-dependent bias and gain terms for all the sensor axes if there is any possibility of temperature changes in the environment. We used a linear model for the gain and bias parameters to scale the magnitude and reduce the bias from all gyroscope and accelerometer measurements. The measurement model is derived from [6] by adding the linear model of temperature for each parameter. The used measurement model for each sensor axis i
∈
x
,
y
,
z is(16)
f
meas
⁡
,
i
b
=
p
gain
f
i
T
f
i
b
+
p
bias
f
i
T
,
ω
meas
⁡
,
i
b
=
p
gain
ω
i
T
ω
i
b
+
p
bias
ω
i
T
,
(17)
p
gain
/
bias
f
i
/
ω
i
T
=
a
gain
/
bias
f
i
/
ω
i
T
+
b
gain
/
bias
f
i
/
ω
i
.In (16) and (17), p
gain
/
bias
f
i
(
T
) is a function of accelerometer gain/bias as a function of temperature T, and p
gain
/
bias
ω
i
(
T
) is a function of gyroscope gain/bias as a function of temperature, both separately for each axis i. In the equation, f
meas
⁡
,
i
b is the accelerometer measurement, and ω
meas
⁡
,
i
b is the gyroscope measurement for each axis i. All accelerations and angular velocities are in body-fixed frame (
b
). In (17), the temperature-dependent linear model is expressed for all different sensors and sensor axes for bias and gain. In the equation, f
i and ω
i are interchangeable similar to subscripts gain and bias. As we used the linear model for all biases and gains as a function of temperature, there are a total of four parameters for each sensor axis in the calibration model for the accelerometer and the gyroscope, thus yielding 24 unknown calibration parameters to tune.The calibration of accelerometers can be performed without accurate reference positions using the iterative mathematical calibration method by Won and Golnaraghi [47]. According to the method, the three-axis accelerometer is placed in six different positions and held stationary during each calibration measurement. Measurements from these six positions are then used in the algorithm iteratively to optimize gains and biases for each axis of the accelerometer sensor. Gyroscope biases and gains are estimated by comparing rotations to a reference measurement and forming a linear model of gains and biases for all axes of the sensor. Similar to Sahawneh and Jarrah [6] who use an instrumented rotation plate to perform gyroscope calibration, we use one rotation axis of the robot arm to accomplish the same task. Whereas their method has 12 parameters, we use 24 unknown parameters. Our parameters can be acquired by using two different strategies and single-temperature methods [6, 47].The first strategy is having two different constant temperatures and performing the calibration [6] at these two different temperatures. From the resulting two sets of calibration parameters, the temperature-dependent linear model (16) can be calculated by fitting a parameterized line (17) into two points in a 12-dimensional space. The other strategy, which could be used if constant temperatures cannot be arranged, is separately cooling the device for one orientation out of six needed in the presented methods and to perform the calibration measurements as a function of temperature while the device is gradually heated. Next, a linear regression line can be fitted into the data for each sensor axis as a function of temperature (similarly as in Figures 11 and 12). This regression model can then be used to estimate constant temperature averages for two different temperatures. These estimates could be used similarly to the average measurements in the first strategy.


## 3.1. DCM Based Partial Attitude Estimation

Our proposed partial attitude estimation builds upon the work by Phuong et al. [12]. It is based on the relation between the estimated direction of gravity and measured accelerations. The direction of gravity is estimated by integrating measured angular velocities using a partial direction cosine matrix (DCM). The results are translated into Euler angles in the Z
Y
X convention [40], which have the following relation to the DCM:(1)
C
b
n
=
θ
c
ψ
c
-
ϕ
c
ψ
s
+
ϕ
s
θ
s
ψ
c
ϕ
s
ψ
s
+
ϕ
c
θ
s
ψ
c
θ
c
ψ
s
ϕ
c
ψ
c
+
ϕ
s
θ
s
ψ
s
-
ϕ
s
ψ
c
+
ϕ
c
θ
s
ψ
s
-
θ
s
ϕ
s
θ
c
ϕ
c
θ
c
.The notation “s” in (1) refers to sine and “c” to cosine, φ to roll, θ to pitch, and ψ to yaw in Euler angles. The direction cosine matrix C
b
n, that is, the rotation matrix, defines rotation from the body-fixed frame (b) to the navigation frame (n). It is integrated from initial DCM using an angular velocity tensor [
ω
b

×

] formed from triaxial gyroscope measurements in the body-fixed frame according to [41](2)
C
˙
b
n
=
C
b
n
ω
b
×
,where(3)
ω
b
×
=
0
-
ω
z
b
ω
y
b
ω
z
b
0
-
ω
x
b
-
ω
y
b
ω
x
b
0
.Normally, in DCM-type filters, the whole DCM matrix would be updated; however, in this partial-attitude-estimation case, only the bottom row of the matrix in (1) is estimated for the proposed filter. These bottom-row elements are collected into a row vector C
3
b
n which can be updated using (4)
C
˙
3
b
n
=
C
˙
31
b
n
C
˙
32
b
n
C
˙
33
b
n
=
0
-
C
33
b
n
C
32
b
n
C
33
b
n
0
-
C
31
b
n
-
C
32
b
n
C
31
b
n
0
︸
C
3
×
ω
x
b
ω
y
b
ω
z
b
︸
u
,which is derived from (1), (2), and (3) [12]. In (4), ω
i
b, i
∈
x
,
y
,
z are measured angular velocities and C
3
i
b
n, i
∈
1,2
,
3 are bottom-row elements of the DCM, which are used as an estimate of the partial attitude. Later in this paper, these three bottom-row elements are called DCM states, which form a DCM vector C
3
b
n. [
C
3

×

] is defined as a rotation operator which rotates the current DCM vector according to the measured angular velocities.The observation model is constructed using accelerometer measurements, which are compared to the current estimate of the direction of gravity by [12](5)
f
b
=
f
x
b
f
y
b
f
z
b
=
C
T
b
n
0
0
g
=
C
31
b
n
C
32
b
n
C
33
b
n
g
,where f
i
b, i
∈
x
,
y
,
z are accelerometer measurements (forming a measurement vector f
b) in the body-fixed frame (
b
) and g is the magnitude of the Earth’s gravitation field. This simple model assumes that the gravity is aligned parallel to the z-axis and that there is no other acceleration than gravity. Later in this paper, this assumption is relaxed with the application of a variable measurement covariance in the extended Kalman filter algorithm.


## 3.2. Adaptive Extended Kalman Filter with Gyroscope Bias Estimation and Variable Covariances

An extended Kalman filter (EKF) is a linearized approximation of an optimal nonlinear filter, similar to the original Kalman filter [42]. Usually, the state and measurements are predicted with the original nonlinear functions, and the covariances are predicted and updated with a linearized mapping. In this case, the measurement model is linear, and the state update is nonlinear. Some attitude estimation algorithms based on previously presented Kalman filters [3, 5, 12, 13, 25] use a simpler linear model; however, in our work, we use a nonlinear state-transition model for a purely nonlinear problem.We enhance the commonly used standard EKF algorithm through a few additions. First, the filter is adapted to changing measurements by using a variable time-dependent state-prediction and acceleration-dependent measurement covariances. Second, the filter is simplified and made computationally more feasible by using gyroscope measurements as control inputs in the EKF. Third, the magnitude of the DCM vector is constrained to be always exactly one. Finally, the filter is formulated for a variable sampling interval to tolerate jitter or changes in sampling rate.The filter principle is shown as a simplified block diagram in Figure1. The accelerometer measurements are used as a measurement for the EKF, and gyroscope measurements are used as control inputs in the prediction subsection. Later on, the EKF is used to fuse these measurements in the update subsection. In Figure 1, x refers to the EKF state vector defined in (6), x
^ is an unnormalized predicted state, z is a measurement, u is a control input, and y
~
k is a measurement residual. The colored blocks in the figure are updated or estimated online. The accelerometer measurement is drawn using different subblocks for gravitational, g, and nongravitational accelerations, a, because nongravitational acceleration is estimated using the predicted state in the EKF, thus allowing these two to be separated.Figure 1
A simplified block diagram of the DCM IMU filter. The covariance computation has been hidden to simplify the work flow of the EKF filter. The colored blocks are adjusted online.The state-transition model to update angular velocities to DCM states (4) and the measurement model to incorporate accelerations (5) are formulated into an extended Kalman filter that has six states: three for orientation (the DCM vector, C
3
b
n) and three for gyroscope biases (the bias vector, b
ω
b):(6)
x
=
C
3
b
n
b
ω
b
=
C
31
b
n
C
32
b
n
C
33
b
n
b
x
ω
b
b
y
ω
b
b
z
ω
b
T
.The state-space model for the proposed system is the following:(7)
x
k
+
1
=
f
k
x
k
,
u
k
+
Γ
k
w
k
,
y
k
=
Η
x
k
+
v
k
,
c
x
k
=
1
constraint
,
E
w
k
=
E
v
k
=
0
,
E
w
k
w
k
T
=
Q
k
,
E
v
k
v
k
T
=
R
k
,
x
0
=
0
0
1
0
0
0
T
.In (7), f
k
x
k
,
u
k is the discrete nonlinear state-transition function at time index k. The state-transition function is presented in (8) (see Appendix for the derivation). The function uses the state vector x
k in (6) and gyroscope measurements as control input u
k. The measurement y
k in (7) is derived with a linear and static observation model H presented in (9). In (8), [
C
3

×

] is a rotation operator defined in (4), and Δ
t is a sampling interval which can vary in this formulation of extended Kalman filter. In (9), g is the magnitude of the gravity(8)
f
k
x
k
,
u
k
=
I
3
-
Δ
t
C
3
×
k
0
3
×
3
I
3
x
k
+
Δ
t
C
3
×
k
0
3
×
3
u
k
,
(9)
H
=
g
I
3
0
3
×
3
.In (7), v
k and w
k represent a zero mean Gaussian white noise, and Γ
k
=
Δ
t is a simplified time-dependent model for the state-prediction noise. This simplified model is derived assuming a Wiener white noise process in angular velocity measurements (used as control inputs) which are integrated into the DCM state and bias estimates over time in each prediction step [43]. Therefore, we can formulate a state-prediction model to have a linear relationship to time step size. This time-dependent modification of the process noise covariance allows the filter to behave more robustly to changing sampling interval. When this is applied to a covariance model, we simplify and assume that there is no cross-correlation between states, thus yielding the following equation for process noise covariance Q
k
-
1:(10)
Q
k
=
Γ
σ
C
3
2
I
3
0
3
×
3
0
3
×
3
σ
b
ω
2
I
3
Γ
T
=
Δ
t
2
σ
C
3
2
I
3
0
3
×
3
0
3
×
3
σ
b
ω
2
I
3
.In (10), there are two parameters. First, σ
C
3
2 is the DCM-state-prediction variance which is mainly driven by the control inputu (angular velocities), and thus the value of the parameter can be approximated as the variance of noise of gyroscope measurements. Second, σ
b
ω
2 is the bias-state-prediction variance. In this work, it is assumed that since gyroscope biases drift very slowly, setting a tiny value for the prediction variance of corresponding bias states is reasonable (see experimental parameters in Table 1). This forces the filter to trust its own bias estimate much more than its attitude estimate, and bias estimates change only slightly during each measurement update. Our work omits the optimal estimation of these experimental parameters as acceptable parameters can be found manually.Table 1
Experimental parameters for IMU algorithms.
Symbol
Quantity
Value
g
The acceleration of gravity (around Helsinki, Finland)
9.8189 m/s2
Δ
t
Sampling interval
~1/150 s
σ
C
3
,
0
2
Initial variance of the DCM state
12 (rad/s)2
(σ
b
,
0
ω)2
Initial variance of bias states
0.12 (rad/s)2
σ
C
3
2
DCM-state-prediction variance
0.12 (rad/s)2
(σ
b
ω)2
Bias-state-prediction variance
0.00012 (rad/s)2
σ
f
2
Variance of accelerometer measurement
0.52 (m/s2)2
σ
a
2
Variance of estimated acceleration
102 (m/s2)2
β
A tuning parameter of Madgwick’s filter
0.1
K
p
A tuning parameter of Mahony’s filter
0.5The measurement covarianceR
k in (7) is adjusted according to the acceleration measurement as follows:(11)
R
k
=
a
k
b
σ
a
2
+
σ
f
2
I
3
,which is a robust covariance for acceleration measurements based on the work by Li and Wang [16]. The proposed measurement covariance R
k is built upon two parts: first, a constant part which represents a variance of a measurement noise for a triaxial accelerometer σ
f
2 and second, a variable part which represents a constant variance of estimated acceleration σ
a
2 scaled using the magnitude of the estimated nongravitational acceleration a
k
b, which is the difference between the measured acceleration and the estimated gravity. These nongravitational accelerations are estimated using a relation between a predicted DCM vector C
^
3
,
k
b
n (the first part of the predicted state vector in the EKF) and the current accelerometer measurement f
k
b deriving from (5): (12)
a
k
b
=
f
k
b
-
g
C
^
3
,
k
b
n
.The proposed measurement covariance adaptation is more effective than the standard approach, since it modifies the algorithm to become more robust against rapid accelerations. However, if measurement errors are correlated (i.e., there exists a long-term or constant nongravitational acceleration), the assumption underlying the proposed model would no longer hold. Therefore, this solution is only limited to cases where nongravitational accelerationa
k
b in (12) can be assumed to be temporary.For simplicity, since the sampling time of accelerometer is assumed to be constant, these parameters (measurement variancesσ
f
2 and σ
a
2) should be tuned to include the effect of the used sampling time. Time-dependent modifications could be added similar to that for Q in (10). However, it is not necessarily needed, as measurement updates can be avoided if a measurement is lost, and the physical sampling time in practice usually remains constant, although the sampling interval might change or measurements might be lost. For a practical implementation, parameter σ
a
2 (the gain for estimated gravitational acceleration) should be set to a much larger value than σ
f
2 (measurement noise). This makes the adaptation to changing acceleration values significant compared to measurement noise. For the values used, see experimental parameters in Table 1.The constraint,c, in (7) keeps the DCM vector C
3
,
k
b
n used in the first three states as a unit vector. The constraint is defined according to (13)
c
x
k
=
C
3
,
k
b
n
=
1
.Many different nonlinear filters could be used to solve the proposed estimation problem, for example, Gaussian filters like extended and unscented Kalman filters [44]. We selected an extended Kalman filter [43] as we wanted to minimize computational load of the filter. We used the projection method by Julier and LaViola Jr. [45] to handle the constraint in (7). The derivation and practical implementation of the proposed EKF and the constraint projection are explained in Appendix.


## 3.3. Computation of Euler Angles from Filter States

To compare our results to other filters and to use the estimate, the estimated attitude should be able to be translated into an Euler angle representation. As the proposed attitude filter only estimates the partial attitude, corresponding to two out of the three Euler angles present in the bottom row of the rotation matrix in (1), the transformation of filter states to Euler angle representation is not trivial. While the yaw angle should be integrated separately, pitch θ and roll φ angles can be estimated using the following equations that can be derived from (1):(14)
θ
k
=
arcsin
⁡
-
C
31
,
k
,
ϕ
k
=
atan
2
⁡
C
32
,
k
,
C
33
,
k
,where a
t
a
n
2 is an inverse tangent function with two arguments to distinguish angles in all four quadrants [46] and C
3
i
,
k is the ith element of the DCM vector at time index k.Yaw angle,ψ, can be integrated from bias-corrected angular velocities with (1) and (2) using previously computed roll, pitch, and yaw angles as a starting point. The yaw can be resolved from the full DCM matrix C using the following equation: (15)
ψ
k
=
atan
⁡
2
C
21
,
k
,
C
11
,
k
,where C
i
j
,
k is the i
,
jth index of the DCM matrix at time index k. Note that indices 2,1 and 1,1 are not estimated in the proposed filter. In (15), since the upper rows of the matrix are needed, the whole rotation matrix needs to be computed outside the filter if the yaw angle estimate is required.


## 3.4. Temperature Calibration Method

MEMS gyroscopes and accelerometers usually show at least some bias error, though some gain error might be present as well. To be able to reduce the effect of these errors and to achieve the best performance of the IMU, it is important to calibrate the system before feeding the data into any attitude estimation algorithm. The gains and biases of the MEMS gyroscope and accelerometer vary over time, a large part of which can be explained by temperature changes in the physical instrument. Our observations (Figures11 and 12) indicate that while working near room temperatures, a linear model for temperature is sufficiently accurate to model most of the changes in bias and gain terms using low-cost MEMS accelerometers and gyroscopes.As our proposed IMU uses accelerometers to calibrate gyroscope biases online, accelerometer calibration is essential for reaching accurate measurements. Therefore, temperature-dependent calibration is needed at least for the accelerometers in order to estimate temperature-dependent bias and gain terms for all the sensor axes if there is any possibility of temperature changes in the environment. We used a linear model for the gain and bias parameters to scale the magnitude and reduce the bias from all gyroscope and accelerometer measurements. The measurement model is derived from [6] by adding the linear model of temperature for each parameter. The used measurement model for each sensor axis i
∈
x
,
y
,
z is(16)
f
meas
⁡
,
i
b
=
p
gain
f
i
T
f
i
b
+
p
bias
f
i
T
,
ω
meas
⁡
,
i
b
=
p
gain
ω
i
T
ω
i
b
+
p
bias
ω
i
T
,
(17)
p
gain
/
bias
f
i
/
ω
i
T
=
a
gain
/
bias
f
i
/
ω
i
T
+
b
gain
/
bias
f
i
/
ω
i
.In (16) and (17), p
gain
/
bias
f
i
(
T
) is a function of accelerometer gain/bias as a function of temperature T, and p
gain
/
bias
ω
i
(
T
) is a function of gyroscope gain/bias as a function of temperature, both separately for each axis i. In the equation, f
meas
⁡
,
i
b is the accelerometer measurement, and ω
meas
⁡
,
i
b is the gyroscope measurement for each axis i. All accelerations and angular velocities are in body-fixed frame (
b
). In (17), the temperature-dependent linear model is expressed for all different sensors and sensor axes for bias and gain. In the equation, f
i and ω
i are interchangeable similar to subscripts gain and bias. As we used the linear model for all biases and gains as a function of temperature, there are a total of four parameters for each sensor axis in the calibration model for the accelerometer and the gyroscope, thus yielding 24 unknown calibration parameters to tune.The calibration of accelerometers can be performed without accurate reference positions using the iterative mathematical calibration method by Won and Golnaraghi [47]. According to the method, the three-axis accelerometer is placed in six different positions and held stationary during each calibration measurement. Measurements from these six positions are then used in the algorithm iteratively to optimize gains and biases for each axis of the accelerometer sensor. Gyroscope biases and gains are estimated by comparing rotations to a reference measurement and forming a linear model of gains and biases for all axes of the sensor. Similar to Sahawneh and Jarrah [6] who use an instrumented rotation plate to perform gyroscope calibration, we use one rotation axis of the robot arm to accomplish the same task. Whereas their method has 12 parameters, we use 24 unknown parameters. Our parameters can be acquired by using two different strategies and single-temperature methods [6, 47].The first strategy is having two different constant temperatures and performing the calibration [6] at these two different temperatures. From the resulting two sets of calibration parameters, the temperature-dependent linear model (16) can be calculated by fitting a parameterized line (17) into two points in a 12-dimensional space. The other strategy, which could be used if constant temperatures cannot be arranged, is separately cooling the device for one orientation out of six needed in the presented methods and to perform the calibration measurements as a function of temperature while the device is gradually heated. Next, a linear regression line can be fitted into the data for each sensor axis as a function of temperature (similarly as in Figures 11 and 12). This regression model can then be used to estimate constant temperature averages for two different temperatures. These estimates could be used similarly to the average measurements in the first strategy.


## 4. Experiments and Results

Experiments were conducted using two independent IMU devices, MicroStrain Inertia-Link [48] and a low-cost SparkFun 6DOF Digital IMU breakout board (combination of an ADXL345 accelerometer [49] and an ITG-3200 gyroscope [50]). The reference measurement was acquired using a KUKA Lightweight Robot 4+ [51] and a Fast Research interface [52] for measuring the pose of the IMUs fixed to the tool of the robot arm. Comparetti et al. [53] measured KUKA LWR 4+ accuracy to be on average 1.18 mm and 0.95° for the translation and rotation components, respectively. Both of the IMU devices were installed coaxially to the robot arm (Figure 2) and aligned to have an axis orientation similar to that for the end effector of the robot. The built-in calibration procedure for MicroStrain Inertia-Link was performed prior to data collection [48].Figure 2
KUKA robot arm and the two independent IMU devices fixed to the tool. MicroStrain Inertia-Link is installed coaxially below SparkFun 6DOF Digital IMU which is inside the topmost aluminum enclosure.Since the developed algorithm should be robust for different parameters between different accelerometers and gyroscopes, only one common choice of experimental parameters was used for both measurement devices. The comparison between proposed algorithm and comparison algorithms is thus more general, as parameter tuning plays a less important role in the paper. The experimental parameters for the proposed filter and comparison algorithms are shown in Table1. These same parameters (measurement and state-prediction covariances and initial values) were used in both IMUs for simplicity. These parameters were tuned using a separate set of measurement data and a robot trajectory as the reference measurement prior to the tests presented later in this work.The variance of the accelerometer was estimated using measured accelerometer noise in a static situation, and DCM-state-prediction variance was similarly estimated using measured gyroscope noise. Bias-state-prediction variance is manually selected as an arbitrary value that is significantly smaller than DCM-state-prediction variance. Similarly, initial values and the variance of estimated acceleration are initially selected as arbitrary values that are large enough and then tuned manually. The reference measurement was compared to the estimate of the proposed algorithm, and the arbitrarily selected parameters were manually changed until the accuracy became satisfactory. The experimental parameters for the comparison methods by Madgwick and Mahony were selected as their default values (Table1).The used data sequence consists of two similar calibration sequences to calibrate accelerometers and gyroscopes before and after the actual test data. These calibration sequences are used to calibrate measurements and remove any bias and gain errors from the measurements using the temperature based calibration method described in Section3.4, except for Inertia-Link measurements which were calibrated using only a simpler temperature-non-dependent method [6]. Temperature changes could not be taken into account in the Inertia-Link data, as the device does not give temperature measurement together with its own orientation estimate. Luckily, the temperature change during the test was small, thus limiting the possibility of any remaining bias and gain errors in the Inertia-Link test data after calibration.After calibration of the test data, we separated the test data into two separate test sequences. The first sequence, the acceleration test, is designed to test the magnitude of errors caused by induced linear accelerations. Our hypothesis is that the larger linear acceleration is induced, the more likely it is that there will be larger errors in the attitude estimate. The second test sequence, the rotation test, is designed to test dynamic performance of gyroscopes at different velocities moving according to a preprogrammed path in 6D. The rotation test is designed to be long enough to truly measure drifts and give reliable error statistics. In addition, tests are designed to have the same path in four times at different velocities to cover different frequencies.In addition to comparing different algorithms with fully calibrated data, the sensitivity of the algorithms to gyroscope biases was tested by adding artificial bias to fully calibrated test data. In the third test, we added different magnitudes of artificial bias to the test data (the same for all sensor axes for simplicity). The root mean squared errors (RMSE) to the reference measurement for yaw, pitch, and roll angles were compared at different added biases. As Madgwick’s implementations of his and Mahony’s algorithms do not include an online bias estimator, this bias test is not completely fair; however, as there were no other freely available implementations to use, we performed our comparison for only these algorithms (see details in Section2). The gyroscope bias tolerance test is presented only with Microstrain Inertia-Link data, which is less noisy and has better accuracies with all algorithms in the other tests. The lower-cost, lower-quality SparkFun 6DOF Digital IMU would have yielded very similar results between the compared algorithms.For the first three tests, the orientation measurement of the KUKA robot arm was used as a reference measurement which was compared to yaw, pitch, and roll angles computed using the proposed DCM-IMU algorithm as well as Madgwick’s [11] and Mahony’s [21] algorithms as a comparison. The built-in estimate of Microstrain Inertia-Link was also used as a comparison. Errors to the reference measurement are plotted separately for yaw, pitch, and roll angles in Figure 3. The reference measurement is plotted to the topmost subplot in the figure. The figure also shows the acceleration test and the rotation test sequences. As can be noted, exact differences between the compared algorithms are difficult to discern from this plot. Therefore, differences between the algorithms are later studied using a box-and-whiskers plot and root mean squared errors.Figure 3
The three compared IMU algorithms, a built-in estimate of Microstrain Inertia-Link, and the reference trajectory which is performed using the KUKA LWR 4+ robot arm. An error to the reference measurement is shown for each algorithm for yaw, pitch, and roll angles. The visible time range covers only the performed tests. The calibration sequences before and after the tests are omitted from the figure.Finally, at the end of results section, we present the effects of temperature change on the used low-cost IMU device, SparkFun 6DOF Digital IMU [49, 50]. This section is important, as it demonstrates the need for our linearly temperature-dependent sensor calibration model and the proposed extension to the previous calibration methods. We also present our temperature-dependent calibration values for our low-cost device.


### 4.1. Rotation Test

In the rotation test, IMUs were rotated in 6D using a preprogrammed path. The same path was driven four times, first at full speed and then by halving the target velocity at each iteration. To use some well-known standard rotation formalism, the quality of algorithms is compared in Euler angles, which is easily computed for all compared algorithms. To highlight the differences, the errors are visualized using a box-and-whiskers plot in Figure4. The statistics in the figure are computed from the errors to the reference measurement during the rotation test sequence. The upper subplot shows yaw errors, and lower subplot shows combined roll and pitch errors. As revealed in the figure, roll and pitch errors behave quite similarly, as the measured gravity helps similarly in their estimation (in the Z
Y
X convention [40]); therefore, their errors are combined into the same statistics plot in Figure 4. The initial yaw error (caused by errors before the test sequence) is reduced from the yaw estimates of all the compared methods.Figure 4
A box-and-whiskers plot showing error statistics in the rotation test. The red line shows the median, the blue box is drawn between the first and the last quadrants, and whiskers are drawn to the most distant measurements.All algorithms are computed for two separate devices, Microstrain Inertia-Link (“A” in Figure4) and SparkFun 6DOF Digital IMU (“B” in Figure 4). The label “Inertia-Link” refers to the built-in orientation estimate of Microstrain Inertia-Link, recorded in addition to raw triaxial accelerations and angular velocities. As our paper focuses on partial attitude estimation (roll and pitch), the main focus of the test is given to the lower subplot in Figure 4. The yaw-error plot (the upper subplot in Figure 4) indicates that yaw drift is not significantly larger than other methods, although its value is integrated outside the proposed partial attitude estimator. The surprisingly good result observed in the yaw angle can be explained by the accurate gyroscope bias estimates in the proposed filter. The root mean squared errors (RMSE) are also counted for all methods in Table 2, where the most accurate results are highlighted for each angle. In this test, the DCM method produced the most accurate algorithm with Inertia-Link data and performed slightly worse than Mahony’s method with the SparkFun data.Table 2
Root mean squared errors of the rotation test.
Method
Yaw RMSE (deg)
Pitch RMSE (deg)
Roll RMSE (deg)
DCMA
1.57∗
0.56∗
0.61∗
MadgwickA
2.40
0.98
1.52
MahonyA
2.49
0.68
0.82
DCMB
3.91
1.29
1.46
MadgwickB
4.28
1.46
1.71
MahonyB
4.20
1.22
1.05
Inertia-Link
5.68
1.17
2.09
Data of Microstrain Inertia-Link (A) and SparkFun 6DOF digital IMU (B).
∗The most accurate value in the test.


### 4.2. Acceleration Test

In the acceleration test, the IMUs were rotated minimally, moving the KUKA robot linearly in thex, y, and z directions separately. The test sequence, shown in Figure 5, consists of back and forth movement, first using maximal velocity and then halving the target velocity at each iteration. The reference velocity, measured using KUKA robot hand, is drawn on top of the figure. The purpose of the test is to show unintended rotations in attitude estimates during temporary accelerations. These errors caused by rapid accelerations have not usually been considered in other papers, but these accelerations are present in practical cases, such as the estimation of a human body [7], a mobile phone [4], or a legged robot [8] orientation.Figure 5
Reference velocities and accelerations during the acceleration test, at firstx-axis, then y-axis, and last z-axis movement separately.The statistics for the acceleration test using fully calibrated data are presented using a box-and-whiskers plot in Figure6. In addition, root mean squared errors are computed for all methods in Table 3, where the most accurate results are highlighted. As can be seen from the results, the proposed DCM method is much more robust against rapid accelerations than any of the compared methods for pitch and roll angles. The yaw angle estimate is less accurate in the DCM method than in Madgwick’s and Mahony’s methods. This is caused by the bias estimate around the yaw axis in the DCM method that is not working perfectly in this test, as there are hardly any rotations present in the test data. In addition, this test reveals that Mahony’s method is much more robust than Madgwick’s method, which is highly prone to errors caused by rapid accelerations in pitch and roll angles.Table 3
Root mean squared errors of the acceleration test.
Method
Yaw RMSE (deg)
Pitch RMSE (deg)
Roll RMSE (deg)
DCMA
1.19
0.42
0.17∗
MadgwickA
0.31
0.93
0.87
MahonyA
0.31
0.40
0.32
DCMB
2.29
0.26∗
0.70
MadgwickB
0.14∗
0.78
0.79
MahonyB
0.16
0.30
0.40
Inertia-Link
2.61
0.50
3.45
Data of Microstrain Inertia-Link (A) and SparkFun 6DOF digital IMU (B).
∗The most accurate value in the test.Figure 6
A box-and-whiskers plot showing error statistics in the acceleration test. The red line indicates the median, the blue box is drawn between the first and the last quadrants, and whiskers are drawn to the most distant measurements which are not considered as outliers (red + signs).


### 4.3. Gyroscope Bias Tolerance Test

The bias test was performed in the same manner for the rotation test (results in Figure8) and for the acceleration test (results in Figure 9) sequences. To save computation time, all algorithms were cold-started at the beginning of the test sequence, and bias estimates are computed during the test sequence; that is, the filter is reset to the default values as the test begins. This cold start reduces the measured quality of our DCM method, as the biases are assumed to be zero at the start of each test. This first part of the test, when bias estimates are converging, adds most of the measured errors to the DCM method with larger values of induced bias.For an example of biased behavior of all the compared algorithms, a rotation test where the same bias of 1 deg./s is added to all gyroscope measurements is shown in Figure7. As can be seen from the figure, for pitch and roll, Madgwick’s method performs almost as well as the DCM method, while Mahony’s method shows the largest error. For the yaw angle, our DCM is the only method that is able to cope with biased gyroscope measurements and to obtain reliable measurements. The reason for this is the fact that since our method can reliably estimate gyroscope biases for each sensor axis, the end result contains less integrated bias error. The start transient caused by the cold start is also visible in the figure.Figure 7
Errors in yaw, pitch, and roll as an artificial 1 deg./s bias is added to all gyroscope measurements in the rotation test.Figure 8
Root mean squared errors of yaw pitch and roll angles in the rotation test as a function of added constant bias in gyroscope measurements.Figure 9
Root mean squared errors of yaw pitch and roll angles in the acceleration test as a function of added constant bias in gyroscope measurements.To test bias tolerance, test sequences were computed using different added biases changing from zero to seven degrees per second separately for rotation and acceleration tests. For both of the test sequences (the rotation test in Figure8 and the acceleration test in Figure 9), the proposed DCM method is able to successfully find the induced bias and estimate it for pitch and roll angles. The bias around the yaw angle for the acceleration test in Figure 9 is not correctly estimated in the EKF, since the test data includes minimally rotations (only linear accelerations). The filter cannot estimate the induced bias around the z-axis due to the lack of information about the bias present in this test data (see the discussion about the observability problem in Section 2). In the rotation test (results in Figure 8), bias estimates work for all angles, and the effect of induced bias is minimal compared to all other presented algorithms. As can be noted from the figures, the proposed DCM method has the smallest error in nearly all cases where there is at least some unknown gyroscope bias present.Convergence of the bias estimate in the acceleration test is interesting, as the test is a special pathological case for bias estimate around thez-axis (corresponds to the yaw angle seen in the upper subplot in Figures 6 and 9, as there are no rotations). In this case, the yaw angle and gyroscope bias estimates around the z-axis are not observable. The behavior of the proposed filter, while estimating biases and their corresponding variances, is shown in Figure 10 when there is an induced bias of 1 deg./s in each gyroscope axis. In the figure, biases for pitch and roll converge rapidly towards the true value of 1 deg./s, whereas the bias estimate around yaw converges very slowly. This happens as the filter receives marginal information about the tiny rotations present in the data. Even in this pathological special case with the observability problem, the presented filter behaves correctly, as demonstrated by the absence of any increase in the variance of the bias estimate; that is, the filter remains stable.Figure 10
An artificial 1 deg./s bias is added to all gyroscope measurements in the acceleration test. Gyroscope bias estimators for bias aroundx and y converge rapidly towards the correct bias (reference, the black slashed line). The corresponding standard deviations estimated by the EKF are visualized in the same plots using 1-sigma distance to the reference bias.Figure 11
Gyroscope and temperature measurements as a function of time for calibration purposes. The SparkFun 6DOF Digital IMU is first cooled and then held stationary for a long period to warm up to a near steady state temperature. A linear model of bias as a function of temperature is drawn over the data.Figure 12
Accelerometer measurements as a function of temperature for calibration purposes. The SparkFun 6DOF Digital IMU is first cooled and then held stationary for a long period to warm up to near steady state temperature. A linear model of data as a function of temperature is drawn over plots.


### 4.4. Effects of Temperature to Bias

To test the sensitivity of low-cost MEMS IMUs to temperature changes, a long calibration sequence over different temperatures was performed for the SparkFun 6DOF Digital IMU. First, the device was cooled down and then held stationary for over 40 minutes. During that time, the excess heat from the electronics warmed the IMU from 15°C to 35°C. The gyroscope and temperature measurements are shown in Figure11. A linear bias model of the measured temperature is plotted over the gyroscope measurements in the figure. Similarly, stationary accelerometer readings show a linear relationship to temperature, as shown in Figure 12. These results indicate that both accelerometer and gyroscope measurements are temperature-dependent and that this relation can be modeled using a linear relationship if working around room temperatures (25
±
10°C). As can be seen, the change in gyroscope bias can be as large as 0.5 deg./s.In addition to presenting linearly temperature-dependent gyroscope and accelerometer measurements, we used our 24 parameter calibration method to calibrate our SparkFun 6DOF Digital IMU. The acquired calibration parameters are presented in Table4 using a notation presented in (17). As it can be noted, all temperature-dependent calibration parameters a are small but not negligible, which indicates the minor but existing temperature-dependent effect in the accelerometer and the gyroscope. In addition, it can be noted that bias terms are more dependent on the temperature than gain parameters.Table 4
Calibration parameters for SparkFun 6DOF Digital IMU.
Parameter
x-axis
y-axis
z-axis
a
gain
f
i
-
0.00049316
0.00040477
0.00102091
b
gain
f
i
1.06731340
1.03869310
0.98073082
a
bias
f
i
-
0.01551443
-
0.00457992
-
0.01929765
b
bias
f
i
0.99740194
0.05868846
0.48880423
a
gain
ω
i
0.00027886
-
0.00122424
-
0.00246201
b
gain
ω
i
0.99130982
1.03580126
1.08040715
a
bias
ω
i
-
0.01188330
-
0.00845710
0.00542382
b
bias
ω
i
0.24566657
0.19236960
-
0.21682853


## 4.1. Rotation Test

In the rotation test, IMUs were rotated in 6D using a preprogrammed path. The same path was driven four times, first at full speed and then by halving the target velocity at each iteration. To use some well-known standard rotation formalism, the quality of algorithms is compared in Euler angles, which is easily computed for all compared algorithms. To highlight the differences, the errors are visualized using a box-and-whiskers plot in Figure4. The statistics in the figure are computed from the errors to the reference measurement during the rotation test sequence. The upper subplot shows yaw errors, and lower subplot shows combined roll and pitch errors. As revealed in the figure, roll and pitch errors behave quite similarly, as the measured gravity helps similarly in their estimation (in the Z
Y
X convention [40]); therefore, their errors are combined into the same statistics plot in Figure 4. The initial yaw error (caused by errors before the test sequence) is reduced from the yaw estimates of all the compared methods.Figure 4
A box-and-whiskers plot showing error statistics in the rotation test. The red line shows the median, the blue box is drawn between the first and the last quadrants, and whiskers are drawn to the most distant measurements.All algorithms are computed for two separate devices, Microstrain Inertia-Link (“A” in Figure4) and SparkFun 6DOF Digital IMU (“B” in Figure 4). The label “Inertia-Link” refers to the built-in orientation estimate of Microstrain Inertia-Link, recorded in addition to raw triaxial accelerations and angular velocities. As our paper focuses on partial attitude estimation (roll and pitch), the main focus of the test is given to the lower subplot in Figure 4. The yaw-error plot (the upper subplot in Figure 4) indicates that yaw drift is not significantly larger than other methods, although its value is integrated outside the proposed partial attitude estimator. The surprisingly good result observed in the yaw angle can be explained by the accurate gyroscope bias estimates in the proposed filter. The root mean squared errors (RMSE) are also counted for all methods in Table 2, where the most accurate results are highlighted for each angle. In this test, the DCM method produced the most accurate algorithm with Inertia-Link data and performed slightly worse than Mahony’s method with the SparkFun data.Table 2
Root mean squared errors of the rotation test.
Method
Yaw RMSE (deg)
Pitch RMSE (deg)
Roll RMSE (deg)
DCMA
1.57∗
0.56∗
0.61∗
MadgwickA
2.40
0.98
1.52
MahonyA
2.49
0.68
0.82
DCMB
3.91
1.29
1.46
MadgwickB
4.28
1.46
1.71
MahonyB
4.20
1.22
1.05
Inertia-Link
5.68
1.17
2.09
Data of Microstrain Inertia-Link (A) and SparkFun 6DOF digital IMU (B).
∗The most accurate value in the test.


## 4.2. Acceleration Test

In the acceleration test, the IMUs were rotated minimally, moving the KUKA robot linearly in thex, y, and z directions separately. The test sequence, shown in Figure 5, consists of back and forth movement, first using maximal velocity and then halving the target velocity at each iteration. The reference velocity, measured using KUKA robot hand, is drawn on top of the figure. The purpose of the test is to show unintended rotations in attitude estimates during temporary accelerations. These errors caused by rapid accelerations have not usually been considered in other papers, but these accelerations are present in practical cases, such as the estimation of a human body [7], a mobile phone [4], or a legged robot [8] orientation.Figure 5
Reference velocities and accelerations during the acceleration test, at firstx-axis, then y-axis, and last z-axis movement separately.The statistics for the acceleration test using fully calibrated data are presented using a box-and-whiskers plot in Figure6. In addition, root mean squared errors are computed for all methods in Table 3, where the most accurate results are highlighted. As can be seen from the results, the proposed DCM method is much more robust against rapid accelerations than any of the compared methods for pitch and roll angles. The yaw angle estimate is less accurate in the DCM method than in Madgwick’s and Mahony’s methods. This is caused by the bias estimate around the yaw axis in the DCM method that is not working perfectly in this test, as there are hardly any rotations present in the test data. In addition, this test reveals that Mahony’s method is much more robust than Madgwick’s method, which is highly prone to errors caused by rapid accelerations in pitch and roll angles.Table 3
Root mean squared errors of the acceleration test.
Method
Yaw RMSE (deg)
Pitch RMSE (deg)
Roll RMSE (deg)
DCMA
1.19
0.42
0.17∗
MadgwickA
0.31
0.93
0.87
MahonyA
0.31
0.40
0.32
DCMB
2.29
0.26∗
0.70
MadgwickB
0.14∗
0.78
0.79
MahonyB
0.16
0.30
0.40
Inertia-Link
2.61
0.50
3.45
Data of Microstrain Inertia-Link (A) and SparkFun 6DOF digital IMU (B).
∗The most accurate value in the test.Figure 6
A box-and-whiskers plot showing error statistics in the acceleration test. The red line indicates the median, the blue box is drawn between the first and the last quadrants, and whiskers are drawn to the most distant measurements which are not considered as outliers (red + signs).


## 4.3. Gyroscope Bias Tolerance Test

The bias test was performed in the same manner for the rotation test (results in Figure8) and for the acceleration test (results in Figure 9) sequences. To save computation time, all algorithms were cold-started at the beginning of the test sequence, and bias estimates are computed during the test sequence; that is, the filter is reset to the default values as the test begins. This cold start reduces the measured quality of our DCM method, as the biases are assumed to be zero at the start of each test. This first part of the test, when bias estimates are converging, adds most of the measured errors to the DCM method with larger values of induced bias.For an example of biased behavior of all the compared algorithms, a rotation test where the same bias of 1 deg./s is added to all gyroscope measurements is shown in Figure7. As can be seen from the figure, for pitch and roll, Madgwick’s method performs almost as well as the DCM method, while Mahony’s method shows the largest error. For the yaw angle, our DCM is the only method that is able to cope with biased gyroscope measurements and to obtain reliable measurements. The reason for this is the fact that since our method can reliably estimate gyroscope biases for each sensor axis, the end result contains less integrated bias error. The start transient caused by the cold start is also visible in the figure.Figure 7
Errors in yaw, pitch, and roll as an artificial 1 deg./s bias is added to all gyroscope measurements in the rotation test.Figure 8
Root mean squared errors of yaw pitch and roll angles in the rotation test as a function of added constant bias in gyroscope measurements.Figure 9
Root mean squared errors of yaw pitch and roll angles in the acceleration test as a function of added constant bias in gyroscope measurements.To test bias tolerance, test sequences were computed using different added biases changing from zero to seven degrees per second separately for rotation and acceleration tests. For both of the test sequences (the rotation test in Figure8 and the acceleration test in Figure 9), the proposed DCM method is able to successfully find the induced bias and estimate it for pitch and roll angles. The bias around the yaw angle for the acceleration test in Figure 9 is not correctly estimated in the EKF, since the test data includes minimally rotations (only linear accelerations). The filter cannot estimate the induced bias around the z-axis due to the lack of information about the bias present in this test data (see the discussion about the observability problem in Section 2). In the rotation test (results in Figure 8), bias estimates work for all angles, and the effect of induced bias is minimal compared to all other presented algorithms. As can be noted from the figures, the proposed DCM method has the smallest error in nearly all cases where there is at least some unknown gyroscope bias present.Convergence of the bias estimate in the acceleration test is interesting, as the test is a special pathological case for bias estimate around thez-axis (corresponds to the yaw angle seen in the upper subplot in Figures 6 and 9, as there are no rotations). In this case, the yaw angle and gyroscope bias estimates around the z-axis are not observable. The behavior of the proposed filter, while estimating biases and their corresponding variances, is shown in Figure 10 when there is an induced bias of 1 deg./s in each gyroscope axis. In the figure, biases for pitch and roll converge rapidly towards the true value of 1 deg./s, whereas the bias estimate around yaw converges very slowly. This happens as the filter receives marginal information about the tiny rotations present in the data. Even in this pathological special case with the observability problem, the presented filter behaves correctly, as demonstrated by the absence of any increase in the variance of the bias estimate; that is, the filter remains stable.Figure 10
An artificial 1 deg./s bias is added to all gyroscope measurements in the acceleration test. Gyroscope bias estimators for bias aroundx and y converge rapidly towards the correct bias (reference, the black slashed line). The corresponding standard deviations estimated by the EKF are visualized in the same plots using 1-sigma distance to the reference bias.Figure 11
Gyroscope and temperature measurements as a function of time for calibration purposes. The SparkFun 6DOF Digital IMU is first cooled and then held stationary for a long period to warm up to a near steady state temperature. A linear model of bias as a function of temperature is drawn over the data.Figure 12
Accelerometer measurements as a function of temperature for calibration purposes. The SparkFun 6DOF Digital IMU is first cooled and then held stationary for a long period to warm up to near steady state temperature. A linear model of data as a function of temperature is drawn over plots.


## 4.4. Effects of Temperature to Bias

To test the sensitivity of low-cost MEMS IMUs to temperature changes, a long calibration sequence over different temperatures was performed for the SparkFun 6DOF Digital IMU. First, the device was cooled down and then held stationary for over 40 minutes. During that time, the excess heat from the electronics warmed the IMU from 15°C to 35°C. The gyroscope and temperature measurements are shown in Figure11. A linear bias model of the measured temperature is plotted over the gyroscope measurements in the figure. Similarly, stationary accelerometer readings show a linear relationship to temperature, as shown in Figure 12. These results indicate that both accelerometer and gyroscope measurements are temperature-dependent and that this relation can be modeled using a linear relationship if working around room temperatures (25
±
10°C). As can be seen, the change in gyroscope bias can be as large as 0.5 deg./s.In addition to presenting linearly temperature-dependent gyroscope and accelerometer measurements, we used our 24 parameter calibration method to calibrate our SparkFun 6DOF Digital IMU. The acquired calibration parameters are presented in Table4 using a notation presented in (17). As it can be noted, all temperature-dependent calibration parameters a are small but not negligible, which indicates the minor but existing temperature-dependent effect in the accelerometer and the gyroscope. In addition, it can be noted that bias terms are more dependent on the temperature than gain parameters.Table 4
Calibration parameters for SparkFun 6DOF Digital IMU.
Parameter
x-axis
y-axis
z-axis
a
gain
f
i
-
0.00049316
0.00040477
0.00102091
b
gain
f
i
1.06731340
1.03869310
0.98073082
a
bias
f
i
-
0.01551443
-
0.00457992
-
0.01929765
b
bias
f
i
0.99740194
0.05868846
0.48880423
a
gain
ω
i
0.00027886
-
0.00122424
-
0.00246201
b
gain
ω
i
0.99130982
1.03580126
1.08040715
a
bias
ω
i
-
0.01188330
-
0.00845710
0.00542382
b
bias
ω
i
0.24566657
0.19236960
-
0.21682853


## 5. Discussion

Experiments and Results tested our proposed algorithm with multiple different tests and compared the results to two state-of-the-art algorithms. Table5 summarizes the main results and contributions of this paper.Table 5
Summary of performed experiments and results.
The test
How it is tested?
The main results
Rotation (Section4.1)
Rotations and movement in 6D using preprogrammed path performed at different velocities.
All algorithms perform similarly well in the standard test without any bias. DCM-IMU was slightly precise compared to other algorithms.
Acceleration (Section4.2)
Linear movement separately tox, y, and z directions at different velocities.
DCM-IMU is robust against rapid nongravitational accelerations compared to state-of-the-art algorithms.
Biases with rotation (Section4.3)
Rotation test is performed with an artificially added gyroscope bias in the measurement data.
Only DCM-IMU can accurately estimate gyroscope biases independent of the amount of added bias.
Biases with linear acceleration and no rotations (Section4.3)
Acceleration test is performed with an artificially added gyroscope bias in the measurement data.
DCM-IMU can estimate gyroscope biases forx and y axes. The gyroscope bias around z-axis is unobservable in this case, but the proposed filter can handle the observability issue.
Temperature (Section4.4)
Gyroscope and accelerometer are measured as a function of temperature while it is changed.
Gyroscope bias estimates change nearly by 0.5 deg./s as the temperature is changed by 20°C. Similarly, accelerometer readings change considerably.Results of the first test (rotation test in Figure4 and Table 2) show that, in normal operation with fully calibrated data (if there are no gyroscope biases or large dynamic accelerations present), the DCM method has error statistics quite similar to those for Mahony’s method and slightly smaller errors than those obtained using Madgwick’s method. The cheaper SparkFun 6DOF IMU is noisier (larger variance) and has larger RMSE, though the maximal errors are similar to those for the data of Inertia-Link. This test shows that our proposed DCM method performs as well as the other methods in the fully calibrated case.Results of the acceleration test (in Figure6 and Table 3) show that when temporary nongravitational acceleration is applied, all methods other than our proposed DCM method induce large temporary errors to the attitude estimate, especially to the roll and pitch angles. As can be seen from the RMSE estimates in Table 3, errors caused by these accelerations do not increase the mean squared errors significantly. It should be noted that while testing for the effect of rapid accelerations, the RMSE does not fully reveal the effects caused by these short and temporary accelerations. Instead, error statistics in the box-and-whiskers plotted in Figure 6 better uncover the differences between these algorithms. As can be noted, these filters behave quite differently in the presence of dynamic accelerations. In the literature, these rare events are typically ignored as outliers. However, as the attitude estimator usually requires robust behavior in all cases, the behavior of the IMU algorithm should be tested for these large temporary accelerations as well.Our DCM method shows the most robust behavior against these temporary nongravitational accelerations as compared to the other algorithms. Madgwick’s method is highly vulnerable to these events with errors nearly one magnitude larger than the DCM method. Finally, the built-in estimate of Microstrain Inertia-Link performs much more unreliably than any of the compared methods. This test also reveals the only drawback of our proposed DCM method: the bias estimate around the yaw angle cannot be correctly estimated if there are no rotations present in the data and gravity is accurately aligned toz-axis of the sensor. Thus, in this special case (the observability problem) with fully calibrated data, the bias estimator impairs the heading angle estimation.The results of the gyroscope bias tolerance test are the most important. As low-cost MEMS gyroscopes usually introduce a temperature-related bias term into the measurements, and as angular velocities measured by the gyroscopes must be integrated to estimate the attitude, the bias error (i.e., zero level error in angular velocity measurements) causes large errors in the attitude estimate. The results of the third test (Figures7, 8, and 9) show that our proposed DCM method is able to handle even large bias errors and that as little as 1 deg./s error in the bias can lead to large errors in all the other compared methods. Mahony’s method is then more vulnerable to added bias than Madgwick’s method, which is able to cope with some bias errors around pitch and roll angles. In contrast, our DCM method can calibrate gyroscope biases online without any extra information from a compass or other sensors.The last test and related results section demonstrate an example of bias errors in a low-cost MEMS gyroscope and accelerometer. As can be noted in Figure11, the values of the gyroscope bias estimates change nearly 0.5 deg./s as the temperature is changed by 20°C within less than an hour. This reveals the importance of calibrating gyroscopes and accelerometers using a temperature-dependent calibration model, of stabilizing the temperature with a heater or cooler, or of using an online bias estimator. The calibration of MEMS sensors is crucial, difficult task, for which the calibration parameters may still change over time. Nevertheless, using a temperature-dependent calibration model and the proposed attitude estimation algorithm can enable the system to perform reliably within changing temperatures and drifting gyroscope biases.


## 6. Conclusion

In this work, we have proposed a partial attitude estimation algorithm for low-cost MEMS IMUs using a direction cosine matrix (DCM) to represent orientation. The attitude estimate is partial, as only the orientation towards the gravity vector is estimated. The sensor fusion of triaxial gyroscopes and accelerometers was accomplished using an adaptive extended Kalman filter. The filter accurately estimates gyroscope biases online, thus enabling the filter to perform effectively even if the calibration is inaccurate or some unknown slowly drifting bias exists in the gyroscope measurements. The proposed DCM IMU is made more robust against temporary contact forces by using adaptive measurement covariance in the EKF algorithm.As indicated by our test results, the proposed DCM-IMU algorithm should be used with low-cost MEMS sensors when at least one of the following is true: (a) only accelerometer and gyroscope measurements are available, (b) there exist large temporary accelerations, (c) there exist unknown or drifting gyroscope biases, or (d) measurements are collected using a variable sampling rate. However, our proposed method should not be used if constant nongravitational accelerations are present, nor would it be needed if gyroscopes are accurately calibrated and no drifting biases are present in the measurements (i.e., an error-free system). Long-term or constant nongravitational accelerations will be mixed with the estimated gravitational force, as there are no external measurements to separate them.Finally, our method is best suited for low-cost MEMS sensors with drifting biases and erroneous measurements. It also eliminates the need for commonly used magnetometers while estimating biases for gyroscope measurements. The method, however, is not designed to give an absolute heading; instead, it is best suited for measuring absolute roll and pitch angles and a minimally drifting relative yaw angle. An open source implementation of the proposed algorithm is available for MATLAB and C++ athttps://github.com/hhyyti/dcm-imu.



---

*Source: 503814-2015-11-30.xml*