# Estimating Three-Dimensional Orientation of Human Body Parts by Inertial/Magnetic Sensing

## Abstract

**:**User-worn sensing units composed of inertial and magnetic sensors are becoming increasingly popular in various domains, including biomedical engineering, robotics, virtual reality, where they can also be applied for real-time tracking of the orientation of human body parts in the three-dimensional (3D) space. Although they are a promising choice as wearable sensors under many respects, the inertial and magnetic sensors currently in use offer measuring performance that are critical in order to achieve and maintain accurate 3D-orientation estimates, anytime and anywhere. This paper reviews the main sensor fusion and filtering techniques proposed for accurate inertial/magnetic orientation tracking of human body parts; it also gives useful recipes for their actual implementation.

## 1. Introduction

The problem of accurate tracking of the orientation (attitude) of rigid objects is important in several domains, among them navigation of man-made vehicles, e.g., air and spacecrafts, robotics and, of interest in this paper, ambulatory human movement analysis, which may include a range of interesting applications, from monitoring of activities of daily living (ADL) to virtual/augmented reality (VR/AR). Several technologies and approaches are available to produce motion tracking systems (trackers), which derive orientation estimates from electrical measurements of acoustic, inertial, magnetic, mechanical, optical and radio frequency sensors [1]. One increasingly popular approach is based on using inertial and magnetic sensors.

Several factors explain the popularity of inertial/magnetic sensing. Most current sensing approaches for motion tracking need the availability of external sources, e.g., cameras for optical trackers, ultrasonic/electromagnetic transmitters for acoustic/electromagnetic trackers. Usually, the sources can operate only over relatively short distances, which makes the trackers highly susceptible to interference and line-of-sight occlusion (shadowing): hence, proper functioning of these trackers is only possible within carefully controlled experimental setups (motion analysis laboratories). This fact precludes, for instance, the quantitative assessment of the behaviour of a human subject in unrestrained conditions. Conversely, inertial sensors are completely self-contained (sourceless), since they measure physical quantities, such as linear acceleration and angular velocity, which are related to the motion of the objects where the sensors are fixed; moreover, although magnetic sensing is externally referenced, the ubiquitous presence of a magnetic field on earth makes the magnetic source available almost everywhere. Recent technological advances in the field of micro-electro-mechanical systems (MEMS) have made it possible to manufacture inertial sensors that are relatively low cost, highly miniaturized and with limited power consumption. Inertial/magnetic sensors can therefore be considered the most valuable opportunity to monitor the ADLs of a human subject outside specialized laboratories, and over possibly extended periods of time. However, the measuring accuracies of MEMS inertial sensors are still largely inferior to those of the sensors used, e.g., in inertial navigation systems (INSs) for aeronautical and military applications [2]. Hence, it becomes of the utmost importance concentrating on the development of efficient filtering algorithms for applications of these sensors, together with modern solid-state magnetic sensors, in human body motion capture.

Accurate estimates of the three-dimensional (3D) orientation of a rigid body by inertial/magnetic sensing require that the complementary properties of gyros, accelerometers and magnetic sensors are purposefully exploited [3]. The orientation can be computed by time-integrating, from known initial conditions, the signals from a triad of mutually orthogonal uni-axial gyros (tri-axial gyro), which is prone to errors that grow unbounded over time, due to low-frequency gyro bias drifts; on the other hand, gyros help achieving accurate orientation estimates for highly dynamic motions. A tri-axial accelerometer is capable of providing drift-free inclination estimates by sensing the gravity vector. It can be used alone or, when heading estimation is also needed, together with a tri-axial magnetic sensor, giving rise to a sensing unit that is referred to in the following as a gyro-free aiding sensor system. Serious limitations affect the operation of a gyro-free aiding sensor system. First, the difficulty of correctly interpreting the acceleration signals, when the component due to the gravity field (vertical reference) coexists with the component related to the motion of the object. Hence, the vertical reference is reliable only for static or slowly moving objects [4]. Second, nearby ferromagnetic materials are critically disturbing sources when attempts are made to interpret the signals from a tri-axial magnetic sensor as the horizontal reference; this problem becomes especially acute within man-made indoor environments [5,6]. Sensor fusion techniques are needed in order that the gyro-free aiding sensor system allows bounding the gyro bias drift errors; in turn, the gyros can be used to smooth the orientation estimates provided by the gyro-free aiding sensor system. Ideally, the filtering algorithm would be also capable of estimating gyro biases, as well as biases in the sensors of the gyro-free aiding sensor system.

The main purpose of this paper is to review important methods for the design of these filtering algorithms. Section 2 surveys main sensing approaches proposed by researchers active in biomedical engineering, biomechanics and related fields. Section 3 provides the reader with background information about mathematical methods for representing the orientation; the kinematic equations of a rigid body and simple numerical methods for their solution are also briefly discussed. Section 4 reviews the main deterministic and stochastic algorithms for estimating the orientation, with particular emphasis on vector matching, linear Kalman Filters (KFs) and the their extended (EKF) version, suited for nonlinear models; KFs and EKFs are presented here as special cases of Bayesian filters. Section 5 discusses the modelling issues behind the implementation of a state-of-the-art EKF, and presents a worked-out example related to a head motion tracking trial. The paper concludes with Section 6.

## 2. Sensing Approaches

A number of pioneering contributions in the 60–70s suggested reconstructing the field of motion of a rigid body, in terms of both position and orientation (pose), by sampling acceleration values in several suitably selected points of it. The rotation of a rigid body with one point fixed requires a minimum of three acceleration measurements; at least, three additional acceleration measurements are needed to resolve the motion of the fixed point in the 3D-space [7]. Sensor systems composed of several accelerometers, suitably arranged in uni-axial, bi-axial, tri-axial clusters, were proposed in [8], for applications mainly in the field of impact biomechanics. It was proven that, in the presence of small experimental errors, numerical drifts in the pose estimation make systems with six accelerometers inherently unstable; even systems with nine accelerometers exhibit critical performance degradation. The six-nine sensor configurations were analyzed in depth in [9], to conclude that severe restrictions exist in the time duration over which motion tracking is feasible by accelerometry methods in routine biomechanical applications. The problem with these configurations is that the angular velocity has to be estimated by time-integrating noisy measured angular accelerations, which restricts the time horizon for accurate motion tracking. More redundancy is necessary to achieve stability and tolerance to positioning/alignment errors of the accelerometers, provided that suitable calibration procedures are also implemented. Since angular velocity is not determined by time-integration anymore, kinematically redundant systems with twelve accelerometers are reported to yield promising results [10].

During the 80–90s, the use of accelerometers in biomechanics was promoted mainly in the clinical assessment of gait: under the simplifying assumption of a gait motion planar model, a minimal configuration set composed of two leg-mounted single-axis accelerometers with parallel sensitive axes would suffice to determine the angular acceleration of the leg. In the attempt to circumvent the problem of numerical integration drift, pairs of accelerometers on each segment were used to resolve the relative angle between two segments, namely the joint angle, without time-integration [11]. These accelerometer-based angle sensors were discussed in [12], where the most important error sources were analyzed in detail, namely not fulfilling the gait motion planar model and the rigid-body condition by external fixation of body-mounted sensors. The potential of accelerometers as sensors that are capable of measuring the inclination of human body parts in gait analysis has been emphasized in later research, e.g., [13]. Very interesting is the work in [14], where the authors used one tri-axial accelerometer to measure inclination during dynamic tasks without requiring additional sensors. A KF-based algorithm was designed to estimate the different acceleration components, namely gravity and inertial acceleration, plus the accelerometer bias, using a simple model of the human motion dynamics. Since the procedure of bias compensation in the KF-algorithm works only in the direction of gravity, the bias estimate in all measurement directions turns out to be reasonably accurate only when the accelerometer is rotated over large angles. In any case, the method was shown to outperform the method based on low-pass filtering the accelerometer signals [4,15], especially as the speed of motion increased.

Toward the end of the 90s and in the early years of this century, the emergence on the consumer market of miniaturized MEMS gyros, with good metrological specifications and low cost, opened a new way to think about the role of inertial sensing in human body motion tracking and analysis [15,16]. At the time when solid-state magnetic sensors also found their way on the consumer market [17], miniaturized, fully integrated inertial/magnetic measurement units (IMMUs) became finally available for use in strap-down INSs. In a strap-down INS the signals produced by the inertial/magnetic sensors are resolved mathematically in a computer, prior to the calculation of navigational information [18]. Using a computer to resolve the inertial/magnetic data reduces the mechanical complexity of an INS, as it is implemented in the classical applications of inertial navigation technology, i.e., stable platform technique, thus decreasing the cost and size of the system and consequently increasing its reliability. The processing speeds of modern computers and microcomputers and their low-cost allow conceiving efficient implementations of wearable strap-down INSs for human body motion capture.

However, it is critical to achieve high accuracy in pose determination by strap-down INSs that incorporate low-cost inertial/magnetic sensors, since their stand-alone accuracy and run-to-run stability are poor. Different applications may involve different accuracy requirements relative to the duration of each observation run: in the absence of special precautions, the requirements of human motion tracking applications are shown to be violated when the duration of the observation run exceeds just several seconds [3]. Nonetheless, during the late 90s inertial tracking with automatic drift correction proved to be a highly successful technique for challenging applications in VR/AR, offering low jitter, fast response, increased range, and greatly reduced problems due to interference and shadowing [19]. InterSense Inc., Billerica, MA, USA pioneered the commercial development of trackers based on miniature MEMS inertial sensors. At the time being, few other companies are marketing IMMUs, among them: Xsens Technologies B.V. (Enschede, The Netherlands); and MicroStrain Inc. (Williston, VT, USA). Several research groups are now active in exploiting them for biomechanical applications, with concentration on the design of filtering algorithms, e.g., [20–25].

Besides being important per se, estimating the orientation is fundamental in the strap-down approach to position estimation: in fact, the orientation solution allows the gravity to be cancelled from the acceleration signals, in order that the inertial acceleration is double-integrated for position estimation (gravity compensation) [3]. If the gravity compensation is not carried out properly, the orientation errors add to the positioning errors, to yield a devastating growth of positioning errors that are proportional to the cube of the system’s operation time [26]. There appear to be different means to deal with these problems, e.g., using externally referenced aids, such as Global Positioning System (GPS), and carry out the integration process underlying the combined use of GPS and INS technologies using KF techniques, e.g., [27,28]. Another approach is to exploit idiosyncrasies of the human motion dynamics by designing algorithms that can keep the drift rate low [29]. The problem of position determination is not addressed in this paper.

## 3. Representation and Determination of Orientation: Mathematical Review

#### 3.1. Representation of Orientation

