# Real-Time Indoor Positioning Approach Using iBeacons and Smartphone Sensors
## 3 Research Method
### PDR on Smartphone  
PDR is a lightweight independent positioning method which can provide continuous location estimates. It requires no specific indoor positioning infrastructure (e.g., BLE beacons or WiFi AP), but it needs an absolute location as initial state. Figure 2 shows the process of coordinate calculation of each step. The coordinates of location \(P_{k}\) is computed by a simple principle shown in Equation (13). Basically, three problems need to be solved for PDR: (1) count steps; (2) estimate stride length; and (3) detect orientation. We use a smartphone of Android operating system (Android phone in short) where sensor information are easily accessed. Three sensors are adopted for PDR computation, including gyroscope, accelerator, and magnetic sensor. As shown in Figure 3, these sensors refer to three rotations, i.e., \(X\)-Axis (Roll), \(Y\)-Axis (Pitch), and \(Z\)-Axis (Yaw). Android phone has provided a default approach to present orientation reading regarding the data of accelerometer and magnetic sensor. We employ this Android orientation in PDR computation. However, orientation error would accumulate fast due to the low accuracy of Android phone's sensors. Especially, heading orientation would vary sharply after turns. In this case, we adopt gyroscope to detect turning locations and separate a pedestrian's trajectory according to the turns. Given a starting point, PDR can be conducted by measuring the heading orientation and stride length at each step. Figure 2 and Equation (13) present this simple computation process. At the  
Figure 3: Axes of Android phone. Figure 2: Coordinate calculation of each step in PDR. step \(k\), its coordinates \((x_{k},y_{k})\) are the cumulative result of the previous \(k\)-\(I\) steps. In the following part, we introduce the means for step detection and orientation correction. \[ \begin{split} x_{k}&=x_{0}+\sum_{n=1}^{k}d_{n}sin \theta_{n}\\ y_{k}&=y_{0}+\sum_{n=1}^{k}d_{n}cos\theta_{n}\end{split}  \tag{13}\]  
Here, we leverage accelerometer in Android phone to count steps [25]. First, we compute the vector module of the readings in three directions of accelerometer (i.e., \(X\), \(Y\), and \(Z\)). All these module values form a waveform along with time (Figure 4). A step is detected by checking two peaks which meet the condition of time difference (e.g., longer than 0.2 s). Meanwhile, the difference between peak and valley should be greater than tolerance. To filter noises in the waveform, a peak is confirmed when the continuous raise is detected more than or equal to two times. Moreover, we adopt a simple but effective linear model to determine stride length [24]. The computational cost of this method is low and it is suitable for real-time positioning. In this model, we only need to fix the appropriate variables of \(a\) and \(b\), and then stride length \(L\) can be decided (Equation (14)). Here, the parameter \(f\) stands for the current step frequency. \[L=a*f+b \tag{14}\]  
The most important part for PDR is to obtain the correct orientation. According to Equation (13), correct direction ensures accurate coordinates. As mentioned above, the accuracy of orientation measurement is bound to smartphone sensors. Figure 5 gives an example of orientation deviation after a turn. Although the real-time orientation reading could vary sharply, in most cases, a pedestrian would walk in a relatively stable direction and pace before making turns. Thus, the user's current movement before the next turn is considered a linear motion. To distinguish the accumulative error of orientation, we divide a pedestrian's trajectory into linear motions according to turn locations. First, we detect turns by checking peaks and valleys in gyroscope data (Figure 6). We compute the modulus of each gyroscope reading vector (g\({}_{x}\), g\({}_{y}\), and g\({}_{z}\)), and locate the exceptional peaks representing the turns (see Figure 6). A tolerance is set for gyroscope data to detect accurate turn locations since there are always large angular rates at turn locations.