- freely available
- re-usable

*Sensors*
**2013**,
*13*(11),
15138-15158;
doi:10.3390/s131115138

^{1}

^{2}

^{3}

Published: 6 November 2013

## Abstract

**:**This paper deals with the attitude estimation of a rigid body equipped with angular velocity sensors and reference vector sensors. A quaternion-based nonlinear observer is proposed in order to fuse all information sources and to obtain an accurate estimation of the attitude. It is shown that the observer error dynamics can be separated into two passive subsystems connected in “feedback”. Then, this property is used to show that the error dynamics is input-to-state stable when the measurement disturbance is seen as an input and the error as the state. These results allow one to affirm that the observer is “robustly stable”. The proposed observer is evaluated in real-time with the design and implementation of an Attitude and Heading Reference System (AHRS) based on low-cost MEMS (Micro-Electro-Mechanical Systems) Inertial Measure Unit (IMU) and magnetic sensors and a 16-bit microcontroller. The resulting estimates are compared with a high precision motion system to demonstrate its performance.

## 1. Introduction

#### 1.1. Motivations and Background

The attitude control problem of a rigid body has attracted a strong interest during the past few decades, and it has been extensively studied. This interest comes from the fact that many aerospace systems, such as spacecrafts, satellites, tactical missiles and many others, enter within the framework of a rigid body with the requirement of precise attitude information [1]. In the last decade, the application of micro-electro-mechanical systems (MEMS) has gained a strong interest. Therefore, the attitude estimation problem has been tackled within new areas, such as terrestrial and aerial robotics [2,3], virtual reality [4], biomechanics [5] and wearable robots [6]. In these cases, the attitude information is obtained from inertial and magnetic sensors, namely, three rate gyros, three accelerometers and three magnetometers, orthogonally mounted, such that the sensor frame axes coincide with the principal axes of the rigid body. Since the attitude is not directly measured, it must be estimated via the measurements of the mentioned sensors. In general, these sensors can be classified into two main categories: Angular velocity sensors that measure the angular velocity of the body with respect to some inertial frame and reference vector sensors that give the coordinates of a fixed vector in the mobile frame.

Rate gyros are angular velocity sensors, and they provide continuous attitude information with good short-term stability when their measurements are integrated by means of the rigid body kinematic Equation. However, since rate gyro measurements are affected by drifts and noise, the attitude estimation based on these sensors diverges slowly from the real attitude. On the other hand, when reference vector sensors measurements, known as vector observations, are available, the attitude can be determinated by algebraic or optimization techniques [7]. Therefore, in order to decrease the effect of noise induced by the vector observations, as well as the attitude divergence provoked by the rate gyro drifts, it is important to fuse both information sources.

To this effect, various estimators have been proposed, using the quaternion attitude parametrization [8]. The Extended Kalman Filter (EKF) [9] and new alternatives to the standard EKF have been applied extensively (see [10] and the references therein). However, the divergence problem [11], the non-Gaussian noise induced [12] and the computational cost render difficult the embedded implementation of the Extended Kalman Filter (EKF). In recent years, significant research efforts have been addressed toward the synthesis of nonlinear attitude observers in order to tackle the previously mentioned issues. The first work on this topic was presented in [13]. Subsequently, in [14–16], quaternion-based nonlinear observers and gyro bias observers are proposed in the framework of satellite sensors calibration and marine vehicle navigation, respectively. Furthermore, the formulation of nonlinear attitude observers based on the the orthogonal group, SO(3), have been proposed in the few last years [17–20]. Recently, an excellent overview of rigid body attitude estimation and comparative study was given in [21,22]. Nevertheless, it is well known that a nonlinear observer is generally vulnerable to measurement disturbance, in the sense that a small arbitrary disturbance can lead to the divergence of the error state [23]. The above mentioned nonlinear attitude observers (with the exception of [20]) do not consider either the present noise in the gyro measurements nor a time-varying gyro bias term. Furthermore, the computational complexity in these approaches is a drawback, since the algorithms work with 3 × 3 matrices and they have to preserve orthogonality properties. The singular value decomposition (SVD) is a well-known approach and an extremely powerful and useful tool in linear control theory and signal processing. However, few works have exploited this approach in the framework of attitude estimation. In [24], the authors use the SVD method to estimate the attitude matrix minimizing Wahba's cost function. In the work reported in [25], the authors use the SVD approach for finding the relative orientation of a robotic manipulator. Nevertheless, the problem of attitude estimation from magnetic and inertial sensors using an SVD approach has not been addressed in the literature. Furthermore, unlike sensors and computer systems used in the marine and aerospace community, the signal output of the low-cost sensors is subject to high levels of noise and a time-varying bias term. These problems must be addressed, since, in a practical framework, the design of efficient and embedded attitude estimator using low-cost sensors is an important issue.

#### 1.2. Contributions

