# A Real-Time GNSS/PDR Navigation System for Mobile Devices
## 2 Materials and Methods
### Methods
#### 2.2.3 Heading Estimation
\begin{split}\alpha_{0,k}&=\frac{2}{T_{k}}\int_{0} ^{T_{k}}f_{k}(\tau)d\tau,\\ \alpha_{n,k}&=\frac{2}{T_{k}}\int_{0}^{T_{k}}f_{k}( \tau)\cos\left(\frac{2\pi}{T_{k}}nt\right)d\tau,\\ \beta_{n,k}&=\frac{2}{T_{k}}\int_{0}^{T_{k}}f_{k}( \tau)\sin\left(\frac{2\pi}{T_{k}}n\tau\right)d\tau,\end{split}  \tag{8}\]  
Figure 6: Representation of filtered \(a_{E}(t)\) and \(a_{N}(t)\) expressed in NED frame on the plane during a sequence of left and right steps  
where \(n\) is the number of harmonics considered for the approximation. With this method the direction estimate takes place considering only the time interval of the last step and not of the last two as for the previously described method. Let \(\mathbf{a}_{NE}(t)\) be the planar acceleration vector  
\[\mathbf{a}_{NE}(t)=a_{N}(t)\mathbf{i}+a_{E}(t)\mathbf{j} \tag{9}\]  
and considering the first harmonic of the corresponding Fourier series  
\[\mathbf{a}_{NE,k}^{1}(t)=\boldsymbol{\alpha}_{1,k}\cos(\omega_{k}t)+ \boldsymbol{\beta}_{1,k}\sin(\omega_{k}t)\,,\quad t\in(t_{k-1},t_{k}) \tag{10}\]  
where  
\[\omega_{k}=\frac{2\pi}{T_{k}}\,. \tag{11}\]  
It can be shown that Equation (10) represents an ellipse centered at the origin whose principle axis is rotated by a certain angle. Indeed, it is possible to rewrite (10) as  
\[ \begin{split}\mathbf{a}_{NE,k}^{1}(t)&=\left( \alpha_{N}\mathbf{i}^{NED}+\alpha_{E}\mathbf{j}\right)\cos(\omega_{k}t)+\left( \beta_{N}\mathbf{i}+\beta_{E}\mathbf{j}\right)\sin(\omega_{k}t)\\ &=\left(\alpha_{N}\cos(\omega_{k}t)+\beta_{N}\sin(\omega_{k}t) \right)\mathbf{i}+\left(\alpha_{E}\cos(\omega_{k}t)+\beta_{E}\sin(\omega_{k}t )\right)\mathbf{j},\end{split}  \tag{12}\]  
where the four values of integrals described in (8) become  
\[ \begin{split}\alpha_{N}&=\tfrac{2}{T_{k}}\int_{t_{ k-1}}^{t_{k}}a_{N}(\tau)\cos(\omega_{k}\tau)d\tau,\quad\alpha_{E}=\tfrac{2}{T_{k}} \int_{t_{k-1}}^{t_{k}}a_{E}(\tau)\cos(\omega_{k}\tau)d\tau,\\ \beta_{N}&=\tfrac{2}{T_{k}}\int_{t_{k-1}}^{t_{k}}a_{N }(\tau)\sin(\omega_{k}\tau)d\tau,\quad\beta_{E}=\tfrac{2}{T_{k}}\int_{t_{k-1} }^{t_{k}}a_{E}(\tau)\sin(\omega_{k}\tau)d\tau.\end{split}  \tag{13}\]  
Now the objective is to find a relationship between the four values of the integrals and the inclination angle of the rotated ellipse that represents the direction of motion. This problem can be solved under the following assumption (1 st order approximation):  
\[\left\{ \begin{aligned} a_{N}(t)&\approx\alpha_{N} \cos(\omega_{k}t)+\beta_{N}\sin(\omega_{k}t)\\ a_{E}(t)&\approx\alpha_{E}\cos(\omega_{k}t)+\beta_{E} \sin(\omega_{k}t)\end{aligned} \right. \tag{14}\]  
Referring to Figure 7, the goal is to find the point \(V(a_{N}(t^{*}),a_{E}(t^{*}))\), where \(t^{*}:\left\|\mathbf{a}_{NE}(t^{*})\right\|\geqslant\left\|\mathbf{a}_{NE}(t) \right\|\;\forall t\in(t_{k-1},t_{k})\,.\) To this aim, the square of the 2-norm of the planar acceleration can be approximated as  
\[ \begin{split}\left\|\mathbf{a}_{NE}(t)\right\|^{2}=a_{N}^{2}(t) +a_{E}^{2}(t)\approx&\alpha_{N}^{2}\cos^{2}(\omega_{k}t)+2\alpha _{N}\beta_{N}\cos(\omega_{k}t)\sin(\omega_{k}t)+\beta_{N}^{2}\sin^{2}(\omega_{ k}t)+\\ &+\alpha_{E}^{2}\cos^{2}(\omega_{k}t)+2\alpha_{E}\beta_{E}\cos( \omega_{k}t)\sin(\omega_{k}t)+\beta_{E}^{2}\sin^{2}(\omega_{k}t)\\ =&\big{(}\alpha_{N}^{2}+\alpha_{E}^{2}\big{)}\cos^{ 2}(\omega_{k}t)+2\big{(}\alpha_{N}\beta_{N}+\alpha_{E}\beta_{E}\big{)}\cos( \omega_{k}t)\sin(\omega_{k}t)+\\ &+\left(\beta_{N}^{2}+\beta_{E}^{2}\right)\sin^{2}(\omega_{k}t) \,.\end{split}  \tag{15}\]  
Finally, assuming  
\[ \begin{split} A&=\beta_{N}^{2}+\beta_{E}^{2}-\alpha _{N}^{2}-\alpha_{E}^{2}\\ B&=\alpha_{N}\beta_{N}+\alpha_{E}\beta_{E}\\ C&=\alpha_{N}^{2}+\alpha_{E}^{2}+\frac{1}{2}\left( \beta_{N}^{2}+\beta_{E}^{2}-\alpha_{N}^{2}-\alpha_{E}^{2}\right)\end{split}