For motion on or near the earth surface, at speeds far below orbital velocity, it is convenient to describe the orientation of a rigid body using two coordinate systems: the earth-fixed coordinate system, specified by the right-handed orthonormal basis E = {**e**_{1} **e**_{2} **e**_{3}}, whose coordinate axes are directed in the local north, east and down directions (NED)—for all practical purposes, an inertial coordinate system; the non-inertial coordinate system, aka body-fixed coordinate system, specified by the right-handed orthonormal basis
$\mathrm{B}=\left\{{\mathbf{e}}_{1}^{\prime}\mathrm{\hspace{0.17em}\u200a\u200a}{\mathbf{e}}_{2}^{\prime}\mathrm{\hspace{0.17em}\u200a\u200a}{\mathbf{e}}_{3}^{\prime}\right\}$, whose coordinate axes are conventionally named “out the nose”, “out the right side” and “out the belly” in the aeronautics jargon (Figure 1).

We recall that an orthonormal basis T = {**i j k**} is said to be right-handed if it satisfies:

An arbitrary vector **x** in the 3D space can be written in the equivalent forms:

The vector **x** can therefore be represented in terms of the coordinates (or components) with respect to either basis:

The subscripts E, B indicate which basis is used for representing the vector **x**. The representations in (3) are related to one another as follows:

The columns of the direction cosine matrix (DCM)
${}_{\mathrm{E}}^{\mathrm{B}}\mathbf{C}$ are the representations of the **e**_{i}, i = 1,…,3 with respect to B, while its rows are the representations of the
${\mathbf{e}}_{i}^{\prime}$, i = 1,…,3 with respect to E. The DCM, also called orientation (attitude) matrix, and its transpose allow therefore moving vector representations from (to) the earth-fixed frame to (from) the body-fixed frame, respectively. The orientation matrix is a 3 × 3 orthogonal matrix with unit determinant, which belongs to the three-dimensional special orthogonal group SO(3) of rotation matrices. Although the orientation matrix is the fundamental representation of the orientation, the orthogonality requirement forces six constraints on its nine elements, namely the column (row) vectors have unit norm and are mutually orthogonal, yielding that the special orthogonal group SO(3) of rotation matrices has dimension three.

Lower-dimensional parameterizations of orientation can be derived based on the following considerations [30]. As shown in Figure 2, a rotation about the **e**_{3}-axis through an angle θ is expressed as:

The resulting rotation matrix is:

_{θ}and s

_{θ}are compact notation for cosθ and sinθ, respectively. By analogy with (6), the rotation matrices that describe rotations about the

**e**

_{2}-axis and the

**e**

_{1}-axis through an angle θ are:

We note that:

For the vector cross product, an equivalent expression is:

**u**×] is the skew-symmetric matrix:

Be **n** any unit column vector, and be **v**_{⊥} the projection of a column vector **v** onto the plane perpendicular to **n** (Figure 3). By analogy with (8) we can write:

For arbitrary vectors **a**, **b** and **c** the Grassman identity yields:

The symbol □ denotes the standard vector dot product. Equation (12) allows deriving the general decomposition of **v** into components that are parallel (**v**_{P}) and perpendicular (**v**_{⊥}) to **n**:

In conclusion:

It follows that two equivalent expressions of the rotation matrix are written (Euler’s formula):

**I**

_{n}denotes the n × n identity matrix.

Euler’s theorem states that the most general motion of a rigid body with one point fixed is a rotation by an angle θ (rotation angle) about some axis **n** (rotation axis), yielding another representation of the orientation in terms of the rotation vector:

All rotations can thus be mapped to points inside and on the surface of a sphere of radius π in rotation vector space (θ ∈]−π, π]). Since points at opposite ends of any diameter of the sphere represent the same orientation, the parameterization of orientation through the rotation vector is redundant, with four parameters and one constraint enforced on its norm. Moreover, no points of singularity exist in the rotation vector space.

The orientation of the body-fixed frame relative to the earth-fixed frame can also be described using the Euler angle formulation, namely in terms of three consecutive rotations through three body-referenced Euler angles [31]. Although, in principle, twelve possible ways exist to define three independent body-referenced Euler angles, just a subset of them have received attention; we discuss here the 3-2-1 rotation sequence, which is the one commonly adopted in the aeronautics community. The orientation of the body-fixed frame (nose-wing-belly) relative to the earth-fixed frame (NED) is described by performing the three rotations as follows. Start with a body-fixed frame in the reference orientation, i.e., one in which all of its body-fixed axes are aligned with the corresponding earth axes; first, the body is rotated about the belly axis through an angle ψ usually called heading angle, or yaw (ψ ∈ ]−π, π]); second, the object is rotated about the wing axis through an angle ϑ (elevation angle, or pitch attitude) (ϑ ∈]−π/2, π/2]); third, the object is rotated about the nose axis through an angle φ (bank angle, or roll attitude), so as to match the body-fixed frame (φ ∈]−π, π]). We can then write:

The rotation matrix as a function of the three Euler angles is given by:

The gravity vector is therefore represented in the body-fixed coordinate system as follows:

Equation (19) shows that a body-fixed tri-axial accelerometer does not convey heading information.

The time rates of change of the Euler angles are related to the components of the angular velocity **ω**_{B} = [p q r]^{T} resolved in the body-fixed frame by the following system of first-order nonlinear differential equations [31]:

Equation (20) can be used to update the orientation of the rigid body in time given the angular velocity. As for all unconstrained representations of orientation, Euler angles suffer from singularities, commonly referred to as gimbal-lock: for instance, in the case of the 3-2-1 rotation sequence, if the pitch angle ϑ is ± π/2, the last two terms of the first and last rows in (20) go to infinite and the Euler angle integration becomes indeterminate. Gimbal lock corresponds to loosing a degree of freedom in the rotation matrix (18); for instance, when ϑ is π/2, the rotation matrix becomes:

The rotation depends on the difference φ –ψ; only one degree of freedom therefore exists instead of two. In other terms, changes of φ and ψ result in rotations about the same axis.

Finally, since matrix multiplication is not generally commutative, finite rotations in space do not commute, unless infinitesimal rotation angles δψ, δθ, δφ are considered, in which case we have:

In fact, the Euler’s formula (15) can be approximated to first order as follows:

**θ**= δθ

**n**is the infinitesimal rotation vector, and its components δθ

_{1}, δθ

_{2}, δθ

_{3}are termed infinitesimal angles.

Finally, another mathematical representation of orientation can be constructed by rewriting the Euler’s formula (15) as follows:

The rotation matrix (24) is formulated as a homogeneous quadratic function of the quantities q_{i}, i = 1,…,4, called the Euler-Rodrigues symmetric parameters or quaternion [32]:

It is commonplace to refer to **q** as the vector part and to q_{4} as the scalar part of the quaternion **q̄** = [**q**^{T} q_{4}]^{T}. As implied by (26), the rotation quaternion satisfies the simple normalization constraint:

The following two basic operations are defined in the quaternion space:

In contrast with quaternion addition, quaternion multiplication is not generally commutative. Moreover, by analogy with complex numbers, we define the conjugate of a quaternion; the definitions of quaternion norm and inverse follow:

The Euler-Rodrigues formulation predates the discovery of quaternions by Hamilton, who was not apparently interested in developing quaternion algebra as means of describing rotational transformations [31]. Hamilton’s quaternions can be considered as 4-component extended complex numbers of the form:

**i**,

**j**,

**k**have the computation rules:

Alternatively, quaternions can be considered as vectors embedded in the four-dimensional Euclidean space R^{4}. The set of quaternions with null vector parts can be identified with R the set of quaternions with null scalar part, aka vector quaternions, can be identified with vectors in the Euclidean space R^{3}. At last, unit quaternions, namely quaternions with unit norm, lie on the three-dimensional sphere S^{3} with unit radius in R^{4}. Henceforth, the vector presentation is used in place of the representation as extended complex numbers.

The connection existing between unit quaternions and the problem of describing orientations starts with examining (24–26). Given the vector quaternion **p̄** = [**p**^{T} 0]^{T}, the vector quaternion:

**p**rotated about the

**n**-axis through an angle θ [32]. Any general three-dimensional rotation θ about an arbitrary unit vector

**n**can be therefore described by a unit quaternion. The rule of composition of rotations is achieved by multiplying the corresponding quaternions. Let

**q̄**

_{1}and

**q̄**

_{2}be arbitrary unit quaternions. Rotation by

**q̄**

_{1}followed by rotation by

**q̄**

_{2}is shown equivalent to rotation by

**q̄**

_{2}⊗

**q̄**

_{1}

The four-component unit quaternion has the lowest dimension of any globally non-singular orientation parameterization. Enforcing the unit norm constraint on a quaternion leaves it with the three degrees of freedom consistent with the SO(3) dimensionality. Moreover, the quaternion representation is redundant, as the rotation vector. The quaternion −**q̄** represents the same rotation as **q̄** a rotation through the angle θ about the **n**-axis can also be expressed as a rotation through an angle −θ about the **n**’-axis (**n**’ = −**n**).

#### 3.2. Kinematic Equations Describing the Motion of a Rigid Body

The kinematic equations that describe the motion of a rigid body capture the relations existing between the temporal derivative of the orientation representation and the angular velocity; we have already discussed the formulation of these equations in the case that the 3-2-1 rotation sequence of Euler’s angles are chosen for representing the orientation, see (20).

Suppose that the orientation changes with time: ${}_{\mathrm{E}}^{\mathrm{B}}\mathbf{C}(t+\delta t)$, i.e., the rotation matrix representing the orientation at time t + δt, differs from ${}_{\mathrm{E}}^{\mathrm{B}}\mathbf{C}(t)$, the rotation matrix at time t, see (23):

**θ**(t) is the infinitesimal rotation vector. We can write:

Taking the limit of (35) as δ t tends to zero, one obtains a system of first-order linear differential equations, aka the Poisson’s kinematic equations:

**ω**

_{B}is the body-referenced angular velocity, defined as:

The time dependence of the angular velocity and the rotation matrix is not made explicit in (36)–(37) to avoid unnecessary cluttering of the notation. Alternatively, the time evolution of a time-varying quaternion with angular velocity **ω**_{B} is given by the solution to the following system of first-order linear differential Equation [32]:

**Ω**(

**ω**

_{B}) is a 4 × 4 skew symmetric matrix. If the angular velocity is time constant, then the closed-form solution to (38) with given initial conditions is given by:

The matrix exponential can be written:

It is worth noting that all three-dimensional representations of orientation are invariably associated to non-linear kinematic equations; on the other hand, higher-dimensional representations of orientation, such as the orientation matrix and the quaternion, present linear kinematic equations, as shown in (36–38).