In the present work, a quaternion-based attitude observer/estimator of a rigid body is presented. In the proposed approach, the attitude estimation problem is solved in two parts. Firstly, a quaternion attitude is estimated by means of vector observations. In this first step, the attitude estimation is performed using an SVD (singular value decomposition) approach. Then, the quaternion obtained in this step is considered an attitude measurement. Contrary to conventional techniques, the SVD maintains the quaternion's unit constraint naturally. Furthermore, the numerical robustness and numerical stability are guaranteed [26]. The second part of the proposed method consists of the design of a nonlinear observer in order to produce an estimate of the time-varying gyro bias and the attitude quaternion. This observer is driven by an attitude error obtained by means of the quaternion propagated by the observer, and this one obtained from the SVD technique. Asymptotic convergence of the estimation error is proven. Moreover, it is shown that the error dynamics can be decomposed in two passive subsystems connected in “feedback”. This result is exploited to prove that the observer is input-to-state stable (ISS) [27,28] when the rate gyro noise is seen as the input and the error as the state. In this sense, using the small gain theorem, one claims that the observer is “robustly stable”. To evaluate the proposed attitude observer behavior in real-time, a complete Attitude and Heading Reference System (AHRS) based on low-cost inertial and magnetic sensors and a 16-bit microcontroller is designed and implemented. A comparison with a high precision motion system is carried out, in order to demonstrate the observer performance.

The ISS paradigm in an attitude observer, the problem of estimating the attitude from vector observations using an SVD approach, as well as a real-time implementation have never been addressed in the literature. These facts show the originality of the present work.

The document is organized as follows. In Section 2, a mathematical background of the attitude parametrization and sensors modeling is given. The main problem is formulated in Section 3. The formulation of the nonlinear attitude observer and stability analysis is presented in Sections 4-6. The AHRS implementation and experimental results are given in Section 7. Finally, conclusions and further research are mentioned in Section 8.

## 2. Mathematical Background

#### 2.1. Unit Quaternions and Attitude Kinematics

Consider two orthogonal, right-handed coordinate frames: the body coordinate frame,
${\mathbf{\text{E}}}^{b}=[{\overrightarrow{e}}_{1}^{b},{\overrightarrow{e}}_{2}^{b},{\overrightarrow{e}}_{3}^{b}]$, located at the center of mass of the rigid body, and the inertial coordinate frame,
${\mathbf{\text{E}}}^{f}=[{\overrightarrow{e}}_{1}^{f},{\overrightarrow{e}}_{2}^{f},{\overrightarrow{e}}_{3}^{f}]$, located at some point in the space. The rotation of the body frame, **E**^{b}, with respect to the fixed frame, **E**^{f}, is represented by the attitude matrix R ∈ SO(3) = { R ∈ ℝ^{3×3} : R^{T}R = I, det R = 1}.

The cross product between two vectors, χ⃗, ξ⃗ ∈ ℝ^{3}, is represented by a matrix multiplication [ξ⃗^{×}]χ = ξ⃗ × χ⃗, where:

The n-dimensional unit sphere embedded in ℝ ^{n}^{+1} is denoted as
^{n} = {x ∈ ℝ^{n+}^{1}: x^{T}x = 1}. Members of SO(3) are often parametrized in terms of a rotation, β ∈ ℝ, about a fixed axis, e⃗ ∈
^{2}, by the map,
: ℝ ×
^{2} → SO(3), defined as:

Hence, a unit quaternion, q ∈
^{3}, is defined as:

_{1}q

_{2}q

_{3}]

^{T}∈ ℝ

^{3}and q

_{0}∈ ℝ are known as the vector and scalar parts of the quaternion, respectively. q represents an element of SO(3) through the map, :

^{3}→SO(3), defined as:

Note that R = (
) (q) = (
) (—q) for each q ∈
^{3}, i.e., quaternions q and –q represent the same physical attitude. The inverse unit quaternion is given by q^{−1} := [q_{0} –q⃗^{T}]^{T} , and the quaternion product is defined by:

Denoting by ω⃗ = [ω_{1} ω_{2} ω_{3}]^{T} the angular velocity vector of the the body coordinate frame, **E**^{b}, relative to the inertial coordinate frame, **E**^{f}, expressed in **E**^{b}, the kinematics equation is given by:

The attitude error is used to quantify the mismatch between two attitudes. If q defines the true attitude quaternion and q̂ is the estimated quaternion, then the error quaternion that represents the attitude error between the true orientation and the estimated one is given by [8]:

In the case that the true quaternion and the estimated one coincide, the quaternion error becomes:

#### 2.2. Sensor Modeling

The sensors in the rigid body are classified into the two following categories.

#### 2.2.1. Angular Velocity Sensors

The angular velocity ω⃗ = (ω_{1} ω_{2} ω_{3})^{T} is measured by three rate gyros orthogonally mounted. The output signal of a rate gyro is influenced by noise and by a slowly varying function, v, called bias [29], that is:

