# Heading Estimation with Real-time Compensation Based on Kalman Filter Algorithm for an Indoor Positioning System

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Error Analysis of Orientation Sensing Data

## 3. Real-Time Heading Correction Algorithm

_{i}captured form phone are transformed from the Body frame (B) into the Navigation frame (N) using the rotation matrix: $ac{c}_{i}^{N}={R}_{B\to N}\xb7ac{c}_{i}^{B}$, as the Figure 2 shows, the coordinate system of the pedestrian's mobile phone is B-frame, and the coordinate system of the pedestrian's walking plane is Navigation frame; then, computing the accelerometer magnitude: $acc\_mag=\sqrt{acc{X}^{2}+acc{Y}^{2}+acc{Z}^{2}}$, where accX, accY and accZ are the tri-axis acceleration in the navigation frame after removing the influence of gravity. And then the value of $acc\_mag$ is used as the gait detection. The FIR filter algorithm [16] is utilized to implement the low-pass filter-based gait detection method according to the peaks and valleys. The step length calculation formula is ${L}_{k}=K\xb7\sqrt[4]{ac{c}_{max}-ac{c}_{min}}$ [17], where ${L}_{k}$ is the the ${k}^{th}$ step length. The coefficient K can be calibrated for different walking styles. $ac{c}_{max}$ and $ac{c}_{min}$ are the minimum and maximum amplitudes of the acceleration. The direction of walk can be calculated through the fusion of magnetic meter, accelerometer and gyroscope. Finally, the pedestrians can be positioned by formula (5),

#### 3.1. Map-Aided Heading Correction

#### 3.2. Heading Error Correction Based on Least Square

#### 3.3. Real Time Heading Compensation Based on Kalman Filter

## 4. Experiment

#### 4.1. Analysis of Heading Error

#### 4.2. PDR-Based Positioning Trajectory Analysis

#### 4.3. Comprehensive Error Analysis Based on the Four PDR Algorithms.

## 5. Conclusions

## Acknowledgments

## Author Contributions

## Conflicts of Interest

## Appendix

Algorithm 1. [sigma, heading] = heading_estimation (FP_Ori, ori, Sgyr). |

Input:
FP_Ori: building geometric direction; ori: the original heading value; Sgyr: Gyro value of Z axis accumulated between a step. |

Output:
heading: Heading value calculated |

1. i = 0; j = 1; flg_Turn = 0; count_T = 0; X = []; Ori_para = [] |

2. Take the direction value of current gait, i++ |

3. If i = 1 |

4. heading(i) = ori(i); sigma(i) = 1000 |

5. If Sgyr(i) < 10 |

6. flg_Turn = 0; Ori_para(j) = ori(i); j = j + 1 |

7. Else |

8. flg_Turn = i; count_T = count_T + 1 |

9. End |

10. Else |

11. flg_gyr = Sgyr(i) * Sgyr(i-1); |

12. If flg_gyr > 0 && abs(Sgyr(i)) > 10 |

13. flg_Turn = i; count_T = count_T + 1;sigma(i) = 1000; heading(i) = ori(i); |

14.
If count_T > 1 |

15. X = []; Ori_para = []; j = 1; |

16. End |

17. Else |

18. flg_Line = i; |

19. If (flg_Turn==0||(count_T > 1)) &&(flg_Line - flg_Turn)>0 &&(flg_Line - flg_Turn)<10 |

20. Ori_para(j) = ori(i); j = j + 1; |

21. If length(Ori_para)>=9 |

22. er_Ori = abs(FP_Ori - mean_Ori_para); [miner_Ori,dex] = min(er_Ori); |

23. If miner_Ori < 15 |

24. flg_KF = 1; Z = zeros(length(Ori_para),1); ori_dex = FP_Ori(dex); |

25. For im = 1:length(Ori_para) |

26. Z(im) = FP_Ori(dex) - Ori_para(im); |

27. End |

28. Else |

29. flg_KF = 0; |

30. End |