The gimbal-lock singularity and the presence of computationally taxing trigonometric functions in the numerical integration of the system (20) are critical elements against the choice of the Euler angles. Mathematically, (36) preserves the orthogonality of the orientation matrix, although errors associated with its numerical integration can cause some degradation in the orthogonality of the matrix, which forces to adopt suitable methods to recover it [33]. Errors associated with numerical integration of the kinematic equations for orientation have been analyzed and characterized for both the rotation matrix and the quaternion parameterizations, and the superiority of the latter is widely recognized [33,34]. In addition to that, another relevant advantage of the quaternion formulation is vastly increased computational speed: trigonometric functions are not to be computed, with further savings that are provided by the reduced number of floating operations involved in numerically integrating (38) as compared with (36) [31].

The claim that the physical interpretation of the quaternion is much less intuitive than that associated with Euler angles does not imply that the quaternion cannot find ample diffusion even in the biomechanical community. A systematic development of the kinematics equations is possible in terms, equivalently, of direction cosines, the rotation vector, Euler angles, the quaternion, and well-established relationships link all these descriptors to one another: at any stage of the processing and visualization tasks, one can adopt the descriptor that is more suited to the application specifics. Henceforth, we direct our attention exclusively to the quaternion-based formulation of the kinematic equations of a rigid body.

## 4. Orientation Estimation Algorithms

Estimating the orientation from body-fixed sensor measurements has a quite long history, in particular in applications of spacecraft guidance and control. Over the years, two main approaches have emerged: the deterministic (least-squares) approach and the stochastic (Kalman filtering) approach. The least-squares approach was originally introduced in 1965, in the so-called Wahba’s problem [35], which is a constrained least-squares optimization problem for finding the rotation matrix from vector measurements taken at a single time (single-frame method). The Kalman filtering approach, first proposed in 1961 for applications of spacecraft guidance and control [36], soon after the publication of the seminal paper by Kalman in 1960 [37], is intended to yield minimum-variance sequential estimates of orientation and, in principle, of other parameters than orientation, such as sensor biases, using information about motion dynamics. Unless suitable generalizations are provided, deterministic approaches are unable to incorporate such information [38,39].

Estimating the orientation of human body parts from body-fixed inertial/magnetic sensor measurements is a relatively novel application. It does not come as a surprise that the same distinction as above is made between deterministic and stochastic approaches, as we will see shortly after.

#### 4.1. Deterministic Single-Frame Approach

Deterministic single-frame estimation algorithms can be proposed in connection with the operation of gyro-free aiding sensor systems. Four variants of the same approach are surveyed here: TRIAD (TRi-axial Attitude Determination), QUEST (QUaternion ESTimator), FQA (Factored Quaternion Algorithm) and Gauss-Newton (GN) optimization. They can be used to solve Wahba’s problem without the need for an a priori estimate. They all are based on the concept of vector matching, which requires, in principle, that measurements of constant reference vectors (e.g., gravity and earth magnetic field) are performed. In their original formulation, they are unable to provide sequential estimates of a time-varying orientation and of other parameters than the orientation, such as sensor biases. In the presence of uncompensated sensor biases, the estimated orientation can be therefore grossly inaccurate.

Suppose that two nonparallel reference unit vectors **v**_{1}, **v**_{2} are available, e.g., in the direction of the gravity field and the earth magnetic field, and resolved in the earth-fixed frame. The corresponding observation vectors **w**_{1}, **w**_{2} are measured in the body-fixed frame and normalized in amplitude to one. The TRIAD algorithm attempts to solve Wahba’s problem by finding an orthogonal matrix **A** such that the pair (**w**_{1}, **w**_{2}) is optimally related to the pair (**v**_{1}, **v**_{2}), namely **Av**_{i} = **w**_{i}, i = 1, 2, which gives rise to an over-determined system of algebraic equations [40].

First, two triads of orthonormal reference and observation vectors are constructed:

Second, the two orthogonal matrices **M**_{ref} and **M**_{obs} are formed, and the optimal estimate of the orthogonal matrix **A** is then computed as follows:

The main disadvantage of the TRIAD algorithm is that it is sensitive to the order at which the algorithm receives the two vector pairs—the pair (**v**_{1}, **w**_{1}) is received first in (41). In fact, part of the information conveyed by the second vector pair is discarded: the cross products that are needed to compute **r**_{2} and **s**_{2} eliminate any contribution of **v**_{2} and **w**_{2} relative to the vertical axis. Since the accuracy of the orientation estimate is more influenced by the vector pair that is processed first, the best choice would be to process first the observation vector of greater accuracy. Another disadvantage of the TRIAD algorithm is that it accommodates only two observation vectors.

The basic QUEST delivers the optimal quaternion that minimizes the loss function:

The loss function (44) can be transformed into a quadratic gain function of the unit quaternion:

**K**is a 4 × 4 matrix constructed from the reference vectors

**v**

_{i}, measurement vectors

**w**

_{i}, and weighting coefficients a

_{i}. The optimal unit quaternion is proven to be the eigenvector of the

**K**matrix corresponding to its largest eigenvalue [40].

In contrast with the TRIAD algorithm, the QUEST is capable of accommodating more than two observation vectors; moreover, it is optimal with sensors with different accuracies by properly selecting the weighting coefficients a_{i}. Although the quaternion produced by the QUEST is unit-norm and globally non-singular, a method is needed for avoiding the singularity that arises when the angle of rotation is π. In fact, the QUEST uses a three-dimensional parameterization, namely the Gibbs vector, in its derivation:

The singularity problem is eliminated in the QUEST by employing the method of sequential rotations, at the expense of computational cost [40].

The FQA is specifically created in the attempt to overcome the limitation of both the TRIAD algorithm and the QUEST that orientation errors arise from errors in just one of the sensor data [41]. Suppose that the two reference vectors are the gravity field, **g**, normalized in amplitude to one (vertical reference); and the earth's magnetic field, or more precisely, the local magnetic field, **h**, normalized in amplitude to one (horizontal reference). Let **g**_{m} and **h**_{m} denote the corresponding measurement vectors, normalized in amplitude to one. In the FQA, acceleration data are used in computing the pitch and roll angles, while local magnetic field data are used only in yaw angle computations. This decoupling eliminates the influence of magnetic variations on calculations that determine pitch and roll angles.

Upon examination of (19), the value of the sine of the pitch angle can be expressed as:

From trigonometric half-angle formulas, half-angle values are given by:

The values of the sine and cosine of the roll angle can be expressed as:

Exploiting the half-angle formulas, the roll quaternion is given by:

The values of the sine and cosine of the yaw angle can be determined by matching the magnetic field reference vector in the horizontal plane [h_{x} h_{y}]^{T}, normalized in amplitude to one, and the measured magnetic vector [m_{x} m_{y}]^{T}, projected from the body-fixed frame to the horizontal plane via the pitch and roll quaternions, and normalized in amplitude to one:

Exploiting the half-angle formulas, the yaw quaternion is:

The rule of composition (33) is applied to (48), (50) and (52) to yield the quaternion estimate representing the orientation of the rigid body:

Since the FQA uses three angles to derive the quaternion estimate, it suffers from a singularity, which occurs when the pitch angle is ± π/2. In order to circumvent this singularity, a method similar to the one proposed in the QUEST algorithm is adopted in the numerical implementation of the FQA. In essence, the FQA is very similar to the tilt compensation procedure customarily used in a strap-down magnetic compass to derive heading [17], Figure 4.

The last method reviewed in this Section is the GN optimizer [42]. First, construct the error vector as follows:

The conventional GN method algorithm provides an iterative solution to this problem:

Give an initial guess,

**q̄**_{0};Compute the correction:

$$\mathrm{\Delta}\overline{\mathbf{q}}={\left({\left(\frac{\partial \hspace{0.17em}\varepsilon}{\partial \hspace{0.17em}\overline{\mathbf{q}}}\right)}^{T}\left(\frac{\partial \hspace{0.17em}\varepsilon}{\partial \hspace{0.17em}\overline{\mathbf{q}}}\right)\right)}^{-1}{\left(\frac{\partial \hspace{0.17em}\varepsilon}{\partial \hspace{0.17em}\overline{\mathbf{q}}}\right)}^{T}\varepsilon (\overline{\mathbf{q}});$$Compute the updated quaternion:

$${\overline{\mathbf{q}}}_{i+1}={\overline{\mathbf{q}}}_{i}-\Delta \overline{\mathbf{q}};$$Normalize the updated quaternion:

$${\overline{\mathbf{q}}}_{i+1}=\frac{{\overline{\mathbf{q}}}_{i+1}}{|{\overline{\mathbf{q}}}_{i+1}|};$$Return to step (2), and repeat until convergence using the stopping criterion:

$$|\Delta \overline{\mathbf{q}}|<\text{TOL},$$

The main merit of a GN optimizer is recognized in its robust estimation capability, nonetheless the intensive calculations required in step (2) and the need for iteratively evaluations until convergence may diminish its importance for real-time applications. It is reported that four-five iterations are requested for typical values of the sensor measurement noise, when the initialization errors are large. Fortunately, during tracking, when errors are much smaller, GN iteration typically converges to sufficient accuracy in only one-two steps. Clever algorithms are reported in the literature in order to reduce the computational burden of GN optimizers [25,42].

For an approach based on single-frame deterministic algorithms to work properly in human motion tracking, the acceleration and magnetic measurement vectors are to be determined by the gravity field and by the reference magnetic field, respectively. However, this assumption can cause serious errors in the orientation solution if any body accelerations and magnetic variations of affect the sensor signals: in principle, only slow motions occurring in magnetically clean environments would be allowed. The widespread practice of low-pass filtering acceleration signals in order to reduce the effect of dynamic motions leads to latency in the estimates produced by the algorithm, with the additional problem of how to optimally select the cut-off frequency of the filter. Alternatively, acceleration measurements would be screened before their use in the algorithm by computing the absolute value of the difference between their norm and the known value of gravity; if the computed value exceeds a preset threshold value, the measurement reliability is considered low. As for the impact of magnetic variations on the reliability of magnetic measurements, a similar approach can be considered by comparing the norm of the sensed magnetic field with the norm of the reference magnetic vector. A more detailed explanation of these vector selection techniques is deferred to Section 5.4, after that, in the next Section, stochastic estimation algorithms are presented and discussed.

#### 4.2. Stochastic Estimation Algorithms

Stochastic estimation algorithms use a model for predicting aspects of the time behaviour of a system (dynamic model) and a model of the sensor measurements (measurement model), in order to produce the most accurate estimate possible of the system state. KF algorithms lend themselves perfectly to this task [37]. There appears to be wide consensus that, e.g., in the VR/AR community the KF is recognized “perhaps the perfect tool for elegantly combining multisensory fusion, filtering, and motion prediction in a single fast and accurate framework” [43].

For the sake of generality, our discussion starts here with considering the Bayesian approach to dynamic state estimation [44]; KFs represent a special class of algorithms for recursive Bayesian state estimation. The Bayesian approach is based on propagating the probability density function (PDF) of the system state in a recursive manner through the application of the Bayes’ rule. The state dynamics is modelled as a Markov process:

_{1:k−1}= [

**x**

_{1}

**x**

_{2}…

**x**

_{k−1}] is the collection of the states traversed by the system up to time k−1, included. The state at time t

_{k}is conditioned only on the previous state and it is independent of the past. This allows for a state representation according to the following discrete-time stochastic model:

**w**

_{k−1}represents the process noise. Process noise accounts for any mismodelling effects or disturbances in the dynamic model. Here the index k is associated to a continuous-time instant t

_{k}, and the sampling interval T

_{k−1}= t

_{k}– t

_{k−1}may be time-dependent, i.e., function of k. Henceforth, we will assume that the sampling interval T

_{s}is constant.

The system state **x**_{k} is related to the measurements by the measurement model:

**z**

_{k}is the measured state of the process at time t

_{k}, h is a generally nonlinear time-variant function mapping of the state of the system to the measured state

**z**

_{k}, and

**v**

_{k}represents the measurement noise. The random processes

**w**

_{k−1}and

**v**

_{k}are assumed to be white, with known PDFs, and mutually independent. The initial state

**x**

_{0}is assumed to have a known PDF p(

**x**

_{0}) and also to be independent of

**w**

_{k−1}and

**v**

_{k}.

The goal of filtering can be stated as finding estimates of the states given **z**_{1:k}. This requires the calculation of the posterior PDF p(**x**_{k}|**z**_{1:k}). Suppose that the required posterior PDF p(**x**_{k−1}|**z**_{1:k−1}) at time t_{k−1} is available. The prediction stage involves the dynamic model (61) to obtain the prior PDF of the state at time t_{k}:

The transitional PDF p(**x**_{k}|**x**_{k−1}) is defined by the dynamic model (62) and the known statistics of the process noise **w**_{k−1}.

The update stage, at time t_{k} when a new measurement becomes available, is based on the Bayes’ rule:

**z**

_{k}|

**x**

_{k}) is defined by the measurement model (62) and the known statistics of the measurement noise

**v**

_{k}.

The Equations (63)–(64) give a recursive way to propagate the posterior density. Bayesian filtering can thus be seen as a two-stage process, a prediction stage of the new state using (63), and an update stage where the prediction is modified by the new measurement using (64). The knowledge of the posterior PDF p(**x**_{k}|**z**_{1:k}) allows estimating the state, and obtaining measures of the accuracy of these estimates. The Bayesian solution cannot be determined analytically, expect that in a restrictive set of cases, including the KF.

The KF assumes that the posterior density at every time step is multivariate Gaussian, and hence it can be completely characterized by the mean vector and the covariance matrix. If the PDF p(**x**_{k−1}|**z**_{1:k−1}) is Gaussian, the PDF p(**x**_{k}|**z**_{1:k}) is proven to be Gaussian provided that:

**w**_{k−1}and**v**_{k}are drawn from Gaussian PDFs with known parameters;f

_{k−1}(**x**_{k−1},**w**_{k−1}) is a known linear function of**x**_{k−1}and**w**_{k−1};h

_{k}(**x**_{k},**v**_{k}) is a known linear function of**x**_{k}and**v**_{k}.

In other words (61)–(62) can be rewritten as:

**F**

_{k−1}(of dimension n

_{x}× n

_{x}) and

**H**

_{k}(of dimension n

_{z}× n

_{z}) are known matrices. The additive noises

**w**

_{k−1}and

**v**

_{k}are mutually independent zero-mean white Gaussian, with known covariance matrices

**Q**

_{k−1}and

**R**

_{k}, respectively. Note that the system and measurement matrices

**F**

_{k−1}and

**H**

_{k}, as well as the covariance matrices

**Q**

_{k−1}and

**R**

_{k}, are allowed to be time-variant. For the reader’s convenience, the KF equations are reported in Appendix A.

The Extended Kalman Filter (EKF) is derived for nonlinear systems with additive noise:

The additive noises **w**_{k−1} and **v**_{k} are mutually independent, zero-mean white Gaussian with known covariance matrices **Q**_{k−1} and **R**_{k}, respectively. The EKF is based on the assumption that local descriptions of the nonlinear functions f_{k−1}(**x**_{k−1}) and h_{k}(**x**_{k}) can be obtained by approximating them using only the first term in the Taylor series expansion. The posterior PDF p(**x**_{k}|**z**_{1:k}) is therefore approximated by a Gaussian density. The local linearization requires the computation of the Jacobian matrices of the dynamic model, the measurement model or both with current predicted states, see Appendix A.

The EKF and its many variants are referred to as analytic approximations because the Jacobian matrices **F**_{k−1} and **H**_{k} have to be computed analytically. Moreover, it is worthy noting that the EKF always approximates the posterior PDF p(**x**_{k}|**z**_{1:k}) as a multivariate Gaussian. If the nonlinearity in models is severe, the non-Gaussian nature of the posterior PDF p(**x**_{k}|**z**_{1:k}) can be pronounced, e.g., it can be multimodal, heavily-tailed or skewed: the approximation to first-order is grossly inaccurate and the performance of the EKF can therefore be seriously degraded. In general, besides the computational costs incurred in the calculations of the Jacobian matrices, other disadvantages of the linearization procedure implemented in an EKF concern the sensitivity to initial conditions, biases in the estimation errors, critical problems of convergence and filter stability, especially when the sampling interval is too small.

The Unscented Kalman Filter (UKF) is developed with the aim to overcome these limitations [45]. The UKF hinges on the assumption that it is easier to approximate a Gaussian distribution than it is to approximate an arbitrary nonlinear function. Instead of linearizing using Jacobian matrices, the UKF adopts a deterministic sampling approach to capture the estimates of the mean vector and the covariance matrix with a minimal set of sample points; this “capture” is accurate to the second-order Taylor series expansion for any nonlinearity. The UKF can be used with non-differentiable functions, it does not require the derivation of Jacobian matrices (derivative-free), and is valid to higher-order expansions than the standard EKF. Some work concerning applications for aircraft guidance and control shows the superiority of UKF over EKF, particularly in the presence of large initialization errors [46]. However, this is not usually the case with human body motion tracking applications. This is because, mostly, the filter operation starts with the human body being typically at rest within magnetically clean regions, and well-calibrated inertial/magnetic sensors, see Section 5. Hence, a gyro-free aiding sensor system can feed the EKF with accurate data for initialization at first contact. Moreover, there appears to be wide consensus that, in human body motion capture applications, although the EKF and the UKF may have roughly the same accuracy, the computational overhead of the UKF, the simplicity of the calculations of the Jacobian matrices, and the quasi-Gaussian nature of the posterior PDF p(**x**_{k}|**z**_{1:k}) contribute to make the EKF a preferred choice, even in the most demanding scenarios [47,48]. In order to keep the length of this paper within reasonable limits, UKF and more advanced Bayesian filters, namely particle filters [48,49], are not further addressed here.

## 5. Designing a Quaternion-Based EKF for Orientation Determination

In applying Kalman filtering to the problem of inertial orientation tracking there is considerable freedom in dynamic and measurement modelling [50]. In this Section the discussion concerns how EKFs can be designed when the quaternion is chosen to represent the orientation. The main difficulty of using quaternion-based state vector components is in the application of the filter equations. This difficulty is due to the lack of independence of the four components of a quaternion, which are related by the constraint that the quaternion must have unit norm in order to represent a valid orientation. Constraints imposed on the estimated state variables cannot be preserved by EKFs in their standard development [51].

#### 5.1. Dynamic Modelling

The most principled way to preserve the unit-norm property of the estimated quaternion is to create an algorithm where the error between the true and estimated quaternions is itself a quaternion and is multiplied (in the sense of quaternion multiplication) with the a priori quaternion estimate to yield the a posteriori estimate [51]. This kind of EKF is called multiplicative EKF (MEKF), which differs from the classic additive EKF (AEKF), which employs quaternion subtraction in place of quaternion multiplication [52]. An MEKF parameterizes the global orientation with a non-singular unit quaternion, while any unconstrained three-dimensional representation is used to represent the orientation errors [53]. The dynamic model in an MEKF describes therefore the kinematic equations of a rigid body in terms of the relationships existing between the three-dimensional orientation error and the angular velocity [46]. Strong similarities exist between the MEKF approach and the so-called indirect-state formulation of the Kalman process. In analogy with an MEKF, the indirect-state EKF includes a three-dimensional orientation error in the state vector [54]. The potential advantages of an indirect-state filter are that the state dimension is smaller as compared with a direct-state filter, with subsequent computational savings [50].

In spite that MEKFs are theoretically correct in treating the normalization constraint, most reported implementations regard the application of AEKFs. AEKFs relax the quaternion unit-norm constraint and treat the four components of the quaternion as independent parameters. A method to preserve the quaternion unit-norm property is to derive a sort of quaternion measurement model from the non-linear equation that expresses the unit-norm property (pseudo-measurement model) [47]. Another popular means is to normalize the a posteriori estimate after the measurement update stage (“brute-force” approach). Even though it is neither elegant nor optimal, the “brute-force” approach is often the preferred choice and is proven to work well [52]. The exemplary EKF developed in the following is direct-state, additive and enforces the unit-norm constraint by the “brute-force” approach.

The dynamic equations for describing the orientation of the parts to be tracked would cause severe difficulties in the filter modelling [55], and especially in human body motion capture applications, where the inputs, i.e., muscle forces and torques, are unknown inputs [14,42]. The use of gyros as the primary means to estimate orientation allows circumventing these problems. Since the angular velocity of human body parts is obtained from the gyro data, the kinematic equations of a rigid body can be used to obtain the orientation state (model replacement). In other words, it is highly convenient to treat gyro data as external inputs to the filter rather than as measurements, and consequently gyro measurement noise and bias enter the filter as process noise rather than as measurement noise [22,56]. Another advantage of this choice is the reduction in the dimension of the state vector, which may lead to minimal-order, computationally efficient filter implementations.

An additional important feature of stochastic estimation algorithms like the EKFs is that gyro drift bias can be estimated by state vector augmentation techniques [57]. Oftentimes, this feature is exploited, especially for applications of air and spacecraft attitude estimation, so as to compensate the gyros before performing the numerical integration of kinematics equations [36,46,56]. This is very important in the case that the only aiding comes from occasional orientation fixes. Drift biases of the gyro-free aiding sensor system may be also estimated in the same way [14,22]. In general, however, these other biases cannot be estimated simultaneously with the orientation and gyro drift bias due to possible problems of system observability [58].

Most studies in VR/AR fields employ head motion trackers that directly provide orientation measurements. In these cases, quaternions can be used with an EKF to estimate the angular velocity, which is needed to predict the future head orientation. Sometimes, angular velocity is measured with inertial sensors; the state vector can therefore be augmented with additional components, i.e., the angular acceleration [48]. Different motion models are implemented in the filtering algorithm, in order to improve the ability of the EKF to predict the head orientation for latency compensation [54,59]. For instance, the Constant Velocity (CV) model assumes a simple first-order Gauss-Markov (GM) model for each angular velocity component [60]:

^{2}is a variance factor. The GM model reflects underlying assumptions about the nature of human movements, namely, (a) the change of viewing direction is infrequent; (b) the angular velocity and acceleration are nonzero only during the infrequent changes in orientation. The decorrelation time constant and the variance factor are tuned in order that the spectral properties of the signal generated by the model match those of the angular velocities for paradigmatic motions [42]. More sophisticated models are also investigated, which opens the way to an interesting avenue of research concerning the development of multiple models of human (head) motion, and multiple model adaptive estimation techniques (MMAE) [61].

In this paper, the application specifics concern orientation measurement devices that use angular velocity to estimate orientation using an EKF. At the sampling intervals that are common for these devices, say between 100–500 Hz, the angular velocity can be considered constant in the time interval between successive measurements, leading to the numerical integration of kinematic equations via (39)–(40); the addition of some process noise may further help improving filter stability.

#### 5.2. Sensor Modelling

In a fully integrated IMMU, the gyro, the accelerometer and the magnetometer are each tri-axial, with mutually orthogonal sensitivity axes. Their output in response to the body angular velocity **ω**_{body}, acceleration (gravity **g** and body acceleration **a**_{body}), and local magnetic field (earth’s magnetic field **h**_{earth} and some local magnetic effect modelled as a time-invariant magnetic vector **h**_{ext}) are:

^{g}

**K**,

^{a}

**K**and

^{m}

**K**are the matrices of the scale factors (ideally, they are equal to

**I**

_{3});

^{g}

**b**,

^{a}

**b**and

^{h}

**b**are the bias vectors (ideally, they are null);

^{g}

**v**,

^{a}

**v**and

^{h}

**v**are assumed uncorrelated white Gaussian measurement noise, with null mean and covariance matrix ${\Sigma}_{g}={\sigma}_{g}^{2}{\mathbf{I}}_{3}$, ${\Sigma}_{a}={\sigma}_{a}^{2}{\mathbf{I}}_{3}$ and ${\Sigma}_{h}={\sigma}_{h}^{2}{\mathbf{I}}_{3}$. Equation (68) is a simplified model that does not account for additional error sources, such as cross-axis sensitivity, gyro g-sensitivity, nonlinearity, hysteresis and misalignment [62]. It is worthy noting that a further simplification is made in the gyro model by omitting the earth’s angular velocity of 15°/hour, since state-of-the-art MEMS gyros are unable to sense this component. Their bias stability is indeed in the order of 1°/s—the bias stability is usually specified as a 1σ value, and it describes how the bias may change over a specified period of time, typically around 100 s, in fixed conditions (usually including constant temperature) [26].

To proceed in the discussion of the sensor model (68), remind that an accelerometer measures the projection along its sensitive axis of the specific force f it is submitted. The specific force additively combines the linear acceleration component a, due to body motion, and the gravitational acceleration component, –g, both projected along the sensitive axis of the accelerometer, Figure 5. In common parlance, the high-frequency component, aka the AC component, is related to the dynamic motion the subject is performing, e.g., walking, hand weaving, head shaking, and so forth, while the low-frequency component of the acceleration signal, aka the zero-frequency (DC) component, is related to the influence of gravity, and it can be exploited to identify static postures [63].

The bias and scale factor of inertial and magnetic sensors are functions of environmental conditions, in particular ambient temperature; this is especially true for gyros [64]. Temperature effects on accelerometers are of relatively lower quantitative relevance, and they are usually negligible on magnetic sensors across the thermal variations that they may encounter in practice. Moreover, scale factor drifts of inertial and magnetic sensors usually affect the accuracy of the measurement process to a much lesser extent than the bias drifts of these sensors. The influence of temperature on the gyro bias drift is particularly significant after that power is applied to gyros, as a result of device self-heating. Provided that gyros are allowed warm-up and thermal stabilization for few minutes, then their biases tend to change quite slowly with time. In practice, gyro bias errors can be calibrated and compensated effectively by so-called “zero attitude updates”, which require keeping the gyros from rotating. It is dependent on the nature of the specific application whether occasional rests can be assumed for the human body part to be monitored and tracked [65]. As for the scale factor calibration, procedures suited for in-field use are available [62,66]. The scale factor and bias errors of accelerometers can be calibrated and compensated by so-called “zero-velocity updates”, which require keeping the accelerometers from moving, although they are difficult to implement and may require specific manoeuvres to work properly [67]. In analogy with accelerometers, the scale factor and electronic bias errors of magnetic sensors can be calibrated and compensated effectively by in-field procedures [68]. In the case of experimental sessions lasting few minutes, it is quite safe to assume that the scale factor and bias errors of inertial and magnetic sensors are null, provided that the sensors are carefully calibrated before starting as explained above.

The problem of magnetic variations due to ferromagnetic materials in the vicinity of a magnetic sensor raises additional modelling considerations. Equation (68) shows that the reference magnetic vector is not necessarily the earth’s magnetic field **h**_{earth}. The presence of any constant field vector **h**_{ext} superimposed on **h**_{earth} does not preclude the possibility of constructing the horizontal reference needed for orientation estimation, provided that **h**_{ext} is accurately known. This is in contrast with the need to perform ambulatory measurements, without prior knowledge of existence and location of disturbances. Moreover, we have to consider dynamic effects that are related to either ferromagnetic objects moving in the vicinity of the sensor or to movements of the body-fixed sensor relative to static ferromagnetic objects. Because of these dynamic effects, **h**_{ext} turns out to be time-variant and unknown. A strategy to tackle this problem is to assume that a time-variant bias error ^{h}**b** is present in the magnetic sensor output. In the dynamic model the kinematics equations are therefore augmented with additional equations yielding the model of the behaviour in time of **h**_{ext} by “absorbing” it into a mathematical model of the magnetic drift bias, e.g., random-walk or first-order Gauss-Markov models (state augmentation). In other terms, the horizontal reference is built and maintained by the EKF itself (auto-calibration) [21,22].

#### 5.3. Measurement Equations

The role of aiding sensors is played by accelerometers, taken alone or in combination with magnetic sensors. Sometimes, and depending on the requirements of a specific application, the complexity of the measurement hardware setup, and the sophistication of the filtering algorithms as well, can be reduced to some extent. Simplifying assumptions are quite common in applications to gait analysis [65]. For instance, in the case that motion outside the sagittal plane is assumed not to take place, accelerometers can be used without magnetic sensors, and, since the acceleration sensitivity axes can be embedded in the sagittal plane, simpler bi-axial configurations may suffice. Analogously, uni-axial gyros are enough to capture angular velocities when rotations are approximately about a single axis, oriented in the medio-lateral direction (orthogonal to the sagittal plane).

If motion occurs in the 3D space, heading estimation requires a horizontal reference, for which construction an IMMU is necessary. Few possibilities exist as for the choice of the measurement model. Since we prefer to take the measured angular velocity as an input to the filter, we have to decide how to handle acceleration and magnetic measurements. They can be fused together directly using any deterministic attitude estimation algorithm, e.g., TRIAD, QUEST, FQA, GN optimizer. An advantage of single-frame deterministic algorithms that deliver the quaternion at their output is that the measurement equations are linear; with the exception of the GN optimizer, see (57)–(58) in this regard, the unit-norm property of the measured quaternion is also preserved. The FQA is a potentially good choice, because of the decoupling of magnetic and acceleration data in estimating heading and inclination. A difficulty with this approach is in constructing the expression of the measurement noise covariance, a problem apparently dismissed in [41]. Analytical expressions of the covariance matrix for the TRIAD algorithm and QUEST are derived in [40]: it is proven that the noise in the quaternion measurements presents quaternion-dependent covariance matrices. The dependence on the quaternion is not a problem per se, since the predicted state can be used in place of the true unknown state. An element of complication is that the noisy reference magnetic vector estimated by the EKF must be used in the process of vector matching.

Alternatively, each reference vector component is given a specific measurement equation, which helps moving its representation from the earth-fixed to the body-fixed frame via either (24) or the rule of composition (33):

#### 5.4. Vector Selection

Another important issue in the EKF design deals with its behaviour when anomalous measurements are received. It takes relatively long for an EKF to recover from false measurements when they are given the opportunity to contribute to the estimate of the state vector [57]. The best approach to deal with this problem would consist of preventing the filter from processing data whose reliability is suspected to be low [22,24].

As for the acceleration, in order to answer the question whether the body-fixed measured acceleration vector is suitable for measuring gravity, we would compare its norm with the known value of gravity; better yet, we may decide to work directly with the norm of the difference between the measured acceleration vector, resolved in the earth-fixed frame, and the gravity. If the deviation exceeds some properly chosen threshold value, a sensor glitch, or a contamination due to body motion would be suspected. Different actions can be taken: the measured vector is discarded, and the filter update is only based on magnetic measurements, unless they too are considered unreliable. This is equivalent to temporarily set the acceleration measurement noise variance to some large value, which can be considered, to all practical purposes, infinite:

_{a}is a suitably chosen threshold. An alternative approach consists of defining a suitable law for relating the increase of the acceleration measurement noise variance to the actual deviation of the measured acceleration vector from the gravity. According to our experience, the norm-based adaptive algorithm (70) works adequately in most practical conditions. Note that the quaternion predicted by the filter at time t

_{k−1}is used in (70), in place of the unknown true quaternion at the time instant t

_{k}.

A similar approach can be pursued as for the magnetic measurements. In this case we have to work with the difference between the measured magnetic vector, resolved in the earth-fixed frame, and the local magnetic reference vector. Sometimes, computing the dip angle is suggested to help improving the process; the dip angle is the angle between the magnetic field and the horizontal plane, which would be constant for given latitude and longitude. Unfortunately, the dip angle varies very erratically, especially within indoor environments, and we find its use somewhat critical. An effective norm-based adaptive algorithm applied to the magnetic sensor measurement noise variance is as follows:

_{h}is a suitably chosen threshold. The problem with this approach is that we must assume that the local magnetic reference vector is known, which is not the case unless the magnetic bias auto-calibration feature is implemented in the EKF. Note that the magnetic bias predicted by the filter at time t

_{k−1}is used in (71), in place of its unknown true value at time t

_{k}.

A final comment concerns the applications in gait analysis, in the particularly important case that the IMMU is placed on the lower limbs, e.g., on the foot instep [65]. Rather than fusing them in an EKF, accelerometer data are used just to align the IMMU when the foot is at rest (stance phase of the gait cycle), followed by gyro integration during the swing phase of the gait cycle. During the swing phase the acceleration signals are indeed dominated by the inertial component, which means that the condition implied by (70) is almost never fulfilled. The stride-by-stride gyro integration reset allows mitigating the random-walk errors associated with the integration of gyro wideband measurement noise. To perform stance detection, we need a variant of the norm-based adaptive algorithm (70), or possibly a similar algorithm applied to gyro data:

