# A Real-Time GNSS/PDR Navigation System for Mobile Devices
## 2 Materials and Methods
### Methods
#### 2.2.3 Heading Estimation  
The heading angle is defined as the angle between the North direction and the motion direction of the person wearing the device. Estimating the motion direction is the most critical part of a pedestrian inertial navigation system due to the complexity of the body motion and the degrees of freedom of the human body. In fact, the walking motion, that can theoretically change at every single step, is not predictable. There are several ways to deal with this problem; for example, it is possible to fix the position of the inertial sensors in a rigid way at chest level or in a belt in order to be able to have a preferential direction of motion [14; 15]. This drastically reduces the degrees of freedom of the system, but represents a situation that cannot be reproduced in a common scenario, in fact a phone is normally kept in a pocket or held in the hand during a walk or in an armband for running. For this reason, a system that is independent of the choice of the device location on body is needed. The considered method, which will be described below, exploits the fact that the acceleration data reported in NED frame can be used to determine the direction of motion. Considering the phone worn on the upper part of the leg, then the acceleration values in the North and East directions are related to the direction of motion and can be used to determine the heading angle. As reported in [13], by analyzing the accelerations on the North and East axes in the NED frame (\(a_{N}(t)\) and \(a_{E}(t)\)) at each couples of steps, it is possible to identify pseudo-ellipses, as shown in Figure 6.  
Even if the shape of the double ellipse is not exactly reproduced at each pair of steps, it is still possible to determine the direction of the motion quite clearly within a tip-to-tail method, except in the case of irregular steps. This method is based on the direct use of the filtered acceleration data. Despite the implementation of the filter, it is possible that the signal is distorted by harmonics higher than that relating to the dynamics of the steps. The idea behind the real-time implementation of this method is to find a direct formula  
Figure 5: The vertical acceleration signal given to the PLL as input (orange line) and the signal provided by the PLL as output (blue line). that can provide the heading angle starting from the Fourier series decomposition of the input planar acceleration signal. It is well known from theory that any periodic signal can be decomposed into the sum of an infinite set of simple oscillating functions, namely sines and cosines. Though the walking signal is not periodic, however, if the period of the single step and consequently its frequency can be determined with some accuracy, it is possible to consider a periodic extension of this signal on which applying the Fourier series decomposition that is valid only in the considered step period. An accurate step tracking system using a PLL to analyze acceleration data can relate the steps taken with the stride characteristics, thereby providing a trigger signal for the forward direction estimation algorithm. The Fourier series at each single step detect is defined as:  
\[f_{k}(t)=\frac{\alpha_{0,k}}{2}+\sum_{n=1}^{\infty}\left[\alpha_{n,k}\cos \left(\frac{2\pi}{T_{k}}nt\right)+\beta_{n,k}\sin\left(\frac{2\pi}{T_{k}}nt \right)\right], \tag{6}\]  
where the subscript \(k\) identifies the number of the step occurred, \(T_{k}\) is the period of the last detected step that can be calculated as the time between the start of the step (\(t_{k-1}\)) and its end, that is also the start of the next step (\(t_{k}\)):  
\[T_{k}=t_{k}-t_{k-1}. \tag{7}\]  
\(\alpha_{0,k},\cdots,\alpha_{n,k}\) and \(\beta_{1,k},\cdots,\beta_{n,k}\) are the so called Fourier coefficients that are computed as follows:  
\[