A Study of WiFi-Aided Magnetic Matching Indoor Positioning Algorithm


Aiming at the shortcomings of the existing indoor location algorithm, such as low accuracy of positioning, high deployment and maintenance cost, and unstable robustness, this paper proposes a method of indoor location based on the integration of smartphone with WiFi and magnetic field using multi-sensor fusion. In the initial stages of positioning, rough location is achieved by Wi-Fi-RSSI fingerprints which provides an initial location and geomagnetic matching area for indoor positioning based on particle filter magnetic field matching. This paper proposes the use of median filter algorithm to deal with the original magnetic field data and covariance interpolation algorithm to generate magnetic field map, and effectively reduce the interference which caused by geomagnetic fluctuations, thereby it will improves the positioning accuracy. Finally, through conducting comprehensive experiments and tests, the results show that the proposed technique can reliably achieve 0.836 meters precision in current experimental environment.

Share and Cite:

Wang, E. , Wang, M. , Meng, Z. and Xu, X. (2017) A Study of WiFi-Aided Magnetic Matching Indoor Positioning Algorithm. Journal of Computer and Communications, 5, 91-101. doi: 10.4236/jcc.2017.53011.

1. Introduction

As the most people spend 70% to 90% of their time using mobile location-based services (LBS) in indoor environments, the need for indoor location technology is increasing and becoming critical. In recent years, with the rapid development of wireless communication technology and the widespread popularity of intelligent terminals, wireless location technology has also become a research focus. At present, the widely used global positioning system in the outdoor field can achieve relatively accurate positioning and navigation, but the GPS signal in the indoor serious degradation or even unavailable [1]. The indoor positioning system based on the wireless network framework is widely studied because it does not need to add other hardware, and has low cost, wide deployment and other advantages [2] [3]. However, WiFi signals may be affected by attenuation, multipath fading, human obstruction and so on, which may lead to a decrease in positioning accuracy, although positioning can be achieved by WiFi fingerprint or propagation model [4].

Modern architecture of reinforced concrete or steel frame structure on the indoor magnetic field disruption, the formation of a non-uniform magnetic field environment create the differences of the magnetic field in different tracks. Thus, using of the magnetic field in the indoor environment, unique, stability and the difference between different regions to achieve positioning become possible. Therefore, some teams began to explore the use of geomagnetism to achieve indoor positioning, which is more representative of the University of Oulu, Finland, Janne Haverinen et al. and the use of geomagnetism for indoor positioning. The research team has completed a verification test in a mine tunnel of about 1380 meters with a positioning accuracy of 1.5 meters [5]. At the Massachusetts Institute of Technology (MIT), the researchers rely on indoor magnetic fingerprint matching and inertial sensor combination to locate in the office environment. The results showed that the cumulative error of 0.71 meters was 50%, 1.64 meters probability was 90% [6]. Due to the complexity of the indoor environment, all kinds of technology have limitations, so many indoor positioning methods are difficult to achieve a wide range of popularization. Therefore, it can achieve the goal of low cost, high precision, favorable timeliness and strong universality by merging the multi-indoor positioning technology, taking advantage of various methods and complementing the deficiency [7]. Combined with the advantages and shortcomings of existing single positioning technology, mobile phone which combined with WiFi and geomagnetic fingerprint fusion positioning is proposed. In the positioning phase, the magnetic matching region is selected by the RSSI positioning result. Subsequently, it is precisely positioned by the geomagnetic field. This combination method can effectively overcome the positioning error caused by multipath effect of RSSI and solve the problem of too slow convergence rate of particle filter in magnetic field localization.

2. Correlation Algorithm

2.1. Location Model

In the office environment, the first set walking path in accordance with certain laws, and then experimental personnel holding a smartphone to walk at a constant speed in the set route, collecting and recording the magnetic field used to generate line magnetic filed map. Secondly, a reference point (RP) which corresponds to an absolute coordinate is used to assist the positioning of the target is set on the route. At the same time, the RSS of WiFi and the magnetic field are captured at each reference point for positioning. Mobile users in the environment has access to map data, the use of handheld terminals, real-time data acquisition and the use of existing algorithms to obtain real-time positioning results.