_{g}is a suitably chosen threshold, and KT

_{s}is the given amount of time to detect when the foot is at rest.

#### 5.5. Filter Parameter Tuning

The parameters to be tuned in an EKF concern the statistical properties assumed for the process noise and the measurement noise. Since they are modelled as Gaussian noise, we need to specify the possibly time-variant covariance matrices **R**_{k} and **Q**_{k} [57,69].

The measurement noise covariance matrix **R**_{k} is usually built from an isotropic model of sensor behaviour: the sensing elements that form each triad are characterized by the same measurement noise variance, hence **R**_{k} is proportional to a identity matrix, or it presents a block-diagonal structure. The measurement noise variances are estimated by taking samples from the sensors at a stationary location. The estimated measurement noise variances can be slightly increased over the on-bench calibration values, to help the EKF stability. In this way, for instance, tremulous motions that an accelerometer can be subject to or minute magnetic variations that can be observed for even very small sensor displacements can be accounted for as noise components in the filter. The EKF is generally quite robust to mismodelling errors in the measurement noise covariance matrix.

Once the structure of the process noise covariance matrix **Q**_{k} is determined, it can be convenient to use scaling parameters that are applied to specific blocks of **Q**_{k}. The values of the scaling parameters can be determined using a non-linear optimization routine for values that optimize the filter behaviour in given operating conditions [59]. Some considerations in parameter tuning must be directed to the belief attached to the validity of the process model. In assessing the model validity, for instance, we have to consider the many gyro error sources besides bias that are not modelled using (68), and the assumption that the angular velocity is constant in the time interval between consecutives updates by the EKF. In particular, the latter assumption can be criticized either for high dynamic motions, low sampling frequencies or both. In any case, it is known that increasing the value of the scaling parameters tends to make the filter response more prompt, at the expense of some degradation in the accuracy of the state vector estimates when the system’s behaviour is more benign. The filter response can also be adjusted by on-line adaptation of **Q**_{k}. This can be done according to different means, e.g., by detecting statistically significant changes in the innovation produced by the filter—fading memory algorithm, [70]. We do not introduce any **Q**-adaptation in the exemplary EKF presented in this paper. In general, it would be said that the EKF is less robust to mismodelling errors in **Q**_{k} than in **R**_{k}.

A study concerning the EKF performance assessment can be performed on experimental or synthetic motion data. With the former approach a series of experiments is performed, where monitored subjects are asked to perform paradigmatic motions. The main problem is that the true motion signals are unknown, because of the noise present in the measurement data. It is possible to smooth the data to some extent and use them as a reference signal, but the risk is to introduce false signal features, while removing true ones. With the latter approach, the main problem is whether the synthetic signals really capture the exact characteristics of the paradigmatic motions or not. If not, it is difficult to predict filter performance when applied to real-life tasks. As neither of these approaches is perfect, both analyses are usually performed and attempts are made to relate them to each other.

Mostly, in order to construct a dataset according to the approach based on experimental motion data, the motion is recorded using a gold standard optical tracker. The truth-reference unit quaternion **q̄**_{true} can be built from the 3D-position coordinates of a minimum of three markers, using, e.g., the Horn algorithm [71]. Quaternion smoothing can be performed by using norm-preserving orientation filters [72] or by independently filtering the quaternion components with any standard low-pass filter, followed by “brute force” normalization [22]. In order to implement a simulation environment for Monte Carlo simulation studies, standard conversion formulas can be applied to construct the orientation vector from the unit quaternion [30]. The orientation vector and its time derivative are then used to synthesize the angular velocity vector that generates the specified orientation [73]. The sensed gravity and magnetic field are computed from resolving gravity and magnetic field into the body frame using (32); additive white Gaussian noises with null mean and assigned variance are added to simulate the sensor measurements during the motion. Any given disturbance, e.g., body acceleration and magnetic variation can also be added into the simulated sensor signals before resolving them in the body-fixed frame.

#### 5.6. Filter Performance Assessment

The performance metrics can be based on computing
$\Delta \overline{\mathbf{q}}={\overline{\mathbf{q}}}_{\text{true}}^{\hspace{0.17em}-1}\otimes \overline{\mathbf{q}}$, where **q̄**_{true} and **q̄** are the true and the estimated quaternions, respectively. The quaternion Δ**q̄** represents therefore the rotation that brings the estimated body frame onto the true body frame. The orientation error Δθ is obtained from the scalar component of Δ**q̄** according to the equation Δθ = 2 arccos (Δq_{4}). The performance metrics are expressed in terms of the root-mean-square-value of the orientation error (RMSE_{θ}), averaged over the number of either the Monte Carlo simulation runs or the experimental trials available. Alternatively, a set of estimated and reference Euler angles can be computed from **q̄**_{true} and **q̄** using standard conversion formulas, and the filter performance can be summarized by presenting the RMSEs of the Euler angles, again averaged over the number of either the Monte Carlo simulation runs or the experimental trials available. An obvious advantage of working with synthetic motion signals is that the errors incurred in estimating the state vector components can be compared with the bounds that are predicted by the error covariance matrix produced by the EKF. This is a useful feature to assess the filter convergence and to diagnose a number of potential problems arising in its numerical implementation. Of course, this possibility is precluded when working with experimental motion signals.

#### 5.7. Exemplary Direct-State EKF

The dynamic model equation is as follows:

The dynamic model is linear and time-variant. Implicit in the formulation (73) is that the gyro biases are negligible. The auto-calibration feature implemented in the filter is limited to handling the problem of magnetic variations, by modelling the magnetic bias as a random-walk process driven by the zero-mean white Gaussian noise vector ^{h}**w**_{k}.

The validity of the model part that describes the time-evolution of the unit quaternion depends on the assumption that the angular velocity is constant in the time interval [t_{k−1} t_{k}]. The process noise component is:

^{q}

**w**

_{k−1}describes how the gyro noise enters the state model through a quaternion-dependent linear transformation. The process noise component

^{h}

**w**

_{k−1}is assumed to have covariance matrix ${}^{b}\Sigma ={T}_{s}\hspace{0.17em}{\sigma}_{b}^{2}\hspace{0.17em}{\mathbf{I}}_{3}$. The variance term ${\sigma}_{b}^{2}$ reflects the a priori belief about the severity of the magnetic variations in the given environment.

Because of the assumption that ^{q}**w**_{k−1} and ^{h}**w**_{k−1} are uncorrelated, the process noise covariance matrix **Q**_{k} has the following block-diagonal structure:

Equation (69) describes the measurement model. The measurement noise covariance matrix is:

**R**-adaptation). Useless to say, when both variance terms are set to some extremely large values, i.e., no aiding comes to the filter, the kinematic equations are integrated based only on the gyro data.

The block diagram of the filter is sketched in Figure 6. The block “project ahead” computes the a priori state estimate and error covariance matrix, using (A2)–(A3). The estimation of the rotation matrix is carried within this block; this estimate is also used to compute the Jacobian matrix of the measurement Equation (69), using (A10), and the Kalman Gain, using (A5)–(A6). The block “update” computes the a posteriori state estimate and error covariance matrix, using (A7)–(A8). Remind the need for normalizing the updated quaternion at this level, in preparation for the next “project ahead” step. The measurement validation tests implement (70)–(71), which is followed by the **R**-adaptation step, via (76)–(77). The iterative nature of the filter allows exploiting the statistics available at any time step to start the computations at the next time-step, when a new set of measurements from the sensors become available.

#### 5.8. Head Motion Tracking Trial

The dataset for the experiment described in this Section was obtained by collecting inertial/magnetic sensor data from the MTx orientation tracker by Xsens Technologies B.V., Enschede, The Netherlands. These data were delivered through the USB interface to a host computer at a rate of 100 Hz together with the unit quaternion time functions estimated by the native Xsens EKF that runs in its default setting. The device was placed on top of a 10 cm × 10 cm plate that was screwed on a cyclist helmet, and fastened using double-side adhesive tape. The plate orientation was recorded using a six-camera Vicon optical tracker with a sampling rate of 100 Hz. A trigger signal was generated by the host computer and enabled time-synchronization of MTx and Vicon data streams. The system measured the position of four reflective markers (diameter: 25 mm), placed at the corners of the plate.

The MTx sensors were calibrated before starting the experimental session and their scale factor and bias errors were therefore zeroed for all practical purposes. The initial orientation of the sensor frame relative to the reference frame was found by asking the subject to stand still for few seconds at the beginning of the trial. The calibration quaternion needed to estimate the reference magnetic vector was built during the still time. The subject was then asked to freely move and turn his helmet-capped head during the trial, while standing on the spot. The head motion trial lasted slightly more than half a minute. The Euler angles time functions delivered by the Vicon system were considered the truth reference for the purpose of error estimation.

The EKF was implemented in Matlab for off-line data processing on a MacBook Air computer. Using the virtualization technology from Parallels Desktop 4.0 for Mac, the cycle time for a single iteration turned out to be about 2.0 ms, without any particular programming effort made to optimize the computational efficiency of the filter. The optimally tuned parameter setting for the EKF is reported in Table 1.

The error statistics are reported in Table 2.

The first and last column report the errors incurred by the EKF and the Xsens EKF, respectively. The columns 3 to 5 give the errors incurred when the gyro is aided by: accelerometer only (column 3); magnetic sensor only (column 4); no sensors (column 5). Suppose that (71) is implemented with ɛ_{h} = 0 The measurements from the magnetic sensor cannot be incorporated in the measurement update stage of the EKF; the same occurs when ɛ_{a} = 0, as for the accelerometer, in (70). When both thresholds are zero, the gyro-free aiding sensor system is inhibited, and the orientation solution is obtained entirely from gyro measurement data. It is apparent that the accelerometer and the magnetic sensor are helpful in inclination and heading stabilization, respectively. Without aiding sensors, random-walk integration of gyro wideband measurement noise yields seriously degraded performance. These results clearly indicate the importance of sensor fusion in improving the accuracy of orientation estimates by inertial/magnetic sensing.

Finally, Figures 7–9 show the time functions of the Euler angles as they are measured from the Vicon system; superimposed on them the time functions of the estimation errors incurred by the EKF.

## 6. Concluding Remarks

A comprehensive review of the endless literature on the problem of orientation determination is virtually impossible and necessarily incomplete, especially if one wishes to encompass all possible applications. We hope this article is interesting to experts and novice alike; the reported information would be sufficient to the readers, in order to cook their formulation of a state-of-the-art algorithm for 3D-orientation estimation using inertial/magnetic sensing in applications of human body motion tracking and analysis.

