**1. Introduction**

Measuring head motion for medical diagnostics, virtual or augmented reality applications or human-machine collaboration usually involves multimodal sensorized interfaces to estimate motion and generate an appropriate control input for the desired application. In the context of human-machine collaboration and direct interaction with assistive technologies these interfaces are often designed to be used hands-free [1–3]. Such an interface needs to be precise, robust and fail safe. The research and development of new interaction technologies is in demand. A promising hands-free sensing modality involves Magnetic AngularRate Gravity (MARG)-sensors to estimate orientation of the operators head to interact with or teleoperate a robotic system [1]. In general MARG-sensors consist of a tri-axis accelerometer, tri-axis gyroscope as well as a tri-axis magnetometer. Such a sensor can also be termed inertial measurement unit (IMU) if it does not feature the tri-axis magnetometer. The orientation estimation from these sensors is based on the integration of the gyroscope raw angular rate data. This raw signal suffers from various noise terms that need to be taken care of, especially the dc-bias [4]. Even if the dc-bias of the gyroscope is set to zero at the MEMS-fab, there is a dc-bias that depends on sensor type, packaging and temperature, which in turn leads to a drift of the integrated gyroscope data [5]. This drift is usually corrected by the underlying data fusion process. Most common algorithms use the absolute references, direction of gravity and geomagnetic field to reduce orientation drift introduced through the gyroscope measurements [4,6]. The influence of permanent magnets, that is, hard iron effect, and magnetizable materials, that is, soft iron effect, in the direct neighborhood of the MARG-sensor will cause superpositions of the surrounding magnetic field. The distorted magnetic field can no longer be used to correct for dc-bias errors in the heading estimate (yaw-axis). During magnetic disturbances the MARG-sensor relies on gyroscope data only and will over time result in a drift in the heading estimate because of the accumulated errors if not corrected somehow [7,8].

This paper presents a novel approach to reduce heading estimation errors of head movement measurements by functional combination of mobile eye tracking and a head worn MARG-sensor. The approach utilizes the physiological connection between eye and head movements to identify static and dynamic motion phases. The eye tracking glasses are used to track visual fixations which indicate static phases. This indication is used for zero orientation change updates in a MARG-sensor data fusion algorithm. The approach relies on an infrared based eye camera only and does not need a scene or world camera and therefore no eye to world camera calibration. The presented approach is decoupled from most surrounding environmental conditions.

Human-robot collaboration in industrial production as well as rehabilitation robotics are applications that benefit from the proposed approach. These applications are mostly indoor and introduce potential magnetic interference at the location of the MARG-sensor. The work presented here not only enhances robustness of heading estimate of the head orientation measurements, it also presents a self-contained device mostly decoupled from varying visual markers and lightning conditions in the surrounding scenery.

#### *1.1. State of the Art in MARG Based Orientation Measurements*

Many algorithms exist to fulfill orientation estimation for head motion tracking. The Kalman filter has become the de facto standard for industrial and research applications [9,10]. However, various fast and lightweight data fusion methods for orientation estimation have been developed to reduce computational load while keeping orientation errors at a reasonable level. A famous method was introduced by Madgwick et al. in 2011 [11]. This method is based on the gradient descent algorithm and has gained popularity due to its fast and effective implementation on a microcontroller. Unfortunately MARG-sensors are exposed to magnetic field disturbance, termed soft- or hard-iron effects, resulting in incorrect orientation estimation [7]. This error scales with respect to the distance between the sensor and source of magnetic disturbance and magnetic properties of the source, for example, 35–50◦ error near large ferromagnetic metal objects or the floor (indoor) [12]. Recent approaches try to overcome these magnetic disturbances by software, for example, online gyroscope bias estimation [13] or fast online magnetometer calibration [14]. These software based corrections do not require additional hardware nor other sources of reference but might require certain motion conditions. For example online magnetometer calibration approaches are usually based on a sampling of sparse 3D magnetometer data points to adapt the calibration matrix, which might not be possible in every situation due to fast changing magnetic field values or the rather small motion space of the head. The use of other hardware, for example, visual odometry, usually provides a decent source of reference for the heading estimate but depends on the surrounding environmental conditions, for example, structured environment, reasonable lighting conditions and small relative motion in the scenery [15]. These conditions can not always be guaranteed especially in the context of human-machine collaboration which will feature a lot of relative motion from the robotic system and heavy dynamic magnetic disturbances due to the robots metal-links and motor-joints.

#### *1.2. State of the Art in Eye Tracking*

The analysis of the direction or the location of interest of a user through eye tracking is key for many applications in various fields, that is, human-computer interfaces (gaze mouse), human-machine interfaces, medical diagnostic and many more [16]. Therefore, fast and reliable eye tracking devices and software have been heavily researched [17]. Eye trackers can be separated into stationary or mobile devices. Stationary eye trackers are fixed in position referenced to the world frame. The devices' camera

observes the users eyes and maps the tracked gaze to a defined surface (e.g., screen monitor) [18]. Mobile devices on the other hand usually consist of a frame, that is worn like a pair of glasses, a mono- or binocular eye camera fixed to the frame monitoring the pupil and a world camera to merge calibrated pupil positions to a gaze point in the world frame [17]. Furthermore, modern mobile eye tracking devices either feature a MARG-sensor or an IMU-sensor or the eye tracker can be extended by a custom or third-party sensor board. In this work, we use a monocular mobile eye tracker that gained popularity in the research community over the past years due to the open source software and affordable pricing [19].