31. If flg_KF == 1 |

32. [H, P, R] = Get_Para(Ori_para); |

33. X = Heading_Para(H, P, R, Z); |

34. End |

35. Ori_para = []; |

36. j = 1; |

37. End //line 21 |

38. End /line 19 |

39. If ~isempty(X) |

40. sigma(i) = X(1) + X(2)*sin(ori(i)*(pi/180)) + X(3)*cos(ori(i)*(pi/180)) + X(4)*sin(2*ori(i)*(pi/180)) + X(5)*cos(2*ori(i)); |

41. heading(i) = ori(i) + sigma(i); |

42. Else |

43. heading(i) = ori(i);sigma(i) = 1000; |

44. End |

45. End //line 10 |

46. End //line 3 |

47. Goto 2 |

## References

- Chintalapudi, K.; Padmanabha Iyer, A.; Padmanabhan, V.N. Indoor localization without the pain. In Proceedings of the Sixteenth Annual International Conference on Mobile Computing and Networking, Chicago, IL, USA, 20–24 September 2010; pp. 173–184.
- Shum, K.C.Y.; Cheng, Q.J.; Ng, J.K.Y.; Ng, D. A signal strength based location estimation algorithm within a wireless network. In Proceedings of the IEEE International Conference Advanced Information Networking and Applications (AINA), Singapore, Singapore, 22–25 March 2011; pp. 509–516.
- Afzal, H.; Renaudin, V.; Lachapelle, G. Assessment of indoor magnetic field anomalies using multiple magnetometers. In Proceedings of the 23rd International Technical Meeting of The Satellite Division of the Institute of Navigation, ION GNSS10, Portland, OR, USA, 21–24 September 2010; pp. 1–9.
- Li, X.; Wang, J.; Liu, C.; Zhang, L.; Li, Z. Integrated WiFi/PDR/Smartphone using an adaptive system noise extended Kalman filter algorithm for indoor localization. Int. J. Geo-Inf.
**2016**, 5. [Google Scholar] [CrossRef] - Zhang, B.; Teng, J.; Zhu, J.; Li, X. Ev-loc: Integrating electronic and visual signals for accurate localization. In Proceedings of the Thirteenth ACM International Symposium on Mobile Ad Hoc Networking and Computing, Hilton Head, SC, USA, 11–14 June 2012; pp. 25–34.
- Gusenbauer, D.; Isert, C.; Krösche, J. Self-contained indoor positioning on off-the-shelf mobile devices. In Proceedings of the Indoor Positioning and Indoor Navigation (IPIN), Zurich, Switzerland, 15–17 September 2010; pp. 1–9.
- Robertson, P.; Angermann, M.; Krach, B. Simultaneous localization and mapping for pedestrians using only foot-mounted inertial sensors. In Proceedings of the 11th International Conference on Ubiquitous Computing, Orlando, FL, USA, 30 September–3 October 2009; pp. 93–96.
- Kang, W.; Korea, D.; Nam, S.; Han, Y.; Le, S. Improved heading estimation for smartphone-based indoor positioning systems. In Proceeding of the 2012 IEEE 23rd International Symposium on Personal Indoor and Mobile Radio Communications (PIMRC), Sydney, Australia, 9–12 September 2012; pp. 2449–2453.
- Roetenberg, D.; Luinge, H.J.; Baten, C.T.; Veltink, P.H. Compensation of magnetic disturbances improves inertial and magnetic sensing of human body segment orientation. IEEE Trans. Neural Syst. Rehabil. Eng.
**2005**, 13, 395–405. [Google Scholar] [CrossRef] [PubMed] - Zhang, R.; Reindl, L.M. Inertial localization system using unscented kalman filter for 3D positioning. In Proceedings of the 2011 4th International Congress on Image and Signal Processing (CISP), Shanghai, China, 15–17 October 2011; pp. 2669–2673.
- Borenstein, J.; Ojed, L. Heuristic drift elimination for personnel tracking systems. J. Naivgation
**2010**, 63, 591–606. [Google Scholar] [CrossRef] - Vasconcelos, J. F.; Elkaim, G.; Silvestre, C.; Oliveira, P. A geometric approach to strapdown magnetometer calibration in sensor frame. Navigation Guid. Control Underw. Veh.
**2008**, 2, 1–11. [Google Scholar] [CrossRef] - Chen, W.; Chen, R.; Chen, Y.; Kuusniemi, H.; Wang, J.; Fu, Z. An Adaptive Calibration Approach for a 2-Axis Digital Compass in a Low-Cost Pedestrian Navigation. In Proceedings of the IEEE International Instrumentation and Measurement Technology Conference (I2MTC), Austin, TX, USA, 3–6 May 2010; pp. 1392–1397.
- Jiménez, A.R.; Zampella, F.; Seco, F. Improving inertial pedestrian dead-reckoning by detecting unmodified switched-on lamps in buildings. Sensors
**2014**, 14, 731–769. [Google Scholar] [CrossRef] [PubMed] - Chen, W.; Chen, R.; Chen, Y.; Kuusniemi, H.; Wang, J.; Fu, Z. An effective pedestrian dead reckoning algorithm using a unified heading error model. In Proceedings of the IEEE/ION Position, Location and Navigation Symposium (PLANS) 2010, Indian Wells, CA, USA, 4–6 May 2010; pp. 340–347.
- Li, F.; Zhao, C.; Ding, G.; Gong, J.; Liu, C.; Zhao, F. A reliable and accurate indoor localization method using phone inertial sensors. In Proceedings of the 2012 ACM Conference on Ubiquitous Computing, Pittsburgh, PA, USA, 5–8 September 2012; pp. 421–430.
- Fang, S.H.; Lin, T.N. Indoor location system based on discriminant-adaptive neural network in IEEE 802.11 environments. IEEE Trans. Neural Netw.
**2008**, 19, 1973–1978. [Google Scholar] [CrossRef] [PubMed]