## Acknowledgments

This work has been supported by funds from the Italian Ministry of Education and Research. The head motion tracking experiment has been performed within the framework of the EC project CLONS, coordinated by Silvestro Micera. Special appreciation is due to the valuable assistance provided by Jacopo Carpaneto, Vincenzo Genovese and Andrea Mannini throughout the experiment.

## References

- Welch, G.F.; Foxlin, E. Motion tracking: no silver bullet, but a respectable arsenal. IEEE Comput. Graph. Appl
**2002**, 22, 24–38. [Google Scholar] - Barbour, N.; Schmidt, G. Inertial sensor technology trends. IEEE Sensors J
**2001**, 1, 332–339. [Google Scholar] - Foxlin, E. Motion tracking requirements and technologies. In Handbook of Virtual Environments: Design, Implementation, and Applications; Stanney, K.M., Ed.; Lawrence Erlbaum Associates: Mahwah, NJ, USA, 2002; pp. 163–210. [Google Scholar]
- Veltink, P.H.; Bussmann, H.B.J.; de Vries, W.H.K.; Martens, W.L.J.; Van Lummel, R.C. Detection of static and dynamic activities using uniaxial accelerometers. IEEE Trans. Rehabil. Eng
**1996**, 4, 375–385. [Google Scholar] - Bachmann, E.R.; Xiaoping, Y.; Peterson, C.W. An investigation of the effects of magnetic variations on inertial/magnetic orientation sensors. Proceedings of IEEE International Conference on Robotics and Automation (ICRA’04), New Orleans, LA, USA, April 26–May 1, 2004; pp. 1115–1122.
- de Vries, W.H.K.; Veeger, H.E.J.; Baten, C.T.M.; van der Helm, F.C.T. Magnetic distortion in motion labs, implications for validating inertial magnetic sensors. Gait Posture
**2009**, 29, 535–541. [Google Scholar] - Morris, J.R.W. Accelerometry—A technique for the measurement of human body movements. J. Biomech
**1973**, 6, 729–736. [Google Scholar] - Padgaonkar, A.J.; Krieger, K.W.; King, A.I. Measurement of angular acceleration of a rigid body using linear accelerometers. J. Appl. Mech
**1975**, 42, 552–556. [Google Scholar] - Giansanti, D.; Macellari, V.; Maccioni, G.; Cappozzo, A. Is it feasible to reconstruct body segment 3-D position and orientation using accelerometric data? IEEE Trans. Biomed. Eng
**2003**, 50, 476–483. [Google Scholar] - Parsa, K.; Lasky, T.A.; Ravani, B. Design and mechatronic implementation of an accelerometer-based, kinematically redundant inertial measurement unit. Proceedings of IEEE/ASME International Conference on Advanced Intelligent Mechatronics, Monterey, CA, USA, 24–28 July 2005; pp. 644–651.
- Willemsen, A.T.M.; van Alsté, J.A.; Boom, H.B.K. Real-time gait assessment utilizing a new way of accelerometry. J. Biomech
**1990**, 23, 859–863. [Google Scholar] - Willemsen, A.T.M.; Frigo, C.; Boom, H.B.K. Lower extremity angle measurement with accelerometers-error and sensitivity analysis. IEEE Trans. Biomed. Eng
**1991**, 38, 1186–1193. [Google Scholar] - Bussmann, J.; Damen, L.; Stam, H. Analysis and decomposition of signals obtained by thigh-fixed uni-axial accelerometry during normal walking. Med. Biol. Eng. Comput
**2000**, 38, 632–638. [Google Scholar] - Luinge, H.J.; Veltink, P.H. Inclination measurement of human movement using a 3-D accelerometer with autocalibration. IEEE Trans. Neural Syst. Rehabil. Eng
**2004**, 12, 112–121. [Google Scholar] - Williamson, R.; Andrews, B. Detecting absolute human knee angle and angular velocity using accelerometers and rate gyroscopes. Med. Biol. Eng. Comput
**2001**, 39, 294–302. [Google Scholar] - Mayagoitia, R.E.; Nene, A.V.; Veltink, P.H. Accelerometer and rate gyroscope measurement of kinematics: An inexpensive alternative to optical motion analysis systems. J. Biomech
**2002**, 35, 537–542. [Google Scholar] - Caruso, M.J. Applications of magnetic sensors for low cost compass systems. IEEE Position Location and Navigation Symposium (PLANS’00), San Diego, CA, USA; 2000; pp. 177–184. [Google Scholar]
- Weston, J.L.; Titterton, D.H. Modern inertial navigation technology and its application. Electron. Commun. Eng. J
**2000**, 12, 49–64. [Google Scholar] - Foxlin, E.; Harrington, M.; Altshuler, Y. Miniature 6-DOF inertial system for tracking HMDs. Proceedings of AeroSense 98 Conference on Helmet and Head-Mounted Displays III; Orlando, FL, USA, 1998; pp. 214–228. [Google Scholar]
- Gallagher, A.; Matsuoka, Y.; Wei-Tech, A. An efficient real-time human posture tracking algorithm using low-cost inertial and magnetic sensors. Proceedings of IEEE/RSJ International Conferenec on Intelligent Robots and Systems (IROS 2004), Sendai, Japan, 28 September–2 October 2004; pp. 2967–2972.
- Roetenberg, D.; Luinge, H.J.; Baten, C.T.M.; Veltink, P.H. Compensation of magnetic disturbances improves inertial and magnetic sensing of human body segment orientation. IEEE Trans. Neural Syst. Rehabil. Eng
**2005**, 13, 395–405. [Google Scholar] - Sabatini, A.M. Quaternion-based extended Kalman filter for determining orientation by inertial and magnetic sensing. IEEE Trans. Biomed. Eng
**2006**, 53, 1346–1356. [Google Scholar] - Yun, X.; Bachmann, E.R. Design, implementation, and experimental results of a quaternion-based Kalman filter for human body motion tracking. IEEE Trans. Robot
**2006**, 22, 1216–1227. [Google Scholar] - Harada, T.; Mori, T.; Sato, T. Development of a tiny orientation estimation device to operate under motion and magnetic disturbance. Int. J. Rob. Res
**2007**, 26, 547–559. [Google Scholar] - Lee, J.K.; Park, E.J. A fast quaternion-based orientation optimizer via virtual rotation for human motion tracking. IEEE Trans. Biomed. Eng
**2009**, 56, 1574–1582. [Google Scholar] - Woodman, O.J. An Introduction to Inertial Navigation; UCAM-CL-TR-696; Computer Laboratory, University of Cambridge: Cambridge, UK, 2007. [Google Scholar]
- Jirawimut, R.; Ptasinski, P.; Garaj, V.; Cecelja, F.; Balachandran, W. A method for dead reckoning parameter correction in pedestrian navigation systems. IEEE Trans. Instrum. Meas
**2003**, 52, 209–215. [Google Scholar] - Tan, H.; Wilson, A.M.; Lowe, J. Measurement of stride parameters using a wearable GPS and inertial measurement unit. J. Biomech
**2008**, 41, 1398–1406. [Google Scholar] - Sabatini, A.M. Quaternion-based strap-down integration method for applications of inertial sensing to gait analysis. Med. Biol. Eng. Comput
**2005**, 43, 94–101. [Google Scholar] - Shuster, M.D. A survey of attitude representations. J. Astronaut. Sci
**1993**, 41, 439–517. [Google Scholar] - Phillips, W.F.; Hailey, C.E.; Gebert, G.A. A review of attitude kinematics for aircraft flight simulation. AIAA 2000-4302 Modeling and Simulation Technologies Conference, Denver, CO, USA; 2000; pp. 1–20. [Google Scholar]
- Chou, J.C.K. Quaternion kinematics and dynamic differential equations. IEEE Trans. Robot. Autom
**1992**, 8, 53–64. [Google Scholar] - Lovren, N.; Pieper, J.K. Error analysis of direction cosines and quaternion parameters techniques for aircraft attitude determination. IEEE Trans. Aerosp. Electron. Syst
**1998**, 34, 983–989. [Google Scholar] - Gebre-Egziabher, D.; Hayward, R.C.; Powell, J.D. Design of multi-sensor attitude determination systems. IEEE Trans. Aerosp. Electron. Syst
**2004**, 40, 627–648. [Google Scholar] - Wahba, G. A least-square estimate of spacecraft attitude. SIAM Rev
**1965**, 7, 409. [Google Scholar] - Lefferts, E.J.; Markley, F.L.; Shuster, M.D. Kalman filtering for spacecraft attitude estimation. J. Guid
**1982**, 5, 417–429. [Google Scholar] - Kalman, R.E. A new approach to linear filtering and prediction problems. ASME Trans. Series D J. Basic Eng
**1960**, 82, 35–45. [Google Scholar] - Markley, F.L. Attitude determination and parameter estimation using vector observations: Theory. J. Astronaut. Sci
**1989**, 37, 41–58. [Google Scholar] - Psiaki, M.L. Attitude-determination filtering via extended quaternion estimation. J. Guid. Contr. Dynamics
**2000**, 23, 206–214. [Google Scholar] - Shuster, M.D.; Oh, S. Three-axis attitude determination from vector observations. J. Guid. Contr
**1981**, 4, 70–77. [Google Scholar] - Yun, X.; Bachmann, E.R.; McGhee, R.B. A simplified quaternion-based algorithm for orientation estimation from earth gravity and magnetic field measurements. IEEE Trans. Instrum. Meas
**2008**, 57, 638–650. [Google Scholar] - Marins, J.L.; Xiaoping, Y.; Bachmann, E.R.; McGhee, R.B.; Zyda, M.J. An extended Kalman filter for quaternion-based orientation estimation using MARG sensors. Proceedings of IEEE/RSJ Internat. Conference on Intelligent Robots and Systems (IROS 2001), Maui, HI, USA, October 29–November 3, 2001; pp. 2003–2011.
- Welch, G.F. The use of the Kalman filter for human motion tracking in virtual reality. Presence
**2009**, 18, 72–91. [Google Scholar] - Arulampalam, S.; Maskell, S.; Gordon, N.; Clapp, T. A tutorial on particle filters for online nonlinear/non-Gaussian Bayesian tracking. IEEE Trans. Signal Process
**2002**, 50, 174–188. [Google Scholar] - Julier, S.J.; Uhlmann, J.K. Unscented filtering and nonlinear estimation. Proc. IEEE
**2004**, 92, 401–422. [Google Scholar] - Crassidis, J.L.; Markley, F.L. Unscented filtering for spacecraft attitude estimation. J. Guid. Contr. Dyn
**2003**, 26, 536–542. [Google Scholar] - LaViola, J.J., Jr. A comparison of unscented and extended Kalman filtering for estimating quaternion motion. Proceedings of American Control Conference, Providence, RI, USA, 4–6 June 2003; pp. 2435–2440.
- van Rhijn, A.; van Liere, R.; Mulder, J.D. An analysis of orientation prediction and filtering methods for VR/AR. Proceedings of IEEE Conferenec on Virtual Reality, Bonn, Germany, 12−16 March 2005; pp. 67–74.
- Carmi, A.; Oshman, Y. Adaptive particle filtering for spacecraft attitude estimation from vector observations. J. Guid. Contr. Dyn
**2009**, 32, 232–241. [Google Scholar] - Foxlin, E. Inertial head-tracker sensor fusion by a complementary separate-bias Kalman filter. Proceedings of IEEE Virtual Reality Annual International Symposium, Santa Clara, CA, USA, 30 March–3 April 1996; pp. 185–194.
- Markley, F.L. Attitude error representations for Kalman filtering. J. Guid. Contr. Dyn
**2003**, 26, 311–317. [Google Scholar] - Bar-Itzhack, I.Y.; Oshman, Y. Attitude determination from vector observations: Quaternion estimation. IEEE Trans. Aerosp. Electron. Syst
**1985**, 21, 128–136. [Google Scholar] - Schaub, H.; Junkins, J.L. Stereographic orientation parameters for attitude dynamics: A generalization of the Rodrigues parameters. J. Astronaut. Sci
**1996**, 44, 1–19. [Google Scholar] - Himberg, H.; Motai, Y. Head orientation prediction: delta quaternions versus quaternions. IEEE Trans. Syst. Man Cybern. B Cybern
**2009**, 39, 1382–1392. [Google Scholar] - Gebre-Egziabher, D.; Elkaim, G.H.; Powell, J.D.; Parkinson, B.W. A gyro-free quaternion-based attitude determination system suitable for implementation using low cost sensors. IEEE Position Location and Navigation Symposium (PLANS’00); 2000; pp. 185–192. [Google Scholar]
- Choukroun, D.; Bar-Itzhack, I.Y.; Oshman, Y. Novel quaternion Kalman filter. IEEE Trans. Aerosp. Electron. Syst
**2006**, 41, 174–190. [Google Scholar] - Maybeck, P.S. Stochastic Models, Estimation and Control; Academic Press: New York, NY, USA, 1982. [Google Scholar]
- Mirzaei, F.M.; Roumeliotis, S.I. A Kalman-filter-based algorithm for IMU-camera calibration: Observability analysis and performance evaluation. IEEE Trans. Robot
**2008**, 24, 1143–1156. [Google Scholar] - Azuma, R.; Bishop, G. Improving static and dynamic registration in a see-through HMD. Proceedings of SIGGRAPH, Orlando, FL, USA, 24–29 July 1994; pp. 197–204.
- Liang, J.; Shaw, C.; Green, M. On temporal-spatial realism in the virtual environment. Proceedings of Symposium on User Interface Software and Technology, Hilton Head, SC, USA; 1991; pp. 19–25. [Google Scholar]
- Kieger, D.W.; Maybeck, P.S. Reducing lag in virtual displays using multiple model adaptive estimation. IEEE Trans. Aerosp. Electron. Syst
**1998**, 34, 1237–1248. [Google Scholar] - Ferraris, F.; Grimaldi, U.; Parvis, M. Procedure for effortless in-field calibration of three-axis rate gyros and accelerometers. Sens. Mater
**1995**, 7, 311–330. [Google Scholar] - Mannini, A.; Sabatini, A.M. Machine learning methods for classifying human physical activity from on-body accelerometers. Sensors
**2010**, 10, 1154–1175. [Google Scholar] - Abbott, E.; Powell, D. Land-vehicle navigation using GPS. Proc. IEEE
**1999**, 87, 145–162. [Google Scholar] - Sabatini, A.M.; Martelloni, C.; Scapellato, S.; Cavallo, F. Assessment of walking features from foot inertial sensing. IEEE Trans. Biomed. Eng
**2005**, 52, 486–494. [Google Scholar] - Scapellato, S.; Cavallo, F.; Martelloni, C.; Sabatini, A.M. In-use calibration of body-mounted gyroscopes for applications in gait analysis. Sens. Actuat. A: Phys
**2005**, 418–422. [Google Scholar] - Lötters, J.C.; Schipper, J.; Veltink, P.H.; Olthuis, W.; Bergveld, P. Procedure for in-use calibration of triaxial accelerometers in medical applications. Sens. Actuat. A: Phys
**1998**, 68, 221–228. [Google Scholar] - Gebre-Egziabher, D.; Elkaim, G.H.; Powell, J.D.; Parkinson, B.W. A non-linear, two-step estimation algorithm for calibrating solid-state strapdown magnetometers. 8th International Conference on Navigation Systems, St. Petersburg, Russia; 2001. [Google Scholar]
- Brown, R.G.; Hwang, P.Y.C. Introduction to Random Signals and Applied Kalman Filtering; John Wiley & Sons: New York, NY, USA, 1997. [Google Scholar]
- Himberg, H.; Motai, Y.; Barrios, C. R-adaptive Kalman filtering approach to estimate head orientation for driving simulator. Proceedings of IEEE/ISTC International Conference on Intelligent Transportation Systems, Toronto, ON, Canada, 17–20 September 2006; pp. 851–857.
- Horn, B.K.P. Closed form solution of absolute orientation using unit quaternions. J. Opt. Soc. Am. A
**1987**, 4, 629–642. [Google Scholar] - Lee, J.; Shin, S.Y. General construction of time-domain filters for orientation data. IEEE Trans. Vis. Comput. Graph
**2002**, 8, 119–128. [Google Scholar] - Bortz, J.E. A new mathematical formulation for strapdown inertial navigation. IEEE Trans. Aerosp. Electron. Syst
**1971**, 7, 61–66. [Google Scholar]