#### **2. Working Principle**

The proposed work is based on the physiological relationship between eye and head rotations during visual fixations of stationary objects. The eyes of a human are centered in a fixed axis of rotation inside the head and are therefore naturally affected by head rotations. Visual fixations of objects will result in small or nonsignificant rotation of the eyeball during stationary motion phases, see Figure 1a. A rotation of the head during visual fixation of a stationary object however, will result in an opposite rotation of the eyeball due to the vestibo-ocular reflex, stabilizing the visual scenery [20], see Figure 1b. The physiological relationship between head and eye rotations therefore represents a natural indicator for head rotation and can be used to support head orientation measurements.

A mobile eye tracker is used to measure the above mentioned relationship and utilize this indicator for MARG-sensor based head orientation measurements. The method assumes that the MARG-sensor is fixed in position with respect to the eye tracker frame, for example, attached to it. The mobile eye tracker is worn by the user and should be adjusted in a way that prevents heavy slippage during head motion, for example, through an eye wear strap which is common practice in mobile eye tracking. From the setup given in Figure 1, the following constraints can be derived.

The coordinate system of the mobile eye tracker and MARG-sensor share a common reference frame with the users head and rotate conjointly, see Figure 1. Every rotation of the head is directly coupled with the rotation of the eye-tracker frame and MARG- or IMU-sensor. This rotation will result in a change of the pupil position in the eye camera image. This is either due to a voluntary change in the visual fixation or a head movement. In contrast to head rotation based changes of the pupil position, a change of visual fixation is usually coupled with high angular velocity of the eyeball due to a significant pupil position change of consecutive eye camera images. If the visual target is moving while the head is stationary or the fixation changes to another visual target, there will be a significant change in pupil position, due to the given coordinate system setup. The eye tracker camera is in a fixed position with respect to the head coordinate system. If the eyes follow a moving target or switch the visual fixation the pupil position changes within consecutive frames because the target changes its position with respect to the head and eye tracker coordinate system. Changes in the pupil position will therefore always indicate motion, whether it is introduced through head motion or voluntary eye motion. Near zero changes in the pupil position between eye tracker camera images however indicate near zero head rotation with one possible exception from this assumption. If a visual fixation stays on a moving target while the head is rotating at the same rotational speed at which the target is moving, all local coordinate systems do keep their relative positions between each other. This would result in a no motion classification from the pupil position change criteria. In this kind of situation the pupil position does not change with respect to the eye tracker coordinate system since the head and target coordinate system do not change their relative positions and orientations between each other. A MARG- or IMU-sensor however does measure motion related to the world coordinate system and will therefore measure a change in the orientation between the world and eye tracker coordinate system. The rotational velocity of the motion, or in other words the change of orientation between coordinate systems, needs to exceed a minimum threshold to distinguish the motion from gyroscope noise during these special phases.

The approach presented here uses this pupil motion description under visual fixation of an object to reduce the drift effect at stationary phases and therefore improve the MARG-sensor based heading estimate. Since all local coordinate systems are in a fixed position towards each other, every simultaneous measured movement or motion is caused by head rotations. Every significat pupil position change indicates motion, either from head rotation or eye rotatation. Zero or no rotation however, is indicated by every visual fixation, independent of the total fixation time, that results in near zero change in the pupil position and angular velocity.

**Figure 1.** Coordinate systems between eye tracker, Magnetic AngularRate Gravity (MARG)-sensor and head when fixating an object (**a**) without and (**b**) with head motion. The condition of fixation of the object results in a stable gaze position. Possible motion of the pupil during fixations itself, so called microsaccades, is very small (0.2◦ at a duration of 20–30 ms) and can be neglected (yellow boundary box).

#### **3. Data Fusion Process**

In this work it is proposed to support MARG-sensor based heading estimates by zero rotation updates measured and indicated by visual fixation detection. The detection of visual fixation (given in subsection A) is used to feed the previous estimate of heading from the MARG-sensor fusion process (given in subsection B) recursively to the filter itself to reduce accumulation of gyroscope bias related heading errors. We calculate an IMU heading vector *N N IMU*,*k* based on the previous estimate of the heading that represents the direction of a horizontalized heading vector in the North East Down (NED) frame. This heading vector can be used as a complete substitute to the magnetometer based horizontalized north direction vector in the MARG-equation of an adapated form of Madgwick's Gradient Descent filter stage.

Synchronization of both systems is achieved through timestamp based message filtering. The data of the mobile eye tracker as well as the used MARG- or IMU-sensor should be accessible in real time by the manufacturers application programming interface (API) and provide a timestamp that can be used for synchronization processes, for example, using the message filter package from the robot operating system (ROS) framework. An angular rate threshold based switching can be either implemented on the MARG-sensor or host computer to account for possible latency issues between both systems. This threshold is based on the median head motion noise in static motion phases indicated by visual fixations. If the gyroscope raw signal exceeds the median noise level, the zero orientation update is turned off. This median noise threshold is also used to address the special case that the pupil position does not change while the head and eyes are following a moving target at the same rotational speed. During these special motions the magnitude of the measured angular rate will exceed the median gyroscope threshold which in turn disables the zero orientation update.

