Cavallo 2014
Cavallo 2014
Cavallo 2014
Keywords: Sensor fusion, Extended Kalman Filter, Advanced Robotics, Attitude estimation
7586
19th IFAC World Congress
Cape Town, South Africa. August 24-29, 2014
k
1.2
f
kŷs k, kỹ s
f
the PCB or other magnetically soft materials.
kŷs k, kỹs
1.1
1.1
1 1
0.9
0.9
0.7
0.8
0.6
7587
19th IFAC World Congress
Cape Town, South Africa. August 24-29, 2014
Given two frames Σd and Σc , the quaternion expressing r 1 = 1/ (I − r 3 r T3 )e1 (I − r 3 rT3 )e1 (14)
the orientation of Σd with respect to Σc is denoted by
T h iT r 2 = S(r1 )r 3 . (15)
T
Qd,c = q1d,c q2d,c q3d,c q4d,c = η d,c ǫd,c
, (7) Hence, the constant magnetic field in the base frame
b b
is computed as h̄ = R̄v hv (0) and the measurement
where η d,c = q1d,c is the scalar part and ǫd,c =
equation of the magnetometer is
[q2d,c q3d,c q4d,c ]T is the vector part. Note that a quaternion
0
is here represented as a 4 × 1 vector and two operators can 0 −1 0
= Q ∗ ∗ Q + , (16)
be applied to two quaternions, i.e. the standard matrix hv v,b
h̄
b v,b nm
product and the quaternion product defined as where nm is the measurement noise affecting magnetic
T
η d,c η e,f − ǫd,c ǫd,c
field measurements, assumed normally distributed.
Qd,c ∗ Qe,f = d,c e,f , (8)
η ǫ + η e,f ǫd,c + S(ǫd,c )ǫe,f Gyroscope. The gyroscope provides measurements of the
where S(·) is the 3 × 3 skew-symmetric operator of the angular velocity, which is related to the time derivative of
vector product. the quaternion through the equation
1 0 −ω vT
In order to simplify the notation, the orientation of Σv Q̇ = Q , E(ωv )Q. (17)
with respect to Σb will be expressed by omitting the frame 2 ωv −S(ω v )
superscripts, i.e., In order to take into account that the angular velocity is
T
Qv,b = [q1 q2 q3 q4 ] , Q, (9) affected by an additive measurement noise nω (assumed
normally distributed), it will be included both among the
which is the quantity to estimate. In order to setup the
measured variables and the variables to be estimated. For
EKF, the measurement equations are considered first.
implementation purposes, Eq. (17) can be written as a
Accelerometer. Under the following assumptions function of the discrete time k as
Qk+1 = Qk + Ts E(ω vk )Qk , (18)
• Σb has the z-axis perfectly vertical
where Ts is the sampling time.
• The vehicle is subject to low translational accelera-
tions and thus the accelerometer measures only the Now, the equations of the estimation filter are presented.
gravity acceleration vector
• The accelerometer is calibrated as in Section 3.1 such The estimation filter. Let us define the augmented state
T T
that av av = 1 and thus ab = [0 0 −1] as
x Qk
where av is the measured acceleration expressed in the xk = 1k = . (19)
x2k ω vk
body-fixed frame and ab is the same acceleration expressed
Assuming the classical constant velocity model, the state
in the base frame, the measurement equation of the
update equation is
accelerometer can be obtained by using the standard
quaternion formula to change the reference frame of a x + Ts E(x2k )x1k
xk+1 = f (xk ) + wk , 1k + wk (20)
vector as x2k
0 −1 0 0 where wk is the process noise which is assumed unbiased,
= Qv,b ∗ b ∗ Qv,b + (10)
av a na uncorrelated with the state and with a covariance matrix
where na is the measurement noise affecting acceleration W with finite norm. In order to setup the EKF, the
measurements, assumed normally distributed. measurement equation is defined as
" v#
ωk x2k
" #
Magnetometer. Under the following assumptions y k = avk + v k = g(xk ) + v k , av (x1k ) + v k (21)
hvk hv (x1k )
• The magnetometer is calibrated as in Section 3.1 such
T where av (x1k ) is expressed as in (10), hv (x1k ) is expressed
that hv hv = 1 as in (16) and v k = [nTω nTa nTm ]T is the measurement
b
• h is constant and is computed as the average value noise, which is assumed normally distributed and with
b
h̄ measured at the beginning of any experiment positive definite covariance matrix V .
Since the initial orientation (at the time instant t = 0) The EKF equations are set in the classical 3-steps form as
of Σv with respect to Σb is unknown, but the base frame
has been chosen with a vertical z-axis, a rotation matrix • prediction step
b b
R̄v = Rbv (0) has to be computed to obtain h̄ from the x̂k+1|k = f (x̂k|k ), x̂0|0 = xi (22)
v
measurement h (0) expressed in frame Σv , i.e.,
b
P̂ k+1|k = F k P̂ k|k F Tk + W, P̂ 0|0 = W (23)
T
R̄v av (0) = [0 0 −1] (11) ∂f
v
where a (0) is the measured (averaged) acceleration in being Fk = (24)
∂x x̂k|k
t = 0. Denoting with
v
R̄b = [r1 r2 r3 ] , (12) • Kalman gain computation step
−1
from (11) it results K k+1 = P̂ k+1|k GT
k+1 G k+1 P̂ k+1|k G T
k+1 + V (25)
r 3 = −av (0), (13)
∂g
while r1 and r2 can be easily computed to complete a being Gk = (26)
∂x x̂k+1|k
right-handed frame as
7588
19th IFAC World Congress
Cape Town, South Africa. August 24-29, 2014
• update step 15
EKF error
15
EKF error
Roll Roll
10 Pitch 10 Pitch
x̂k+1|k+1 = x̂k+1|k + K k+1 y k − g(x̂k+1|k ) (27) Yaw Yaw
Error [degrees]
Error [degrees]
5 5
−5 −5
where xi is the initial state which is chosen with zero
−10 −10
angular velocity and orientation aligned with the base
−15 −15
frame, I is the 7×7 identity matrix, x̂k+1|k and P̂ k+1|k de- 0 10 20
Time [s]
30 40 0 5 10
Time [s]
15 20
note the expected value and covariance matrix estimates, Madgwick error Madgwick error
respectively, at time step k + 1 given the observations up 15
Roll
15
Pitch
to time step k. 10
Yaw
10
Error [degrees]
Error [degrees]
5 5
0 0
4.2 Madgwick Algorithm
−5 −5
Roll
−10 −10 Pitch
It is applicable to IMU’s consisting of tri-axis gyroscopes −15 −15
Yaw
(MARG) sensor arrays that also include tri-axis magne- Mahony error Mahony error
tometers. The algorithm incorporates magnetic distortion 15 15
Roll
Pitch
compensation and it uses a quaternion representation, 10 10
Yaw
Error [degrees]
Error [degrees]
allowing accelerometer and magnetometer data to be used 5 5
4.3 Non-Linear Complementary Filter Fig. 3. Orientation error: slow trajectory (left) and fast
trajectory (right).
Mahony et al. (2008) propose the orientation estimation
problem as a deterministic observation problem posed di- time derivative of the quaternion, which is exact except
rectly on the special orthogonal group SO(3). Thought the for the numerical integration error.
definition of a Direct Complementary Filter and a Passive The sole adjustable parameter of the algorithm recalled in
Complementary Filter they arrive to a reformulation of Section 4.2 has been chosen as the optimal value proposed
the complementary filter, named Explicit Complementary by Madgwick et al. (2011) for the MARG implementation,
Filter, in terms of direct vectorial measurements, such as i.e., β = 0.041. The gain parameters of the algorithm re-
gravitational or magnetic field directions obtained from called in Section 4.3 and implemented using the quaternion
an IMU. This observer does not require online algebraic representation, have been chosen as proposed by Mahony
reconstruction of attitude and is ideally suited for imple- et al. (2008), i.e., KP = 2 and KI = 0.6, which have been
mentation on embedded hardware platforms owing to its verified to be optimal also in this case.
low complexity. However, it suffers from possible disconti-
nuities in the bias correction signal when the equivalent The three algorithms have been implemented in Mat-
rotation angle of the estimated quaternion approaches lab/Simulink with a sampling time Ts = 2 ms, since the
±π rad that could result in systematic errors in the re- sensor data have been acquired from IMU at sampling
constructed attitude. frequency of 500 Hz, which is the frequency experimen-
tally found to guarantee the most reliable communica-
5. EXPERIMENTAL RESULTS tion. To compare the three AHRS algorithms, two robot
trajectories are considered. In the first (slow) trajectory,
an average speed of 18 deg/s is applied to robot joints,
The parameters of each of the three algorithms to be
while, in the second (fast) trajectory, the average speed
compared have been set as follows. For the EKF, the
is raised to 45 deg/s. The ground truth is computed using
measurement covariance matrix V has been estimated by
the direct kinematics of the robot and, thus, computing
a simple static acquisition of the sensor signals and the
the end-effector frame orientation (aligned to the body-
resulting values are
fixed frame) in terms of the unit quaternion Qv,r , being Σr
V = diag{2.9 · 10−5 , 2.3 · 10−5 , 3.2 · 10−5 , 3.1 · 10−5 , the robot base frame. Thus, the estimated orientation of
, the body-fixed frame resulting from the AHRS algorithms
4.5 · 10−5 , 5.5 · 10−5 , 2.0 · 10−3 , 2.1 · 10−3 , 2.0 · 10−3 }
while the entries of the process covariance matrix have Q̂v,b , is compared with the ground truth Qv,b (computed
been tuned so as to obtain a satisfactory response time as Qv,b (0) ∗ Qr,v (0) ∗ Qv,r (t)) and the orientation error
−1
and a good noise rejection, as well as to guarantee filter is calculated as the quaternion Q̃(t) = Q̂v,b (t) ∗ Qv,b (t).
convergence according to the result by Natale (2011), i.e., This orientation error is then expressed in terms of Euler
W = diag{10−10 , 10−10 , 10−10 , 10−10 , 10−3 , 10−3 , 10−3 }. angles in Roll-Pitch-Yaw representation and it is reported
in Fig. 3.
Note how the first four entries are significantly lower than
the others since the first four state update equations in (20) To better appreciate the response time and noise rejec-
are the kinematic relation between angular velocity and tion of the three algorithms, Fig. 4 shows the quaternion
7589
19th IFAC World Congress
Cape Town, South Africa. August 24-29, 2014
1.5 1.5 1 x x
1 y
y
z
Quaternion components
Quaternion components
z
0.5 0.5 0
q1−Ground truth q −Ground truth 0
1
q −EKF q −EKF
1 1
0 q1−Madgwick 0 q −Madgwick −0.5 −0.5
1
q −Mahony q −Mahony
1 1
−0.5 −0.5 −1 −1
0 10 20 30 40 0 5 10 15 20
Time [s] Time [s] 0 5 10 15 20 25 30 35 40 0 5 10 15 20 25 30 35 40
Time [s] Time [s]
0.2 0.2
Quaternion components
0 0
disturbance (right).
−0.2 −0.2
Error [degrees]
−0.8 −0.8 5
0 10 20 30 40 0 5 10 15 20
Time [s] Time [s]
0
0.2 0.2
−5
Quaternion components
Quaternion components
0 0 −10
Error [degrees]
5
0.8 0.8 0
q −Ground truth q4−Ground truth
4
q −EKF
Quaternion components
Quaternion components
0.2 0.2
−15
0 10 20 30 40
Time [s]
0 0
Mahony error
−0.2 −0.2
15
0 10 20 30 40 0 5 10 15 20
Time [s] Time [s] 10
Error [degrees]
5
Fig. 4. Estimated and true attitude: slow trajectory (left) 0
and fast trajectory (right).
−5
Roll
Euler angles [◦ ] EKF Madgwick Mahony −10 Pitch
Yaw
Roll (static) 0.04 0.03 0.02 −15
0 10 20 30 40
Pitch (static) 0.01 0.05 0.05 Time [s]
Yaw (static) 0.30 1.92 1.85
Roll (slow) 4.71 4.85 5.07 Fig. 6. Orientation error: slow trajectory in the noisy case.
Pitch (slow) 1.91 2.65 2.89
Yaw (slow) 5.19 5.13 5.67 Euler angles [◦ ] EKF Madgwick Mahony
Roll (fast) 6.55 6.51 6.69 Roll 5.05 5.54 5.87
Pitch (fast) 2.83 3.34 2.85 Pitch 3.24 3.93 4.53
Yaw (fast) 6.71 7.07 6.92 Yaw 5.93 6.27 6.66
Table 1. Static and dynamic RMSE Table 2. Dynamic RMSE with noisy measure-
ments.
components of the estimated orientation for both trajec-
tories compared to the ground truth. To quantify the Fig. 5 reports the measured magnetic field in absence
algorithms performance, the static and dynamic RMSE and presence of the disturbance showing the high noise
(root-mean-square-error) still in terms of Euler angles have level. Executing the slow trajectory in such condition, the
been computed and reported in Tab. 1. The results of algorithms exhibit a degradation of the performance as it
the experiments show that in the slow trajectory, the can be appreciated in Fig. 6 and from the RMSE figures
three algorithms provide comparable results in terms of reported in Tab. 2.
accuracy. In terms of RMSE, the proposed EKF algorithm
As a further analysis, a comparison on the computational
provides a more accurate estimation in both static and
burden of the considered algorithms has been carried out.
dynamic conditions.
In particular, the algorithms have been implemented in
To test the capability of the algorithms to work under se- Matlab/Simulink environment on an Intel I7 quad-core
vere disturbance conditions a specific experiment has been processor at 1.6 GHz. The tic-toc Matlab functions have
carried out by intentionally actuating the robot gripper been used to estimate the execution time of a single cycle
with a periodic signal so as to generate an electromag- that includes the gyroscope, accelerometer and magne-
netic disturbance which mainly affects the magnetometer. tometer measurement and the attitude estimation. The
7590
19th IFAC World Congress
Cape Town, South Africa. August 24-29, 2014
Algorithm Matlab/Simulink [ms] Embedded System [ms] Gietzelt, M., Wolf, K.H., Marschollek, M., and Haux, R.
EKF 0.1 2.7 (2013). Performance comparison of accelerometer cal-
Madgwick 0.017 0.15 ibration algorithms based on 3d-ellipsoid fitting meth-
Mahony 0.014 0.11 ods. Computer Methods and Programs in Biomedicine,
Table 3. Computational burden estimation 3, 62–71.
Jingang, Y., Junjie, Z., Dezhen, S., and Jayasuriya, S.
superior performance of the EKF can be attributed to (2007). Imu-based localization and slip estimation for
the availability of a tunable parameter for each sensor skid-steered mobile robots. In IEEE/RSJ Int. Conf. on
measurement, which is paid in terms of a higher execu- Intelligent Robots and Systems (IROS), 2845–2850.
tion time. Finally, to validate the proposed results, the Joong-hee, H., Kwon, J., Impyeong, L., and Kyoungah,
algorithms have been coded for implementation on the C. (2011). Position and attitude determination for uav-
STM32F3Discovery evaluation board using Chibi/OS as based gps, imu and at without gcps. In Int. Workshop
real-time embedded operating system. To this aim, the on Multi-Platform/Multi-Sensor Remote Sensing and
ARM Cortex Microcontroller Software Interface Standard Mapping (M2RSM), 1–5.
(CMSIS) DSP library is used to implement the mathe- Kim, H.S., Choi, H.S., su Yoon, J., and Ro, P. (2011).
matical operations, i.e., matrix product and inverse. Ta- Study on ahrs sensor for unmanned underwater vehicle.
ble 3 reports the average time required to compute one Int. J. of Ocean System Engineering, 1, 165–170.
estimation cycle in both Matlab/Simulink environment Madgwick, S., Harrison, A., and Vaidyanathan, R. (2011).
and embedded system implementation. Even though the Estimation of imu and marg orientation using a gradient
execution times of the two fastest algorithms would allow descent algorithm. In IEEE Int. Conf. on Rehabilitation
to use a lower sampling time, this would lead to a negli- Robotics (ICORR), 1–7.
gible improvement due to the limited update rate of the Mahony, R., Hamel, T., and Pflimlin, J.M. (2008). Non-
magnetometer and gyroscope sensors. linear complementary filters on the special orthogonal
group. IEEE Trans. on Automatic Control, 53, 1203–
6. CONCLUSION 1218.
Marins, J., Yun, X., Bachmann, E., McGhee, R., and Zyda,
An experimental comparison of popular IMU-based al- M. (2001). Extended kalman filter for quaternion-based
gorithms for orientation estimation of a rigid body with orientation estimation using marg sensors. In Proc. of
respect to a reference frame is presented in this work. the 2001 IEEE/RSJ Int. Conf. on Intelligent Robots and
In particular, two specifically designed solutions are com- Systems, 2003–2011.
pared to a standard EKF algorithm, which outperforms Natale, C. (2011). Kinematic control of robots with noisy
the others, as experimentally demonstrated, at the expense guidance system. In Proc. of the 18th IFAC World
of a higher computational burden. However, its generality Congress, 6937–6944.
allows the user to add further sensory information without Pedley, M. (2013). High precision calibration of a three-
the need to completely re-design the estimation filter or to axis accelerometer - an4399. Technical report, Freescale
re-tune the parameters of the algorithm, which are simply Semiconductor.
based on the statistics of the noise affecting each measured Prayudi, I. and Doik, K. (2012). Design and implemen-
signal. tation of imu-based human arm motion capture system.
In Int. Conf. on Mechatronics and Automation (ICMA),
REFERENCES 670–675.
Sabatini, A. (2006). Quaternion-based extended kalman
Bennett, C., Odom, C., and Ben-Asher, M. (2013). Knee filter for determining orientation by inertial and mag-
angle estimation based on imu data and artificial neural netic sensing. IEEE Trans. on Biomedical Engineering,
networks. In Biomedical Engineering Conf. (SBEC), 53, 1346–1356.
111–112. Xia, L., Wang, J., and Liu, Y. (2008). Quadratic ekf
Bischoff, R., Huggenberger, U., and Prassler, E. (2011). algorithm enhancements for low cost tightly-coupled
Kuka youbot - a mobile manipulator for research and ahrs/gps. In 2nd Int. Symposium on Systems and
education. In IEEE Int. Conf. on Robotics and Au- Control in Aerospace and Astronautics, 1–6.
tomation (ICRA), 1–4. Zecca, M., Saito, K., Sessa, S., Bartolomeo, L., Lin, Z.,
Camps, F., Harasse, S., and Monin, A. (2009). Numerical Cosentino, S., Ishii, H., Ikai, T., and Takanishi, A.
calibration for 3-axis accelerometers and magnetome- (2013). Use of an ultra-miniaturized imu-based motion
ters. In IEEE Int. Conf. on Electro/Information Tech- capture system for objective evaluation and assessment
nology, 217–221. of walking skills. In 35th Annual Int. Conf. of the IEEE
Chen, S., Ding, C., Han, Y., Fang, Y., and Chen, Y. (2012). Engineering in Medicine and Biology Society (EMBC),
Study on information fusion algorithm for the miniature 4883–4886.
ahrs. In 4th Int. Conf. on Intelligent Human-Machine Ziegler, J., Kretzschmar, H., Stachniss, C., Grisetti, G.,
Systems and Cybernetics, 114–117. and Burgard, W. (2011). Accurate human motion
Crassidis, J.L., Markley, F.L., and Cheng, Y. (2007). A capture in large areas by combining imu- and laser-based
survey of nonlinear attitude estimation methods. J. of people tracking. In IEEE/RSJ Int. Conf. on Intelligent
Guidance, Control, and Dynamics, 30, 12–28. Robots and Systems (IROS), 86–91.
Falco, P., Maria, G.D., Natale, C., and Pirozzi, S. (2012).
Data fusion based on optical technology for observation
of human manipulation. Int. J. of Optomechatronics, 6,
37–70.
7591