_{G}and η⃗

_{v}∈ ℝ

^{3}are bounded noises and T = τI

_{3}is a diagonal matrix of time constants.

#### 2.2.2. Reference Vector Sensors

Let us consider the representation of a vector, x⃗_{i}, with respect to **E**^{f} and **E**^{b} and denoted by r⃗_{i} and b⃗_{i}, respectively. The vectors, r⃗_{i}, are also called the “reference vectors” and, in general, are known quite accurately. The body vectors, b⃗_{i}, are known as “vector observations” and are obtained from on-board sensors (for instance, magnetometers, star trackers, accelerometers). Let b_{iq} and r_{iq} be the associate quaternion to the vectors, b⃗_{i} and r⃗_{i}:

From Equation (4) and using quaternion algebra, the following measure model can be obtained [25]:

^{4×4}. Note that Equation (12) is a well-structured linear system of equations.

## 3. Problem Statement

The objective is to design an attitude observer that estimates the rigid body attitude doing a trade-off between a good short-term precision given by rate gyro integration and a reliable long-term accuracy provided by vector observations.

If at least two vector observations are non-collinear, the quaternion can be estimated using these simultaneous vector measurements. For this purpose, the measurement Equation (12) is exploited. The observation matrix in a function of m pair vectors (b⃗_{i}, r⃗_{i}) with i ∈ {1, 2,…, m} is written as follows:

In the case of perfect measurements, the measure Equation H̄_{q} = 0 is always satisfied. However, in practice, the measurements are polluted with perturbations originated from noise, vibrations, etc. Therefore, the problem consists of estimating the attitude quaternion from a perturbed observation matrix, H̄, that is:

On the other hand, if the initial value, q(t_{0}), is known and the angular velocity measurements are perfect, i.e., ω⃗ = ω⃗_{G}, it is possible to obtain q(t) by integrating the kinematics Equation (5). Nevertheless, q(t_{0}) is, in general, unknown, furthermore, the angular velocities are polluted with bias and noise (see Equation (8)), which results in slow divergence of attitude over time. Therefore, the observation idea can be used to on-line correct the integration, q̂(t), of some erroneous q̂ (t_{0}) and attitude errors caused by the bias, and the noise presents in the rate gyro measurements. This correction can be carried out according to the measurable error q_{e} = q̂^{-1} ⊗ q_{ps}, where q_{ps} is considered an attitude measure obtained by the vector observations.

The observation problem 1can then be formulated as follows: Given the kinematic equation of the rigid body and the model of time-varying bias evolution, find an estimate q̂ (t) and v̂ (t) from the knowledge of ω_{G}(t) and q_{ps}(t) for all t ≥ t_{0} ∈ ℝ_{≥ 0}.

## 4. Nonlinear Observer Formulation

#### 4.1. Attitude Estimation from Vector Observations

**Assumption 1.** There are at least two linearly independent vectors, b⃗_{i} and b⃗_{j}, with i ≠ j, that is, rank(H̄) ≥ 3.

**Lemma 1**. Let H̄ ∈ ℝ^{4m×4} be the observation matrix formed by the m pair of vectors (b⃗_{i}, r⃗_{i}) with i ∈ {1, 2, …,m}. Then, there is an orthonormal matrix U = (U_{1} U_{2} … U_{4m}) ∈ ℝ^{4m×4m}, an orthonormal matrix V = (V_{1} V_{2} V_{3} V_{4}) ∈ ℝ^{4×4} and an orthonormal matrix S ∈ ℝ^{4m×4}, with elements σ_{k} along the diagonal and zeros everywhere else, where k = 1 : 4, such that:

Then, the attitude quaternion is given by the last column of the matrix, V, that is:

_{ps}‖

_{2}= 1 is satisfied.

Proof. The proof follows the standard least squares solution of homogeneous equations via the SDV approach [30].

#### 4.2. Nonlinear Attitude Observer with Bias Estimation

The proposed attitude nonlinear observer that includes the bias and the error update is given by:

^{3×3}has been defined in Equation (9) and K

_{1}, K

_{2}are positive constant parameters. q̂ is the prediction of the attitude at time t. It is obtained via the integration of the kinematics Equation (17), using the measured angular velocity, ω⃗

_{G}, the bias estimate, ν̂ and q⃗

_{e}, which is the vector part of the quaternion error, q

_{e}, that measures the discrepancy between q̂ and the measured attitude, q

_{ps}, obtained by means of Lemma 1, that is:

Actually, the observer Equation (17) allows one to fuse the data that arise from the vector observations and the rate gyro measurements. The observer structure is shown in Figure 1.

Note that the attitude quaternion, q_{ps}, can be expressed by:

For the first time, a Lyapunov stability analysis is carried out. As is always done, the error dynamic is obtained in a noise-free context; then, the following hypotheses are made:

- ●
η⃗

_{G}= η⃗_{v}= 0. The measurement rate gyro noise is not included in the error dynamics.- ●
Δq = (1 0 0 0)

^{T}, i.e., q = q_{ps}. This is a good assumption for the case of static attitudes and for quasistatic movements [17].

Combining Equations (5)-(9) and (17), the error dynamics is expressed as:

_{1}q⃗

_{e}and $\stackrel{\u0303}{v}=\stackrel{\u20d7}{v}-\widehat{\stackrel{\u20d7}{v}}$.

The system Equation (20) admits a set of equilibrium points
:= {p_{e}_{+}, p_{e}_{−}}, where:

- ●
p

_{e}_{+}:=(1 0^{T}0^{T})^{T}∈^{3}× ℝ^{3}- ●
p

_{e}_{−}:= (-1 0^{T}0^{T})^{T}∈^{3}× ℝ^{3}

In both scenarios, one shows that the following stability property is ensured with respect to different sets.

**Definition 1.** (Asymptotic Stability in the Large) [31]. Let χ ⊂ ℝ^{n} be given. The trivial solution x = 0 of ẋ = f(t, x) is called asymptotically stable in the large with respect to χ if it is stable in the sense of Lyapunov and every other solution x(t, t_{0}, x_{0}) → 0 as t → ∞ for any initial states, x_{0}∈ χ, and for any initial times, t_{0}∈ ℝ _{≥0}.

One considers that the state space of Equation (20) corresponds to either χ_{+} = {q_{e} ∈
^{3}|q_{e0} ∈ [0, 1]} × ℝ^{3} or χ_ = {q_{e} ∈
^{3}|q_{e0} ∈ [-1, 0]} × ℝ^{3}, depending on which target equilibrium is chosen.

**Proposition 1.** Assume that all trajectories with initial conditions, (
${{q}_{{e}_{o}}({t}_{0}){\overrightarrow{q}}_{e}^{T}({t}_{0}){\tilde{v}}^{T}({t}_{0}))}^{T}\in {\chi}_{+}$, satisfy sgn(q_{e0}(t)) = sgn(q_{e0}(t_{0})) ≥ 0 for all t > t_{0} (mutatis mutandis for χ_{–}). Then, the equilibrium point, p_{e}_{+} (respectively, the equilibrium point, p_{e}_{−}) of the system Equation (20) is asymptotically stable in the large with respect to χ_{+} (respectively, with respect to χ_{–}).

Proof. Consider the candidate Lyapunov function, V :
^{3} × ℝ^{3} → ℝ, which is proper and positive definite:

The derivative of Equation (21), together with Equation (20), is given by:

Thus, q⃗_{e}→ 0 and ṽ → 0 and, due to the normality condition, q_{e0} → 1. Hence, solutions of the system Equation (20) whose initial conditions are in χ_{+} converge asymptotically to p_{e}_{+} := (1 0^{T} 0^{T})^{T} . That concludes the proof.

**Remark 1.** In a practical context, one aims at improving the convergence speed of the observer. Since, physically, the set of equilibrium points,
:= {p_{e}_{+},p_{e}_{−}}, corresponds to the same attitude error, it is necessary to establish the desired equilibrium point to be achieved, depending on the given initial condition. This improvement can be ensured by choosing the equilibrium point corresponding to the sign of q_{e0}(t_{0}). The point, p_{e}_{+}, is chosen if q_{e0}(t_{0}) ≥ 0 and the point, p_{e}_{−}, otherwise. Then, a slight modification on the observer Equation (17) is done, obtaining

This fact can be shown adapting the proof of Proposition 1 using the following Lyapunov function instead:

#### 5. Passivity Interpretation of the Attitude Nonlinear Observer

**Lemma 2.** (Kalman-Yakubovich-Popov (KYP) lemma) Let Z(s) = C(sI – A)^{−1}B be a p × p transfer function matrix, where A is Hurwitz, (A, B) is controllable and (A, C) is observable. Then, Z(s) is strictly positive real (SPR) if and only if there exist a positive definite symmetric matrix P = P^{T} > 0 and Q = Q^{T} > 0, such that:

Since K_{2} is a scalar, the dynamics error Equation (20) for the bias observer can be written as:

Although the error system Equation (27) has no output, it is possible to define the following virtual output:

Using Equation (28), the error dynamics Equation (20) can be structured as the one shown in Figure 2.

**Proposition 2.** The transfer function matrix of the error system Equations (27) and (28) is SPR. That is, the mapping, q⃗_{e} → y⃗_{e}, satisfies the KYP lemma.

Proof. Since the matrix, –T^{−1}, is symmetric and a Hurwitz, one has for all Q symmetric positive definite matrices a P symmetric positive definite matrix, such that:

If the Q matrix is specified as Q = 2T^{−1}, one gets:

**Proposition 3.** The dynamics of the quaternion error, represented by the system,
_{1}, is state strictly passive.

Proof. Consider the candidate Lyapunov function, V_{q}, which is positive, definite and proper:

Analyzing for q_{e0} ≥ 0, the derivative of Equation (32) along the trajectories of q_{e} (Equation (20)), is given by:

Since q_{e0} ∈ [0, 1], one obtains:

**Theorem 1.** The attitude nonlinear observer Equation (17) is passive.

Proof. Propositions 2 and 3 establish that the systems,
_{2} and
_{1}, are SPR and state strictly passive, respectively. Since the two systems are connected in feedback (see Figure 2), the attitude nonlinear observer Equation (17) is passive.

## 6. Input to State Stability (ISS) of the Attitude Nonlinear Observer

Note that the convergence and the passivity interpretation of the observer were accomplished within a context free from noise and perturbation. However, the rate gyro measurements are corrupted by measurements noise and bias components that are time-varying. Owing to the nonlinearity of the observer, this type of disturbance can cause instability or even the finite time escape of the estimate.

In this section, the robustness of the proposed observer is discussed, which follows from passivity propriety. It will be shown that the error dynamics is input-to-state stable when the disturbances are viewed as the input and the error quaternion as the state.

In the case that noise is included, the error dynamics Equation (20) becomes:

This equation can be described as illustrated in Figure 3, where the inputs, d⃗_{1} and d⃗_{2}, are such that:

It is assumed that the noise components are bounded. That is:

However, neither the bounds nor the noise distribution are necessarily known.

**Proposition 4.** The system,
_{2}, is input-to-state stable (ISS) with respect to the input, d⃗_{2}. Then, the output of
_{2} (y⃗_{e} = K_{2}I_{3}ṽ) is always bounded.

Proof. Consider the second equation of the system Equation (37). Since the matrix, –T^{−1}, is a Hurwitz, one obtains:

_{0})‖

_{2},(t − t

_{0}) = e

^{−}

^{T}

^{−1(}

^{t}

^{−}

^{t}

^{0)}‖ṽ(t

_{0})‖

_{2}is a $\mathcal{L}$ function and ς

_{21}(‖q⃗

_{e}(s)‖

_{2}) = K

_{2}‖q⃗

_{e}(s)‖

_{2}and ς

_{2}(‖η⃗

_{v}(s)‖

_{2}) = ‖η⃗

_{v}(s)‖

_{2}are functions. Then, the bias estimation error, ṽ(t), is input-to-state stable, and the output y⃗

_{e}(y⃗

_{e}= K

_{2}I

_{3}ṽ) is always bounded.

**Proposition 5.** The system,
_{1}, is input-to-state stable with respect to d⃗_{2}.

The key to showing the ISS of the system,
_{1}, is the fact that a system is input-to-state stable if it admits an ISS-Lyapunov function. In this sense, a Lyapunov function will be proposed; then, it will be shown that this function is a ISS-Lyapunov function.

Proof. Consider the candidate Lyapunov function, V, which is proper and positive definite:

Analyzing for q_{e0} ≥ 0, the derivative of Equation (32) along the trajectories of q_{e} (Equation (37)) is given by:

_{e0}∈ [0,1], one obtains:

_{q}is proper ∃ α

_{1}, α

_{2}

_{∞}functions, such that:

Furthermore, α_{3} ((1 – q_{e0})^{2}) = K_{1}K_{2}((1 – q_{e0})^{2} and α_{3}((1−q_{e0})^{2} = K_{1}K_{2})((1−q_{e0})) are
_{∞} functions. Then, the Lyapunov function, V_{q}, is a ISS-Lyapunov function (see [27]), and this fact implies that the system,
_{1}, is ISS.

Since the system,
_{1}, is ISS, the following inequality is accomplished:

_{1}is a $\mathcal{L}$ function and ζ

_{12}(‖ṽ‖

_{2}) = K

_{2}‖ṽ‖

_{2}and ζ

_{1}(‖η⃗

_{G}‖

_{2}) = K

_{2}‖ η⃗

_{G}‖

_{2}are functions. That is, every trajectory of the attitude error dynamics asymptotically approaches a ball around the origin, whose radius is a function of supremum norm of the bias estimation error and of the measure noise of the rate gyro.

Using the interesting properties of ISS systems, the stability of the entire error dynamics is studied. Then, one has the following result.

**Theorem 2.** Let K_{2} be a positive constant, such that K_{2} < 1. Then, the attitude nonlinear observer is robust towards to measurement disturbance of the rate gyro.

Proof. The claim follows from the small gain theorem for the interconnection of nonlinear systems that are input-to-state stable [32]. The error dynamics of a nonlinear observer (Equation (37)) is composed of the feedback interconnection of the systems
_{1}-
_{2}). From Propositions 4 and 5, it follows that:

The composition of the functions, ς_{12} and ς_{21}, is given by:

Since K_{2} < 1, it follows that:

Then, the system (
_{1}-
_{2}) is ISS, when the measurements disturbances, η⃗_{G} and η⃗_{v}, are seen as the input and the error state, [q⃗_{e}^{T}ṽ^{T}]^{T}, as the state. This means that the attitude observer is robust with respect to measurement disturbance.

## 7. Experimental Results

The estimation methodology proposed in this work is implemented and evaluated in real time, in order to assess its effectiveness. For this purpose, an embedded system was designed and developed. Special attention was paid to the low power consumption requirements and weight, leading to the selection of the digital signal controller (DSC), dsPIC33FJ128MC802, which was used with a clock speed of 4 MHz. It contains extensive digital signal processor (DSP) functionality with a high performance, 16-bit microcontroller (MCU) architecture, but without a floating point unit. The sensor suite is based on a sensor board equipped with a tri-axis accelerometer (ADXL135), a dual axis gyro (LPR530AL), a single axis gyro (LY530ALH) and a tri-axis magnetometer (Micromag 3). All sensors outputs are analog, except for the Micromag 3, which is digital and uses the serial peripheral interface (SPI) bus system as the underlying physical communication layer. The aim was to test the DSC implementation with an update rate of the estimation of at least 55 Hz.

Furthermore, the system is equipped with a Bluetooth module (BlueSMiRF Silver), which provides wireless capabilities. The total system supply voltage is 3.3 V. The dimension and weight are 60 × 40 × 15 mm and 60 g, respectively. The system is depicted in Figures 4 and 5.

In order to experimentally evaluate the performance of the proposed AHRS, the experiments were carried out with a two degrees-of-freedom high accuracy system. Actually, this system is the Twin Rotor System [33] (see Figure 6). This system has two rotational joints, which allow for movement about two orthogonally axes with a resolution of 0.35° considered a true attitude for performance evaluation. In order to test the complete attitude estimation, two trials were carried out. In the first one, the axes,
${\overrightarrow{e}}_{1}^{b}$ and
${\overrightarrow{e}}_{3}^{b}$, of the AHRS coordinate frame (body coordinate frame
${\mathbf{\text{E}}}^{b}=[{\overrightarrow{e}}_{1}^{b},{\overrightarrow{e}}_{2}^{b},{\overrightarrow{e}}_{3}^{b}]$) coincide with the axes,
${\overrightarrow{e}}_{1}^{t}$ and
${\overrightarrow{e}}_{3}^{t}$, of the Twin Rotor System. Thus, θ (pitch) and Ψ (yaw) angles were evaluated. In order to evaluate the angle, Φ (roll), the AHRS was rotated π/2 about the axis,
${\overrightarrow{e}}_{1}^{b}$, such that
${\overrightarrow{e}}_{1}^{b}$ coincides with
${\overrightarrow{e}}_{1}^{t}$ and
${\overrightarrow{e}}_{2}^{b}$ with
${\overrightarrow{e}}_{3}^{t}$. Note that the attitude is estimated with respect to the inertial coordinate frame
${\mathbf{\text{E}}}^{f}=[{\overrightarrow{e}}_{1}^{f},{\overrightarrow{e}}_{2}^{f},{\overrightarrow{e}}_{3}^{f}]$. **E**^{f} is chosen to be the NED (north, east, down) coordinate frame. In this case, the reference vectors are the gravitational and magnetic vectors. The vector observations, i.e., the gravitational and magnetic vectors expressed in the body frame, **E**^{b}, are obtained from the mentioned tri-axis accelerometer and tri-axis magnetometer. The angular velocity is obtained from three rate gyros.

The attitude and gyro bias observer is implemented at 55 Hz using a fourth-order Runge-Kutta method, with tuning parameters, K_{1} = 3.2 and K_{2} = 0.9, such that the restriction of Theorem 2 is accomplished. No particular emphasis was given on the tuning process, since the resulting performance with these simple parameters is very acceptable. The attitude is maintained as a quaternion, which is normalized at each time step to compensate for numerical errors. After that, the quaternion is converted to Euler Angles, since they are more intuitive, and it allows for comparing with the angles obtained from the Twin Rotor System. For the entire experimentation time span, the vector v⃗_{f} = v⃗_{o} + v⃗_{r} was added to the vector of the rate gyro measurements, in order to test the ability to estimate and compensate for the rate gyro bias. In this case, one has v⃗_{o} = 0.1(1 – 1 1)^{T} and v⃗_{r} = 0.0001k(1 1 1)^{T}, where k represents the iteration index.

