**Abbreviations**

The following abbreviations are used in this manuscript:


#### **Appendix A. Sensor Unit Orientation Estimation**

The orientation estimation method in [40] combines orientation estimates based on two sources of information. The first estimate is obtained simply by integrating the gyroscope angular rate measurements. This estimate is accurate in the short term but drifts in the long term. The second relies on the direction of the gravity vector measured by the accelerometer and the magnetic field of the Earth detected by the magnetometer in the long term. For the long-term estimation, the Gauss-Newton method [40] is used to solve a minimization problem where the cost function decreases as the acquired acceleration vector is aligned with the gravity vector and as the acquired magnetic field vector is aligned with the magnetic North of the Earth. The short- and long-term estimates are combined through weighted averaging [40].

In the orientation estimation algorithm, we relate the sensor and the Earth frames by a quaternion **q**ˆ *n* = (*q*1, *q*2, *q*3, *q*4) *T* corresponding to the rotation matrix **R**ˆ *Sn E* = **R**ˆ *E Sn* −1 for all *n* as follows [50]:

$$\hat{\mathbf{R}}\_{E}^{S\_{n}} = \begin{bmatrix} q\_1^2 + q\_2^2 - q\_3^2 - q\_4^2 & 2 \left( q\_2 q\_3 - q\_1 q\_4 \right) & 2 \left( q\_1 q\_2 + q\_2 q\_4 \right) \\ 2 \left( q\_2 q\_3 + q\_1 q\_4 \right) & q\_1^2 - q\_2^2 + q\_3^2 - q\_4^2 & 2 \left( q\_3 q\_4 - q\_1 q\_2 \right) \\ 2 \left( q\_2 q\_4 - q\_1 q\_3 \right) & 2 \left( q\_1 q\_2 + q\_3 q\_4 \right) & q\_1^2 - q\_2^2 - q\_3^2 + q\_4^2 \end{bmatrix} \tag{A1}$$

The short- and long-term orientation estimates are denoted by **q**ˆ *n*, ST and **q**ˆ *n*, LT and the overall estimate is denoted by **q**ˆ *n*.

The short-term estimate of the sensor quaternion **q**ˆ *n*, ST at time sample *n* based on the overall estimate **q**ˆ *<sup>n</sup>*−1 at the previous time sample is given by:

$$\mathbf{\hat{q}}\_{n,\text{ST}} = \mathbf{\hat{q}}\_{n-1} + \Delta t \left(\frac{1}{2}\mathbf{\hat{q}}\_{n-1} \odot \mathbf{w}^S[n]\right) \tag{A2}$$

where ω*<sup>S</sup>*[*n*] = 0, *ωSx* [*n*], *ωSy* [*n*], *ωSz* [*n*]*<sup>T</sup>* is an augmented vector consisting of zero and the angular rate vector acquired by the gyroscope at time sample *n* [40] and Δ*t* is the sampling interval. Note that the equation involves feedback because **q**ˆ *n*, ST is calculated based on **q**ˆ *<sup>n</sup>*−1.

For the long-term estimation, let **a***<sup>S</sup>*[*n*] and **m***<sup>S</sup>*[*n*] be the acceleration and the magnetic field vectors, respectively, represented in the sensor frame and normalized by their magnitudes. To align **a***<sup>S</sup>*[*n*] with the *zE* axis of the Earth frame, we represent it in the Earth frame as **a***<sup>E</sup>*[*n*] = **q***n* ⊗ **a***<sup>S</sup>*[*n*] ⊗ **q**<sup>∗</sup>*n*, and solve the following minimization problem [40]:

$$\mathbf{\dot{q}}\_{\text{tr},\text{LT}:1} = \underset{\mathbf{q}\_{\text{tr}}}{\arg\min} \ \mathbf{f}\_{1}\left(\mathbf{q}\_{\text{tr}}, \mathbf{a}^{\text{S}}[n]\right) \quad \text{where} \quad \mathbf{f}\_{1}\left(\mathbf{q}\_{\text{tr}}, \mathbf{a}^{\text{S}}[n]\right) = \left\| \begin{pmatrix} 0 \ \mathbf{0} \ \mathbf{1} \end{pmatrix}^{T} - \mathbf{q}\_{\text{tr}} \otimes \mathbf{a}^{\text{S}}[n] \otimes \mathbf{q}\_{\text{tr}}^{\*} \right\| \tag{A3}$$