**Figure 2.**Measurement setup. (

**a**) Illustration of the two coordinate systems; (

**b**) Test subject holding a phone.

**Figure 13.**Analysis on positioning trajectory (rectangular corridor on the 3rd floor) for four methods Standard deviation of the positioning error and root mean square deviation of the positioning results were recorded for three groups of experiments.

Mean Error (Degrees) | Max. Error (Degrees) | Min. Error (Degrees) | |||||||
---|---|---|---|---|---|---|---|---|---|

OHD | LHD | KHD | OHD | LHD | KHD | OHD | LHD | KHD | |

125° | 16.34 | 6.08 | 5.95 | 27.12 | 11.21 | 8.32 | 0.75 | 0.68 | 0.25 |

90° | 7.89 | 4.56 | 1.25 | 13.23 | 12.15 | 3.12 | 0.56 | 0.23 | 0 |

0° | 13.12 | 7.25 | 2.23 | 25.36 | 21.25 | 5.24 | 0.25 | 0.19 | 0 |

270° | 8.39 | 6.56 | 4.87 | 32.25 | 31.56 | 28.96 | 0.35 | 0.18 | 0.12 |

OHPDR | GEPDR | LSMPDR | KFPDR | |
---|---|---|---|---|

Mini. error/m | 2.56 | 2.16 | 2.34 | 0.32 |

Mean error/m | 12.03 | 3.52 | 4.43 | 2.31 |

Max. error/m | 22.67 | 5.27 | 5.97 | 3.84 |

**Table 3.**Positioning analysis for different solutions associated with PDR in rectangular corridor on the 3rd floor.

OHPDR | GHPDR | LSMPDR | KFPDR | |||||
---|---|---|---|---|---|---|---|---|

STDE/m | RMSE/m | STDE/m | RMSE/m | STDE/m | RMSE/m | STDE/m | RMSE/m | |

1 | 0.794 | 18.21 | 0.044 | 2.68 | 0.114 | 6.35 | 0.047 | 2.63 |