For the first trial, the initial condition for the quaternion estimate is q⃗(t_{0}) = (0.85 0.06 0.11 – 0.49)^{T}, i.e., (ϕ̂ = 0°, θ̂ = 15°, ψ̂ = −60°). For the second trial, the initial condition for the quaternion estimate is q̂(t_{0}) = (0.76 0 0 - 0.64)^{T}, i.e., (ϕ̂ = 0°, θ̂ = 0°, ψ̂ = −80°). In both cases, the rate gyro bias initial estimate was set to zero. The observer angle estimates are compared with the ones obtained from the encoders of the Twin Rotor System. In Figure 7, the evolution of θ (pitch) and Ψ (yaw) angles is depicted. Figure 8 shows the evolution of the second trial, i.e., Φ (roll) and Ψ (yaw) angles. Finally, the convergence of the rate gyros bias estimates is shown in Figure 9. These results indicate that the observer faces up to the slowly time-varying nature of the rate gyro biases.

It is worth mentioning that the algorithm itself uses only 81% of the 55 Hz cycle time. This is depicted in Figure 10. Finally, we invite the readers to watch the following video: https://www.dropbox.eom/s/r3pq57rwlf0pxuv/AttitudeObserver.mov.

## 8. Conclusions

This paper presented an original quaternion-based strategy for the attitude estimation of a rigid body equipped with angular velocity sensors and reference vector sensors. To accomplish the objective, a robust nonlinear observer for attitude estimation was developed. This observer ensures the asymptotic estimation convergence and local exponential estimation convergence. Furthermore, by means of an ISS analysis, it was shown that the observer is robust towards noise and the disturbance of the rate gyro sensors. Thus, an embedded AHRS was designed and developed. Experimental results were presented, where the AHRS outputs are compared with a two degrees-of-freedom high accuracy motion system. This illustrates the achievable performance of the proposed estimation schema.

The authors wish to thank W. Fermín Guerrero-Sánchez, Facultad Ciencias Físico-Matemáticas (BUAP), for providing us with the Twin Rotor System and for many valuable discussions. German Ardul Muñoz-Hernández wishes to thank the Instituto Tecnologico de Puebla, who supported him with a sabbatical year that made the participation in this work possible.

## Conflict of Interest

The authors declare no conflict of interest.

## References