In this paper, the feasibility and data acquisition and processing of magnetic field for indoor location are introduced. As shown in Figure 1, the magnetic matching indoor positioning algorithm assisted by WiFi is introduced. Compared with the wireless fingerprint positioning method, the geomagnetic matching location error is small [8], but due to the non-uniqueness of the geomagnetic field, the mismatch ratio of the magnetic matching algorithm is seriously. In order to reduce the mismatch ratio of magnetism positioning, and WiFi fingerprint algorithm is combined to improve positioning accuracy [9] [10].

2.2. Geomagnetic Data Acquisition and Processing

With the development of micro-electro-mechanical systems (MEMS), mobile intelligent terminals are embedded with sensors, such as magnetometers and the like for mobile users to use and magnetic field positioning, and it provides the possibility. In order to prove the stability of the geomagnetic signal, two sets of data are collected at different time periods in the same place. As shown in Figure 2, the geomagnetic signal has a certain stability, but there is some fluctuation in the local, which provides a theoretical basis for making full use of the geomagnetic field to do indoor positioning.

2.3. Median Filter Algorithm

Median filtering is essentially a method of determining the filter output response by minimizing the sum of the absolute values of the errors [11]. Let a set of observations be the sum of the absolute values of the approximations.


To the minimum, it must have

Figure 1. Algorithm architecture.

(a) (b)

Figure 2. Stability and local fluctuation of geomagnetic field with (a) at different days and (b) different mobile phones.


To satisfy the Formula (2), the value in the middle position after the size order should be taken. As shown in Figure 3, the collected geomagnetic field intensity data, even in the same sampling point, for a period of time, the data will be 2uT jitter, so we use the median filter and the original data Smoothing filter. The filtered data can improve the match rate when the original data is retained, which is the main feature of the original data.

2.4. Covariance Interpolation Algorithm

Because of the characteristics of geomagnetic space fluctuation, the covariance interpolation algorithm is more effective than other interpolation algorithms. Kriging is a mathematical statistical method for spatial interpolation [12]. Being used to weight around the measurements to arrive at the location of the forecast is not measured. Commonly used formula is:


where is the position of the magnetic field value; is the number of measured values .In order to reduce the computational complexity of the interpolation algorithm, only the local magnetic field around the estimated point is

Figure 3. Median filtering of geomagnetic data.

calculated every time, and then it fused to the global grid map. And the magnetic field predicted value of is obtained. As shown in Figure 4, a set of geomagnetic field strength data is measured in a 27-meter-long and 1- meter-wide corridor. The median filtering algorithm is used to smooth out the singular value of the field strength. Then, Interpolation algorithm to obtain interpolated geomagnetic field map.

2.5. Particle Filtering Algorithm

The use of smartphone that owns magnetometer to read the magnetic field data is relative to the phone’s coordinate system. In terms of the same position to change the attitude of the mobile phone, reading the magnetic field vector is different, while the smartphone carried by the magnetometer itself exists measuring noise, and the error is random. This also leads to the non-uniqueness of geomagnetic fingerprints in the region. The particle filter algorithm can solve this problem. Particle filter algorithm, including the following basic steps:

1) Initialization. The particle set is generated by a priori probability, and all the particle weights are.

2) Particle update.



Which represents the step size, represents the direction of the user changes in the value of the direct use of compass and gyroscope measured, that is the direction of the particles at the moment, similarly, that represents the particles at the time of the location coordinates. Respectively, are subject to and gaussian noise.

Figure 4. Spatial distribution of interpolated magnetic field.

3) Importance of resampling

Based on the Monte Carlo method, the objective function is fitted by random sampling. At the moment, for a set of particles, the state of each particle is updated to produce random particles around the new position to get a new set of particles.

4) Weight calculation.

Since each particle represents a possibility of the target state, the purpose of system observation to make the particle similar to the actual situation obtains a larger weight, and the particle with the larger difference from the actual situation gets a smaller weight. Consequently, the weighting of exponential distribution is calculated:


Weighted normalization:


5) Estimate the user location

The current location is estimated using the particles sampled in the previous step.