## Appendix

In this Appendix we report in short the equatons of both the KF and the EKF. For an excellent treatment of these topics, consult [57].

#### 1. KF Equations

Dynamic and measurement models:

Compute the a priori state estimate:

$${\mathbf{x}}_{k}^{-}={\mathbf{F}}_{k-1}{\mathbf{x}}_{k-1}^{+};$$_{k}, before the current measurement**z**_{k}is used in computing the a posteriori estimate”; the superscript + in ${\mathbf{x}}_{k-1}^{+}$ stands for “the a posteriori estimate at time t_{k}, which is computed based on the evidence in the current measurement**z**_{k}”.Compute the a priori error covariance matrix:

$${\mathbf{P}}_{k}^{-}={\mathbf{F}}_{k-1}{\mathbf{P}}_{k-1}{\mathbf{F}}_{k-1}^{T}+{\mathbf{Q}}_{k-1};$$Compute the innovation and its covariance matrix:

$${\mathbf{\nu}}_{k}={\mathbf{z}}_{k}-{\mathbf{H}}_{k}({\mathbf{x}}_{k}^{-});$$Compute the covariance matrix of the innovation:

$${\mathbf{S}}_{k}={\mathbf{H}}_{k}{\mathbf{P}}_{k}^{-}{\mathbf{H}}_{k}^{T}+{\mathbf{R}}_{k};$$Compute the Kalman gain:

$${\mathbf{K}}_{k}={\mathbf{P}}_{k}^{-}{\mathbf{H}}_{k}^{T}{\mathbf{S}}_{k}^{-1};$$Compute the a posteriori state estimate:

$${\mathbf{x}}_{k}^{+}={\mathbf{x}}_{k}^{-}+{\mathbf{K}}_{k}{\mathbf{\nu}}_{k};$$Compute the a posteriori error covariance matrix:

$${\mathbf{P}}_{k}^{+}={\mathbf{P}}_{k}^{-}-{\mathbf{K}}_{k}{\mathbf{H}}_{k}{\mathbf{P}}_{k}^{-}.$$

#### 2. EKF Equations

When the dynamic model, the measurement model or both are nonlinear the EKF comes to our rescue:

The EKF equations differ from the Equations (A1)–(A8) only in the specifications of the matrices **F**_{k−1} and **H**_{k}:

**Figure 3.**The vector

**v**is rotated about the axis

**n**(Euler axis) through an angle of rotation θ. Note that the rotated vector

**R**(

**n**, θ)

**v**shares the parallel component with

**v**.

**Figure 4.**Inclination of the strap-down magnetic compass relative to the horizontal plane as defined by gravity direction.

**Figure 5.**A single-axis accelerometer measures the projection (in the direction of the sensitive axis) of the specific force

**f**resulting from the sum of the inertial acceleration

**a**and the equivalent gravity acceleration −

**g**.

**Table 1.**Optimally tuned parameter setting for the EKF. The raw magnetic data from the MTx are expressed in arbitrary units (a.u.), since they are normalized to earth field strength by the manufacturer.

Process noise statistics | |

Gyro standard deviation ^{g}σ, °/s | 0.4 |

Magnetic bias standard deviation ^{b}σ, a.u. (× 10^{−3}) | 0.1 |

Measurement noise statistics | |

Accelerometer standard deviation ^{a}σ, mg | 10.0 |

Magnetic sensor standard deviation ^{h}σ, a.u. (× 10^{−3}) | 1.0 |

Thresholds for R-adaptation | |

Acceleration measurements: ɛ_{a}, mg | 40.0 |

Magnetic sensor measurements: ɛ_{h}, a.u. (× 10^{−3}) | 50.0 |

RMSE | EKF | ɛ_{h} = 0 | ɛ_{a} = 0 | ɛ_{a} = ɛ_{h} = 0 | Xsens EKF |
---|---|---|---|---|---|

Roll angle, ° | 0.72 | 0.89 | 3.13 | 0.97 | 0.94 |

Pitch angle, ° | 0.83 | 0.88 | 1.20 | 4.91 | 0.76 |

Yaw angle, ° | 1.23 | 3.88 | 4.30 | 3.76 | 1.30 |

Orientation angle, ° | 1.62 | 3.96 | 5.26 | 6.19 | 1.72 |

© 2011 by the authors; licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution license (http://creativecommons.org/licenses/by/3.0/).

## Share and Cite

**MDPI and ACS Style**

Sabatini, A.M. Estimating Three-Dimensional Orientation of Human Body Parts by Inertial/Magnetic Sensing. *Sensors* **2011**, *11*, 1489-1525.
https://doi.org/10.3390/s110201489

**AMA Style**

Sabatini AM. Estimating Three-Dimensional Orientation of Human Body Parts by Inertial/Magnetic Sensing. *Sensors*. 2011; 11(2):1489-1525.
https://doi.org/10.3390/s110201489

**Chicago/Turabian Style**

Sabatini, Angelo Maria. 2011. "Estimating Three-Dimensional Orientation of Human Body Parts by Inertial/Magnetic Sensing" *Sensors* 11, no. 2: 1489-1525.
https://doi.org/10.3390/s110201489