- Wertz, J. Spacecraft Attitude Determination and Control; Kluwer Academic Publisher: Alphen aan den Rijn, The Netherlands, 1990. [Google Scholar]
- Roumeliotis, S.; Sukhatme, G.; Bekey, G. Smoother based 3D Attitude Estimation for Mobile Robot Localization. Proceedings of IEEE International Conference on Robotics and Automation (ICRA 1999), Detroit, MI, USA, 10–15 May 1999.
- Guerrero-Castellanos, J.; Marchand, N.; Hably, A.; Lesecq, S.; Delamare, J. Bounded attitude control of rigid bodies: Real-time experimentation to a quadrotor mini-helicopter. Control. Eng. Pract.
**2011**, 19, 790–797. [Google Scholar] - Hol, J.D.; Schn, T.B.; Gustafsson, F.; Slycke, P.J. Sensor Fusion for Augmented Reality. Proceedings of the 9th International Conference on Information Fusion (FUSION 2006), Florence, Italy, 10–13 July 2006.
- Luing, H.; Veltink, P. Measuring orientation of human body segments using gyroscopes and accelerometers. Med. Biol. Eng. Comput.
**2005**, 43, 273–281. [Google Scholar] - Mohammed, S.; Amirat, Y.; Rifai, H. Lower-limb movement assistance through wearable robots: State of the art and challenges. Adv. Robot.
**2012**, 26, 1–22. [Google Scholar] - Whaba, G. A least squares estimate of spacecraft attitude. SIAM Rev.
**1965**, 7, 409. [Google Scholar] - Shuster, M. A survey of attitude representations. J. Astronaut. Sci.
**1993**, 41, 439–517. [Google Scholar] - Guerrero-Castellanos, J.; Lesecq, S.; Marchand, N.; Delamare, J. A Low-Cost Air Data Attitude Heading Reference System for the Tourism Airplane Applications. Proceedings of 2005 IEEE Sensors, Irivine, CA, USA, 31 October–3 November 2005; pp. 1388–1391.
- Markley, F.; Crassidis, J.; Cheng, Y. Nonlinear Attitude Filtering Methods. Proceedings of Conference on AIAA Guidance, Navigation, and Control (GNC 2005), San Francisco, CA, USA, 15–18 August 2005.
- Bensançon, G. Nonlinear Observers and applications. In Control and Information Science 363; Springer-Verlag: Berlin, Germany, 2007. [Google Scholar]
- Gning, A.; Bonnifait, P. Constraints propagation techniques on intervals for a guaranteed localization using redundant data. Automatica
**2006**, 42, 1167–1175. [Google Scholar] - Salcudean, S. A globally convergent velocity obsever for rigid body motion. IEEE Trans. Autom. Control.
**1991**, 36, 1493–1497. [Google Scholar] - Thienel, J.; Sanner, R. A coupled nonlinear spacecraft attitude controller and observer with an unknown constant gyro bias and gyro noise. IEEE Trans. Autom. Control.
**2003**, 48, 2011–2014. [Google Scholar] - Vik, B.; Fossen, T. An Nonlinear Observer for GPS and INS Integration. Proceedings of 40th IEEE Conference on Decision and Control (CDC 2001), Orlando, FL, USA, 4–7 December 2001.
- Grip, H.; Fossen, T.; Johansen, T.; Saberi, A. Attitude estimation using biased gyro and vector measurements with time-varying reference vectors. IEEE Trans. Autom. Control.
**2012**, 57, 1332–1338. [Google Scholar] - Mahony, R.; Hamel, T.; Pflimlin, J. Complementary Filter Design on the Special Orthogonal Group SO(3). Proceedings of 44th IEEE Conference on Decision and Control and the European Control Conference (CDC-ECC 2005), Seville, Spain, 12–15 December 2005.
- Mahony, R.; Hamel, T. Intelligent Systems, Control, and Automation: Science and Engineering. In Advances in Unmanned Aerial Vehicles; Springer: Amsterdam, The Netherlands, 2007. [Google Scholar]
- Vasconcelos, J.F.; Silvestre, S.; Olveira, P. A Nonlinear Observer for Rigid Body Attitude Estimation Using Vector Observations. Proceedings of 2008 IFAC World Congress, Seoul, Korea, 6–11 July 2008; pp. 8599–8604.
- Vasconcelos, J.F.; Cunha, R.; Silvestre, S.; Olveira, P. Stability of a Nonlinear Attitude Observer on SO(3) with Nonideal Angular Velocity Measurements. Proceedings of European Control Conference (ECC 2009), Calgary, AB, Canada, 24–26 August 2009.
- Madinehi, N. Rigid Body Attitude Estimation: An Overview and Comparative Study. Ms.C Thesis, University of Western Ontario, London, ON, Canada, 2013. [Google Scholar]
- Tayebi, A.; Roberts, A.; Benallegue, A. Inertial vector measurements based velocity-free attitude stabilization. IEEE Trans. Autom. Control.
**2013**, 58, 2893–2898. [Google Scholar] - Shim, H.; Seo, J.; Teel, A. Nonlinear observer design via passivation of error dynamics. Automatica
**2003**, 39, 885–892. [Google Scholar] - Markley, F. Attitude determination using vector observations and the singular value decomposition. J. Astronaut. Sci.
**1988**, 38, 245–258. [Google Scholar] - Chou, J.; Kamel, M. Quaternion Approach to Solve the Kinematic Equation of Rotation, A
_{a}A_{x}= A_{z}Ab of A Sensor-Mounted Robotic Manipulator. Proceedings of IEEE International Conference on Robotics and Automation (ICRA 1998), Lueven, Belgium, 16–20 May 1998. - Barraud, A. Outils d'Analyse Numerique pour l'Automatique; Lavoisier: Paris, France, 2002. [Google Scholar]
- Sontag, E.; Wang, Y. On charactrization of the input-to-state stability property. Sys. Control. Lett.
**1995**, 24, 351–359. [Google Scholar] - Arcak, M.; Sontag, E. Passivity-Based Stability of Interconnection Structures. In Recent Advances in Learning and Control; Blondel, V., Boyd, S., Kimura, H., Eds.; Springer-Verlag: London, UK, 2008. [Google Scholar]
- Brown, R.; Hwang, P. Introduction to Random Signal and Applied Kalman Filtering; Wiley: New Work, NY, USA, 1997. [Google Scholar]
- Hartley, R.I.; Zisserman, A. Multiple View Geometry in Computer Vision, 2nd ed.; Cambridge University Press: Cambridge, UK, 2004. [Google Scholar]
- Schlanbusch, R.; Loria, A.; Nicklasson, P.J. On the stability and stabilization of quaternion equilibria of rigid bodies. Automatica
**2012**, 48, 3135–3141. [Google Scholar] - Jiang, Z.P.; Teel, A.; Praily, P. Small-gain theorems for ISS systems and applications. Math. Control. Signal Sys.
**1994**, 7, 104–130. [Google Scholar] - Feedback Instruments. Available online: http://www.feedback-instruments.com (accessed on 23 October 2013).

**Figure 1.**Block diagram of the nonlinear observer (⊗ quaternion multiplication, ⊗ matrix multiplication.)

**Figure 2.**Block diagram of the dynamics of attitude and bias error.

**Figure 3.**Block diagram of the dynamics of attitude and bias error with measurement disturbances.

**Figure 4.**Block diagram for the Attitude and Heading Reference System (AHRS) prototype.

**Figure 5.**The AHRS prototype.

**Figure 6.**Experimental setup.

**Figure 9.**Evolution of the rate gyro bias estimate.

**Figure 10.**Algorithm CPU usage.

© 2013 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/).