3. Experimental and Results

3.1. Experimental Setup

In order to verify the fingerprint model and proposed algorithm in this paper, an experimental building was chosen as the experimental environment. In the experiment, we select the Huawei honor-7 smartphone as a receiving device. TP- link dual-band router is as the WiFi access point to construct the WiFi fingerprint library and auxiliary magnetic matching positioning. The experimental scenarios were selected in the back hall corridor of the Science and Technology Building hall. In this area, four APs were deployed. In the corridor, according to the established route, setting a RP reference point every 0.5 meters, and recording the RP’s WiFi signal RSSI which generates fingerprints database. Then, on the same route, according to the uniform velocity motion, the geomagnetic field is collected, and the collected data is filtered through the median filter, mapped to the route uniformly. Finally, covariance interpolation is used to generate the geomagnetic map.

3.2. Experimental Simulation and Analysis

In the positioning phase, first, the use of WiFi fingerprints obtain the initial position and rough location of the delineation. In combination with the error of the RSSI localization algorithm in the experiment, we will delimit the rough position and then retrieve the magnetic filed data of the database in the coarse position and use the particle filter algorithm to match the geomagnetic data in the geomagnetic map, and the geomagnetic data is collected in the actual movement. Secondly, the use of mobile phones with accelerometer and electronic compass inferres the direction and displacement of the user movement. Subsequently, using the geomagnetism distribution in the coarse region, the particle filter algorithm is used to realize the accurate indoor location, and finally determine the moving trajectory of the user.

In the use of WiFi positioning phase, we use the commonly used location fingerprint method. In the known indoor area, n WiFi access points (AP1, AP2, AP3... APn) is deployed. Furthermore, the RSS values from the n different APs collected at the m reference point are stored in the database, as a fingerprint use to location, the database is offline phase of the fingerprint library. In the positioning phase, the fingerprint database is used as a map of the location area. The data in the fingerprint library is used as a known map map during the positioning. The corresponding RSSI spatial distribution of an AP in the database, as shown in Figure 5.

As shown in Figure 5, WiFi signal strength as the user and the AP access point distance increases gradually weakened. In the online positioning phase, the signal strength values sent from n different APs are collected in real time by the smart phone, and then matched with the fingerprints in the fingerprint database. In the match-

Figure 5. WiFi RSSI spatial distribution.

ing, K nearest neighbor algorithm is used. Instead of using the nearest distance as the location of the mobile terminal, the nearest K () sampling points are selected and the K sampling points are calculated by the Formulas (9) and (10) of the average coordinates, as the target location coordinates.



Here the distance is calculated using the Euclidean distance. In Equation (9), represents the position coordinates of the i sample point. With as the center and 3 times the standard deviation of the RSSI as the radius to determine the matching area of the magnetic field, to achieve accurate matching of magnetic field by particle filter.

According to the specific circumstances of the experimental scene, the next phase of the magnetic filed data generated by the map is shown in Figure 6. It can be seen from Figure 6 that the color of the energy distribution is closer to red in the one-meter wide corridor, indicating that the energy is stronger near the coordinate point (2750, 750), because the energy is the strongest point near the floor for the building body pillars.

In this paper, the particle filter algorithm for magnetic matching positioning can use the location of the results of geomagnetic matching to provide a search range. At the same time, the geomagnetic data collected online includes the location information at this moment, (magnetic field data and direction angle, which the online data and database map to match.) The resulting positioning of the trajectory is shown in Figure 7.

The error analysis of WiFi-RSSI and geomagnetic field in Figure 8 shows that the average error of WiFi-RSSI positioning is 2.23 meters, at the same time, due

Figure 6. The geomagnetic map after interpolation.

Figure 7. WiFi-RSSI and geomagnetic fusion positioning of the trajectory.

Figure 8. Error of WiFi-RSSI and magnetic field fusion positioning.

to the location of WiFi-RSSI, the convergence of the particle filter is obviously improved, and the run-time is saved, and the mean of positioning error is 0.836 meters. Because the measured value is disturbed by the surrounding environment, the effect of the whole algorithm is in a fluctuating state. The accuracy and stability of the algorithm are determined by the RSSI algorithm that was originally used. At the same time, the whole consideration is used in the algorithm, instead of judging the position of one or several data, so the degree of susceptibility to interference is better than that of wifi.