#### *3.1. Visual Zero Rotation Detection*

The trigger signal for the zero rotation update is based on an online visual fixation detection algorithm that utilizes dispersion (spatial movement, *thd*) and duration (*tht*) thresholds to identify fixations. These thresholds define the total amount of allowed gaze or pupil position differences ( Δ*p*) between time successive eye camera images ( Δ*t*). The algorithm utilizes a sliding window which length is determined by the duration threshold *tht* and sampling frequency. Dispersion *p* is calculated as the sum of the differences between consecutive pupil positions

$$
\Delta p = [(\max(\mathbf{x}) - \min(\mathbf{x}) + (\max(y) - \min(y))], \tag{1}
$$

where *x* and *y* are the eye tracker cameras pixel positions. The dispersion is compared to the maximum dispersion threshold *thd*. Fixations are identified as such if the dispersion stays below *thd*. This results in an expansion of the window to the right until the dispersion exceeds this threshold. If no fixation is detected the window does not expand but moves forward in time [21].

This kind of algorithm has proven to be very accurate and robust regarding online fixation identification but needs careful parameter setting [21]. While the visual fixation stays on a target and inside the dispersion threshold boundaries, the head is assumed to be stationary. The threshold parameter ratings for the magnitude of dispersion in time is given due to involuntary movement, for example, microsaccades and tremor. However, these involuntary movements usually consist of rather small duration in the range of 20–30 ms and amplitudes peaking in a visual angle of 0.2◦ [22]. The fixation detection parameters should be chosen in a way that fixations are still detected even in the presence of microsaccades and tremor. A fixation is identified and labeled as such, as soon as the fixation duration threshold is reached. Upon this a trigger signal (*St*) is emitted indicating a zero orientation update cycle for the MARG-sensor data fusion process.

$$S\_t = \begin{cases} 1, \,\Delta p \le th\_d \wedge \Delta t \le th\_l\\ 0 \end{cases} \tag{2}$$

The trigger starts an acquisition cycle that stores gyroscope raw data while the fixation holds true. When a sufficient amount of gyroscope samples has been recorded, updated motion noise parameters are sent to the MARG-sensor to update the threshold to account for desynchronization and latency issues between both systems and their different sampling rates. This procedure ensures adaptive and individual noise parameterization for the current user and use case and enables a real-time support.

#### *3.2. MARG-Sensor Datafusion*

In general the approach can be used independently of the underlying MARG-sensor data fusion process, since it indicates whether the users head is in dynamic or static motion phases. In this work, we exploit the approach on an adaptation of Madgwick's gradient descent algorithm (GDA) based filter. Figure 2 depicts the complete filter fusion approach that will be explained in detail in the following subsection.

As proposed by Madgwick et al. a quaternion *N B* **q** is computed by solving a minimization problem

$$\min\_{\substack{\mathcal{N}\neq\mathbf{q}\in\mathbb{R}^{4}\\ \mathcal{S}\neq\mathbf{q}\in\mathbb{R}^{4}}} f(^{N}\_{B}\mathbf{q}\_{\prime}\,^{N}d^{\prime}\_{\prime}\,^{B}\vec{s})\_{\prime} \tag{3}$$

that rotates a vector *Nd* into the orientation of a reference vector *<sup>B</sup>s*

$$f(\prescript{N}{B}{\mathbf{q}}\_{\prime}\prescript{N}{d}{\vec{d}}\_{\prime}\prescript{B}{\vec{s}}{\vec{s}}) = \prescript{N}{B}{\mathbf{q}}\_{\prime}\mathbf{q} \bullet \begin{pmatrix} 0\\ \prescript{N}{d}{d} \end{pmatrix} \bullet \prescript{N}{B}{\dot{\mathbf{q}}} - \begin{pmatrix} 0\\ \prescript{B}{\vec{s}}{\vec{s}} \end{pmatrix} \,\,\,\tag{4}$$

where *NB* denotes the orientation of the global navigation frame relative to the body frame and *NB* **q** is the four component quaternion

$$\mathbf{q}\_B^N \mathbf{q} = \begin{pmatrix} q\_1 & q\_2 & q\_3 & q\_4 \end{pmatrix}^T. \tag{5}$$

A possible solution to the optimization problem in Equation (3) can be given by gradient descent based solving for the obtained magnetometer and accelerometer vector measurements respectively

$$\mathbf{q}\_{B}^{N}\mathbf{q}\_{k+1} = \mathbf{^{N}\_{B}}\mathbf{q}\_{k} - \mu\_{t}\frac{\nabla f(\mathbf{^{N}\_{B}}\mathbf{q}\_{k'}\mathbf{^{N}\_{t}}\mathbf{^{B}}\mathbf{s})}{||\nabla f(\mathbf{^{N}\_{B}}\mathbf{q}\_{k'}\mathbf{^{N}\_{t}}\mathbf{d^{\prime}\_{t}}\mathbf{^{B}}\mathbf{s})||}, k = 0, 1, 2, \dots, n,\tag{6}$$

where *μt* denotes the stepsize of the gradient function. For a complete mathematical explanation of the filter see Reference [11] or Reference [8]. The GDA filter stage computes a complete quaternion *N B* **q***k* either based on gyroscope, magnetometer and accelerometer (MARG-case) or gyroscope and accelerometer only data (IMU-case). This is to reduce errors in the heading estimate from magnetic disturbances but requires two different sets of equations [8]. This is due to the missing magnetometer measurement vector in the IMU case set of equations and therefore needs an adapted objective function and Jacobian respectively.

**Figure 2.** Block diagram of the proposed fusion approach. Upon detection of a zero rotation update through the eye tracker (*St* = 1), the current orientation is used to define an inertial measurement unit (IMU) heading vector (*N N IMU*). This IMU heading vector will be updated with accelerometer measurements and fixed heading information as long as *St* = 1 is triggered and magnetic disturbance is present. If magnetic disturbance is present and the trigger is zero (*St* = 0) the IMU heading vector is iterativly updated. Switching between magnetometer based north direction vector (*N N m* )and IMU heading vector (*N N IMU*) is based on the deviation angle between both vectors.

In this work, we propose calculating an IMU heading vector that substitutes the magnetometer vector while magnetic disturbance is present to reduce the needed sets of equations as well as to guarantee convergence and a continuous quaternion solution to the minimization problem. We use the north direction vector *N N m* from the NED formulation through accelerometer and magnetometer measurements while no disturbance is present. The north direction vector is defined as the cross product between the down and east vector,

$${}^{N}\vec{N}\_{\rm m} = {}^{N}\vec{D} \times {}^{N}\vec{E},\tag{7}$$

where the down vector is defined as the inverse of the acceleration measurement vector (*<sup>B</sup>a*)

$${}^{N}\mathcal{D} = -{}^{B}\vec{a},\tag{8}$$

and the east vector is defined as the cross product between the down vector and the magnetometer measurement vector (*Bm* )

$${}^{N}\vec{E} = {}^{N}\vec{D} \times {}^{B}\vec{m}.\tag{9}$$

During rotation the acceleration vector will be subject to motion acceleration and therefore does not accurately reflect the direction of gravity. This effect however is typically reduced by low pass filtering the acceleration vector. Most modern sensors provide onboard low pass filter banks that can be configured by the user to the appropriate needs. Furthermore, the rotational accelerations will be rather small compared to the dominant acceleration originating from gravity. This is due to the small distance (in this case 0.1 m) between the rotational center of the head and the position of the MARG-sensor resulting in minor inaccuracies during dynamic motion. The influence of these incaccuracies during dynamic motion is further reduced by the subsequent data fusion filter. The data fusion filter usually does emphasize gyroscope data integration during fast dynamic motion to reduce inaccuracies from the motion acceleration on the orientation estimation.

We calculate a substitute to the north direction vector, termed IMU heading vector *N N IMU*, based on the orientation estimation from the gyroscope and accelerometer measurements. This is achieved through the following process.

We extract the heading information of the output quaternion *N B* **q***k* by calculating a three component vector ( *N N IMU*,*<sup>k</sup>*) describing heading information in the NED frame. First the heading information (yaw angle, *ψE*) from the quaternion *N B* **q***k* is converted to Euler angle representation

$$\begin{aligned} a &= (q\_{k,1}^{-2} + q\_{k,2}^{-2} - q\_{k,3}^{-2} - q\_{k,4}^{-2}) \\ b &= 2 \cdot (q\_{k,2} \cdot q\_{k,3} + q\_{k,1} \cdot q\_{k,4}) \\ \psi\_E &= \operatorname{atan2}(b, a) . \end{aligned} \tag{10}$$

When a zero rotation update is triggered, the fusion process samples the current output angle *ψE* from the last output quaternion *N B* **q***k* of the GDA filter stage and holds it while the trigger *St* is true. The subscript *E* indicates that the angle *ψ* is not updated if the sample and hold mechanism is activated. If the trigger signal is false, indicating head motion, the fusion process updates the angle *ψE* with every new output quaternion *N B***q***k*.

Second we convert the iterative updated roll (*φk*) and pitch (*θk*) angles derived from the current quaternion *N B* **q***k* by the following process

$$\begin{aligned} a &= 2 \cdot (q\_{k,3} \cdot q\_{k,4} + q\_{k,1} \cdot q\_{k,2}) \\ b &= (q\_{k,1}^2 - q\_{k,2}^2 - q\_{k,3}^2 + q\_{k,4}^2) \\ c &= 2 \cdot (q\_{k,2} \cdot q\_{k,4} + q\_{k,1} \cdot q\_{k,3}) \\ \Phi\_k &= a \tan 2(b, a) \\ \theta\_k &= a \sin(-c). \end{aligned} \tag{11}$$

From the yaw ( *ψE*) angle and the current roll (*φk*) and pitch (*θk*) angles we build a new temporary quaternion shown in Equation (12),

$$\begin{aligned}{}^{N}\_{B}\mathbf{q}\_{E,k} &= \begin{bmatrix} c(\frac{\Phi\_{k}}{2})c(\frac{\theta\_{k}}{2})c(\frac{\Psi\_{E}}{2}) + s(\frac{\Phi\_{k}}{2})s(\frac{\theta\_{k}}{2})s(\frac{\Psi\_{E}}{2}) \\ s(\frac{\Phi\_{k}}{2})c(\frac{\theta\_{k}}{2})c(\frac{\Psi\_{E}}{2}) - c(\frac{\Phi\_{k}}{2})s(\frac{\theta\_{k}}{2})s(\frac{\Psi\_{E}}{2}) \\ c(\frac{\Phi\_{k}}{2})s(\frac{\theta\_{k}}{2})c(\frac{\Psi\_{E}}{2}) + s(\frac{\Phi\_{k}}{2})c(\frac{\theta\_{k}}{2})s(\frac{\Psi\_{E}}{2}) \\ c(\frac{\Phi\_{k}}{2})c(\frac{\theta\_{k}}{2})s(\frac{\Psi\_{E}}{2}) - s(\frac{\Phi\_{k}}{2})s(\frac{\theta\_{k}}{2})c(\frac{\Psi\_{E}}{2}) \end{bmatrix} \tag{12}$$

where *c* and *s* are sine and cosine functions respectively.

This quaternion is now applied to a x-axis unit vector because the north direction vector defines the sensors body x-axis, resulting in

$$\begin{aligned} \vec{\mathbf{x}} &= \begin{pmatrix} 1 & 0 & 0 \end{pmatrix}^T\\ \bullet^N \vec{\chi}\_{IMIL,k} &=\_B^N \mathbf{q}\_{E,k} \bullet \begin{pmatrix} 0\\ \vec{\chi} \end{pmatrix} \bullet\_B^N \dot{\mathbf{q}}\_{E,k} \end{aligned} \tag{13}$$

where • indicates quaternion multiplication and **q**˙ represents the conjugate quaternion to **q**. The vector *N N IMU*,*k* now represents the direction as a substitute to the magnetometer based north direction vector in the NED frame, as can be seen in Figure 3.

**Figure 3.** Depiction of the north direction vector substitutes, (**a**) north direction vector, termed *N N m* from accelerometer (*<sup>B</sup>a*) and magnetometer (*Bm* ) measurements in the case of undisturbed magnetic field measurement, and (**b**) IMU heading vector, termed *N N IMU* calculated based on quaternion vector multiplication from the gradient descent algorithm (GDA) filter without magnetometer data in the case of disturbed magnetic field measurements.

Since the vectors *N N m* and *N N IMU* lie in the same plane it is possible to calculate a deviation angle () that can be used to determine magnetic disturbance due to sudden changes in the direction of the north direction vector in contrast to the IMU heading vector. The deviation angle is calculated as follows

$$\epsilon = \cos^{-1} \left( {}^N \vec{N}\_m \bullet {}^N \vec{N}\_{IMIL} \right) \, \tag{14}$$

where • represents the dot product respectively.

If magnetic disturbance is present, the deviation angle will increase. If it exceeds a threshold Δ*θ*, the filter switches towards the virtual sensor vector based quaternion calculation and vice versa if it vanishes. This procedure enables the calculation of a complete and continuous quaternion solution that involves current sensor measurements from the accelerometer and the extracted heading information from the previous quaternion. It is possible to use the same set of equations without any adaptation and switch from magnetometer based north direction vector to the IMU heading vector without divergence of the quaternion. While the zero rotation trigger is enabled, the fusion process holds the recent calculated yaw angle *ψ<sup>E</sup>*. This ensures that the GDA based calculation of the new quaternion *N B* **q***k* is less affected by possible drift in the heading direction due to uncorrected gyroscope bias but will however be corrected in the remaining axes through accelerometer updates and preserves a continuous solution and convergence. While no trigger is emitted, the fusion approach simply updates the measurement quaternion with every iteration based on either magnetic north direction vector when no disturbance is present or the IMU heading vector from the current orientation. It is known that Euler angle representation is subject to gimbal lock if two rotation axis align. This effect can be dealt with in two different ways. Either by designing the experiment in a way that does not include head rotations around the pitch exceeding ±90◦, which causes gimbal lockin the chosen rotation order (Z-Y-X), or by formulating a quaternion based heading orientation estimation method. The quaternion based solution can be found in the following paragraph.

The heading information (yaw angle, *ψE*) from the quaternion *N B* **q***k* is converted to a quaternion representing only the yaw rotation ( *N B* **<sup>q</sup>***ψ*,*<sup>E</sup>*) by deriving it from the corresponding Euler angle representation [23]. A unit quaternion representing heading information ( *N B* **<sup>q</sup>***ψ*) is expressed as a rotation *ψ* around the z-axis

$$\begin{array}{ll} \mathbf{q} = \begin{pmatrix} \cos(\psi/2) & 0 & 0 & \sin(\psi/2) \end{pmatrix}^{T} \end{array} \tag{15}$$
  $\begin{array}{ll} \mathbf{q}\_{B} = \frac{\mathbf{q}}{\|\mathbf{q}\|} \end{array} \tag{15}$ 

We can express the heading quaternion *N B* **q***ψ*,*<sup>E</sup>* without trigonometric functions by substituting the corresponding Euler angle Equation (10) with (15) and normalize it, resulting in

$$\begin{array}{llll} \mathbf{q} = \left( ((q\_{k,1}\,^2 + q\_{k,2}\,^2 - q\_{k,3}\,^2 - q\_{k,4}\,^2)) \quad 0 & 0 & \left( 2 \cdot (q\_{k,2} \cdot q\_{k,3} + q\_{k,1} \cdot q\_{k,4}) \right) \right)^T, \\\ \mathbf{q}\_B^N \mathbf{q}\_\psi = \frac{\mathbf{q}}{\|\mathbf{q}\|}. \end{array} \tag{16}$$

To ge<sup>t</sup> the half rotation angle from Equation (10) we add a unit quaternion and normalize the result

$$\begin{array}{l} \mathbf{q} =\_{B}^{N} \mathbf{q}\_{\psi} + \begin{pmatrix} 1 & 0 & 0 & 0 \end{pmatrix}^{T}, \\\ {}^{N}\_{B} \mathbf{q}\_{\psi,E} = \frac{\mathbf{q}}{\|\mathbf{q}\|}. \end{array} \tag{17}$$

Likewise, to the Euler angle solution the zero rotation update trigger samples the current output quaternion *N B* **q***ψ*,*<sup>E</sup>* from the last output quaternion *N B* **q***k* of the GDA filter stage and holds it while it is activated. If the trigger signal is deactivated, the fusion process updates the heading quaternion *N B* **q***ψ*,*<sup>E</sup>* with every new output quaternion *N B***q***k*.

We calculate a quaternion ( *N B* **<sup>q</sup>***φ*,*θ*,*<sup>k</sup>*) representing the iterative updated roll (*φk*) and pitch (*θk*) angles based on the current quaternion *N B* **q***k*. This is achieved by removing the yaw component of the current quaternion *N B* **q***k* through conjugate quaternion multiplication. We calculate a yaw quaternion *N B* **q***ψ*,*<sup>k</sup>* based on the Equation (16) and apply the conjugate to the current quaternion *N B* **q***k*

$$\mathbf{q}\_B^N \mathbf{q}\_{\phi,\theta,k} = ^N\_B \dot{\mathbf{q}}\_{\phi,k} \bullet ^N\_B \mathbf{q}\_{k\prime} \tag{18}$$

where • indicates quaternion multiplication and **q**˙ represents the conjugate quaternion to **q**.

The final quaternion *N B* **q***E*,*<sup>k</sup>* can be computed by combining the heading quaternion *N B* **q***ψ*,*<sup>E</sup>* and the iterative updated quaternion representing only roll and pitch *N B***q***φ*,*θ*,*<sup>k</sup>*through quaternion multiplication,

$$\mathbf{^N\_B}\mathbf{q}\_{E,k} = \mathbf{^N\_B}\mathbf{q}\_{\psi,E} \bullet \mathbf{^N\_B}\mathbf{q}\_{\phi\beta\,k}.\tag{19}$$

The quaternion *N B* **q***E*,*<sup>k</sup>* now represents a complete orientation expressed as quaternion and combines heading information from the sample and hold mechanism with current updates regarding roll and pitch information from the filter's output quaternion. This solution does not suffer from gimbal lock and can be used as the input quaternion to Equation (13). Both methods, Euler angle conversion or the complete quaternion based heading calculation, are valid and can be chosen based on the desired application and design of experiment.

## **4. Interface Setup**

We use a custom designed MARG-sensor board running the GDA based sensor data fusion on an Espressif 32 bit dual-core microcontroller unit (MCU). The sensor board features a low power 9-axis ICM 20948 InvenSense MARG-sensor, see Figure 4. The MCU is running the FreeRTOS realtime operating system on both cores at 1 kHz scheduler tick rate [24]. The standalone implementation is designed to simultaneous calculate orientation data from two copies of the data fusion process at 250 Hz, while their only difference is the active eye tracking trigger update. The two data fusion filters run in real time on the MCU and publish the two sets of fused orientation data and the calibrated 9-axis sensor data are at 100 Hz via micro-USB over UART. The sensor is attached via a custom casing to a low cost monocular eye tracker from Pupil Labs [19]. The tracker frame is secured via an eyewear strap on the users head. The eye tracker features 120 Hz frame rate of the eye tracking process at a resolution of 400 × 400 pixels. It is connected to a host computer running the Pupil Labs open source capture tool to acquire and preprocess the data as well as taking care of online fixation detection. The data are accessible in real-time through ZeroMQ. Two custom c++ ROS (Robot Operating System) nodes handle the synchronization and inter device communication. Synchronization between the MARG and eye tracking data is achieved through comparison of their corresponding timestamp upon arriving at the host system with a maximum lag of 3 ms between the timestamps. While fixation is true, the trigger signal is broadcasted to the MARG-sensor system indicating zero rotation. Furthermore, the trigger starts the gyroscope raw data capture process on the host computer. When the visual fixation is released the trigger is set to false which stops the gyroscope capture process as well as the zero orientation update cycle. The median gyroscope noise for stationary motion phases is sent to the MARG-sensor, when sufficient amount of data has been captured. To reduce latency impact on the orientation calculation, a movement threshold based on this median gyroscope noise is implemented on the MARG-sensor to ensure that the trigger will be set to false without latency drops or desynchronization.

**Figure 4.** Proposed head interface and custom designed MARG-sensor board. The head interface (**a**) consists of a pupil core headset, a passive IR-marker tree that is in line to the custom MARG-sensor board (**b**) which is attached to the eye tracker frame.

#### **5. Experimental Setup**

The accuracy of the proposed interface is benchmarked against a Qualisys motion capture system (Qualisys Miqus Camera M3, Qualisys AB, Kvarnbergsgatan 2, Göteborg, Sweden). The interface is worn by a user alongside a leightweight medium density fiberboard based rigid body passive IR-marker tree connected to the MARG-sensor casing, see Figure 4. The capture process of the Qualisys motion capture system broadcasts data at 120 Hz over a real-time client, allowing for timestamp based synchronization via the before mentioned ROS-nodes.The threshold Δ*θ* is chosen based on the 3 *σ* standard deviation of the north direction vector under static conditions for a short period of time (10 s). The first calculated north direction vector of this series is the initial vector. This initial vector is used to calculate the standard deviation of this series of deviation angles based on Equation (14). For the ICM20948 on the custom sensor board the threshold Δ*θ* results in 3◦. After a warm up phase, the magnetometer data is turned off to simulate a magnetically disturbed environment and examine the eye tracking supported zero orientation change trigger update mechanism as a proof of concept. The proof of concept of the proposed orientation estimation update mechanism can be provided either by using real magnetometer data or by turning off the magnetometer data measurement completely. A difference is not evident. This is due to the switching from north heading vector to IMU heading vector when a magnetic disturbance is present. In such a case magnetometer data is not used in the orientation estimation algorithm and is therefore not dependent on real magnetometer data input. Thus, we simulate disturbance by switching magnetometer data off to investigate the performance of the proposed data fusion during periods of non usable magnetometer input. To compare rotations, the coordinate system of the Qualisys data is transformed into the body coordinate frame of the MARG-sensor by calculating an alignment matrix from six stationary positions through least square method described in Reference [25]. The user is instructed to freely move his head and eyes with some static or no-rotation phases spanning between 2–5 s in duration. The total duration for one trial was limited to 15 min. A total of six trials was gathered for one individual user as a proof of concept for the proposed method. Visual fixation detection parameters were chosen based on experimental pretests that minimize latency drops when changing from stationary to dynamic head motion and were set to the following: *thd* = 0.21◦, and *tht* = 220 ms.

Two pretests were conducted to demonstrate the interchangeability of the north direction vector substitute calculations described in Section 3.2 and the filter's capability to detect interference based on the deviation angle . The three axis magnetometer was calibrated based on the process described in Reference [26]. The MARG-sensor is rotated arbitrarily in all dimensions. The tri-axis magnetometer data is sampled during this period. After recording the magnetometer data is calibrated through least square fitting of the ellipsoid data into a unit sphere and scaled to the surrounding field strength afterwards. During a 10 min warm up phase, the filter uses magnetometer data to converge towards the direction of magnetic north and gravity respectively. To demonstrate the interchangibility of the vectors we switch off the filter to use the IMU heading vector instead of the magnetometer based north direction vector and move the sensor arbitrarily for a short period of time (50 s). Both vector measurements are recorded throughout the trial. The second pretest covers the validation of magnetic interference detection and the switching from north to IMU heading vector. The sensor is set up according to the previous mentioned calibration and warm up routines. We record two sets of orientation: (a) The proposed filter with magnetic interference detection and switching and (b) the same filter without the switching mechanism. After 44 s an iron bar is brought close to the sensor (15 cm) to introduce magnetic interference.

#### **6. Results and Discussion**

In this work it is proposed to support MARG-sensor based heading estimates by zero rotation updates measured and indicated by visual fixation detection. An interchangeable north direction vector substitute is used for a gradient descent based orientation estimation. Section 6.1 gives an overview of the pretest to show the interchangeability of the heading vector substitutes calculation described in Section 3.2 whereas Section 6.2 the filters capability to detect magnetic disturbance and switch towards IMU heading vector. Section 6.3 presents the experimental results from the full fusion approach using visual fixations for zero rotation update.

#### *6.1. Interchangeable North Direction Vector Substitutes*

Figure 5 depicts normalized individual x-, y- and z-axis results for north direction vector *N N m* from calibrated magnetometer data through Equations (7)–(9) and the IMU heading vector *N N IMU* based on the process given by Equations (10)–(13). Both vectors show similar results during the whole trial with maximum deviations of ±0.1 normalized units. The north direction vector from magnetometer data has a larger spread of measurement values compared to the IMU heading vector. This originates from the different noise characteristics and computations of the vector components. The north direction vector is directly calculated from raw accelerometer and magnetometer data and will directly reflect raw sensor noise, whereas the IMU heading vector is based on smoothed quaternion fusion from gyroscope and accelerometer readings from the GDA filter. The noise spreading level, however, does stay at a reasonable level during the trial. This pretest shows the interchangeability of the different north direction vector substitutes which guarantees a continuous quaternion solution and convergence of the filter.

**Figure 5.** Comparison between (**a**) magnetometer based normalized x-axis north direction vector and normalized x-axis IMU heading vector, (**b**) magnetometer based normalized y-axis north direction vector and normalized y-axis IMU heading vector and (**c**) magnetometer based normalized z-axis north direction vector and normalized z-axis IMU heading vector.

The IMU heading vector will drift apart from the north direction vector with respect to time. This is due to uncorrected gyroscope biasresulting in drift in the heading estimate of the quaternion used for determining the IMU heading vector. For short periods of time and under the same initial conditions however both vectors are almost identical. The length of the time period in which both vectors are mostly identical depends on the individual noise characteristics of the used gyroscope and computational errors from the discrete implementation. High grade navigation gyroscopes will experience less drift compared to consumer based gyroscopes used in this work. The maximum time before gyroscope errors accumulate more than 1◦ drift in the heading estimate is 50 s for the custom MARG-sensor board used in this work.

#### *6.2. Magnetic Disturbance Detection*

Figure 6 depicts yaw angle results as well as the corresponding yaw angle errors for the magnetic disturbance detection and switching from north direction to IMU heading vector based on Equation (14). The Figure 6a presents three different yaw angle estimations over time: ground truth yaw data (Qualisys, yellow), yaw estimations from the proposed filter with deviation detection and heading vector substitutes ( *ME*, blue) as well as yaw estimations of a version of the filter without heading vector switching ( *MO*, orange). The figure also presents values for the magnetic deviation angle (black) over time. Figure 6b presents the corresponding yaw angle errors referenced to the ground truth yaw data. Magnetic disturbance is introduced for a short period of time starting at 44 s and ending at 66 s by bringing an iron bar close to the sensor (15 cm).

**Figure 6.** Influence of magnetic disturbance on yaw angle estimation: (**a**) yaw angle comparisons between ground truth (Qualisys, yellow), the proposed filter with magnetic disturbance detection and heading vector substitute switching ( *ME*, blue), a filter version without heading vector switching (*MO*, orange) as well as the magnetic deviation angle (black). (**b**) depicts the corresponding heading error referenced to the Qualisys system. Magnetic interference is introduced for a short period of time (43 s to 66 s) by bringing and iron bar close to the MARG-sensor. The proposed filter detects the interference and switches towards IMU heading vector usage resulting in less error.

The proposed filter ( *ME*) detects the disturbance when it is introduced because the deviation angle exceeds the threshold Δ*θ*, see Figure 6a. The filter switches towards IMU heading vector substitute and is not affected by the disturbance, resulting in a maximum error of 2◦ during this phase. In contrast, the filter without switching mechanism experiences large yaw angle erros and results in up to 17◦ total error (see Figure 6b). This pretest demonstrates the filters capability of magnetic disturbance detection based on the deviation angle calculation between north direction and IMU heading vector. After the filter detects a disturbance it uses the IMU heading vector for orientation estimation. In this mode the filter furthermore enables visual zero rotation updates mechanism to reduce heading error accumulation over time.

#### *6.3. MARG-Sensor Data Fusion Approach Using Visual Fixations*

Figure 7 shows typical data for yaw angle measurements from a 30 s sequence of one 900 s trial. The yaw angles are presented in degrees over time in seconds. The figure depicts yaw angle estimation data from the ground truth motion capture system (Qualisys system, yellow), the proposed ( *ME*, blue) and standard version ( *MO*, orange) of the data fusion process. The visual fixation trigger state *St* is presented in purple. During visual fixation phases (*St*, purple) the proposed eye tracking supported version *ME* does drift less compared to the standard implementation *MO*. In dynamic motion phases both filter versions do accumulate the same amount of drift.

**Figure 7.** Typical yaw angle measurements for a motion sequence from the Qualisys system (yellow), the proposed ( *ME*, blue) and standard version ( *MO*, orange) of the data fusion. During stationary motion, the trigger signal *St* (purple) is set to high and indicates zero orientation change.

The performance of the proposed approach for the heading estimation is presented as total Euler angle error (degrees see Figure 8) as well as mean error reduction rate (*<sup>e</sup>ψ*, unitless see Table 1). The total Euler angle errors are calculated as the difference between the ground truth of absolute orientation from the Qualisys system and the orientation estimation of the proposed ( *ME*) and standard version (*MO*) of the data fusion process (see Figure 7). The dashed black line indicates the reference for zero heading error. Figure 8 presents two sets of Euler angle errors in degrees over time for the complete 900 s duration of two different trials. At the start of the trial the eye tracking supported version of the filter ( *ME*, blue) as well as the standard GDA filter ( *MO*, orange) perform identical. During dynamic phases both filters accumulate the same amount of error due to uncorrected gyroscope bias. However, when stationary phases are indicated and the trigger signal *St* is enabled, the eye tracker supported GDA filter version accumulates less gyroscope drift in contrast to the standard implementation, see Figure 8. This effect covers the entire duration of the trials. The orientation estimation errors rise significantly over time for both solution. The GDA based approach with eye tracking based zero orientation change update results in nearly 50% less absolute orientation, see Figure 8.

The mean error reduction rate *<sup>e</sup>ψ* and its standard deviation is calculated based on the absolute error quotient between the proposed (*ME*) and standard version (*MO*) of the fusion process at 900 s. Table 1 presents total Euler angle errors from six different trials for the proposed (*ME*) and standard version (*MO*) of the fusion after 900 s and the calculated error reduction rate. On average, the eye tracking supported GDA filter approach accumulates near 50% less orientation error (0.46 ± 0.07) compared to the GDA filter without eye tracking data support, see Table 1.

**Figure 8.** Typical results for absolute heading error referenced to the Qualisys system from the GDA based approach with (*ME*, blue) and without eye tracking (*MO*, orange) support for two different trials. The eye tracking supported filter results in (**a**) a total of 18.84◦ error whereas the standard version results in 32.76◦ and (**b**) in a total of 8.82◦ error for the eye tracking supported version whereas the standard version results in 22.55◦.

**Table 1.** Absolute error values and error reduction rate (*<sup>e</sup>ψ*) for the GDA based data fusion with (*ME*) and without eye tracking (*MO*) support after 900 s.