2 | 0.745 | 17.43 | 0.035 | 2.55 | 0.107 | 6.26 | 0.043 | 2.54 |

3 | 0.763 | 17.39 | 0.039 | 2.66 | 0.098 | 6.07 | 0.042 | 2.57 |

4 | 0.729 | 17.24 | 0.032 | 2.49 | 0.086 | 5.94 | 0.036 | 2.44 |

5 | 0.736 | 17.35 | 0.037 | 2.52 | 0.099 | 6.09 | 0.045 | 2.59 |

6 | 0.785 | 18.01 | 0.042 | 2.62 | 0.109 | 6.32 | 0.046 | 2.60 |

**Table 4.**Positioning analysis for different solutions associated with PDR in B–C area on the 5th floor.

OHPDR | GHPDR | LSMPDR | KFPDR | |||||
---|---|---|---|---|---|---|---|---|

STDE/m | RMSE/m | STDE/m | RMSE/m | STDE/m | RMSE/m | STDE/m | RMSE/m | |

1 | 0.643 | 14.86 | 0.022 | 2.35 | 0.104 | 5.75 | 0.036 | 2.38 |

2 | 0.617 | 14.42 | 0.024 | 2.22 | 0.098 | 5.48 | 0.024 | 2.02 |

3 | 0.627 | 14.52 | 0.028 | 2.29 | 0.099 | 5.65 | 0.036 | 2.28 |

4 | 0.618 | 14.39 | 0.023 | 1.99 | 0.094 | 5.37 | 0.024 | 1.99 |

5 | 0.632 | 14.56 | 0.025 | 2.31 | 0.098 | 5.47 | 0.026 | 2.03 |

6 | 0.638 | 14.65 | 0.029 | 2.32 | 0.102 | 5.68 | 0.034 | 2.36 |

**Table 5.**Positioning analysis for different solutions associated with PDR in C-B area on the 5th floor.

OHPDR | GHPDR | LSMPDR | KFPDR | |||||
---|---|---|---|---|---|---|---|---|

STDE/m | RMSE/m | STDE/m | RMSE/m | STDE/m | RMSE/m | STDE/m | RMSE/m | |

1 | 0.534 | 13.39 | 0.032 | 3.67 | 0.094 | 4.66 | 0.038 | 2.47 |

2 | 0.529 | 12.99 | 0.028 | 3.64 | 0.087 | 4.63 | 0.035 | 2.24 |

3 | 0.528 | 13.19 | 0.034 | 3.87 | 0.089 | 4.65 | 0.033 | 2.31 |

4 | 0.516 | 12.87 | 0.029 | 3.67 | 0.086 | 4.58 | 0.029 | 2.15 |

5 | 0.524 | 12.89 | 0.034 | 3.82 | 0.092 | 4.64 | 0.031 | 2.25 |

6 | 0.536 | 13.40 | 0.035 | 3.92 | 0.098 | 4.70 | 0.040 | 2.52 |

© 2016 by the authors; licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC-BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Li, X.; Wang, J.; Liu, C.
Heading Estimation with Real-time Compensation Based on Kalman Filter Algorithm for an Indoor Positioning System. *ISPRS Int. J. Geo-Inf.* **2016**, *5*, 98.
https://doi.org/10.3390/ijgi5060098

**AMA Style**

Li X, Wang J, Liu C.
Heading Estimation with Real-time Compensation Based on Kalman Filter Algorithm for an Indoor Positioning System. *ISPRS International Journal of Geo-Information*. 2016; 5(6):98.
https://doi.org/10.3390/ijgi5060098

**Chicago/Turabian Style**

Li, Xin, Jian Wang, and Chunyan Liu.
2016. "Heading Estimation with Real-time Compensation Based on Kalman Filter Algorithm for an Indoor Positioning System" *ISPRS International Journal of Geo-Information* 5, no. 6: 98.
https://doi.org/10.3390/ijgi5060098