Professional Documents
Culture Documents
Estimation of IMU and MARG Orientation Using A Gradient Descent Algorithm
Estimation of IMU and MARG Orientation Using A Gradient Descent Algorithm
Rehab Week Zurich, ETH Zurich Science City, Switzerland, June 29 - July 1, 2011
Abstract—This paper presents a novel orientation algorithm of significant utility in this realm. In a recent survey, Zhoua
designed to support a computationally efficient, wearable inertial [7], cited real time operation, wireless properties, correctness
human motion tracking system for rehabilitation applications. It of data, and portability as major deficiencies that must be
is applicable to inertial measurement units (IMUs) consisting of
tri-axis gyroscopes and accelerometers, and magnetic angular addressed to realize a clinically viable system.
rate and gravity (MARG) sensor arrays that also include tri-axis
magnetometers. The MARG implementation incorporates mag-
netic distortion compensation. The algorithm uses a quaternion A. Inertial Motion Tracking Systems
representation, allowing accelerometer and magnetometer data to Whilst a variety of technologies enable the measurement of
be used in an analytically derived and optimised gradient descent
algorithm to compute the direction of the gyroscope measurement
orientation, inertial based sensory systems have the advantage
error as a quaternion derivative. Performance has been evaluated of being completely self contained such that the measurement
empirically using a commercially available orientation sensor entity is constrained neither in motion nor to any specific
and reference measurements of orientation obtained using an environment or location. An IMU (Inertial Measurement Unit)
optical measurement system. Performance was also benchmarked consists of gyroscopes and accelerometers enabling the track-
against the propriety Kalman-based algorithm of orientation
sensor. Results indicate the algorithm achieves levels of accuracy
ing of rotational and translational movements. In order to
matching that of the Kalman based algorithm; < 0.8◦ static measure in three dimensions, tri-axis sensors consisting of 3
RMS error, < 1.7◦ dynamic RMS error. The implications of the mutually orthogonal sensitive axes are required. A MARG
low computational load and ability to operate at small sampling (Magnetic, Angular Rate, and Gravity) sensor is a hybrid
rates significantly reduces the hardware and power necessary IMU which incorporates a tri-axis magnetometer. An IMU
for wearable inertial movement tracking, enabling the creation
of lightweight, inexpensive systems capable of functioning for
alone can only measure an attitude relative to the direction of
extended periods of time. gravity which is sufficient for many applications [2], [1], [6].
MARG systems, also known as AHRS (Attitude and Heading
Reference Systems) are able to provide a complete measure-
I. I NTRODUCTION ment of orientation relative to the direction of gravity and the
The accurate measurement of orientation plays a critical earth’s magnetic field. An orientation estimation algorithm is
role in a range of fields including: aerospace [1], robotics [2], a fundamental component of any IMU or MARG system. It is
[3], navigation [4], [5] and human motion analysis [6], [7] required to fuse together the separate sensor data into a single,
and machine interaction [8]. In rehabilitation, motion tracking optimal estimate of orientation.
is vital enabling technology, in particular for monitoring The Kalman filter [9] has become the accepted basis for
outside clinical environs; ideally, a patient’s activities could the majority of orientation algorithms [2], [10], [11], [12]
be continuously monitored, and subsequently corrected. While and commercial inertial orientation sensors; xsens [13], micro-
extensive work has been performed for motion tracking for strain [14], VectorNav [15], Intersense [16], PNI [17] and
rehabilitation, an unobtrusive, wearable system capable of Crossbow [18] all produce systems founded on its use. The
logging data for extended periods of time has yet to be widespread use of Kalman-based solutions are a testament
realized. Existing systems often require a laptop or handheld to their accuracy and effectiveness, however, they have a
PC to be carried by the subject due to the processing, data number of disadvantages. They can be complicated to im-
storage, and power requirements of the sensory equipment. plement which is reflected by the numerous solutions seen
This is not practical outside of a laboratory environment, thus in the subject literature [2], [10], [11], [12], [19], [20], [21],
detailed data may only be obtained for short periods of time [22], [23]. The linear regression iterations, fundamental to the
for a limited range of subject’s motion. More precise data Kalman process, demand sampling rates which can far exceed
representative of a subject’s natural behaviour over extended the subject bandwidth (e.g. a sampling rate between 512 Hz
periods of time (e.g. an entire day or even a week) would be [13] and 30 kHz [14] may be necessary for human motion
capture applications where system portability is critical). The
Sebastian Madgwick is with the Department of Mechanical Engineering, state relationships describing rotational kinematics in three-
University of Bristol, e-mail: s.madgwick@bristol.ac.uk.
Ravi Vaidyanathan is with the Department of Mechanical Engineering, Uni- dimensions typically require large state vectors and an ex-
versity of Bristol, Queens Building, BS8 1TR and the Department of Sys- tended Kalman filter implementation [2], [12], [19] to linearise
tems Engineering at the US Naval Postgraduate School, Monterey, CA, USA, the problem.
93940. e-mail: r.vaidyanathan@bristol.ac.uk.
Andrew Harrison is with the Department of Mechanical Engineering, Uni- These challenges demand a large computational load for
versity of Bristol, e-mail: andrew.j.l.harrison@bristol.ac.uk. implementation of Kalman-based solutions and provide a clear
978-1-4244-9862-8/11/$26.00 ©2011 IEEE
motivation for alternative approaches. Previous approaches The orientation of the earth frame relative to the sensor
to address these issues have implemented either fuzzy pro- frame at time t, E S qω,t , can be computed by numerically
cessing [1], [3] or frequency domain filters [24] to favour integrating the quaternion derivative SE q̇ω,t as described by
accelerometer measurements of orientation at low angular equations (3) and (4), provided that initial conditions are
velocities and the integrated gyroscope measurements at high known. In these equations, S ωt is the angular rate measured
angular velocities. Such an approach is simple but may only at time t, Δt is the sampling period and SE q̂est,t−1 is the
be effective under limited operating conditions. Bachman et al previous estimate of orientation. The subscript ω indicates that
[25] and Mahony et al [26] present separate algorithms which the quaternion is calculated from angular rates.
both employ a complementary filter process. This algorithm
S 1S
structure has been shown to provide effective performance at E q̇ ω,t = q̂est,t−1 ⊗ S ωt (3)
relatively little computational expense. 2E
This paper introduces orientation estimation algorithm that
S
is applicable to both IMU and MARG systems. The algorithm E qω,t = SE q̂est,t−1 + SE q̇ ω,t Δt (4)
employs a quaternion representation of orientation (as in:
[25], [12], [19]) to describe the coupled nature of orientations B. Orientation from a homogenous field
in three-dimensions and is not subject to the problematic
In the context of an orientation estimation algorithm, it will
singularities associated with an Euler angle representation.
initially be assumed that an accelerometer will measure only
A complete derivation and empirical evaluation of the new
gravity and a magnetometer will measure only the earth’s
algorithm is presented. Its performance is benchmarked against
magnetic field. If the direction of an earth’s field is known
existing commercial filters and verified with optical tracking
in the earth frame, a measurement of the field’s direction
system.
within the sensor frame will allow an orientation of the
sensor frame relative to the earth frame to be calculated.
II. O RGANISATION OF PAPER However, for any given measurement there will not be a unique
Section III delineates the mathematical derivation of the sensor orientation solution, instead there will infinite solutions
orientation estimation algorithm, including a description of the represented by all those orientations achieved by the rotation
parameterization and compensation for magnetic distortion. the true orientation around an axis parallel with the field.
Section IV describes the experimental equipment used to test A quaternion representation requires a single solution to be
and verify the performance of the algorithm. Section V quanti- found. This may be achieved through the formulation of an
fies the experimental testing and accuracy of the algorithm and optimisation problem where an orientation of the sensor, SE q̂,
compares it to existing systems. Section VII expands briefly is found as that which aligns a predefined reference direction
gives details on implementations of the system underway of the field in the earth frame, E d, ˆ with the measured field
currently in our laboratory in human motion tracking while S
in the sensor frame, ŝ; thus solving (5) where equation (6)
Section VI summarizes conclusions and contributions of this defines the objective function.
work. Throughout the paper, a notation system of leading
superscripts and subscripts adopted from Craig [27] is used ˆ S ŝ)
min f (SE q̂, E d, (5)
S q̂∈4
to denote the relative frames of orientations and vectors. A E
S βΔt ∇f E
ĥt = 0 hx hy hz = SE q̂est,t−1 ⊗ S m̂t ⊗ SE q̂est,t−1
∗
E qest,t = −μt +(1−0) SE q̂est,t−1 + SE q̇ ω,t Δt
μt ∇f (31)
(28)
Equation (28) can be simplified to equation (29) where E
b̂t = 0 h2x + h2y 0 hz (32)
S
E q̇est,t is the estimated orientation rate defined by equation
(30). Compensating for magnetic distortions in this way ensures
that magnetic disturbances are limited to only affect the
S
E qest,t = SE q̂est,t−1 + SE q̇est,t Δt (29) estimated heading component of orientation. The approach
also eliminates the need for the reference direction of the
S ∇f earth’s magnetic field to be predefined; a potential disad-
E q̇est,t = SE q̇ ω,t − β (30) vantage of other orientation estimation algorithm [12], [19].
∇f
Fig.2 shows a block diagram representation of the complete
It can be seen from equations (29) and (30) that the algorithm implementation for a MARG sensor array, including
algorithm calculates the orientation SE qest by numerically inte- the magnetic distortion compensation.
grating the estimated rate of change of orientation SE q̇ est . The
algorithm computes SE q̇est as the rate of change of orientation
measured by the gyroscopes, SE q̇ ω , with the magnitude of E. Algorithm adjustable parameter
the gyroscope measurement error, β, removed in a direction The orientation estimation algorithm requires 1 adjustable
based on accelerometer and magnetometer measurements. parameter, β, representing the gyroscope measurement error
Fig.1 shows a block diagram representation of the complete expressed as the magnitude of a quaternion derivative. It
orientation estimation algorithm implementation for an IMU. is convenient to define β using the angular quantity ω̃max
S
⊗ S m̂t ⊗ SE q̂ ∗est,t−1 Measured and estimated angle θ
E q̂ est,t−1
100
E
ĥt Measured
50 Kalman−based algorithm
θ (degrees)
0 h2x + h2y 0 hz Proposed filter (MARG)
E 0
b̂t
S
Magnetometer m̂t −50
J Tg,b (SE q̂ est,t−1, E b̂t )f g,b (SE q̂ est,t−1, S â, E b̂t , S m̂)
Accelerometer S ât −100
42 44 46 48 50 52 54 56 58 60 62
∇f Error
∇f 5
z−1 Kalman−based algorithm
Proposed filter (MARG)
θε (degrees)
β
0
1S q S
S
Gyroscope ω t q̂ ⊗ S ωt .dt
q E q̂ est,t
2 E est,t−1
S −5
E q̇ est,t 42 44 46 48 50 52 54 56 58 60 62
z−1 time (seconds)
Fig. 3. Typical results for measured and estimated angle θ (top) and error
Fig. 2. Block diagram representation of the complete orientation estima- (bottom)
tion algorithm for an MARG implementation including magnetic distortion
compensation
TABLE I
S TATIC AND DYNAMIC RMS ERROR OF K ALMAN - BASED ALGORITHM
AND PROPOSED ALGORITHM IMU AND MARG IMPLEMENTATIONS
representing the maximum gyroscope measurement error of
each axis. Using the relationship described by equation (2), Euler parameter Kalman-based MARG IMU
algorithm algorithm algorithm
β may be defined by equation (33) where q̂ is any unit RMS[φ ] static 0.789◦ 0.581◦ 0.594◦
quaternion. RMS[φ ] dynamic 0.769◦ 0.625◦ 0.623◦
RMS[θ ] static 0.819◦ 0.502◦ 0.497◦
RMS[θ ] dynamic 0.847◦ 0.668◦ 0.668◦
1 3 RMS[ψ ] static 1.150◦ 1.073◦ N/A
β=
2 q̂ ⊗ 0 ω̃max ω̃max ω̃max
= 4 ω̃max (33) RMS[ψ ] dynamic 1.344◦ 1.110◦ N/A
0
1.5 1.5
β = 0.033 β = 0.041 3 2.8 2.6 2.4 2.2 2 1.8 1.6
foot x−axis 1.4 1.2 −0.2
1 0.8 0
0.6 0.4 0.2
foot y−axis 0.2 0
1 1
foot z−axis
0.5 0.5
Fig. 6. Recovered foot position plotted at 20 samples per second
0 0.2 0.4 0 0.2 0.4
β β
Fig. 4. The effect of the adjustable parameter, β, on the performance of the load relative to a Gauss-Newton method [25]; quantified
proposed algorithm IMU (left) and MARG (right) implementations as 109 and 248 scalar arithmetic operations per update
Sampling rate vs. filter performance (IMU) Sampling rate vs. filter performance (MARG)
for C code implementations of the IMU and MARG
mean[ RMS[φε], RMS[θε], RMS[ψε] ] (degrees)
30 30 implementations respectively.
mean[ RMS[φε], RMS[θε] ] (degrees)