where · denotes the Euclidean norm and ⊗ denotes the quaternion product operator.

We represent the magnetic field vector **m***<sup>S</sup>*[*n*] as **m***<sup>E</sup>*[*n*] = **q***n* ⊗ **m***<sup>S</sup>*[*n*] ⊗ **q**∗*n* in the Earth frame and allow it to have only a vertical component along the *zE* direction and a horizontal component along the *xE* direction. Hence, we align **m***<sup>E</sup>*[*n*] with the magnetic reference vector defined as **<sup>m</sup>**0[*n*] - (*mEx* [*n*])<sup>2</sup> + (*mEy* [*n*])2, 0, *mEz* [*n*]*<sup>T</sup>* in the Earth frame by solving the following minimization problem [40]:

$$\mathbf{\dot{q}}\_{\text{tr},\text{LT}:2} = \underset{\mathbf{q}\_{\text{tr}}}{\text{arg}} \min \ \mathbf{f}\_{2}\left(\mathbf{q}\_{\text{tr}},\mathbf{m}^{\text{S}}[n]\right) \quad \text{where} \quad \mathbf{f}\_{2}\left(\mathbf{q}\_{\text{tr}},\mathbf{m}^{\text{S}}[n]\right) = \left\|\mathbf{m}\_{0}[n] - \mathbf{q}\_{\text{n}} \otimes \mathbf{m}^{\text{S}}[n] \otimes \mathbf{q}\_{\text{n}}^{\*}\right\| \tag{A4}$$

To simultaneously align the acceleration and magnetic field vectors, we combine the minimization problems defined in Equations (A3) and (A4) into one and solve the following joint minimization problem:

$$\mathbf{\dot{q}}\_{n,\text{LT}} = \underset{\mathbf{q}\_{\text{fl}}}{\text{arg min }} \mathbf{f} \left( \mathbf{q}\_{\text{fl}}, \mathbf{a}^{S}[n], \text{ } \mathbf{m}^{S}[n] \right) \tag{A5}$$

where the combined objective function is

$$\mathbf{f}\left(\mathbf{q}\_{n\prime}, \mathbf{a}^S[n], \mathbf{m}^S[n]\right) = \mathbf{f}\_1^2 \left(\mathbf{q}\_{n\prime}, \mathbf{a}^S[n]\right) + \mathbf{f}\_2^2 \left(\mathbf{q}\_{n\prime}, \mathbf{m}^S[n]\right) \tag{A6}$$

We use the Gauss-Newton method to solve the problem defined in Equation (A5) iteratively [40]. The quaternion at iteration *i* + 1 can be calculated based on the estimate at the *i*th iteration as follows:

$$\mathbf{q}\_{n,\rm LT}^{(i+1)} = \mathbf{q}\_{n,\rm LT}^{(i)} - \left(\mathbf{J}^T \mathbf{J}\right)^{-1} \mathbf{J}^T \mathbf{f}\left(\mathbf{q}\_{n,\rm LT'}^{(i)}, \mathbf{a}^S[n], \,\mathbf{m}^S[n]\right) \tag{A7}$$

where **J** is the 6 × 4 Jacobian matrix of **f** with respect to the elements of **q**(*i*) *n* . This matrix is provided in closed form in [40].

Finally, the short- and long-term estimates are merged by using weighted averaging [40]:

$$
\dot{\mathbf{q}}\_{\rm n} = \boldsymbol{\kappa} \dot{\mathbf{q}}\_{\rm n,ST} + (1 - \boldsymbol{\kappa}^{\circ}) \dot{\mathbf{q}}\_{\rm n,LT} \tag{A8}
$$

where the parameter K is selected as 0.98 as in [40]. The estimated quaternion **q**ˆ *n* represents the rotation matrix **R** ˆ *Sn E* compactly, where we drop the hat notation (ˆ) in the main text for simplicity.