4. Conclusion

In order to solve the problem which is high mismatching rate in the process of matching the location of the magnetic field, this paper proposes a fusion location algorithm of WiFi aid magnetic field, which is simple and low cost, and it combines with particle filter algorithm to achieve ideal the positioning effect. The experimental results show that this method has potential advantages in improving the accuracy and real-time performance. Future work will continue to optimize the algorithm and research to improve positioning accuracy and timeliness.


This work is suported by the National Natural Science Foundation of China (No.61371107), the Guangxi Experiment Center of Information Science (No.LD16061X), the Guangxi Natural Science Foundation (No.2016GXNSFBA38014), and the China Postdoctoral Science Foundation (No.2016M602921XB), the Innovation Project of GUET Graduate Education (YJCXS201517).

Conflicts of Interest

The authors declare no conflicts of interest.


[1] Liang, D., Zhang, Z. and Peng, M. (2015) Access Point Reselection and Adaptive Cluster Splitting-Based Indoor Localization in Wireless Local Area Networks. IEEE Internet of Things Journal, 2, 573-585. https://doi.org/10.1109/JIOT.2015.2453419
[2] Yang, J., Chen, Y., Martin, R.P., Trappe, W. and Gruteser, M. (2012) On the Performance of Wireless Indoor Localization Using Received Signal Strength. Handbook of Position Location, 395-424.
[3] Milioris, D., Tzagkarakis, G., Papakonstantinou, A., Papadopouli, M. and Tsakalides, P. (2012) Low-Dimensional Signal-Strength Fingerprint-Based Positioning in Wireless Lans. Elsevier Ad Hoc Networks.
[4] Zampella, F., Jimenez Ruiz, A.R. and Seco Granja, F. (2015) Indoor Positioning Using Efficient Map Matching, RSS Measurements, and an Improved Motion Model. IEEE Transactions on Vehicular Technology, 64, 1-1. https://doi.org/10.1109/TVT.2015.2391296
[5] Haverinen, J. and Kemppainen, A. (2011) A Geomagnetic Field Based Positioning Technique for Underground Mines. IEEE International Symposium on Robotic and Sensors Environments. IEEE, 7-12.
[6] Priyantha, B.N. Chakraborty, A. and Balakrishnan, H. (2000) The Cricket Location-Support System. In: 6th Annual In-ternational Conference on Mobile Computing and Networking. https://doi.org/10.1145/345910.345917
[7] Li, Y., Zhuang, Y., Lan, H., et al. (2015) WiFi-Aided Magnetic Mathicng for Indoor Navigation with Consumer Portable Devices. Micromachines, 2015, 747-764. https://doi.org/10.3390/mi6060747
[8] Shu, Y., Bo, C., Shen, G., et al. (2015) Magicol: Indoor Localization Using Pervasive Magnetic Field and Opportunistic WiFi Sensing. IEEE Journal on Selected Areas in Communications, 33, 1-1. https://doi.org/10.1109/JSAC.2015.2430274
[9] Li, D., Zhang, B. and Li, C. (2015) A Feature Scaling Based k-Nearest Neighbor Algorithm for Indoor Positioning Systems. 3, 436-441.
[10] Carrillo, D., Moreno, V., úbeda, B., et al. (2015) MagicFinger: 3D Magnetic Fingerprints for Indoor Location. Sensors, 15, 17168-94. https://doi.org/10.3390/s150717168
[11] Boles, W.W., Kanefsky, M. and Simaan, M. (1990) A Reduced Edge Distortion Median Filtering Algorithm for Binary Images. Signal Processing, 21, 37-47.
[12] Beagum, S.S., Hundewale, N. and Sathik, M.M. (2015) Improved Adaptive Median Filters Using Nearest 4-Neighbors for Restoration of Images Corrupted with Fixed-Valued Impulse Noise. IEEE International Conference on Computational Intelligence and Computing Research. IEEE.

Copyright © 2023 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.