MagPP: Combining Particle Filters and Pedestrian Dead Reckoning Algorithm with Geomagnetism for Indoor Positioning Using Smartphone

Geomagnetic positioning technology has proven to be worth investigating in the field of location-based services (LBSs), but the positioning of geomagnetic technology alone will generate a certain amount of error. To overcome the ambiguity of single-point geomagnetic data, we developed a geomagnetic indoor navigation system, magnetic + particle filters + pedestrian dead reckoning (MagPP) based on the pedestrian dead reckoning (PDR) algorithm using a smartphone as a hardware platform. We calculate the measurement trajectory contour of the PDR to solve the gross error of the magnetic field sequence (MFS). The mean square error criterion of the matching trajectory is established, and the particle filter (PF) algorithm is used to realize the iterative calculation of the real-time correction of the PDR cumulative error. In the test, with an area of 68 × 1.8 m2, the experimental results produced an average positioning error of 1.13 m and a maximum positioning error of 2.17 m. The positioning of the fusion algorithm proposed in this paper is 42% higher than that of the PDR algorithm alone. Compared with the single geomagnetic fingerprint-matching algorithm for indoor positioning, the positioning accuracy is improved by 57%. Therefore, the MagPP algorithm significantly improved indoor positioning.


Introduction
With the advent of artificial intelligence and the era of big data, there is an increasing demand for positioning and navigation. Location-based services (LBSs) and their related applications have recently attracted significant attention commercially and socially. (1) In complex indoor environments, such as airport halls, exhibition halls, warehouses, supermarkets, and libraries. It is often necessary to determine the location information of a mobile terminal or its holders, facilities, and items indoors. However, owing to the limitations of positioning time, positioning accuracy, and complex indoor environments, GPS, BDS, and other GNSS technologies cannot be used for indoor positioning. Therefore, experts and scholars have proposed various indoor positioning technology solutions, such as the use of Wi-Fi, (2)(3)(4) bluetooth, (5) magnetic field, (6)(7)(8)(9) visible light, (10) ultrasound, (11) wireless radio frequency signals, (12) inertial navigation systems (INS), (13) and simultaneous localization and mapping (SLAM). (14) Among all the mentioned positioning technologies, the positioning method based on geomagnetic fingerprints has become a more effective solution to solve the problems in indoor positioning.
The geomagnetic field (15) is generated by the main magnetic field, the anomalous field, and the interfering magnetic field of the internal structure of Earth, and its intensity is in the 30000-60000 nT range on the surface. It can be seen that the fluctuation of geomagnetism is not large, and it is not necessary to update the geomagnetic reference map frequently. Owing to different buildings and the internal structures of buildings, each position in a building may have geomagnetic fluctuation characteristics of a recognizable position, and it is more convenient to extract the position information from such an information-rich three-dimensional vector magnetic field, especially indoor positioning based on smartphones. Smartphones contain many sensors that enable pedestrian awareness and context recognition, providing vertical data and potential uses for new solutions to indoor positioning problems.
The matching of geomagnetic data can have seven main feature quantities: total magnetic field strength F, horizontal intensity H, east direction intensity Y, north direction intensity X, vertical intensity Z, magnetic declination D, and magnetic dip angle I. The magnetic field readings of the three axes (X, Y, and Z) of a smartphone, as shown in Fig. 1, can directly use the magnetic sensor of the smartphone to collect the geomagnetic fingerprint data to achieve the target positioning.
Previous studies by various scholars have spurred our enthusiasm for the determination of a translational position in pedestrian navigation and the study of indoor environmental localization based on magnetic fields. Leppakoski et al. integrated Wi-Fi, inertial sensor data, and electronic map geometry information, and designed and implemented an indoor personnel positioning system. (16) First, the extended Kalman filter (EKF) is used to fuse Wi-  Fi information with inertial sensor information. Then, a particle filter (PF) is used to fuse the inertial sensor information and the electronic map geometry information, and the positioning result is finally obtained. Galván-Tejada et al. discussed the creation of maps containing magnetic landmarks for indoor navigation using a wide range of mobile-phone-embedded Hall sensors. (17) In 2014, Huang and coworkers introduced an indoor positioning solution using a smartphone equipped with inertial and magnetic sensors (18) by applying an improved pedestrian dead reckoning (PDR) (19) algorithm and a variable weighted magnetic map matching algorithm. Xie et al. further proposed a dynamic step size estimation algorithm and a heuristic particle resampling algorithm in 2016. (9) They used a hybrid measurement model that combines the new magnetic fingerprint model with an existing fingerprint model to improve system performance, but the key is to avoid using a calibration magnetometer for different smartphones. Hong Kong's Wherami software has used sensing technology to combine signals from multiple sources such as Wi-Fi, geomagnetic fields, Bluetooth, video, and accelerometer readings. In a typical environment, it can reduce the position error to less than 2.5 m. It has been deployed in Harbour City at Tsim Sha Tsui and is now under commercial trials in malls and hospitals. Table 1 summarizes the current algorithm presented in other papers that used the magnetic field fingerprint-based matching method and inertial sensors. It was found from various studies that multisensor fusion positioning can expand the positioning range and improve positioning accuracy and robustness. Therefore, the development of indoor and outdoor full-space low-cost positioning systems has become a research hotspot. The main problem in solving indoor positioning is to achieve sufficient positioning accuracy at a low cost with minimal additional facilities.
To solve this problem, we have focused our research on geomagnetism that does not require the deployment of additional infrastructure. However, studies (6,8,17) show that magnetic fingerprints may not be unique in large indoor spaces, so it is difficult to estimate the area where the magnetic field distribution changes little in a building and the area where the magnetic field excessively fluctuates, as shown in Fig. 2. Therefore, to overcome the problem of a fuzzy solution of geomagnetic fingerprint data positioning and consider the applicability of hardware cost, we use the accelerometer and gyroscope of a smartphone to add the auxiliary technology PDR to geomagnetic positioning technology. The PDR can be used to roughly estimate the pedestrian's path trajectory by using the inertial sensor line to obtain the pedestrian direction and step size, but only the relative position information is obtained, resulting in a cumulative error. We diverged from the traditional view and developed a geomagnetic indoor navigation system, magnetic + PFs + PDR (MagPP), which does not require additional facilities (additional deployment facilities are required in Refs. 89, 14, 21), using smartphones as the hardware platform. Specifically, in this study, we achieved the following: (a) We developed and propose a fusion technology based on fingerprint recognition. (b) By using the PDR algorithm to improve the dynamic equation of the PF algorithm, we solved the non-unique solution problem of the geomagnetic online matching stage, and realized the iterative calculation of the PDR cumulative error real-time correction using the PF algorithm. (c) We made up for the shortcomings of the single positioning technology to optimize the accuracy of indoor positioning. The rest of this paper is organized as follows. In Sect. 2, the related algorithms used in constructing the geomagnetic positioning system are described in detail. In Sect. 3, we explain the process of the positioning system that we developed. Moreover, the experimental work and the discussion of the experiment results are presented in Sects. 4 and 5. Finally, in Sect. 6, we conclude the paper and point out the future research direction.

PDR algorithm
The PDR algorithm is shown in Fig. 3. The basic idea is to use the accelerometer in a mobile phone to calculate the user's step size after obtaining the target initial position and then use the direction sensor in the mobile phone to calculate the pedestrian's moving direction, and finally estimate the pedestrian's next position coordinate. If the coordinates of the pending target at k are known (x k , y k ), the step length is l k , the direction angle is θ k , and the calculation formula for the position coordinates of the target at the next moment (x k+1 , y k+1 ) is According to the recursive Eq. (1), the two key factors in the entire calculation process are the walking step length and direction angle.

Step size estimation
The nonlinear step-size estimation model uses statistical analysis to establish a mathematical model. There are several implementations of this model, the most common being the Weinberg approach model, (22) which uses Eqs. (2) and (3): where K is a constant that changes with the person's gender, height, and weight; n represents the number of steps to walk, and a max and a min respectively represent the maximum and minimum accelerations in the vertical direction obtained by the sensor in one step. L represents the distance of each step of the pedestrian, (x 1 , y 1 ) represents the current position coordinates of the pedestrian, and (x 2 , y 2 ) represents the coordinates of the position of the pedestrian walking forward. It can be seen from Fig. 4 that the z-axis direction of the mobile phone, that is, the acceleration of the human body in the vertical direction, will reflect an obvious periodic change during the pedestrian's natural walking, which can reflect the number of steps in the walking process. However, the pedestrian walking process will be affected by various factors, and a large amount of interference data will appear. We use the FFT algorithm to eliminate the noise data, reducing the amount of calculation in the positioning process. We show the step detection process in Fig. 5. Step detection process.

Estimation of direction
The pedestrian's direction can be obtained directly by the direction sensor or by combining with the gyroscope and combining the map constraint information. This study is based on the three values of azimuth, tilt, and rotation provided by the Android API.
By analyzing the basic principles of the pedestrian track calculation technology, we can see that this kind of relative positioning method will surely have a cumulative error, and this technology cannot eliminate the accumulated error, so it is necessary to introduce other technologies for joint positioning.

PF algorithm
Particle filtering is a filtering algorithm based on the Monte Carlo method (23) and sequential importance sampling. It retains the advantages of the Monte Carlo method and does not have a nonlinear or non-Gaussian state space model.
The key idea of particle filtering is to use a set of weighted random samples to approximate the posterior density function. Equation (4) is derived as follows: First, establish a state space model, including Eq. (5) of state: Observation equation: where y t represents the observation signal, x t the status signal, v t the observation noise, and w t the state noise. The y 0:t recursive estimation can be used to verify the distribution and its associated characteristics.
When it is not possible to directly use ( ) Normalized form: i t w is the importance weight.
The unbiased estimate of ( ) 0: 1: We set a threshold N-th; when ˆe ff th N N ≤ , this means that the degradation is more serious and we need to remove these degraded particles.

MagPP Indoor Positioning System
The positioning system of the fusion algorithm is based on the geomagnetic positioning system. The geomagnetic map matching algorithm is divided into two phases, offline and online, as shown in Fig. 6. In the offline phase, the magnetometer sensor in the smartphone collects the geomagnetic data, and the geomagnetic data is stored in the geomagnetic map to construct a reference map. Online matching is the collection of geomagnetic data in real time during the target phase of motion and the use of the matching algorithm to make an optimal estimation with the reference map and to obtain the best estimate of the target position.
By introducing the basic principles of geomagnetic fingerprinting and PDR positioning, as well as the advantages and limitations of their own independent positioning, we analyze the superiority of fusion positioning. On the basis of this, the scheme and structure of fusion positioning are presented in Fig. 7.
The positioning process of the entire system is as follows. First, geomagnetic information in the active area is collected in the offline phase to create a geomagnetic fingerprint library. In the online phase, the position coordinates of the target are roughly estimated using the PDR positioning during the movement of the smartphone.
The collected geomagnetic data and geomagnetic fingerprints are matched with the PF algorithm. The matching process is as follows: ( x y is the origin, the Euclidean distance between each particle and the observed value is the input, and the standard deviation is 1.1. At this time, the particle weight is where d i is the distance between the particle and the observation ( , ) Then calculate updated particle weights using Eq. (8) in order to ensure that all particle weights add up to 1. (d) Resample. We need to reference the "Resampling" technique. (24) The method is as follows: (1) Randomly generate a sample from the uniformly distributed [0, 1] interval [0, 1].
(2) Set the particle set ( , ) i i k k x y corresponding to the particle index i satisfying Eq. (14) as the t-th particle ˆ( , ) t t k k x y in the new particle set: (3) Repeat n times to generate a new set of particles, each with a weight of 1/n. If ˆe ff N is less than the preset threshold, the resampling phase is performed. Obtain the final positioning result of the system. (e) Update location. Updated pedestrian position (x k , y k ).

Experiment setup
The study area is a 1.8 m wide and 68 m long corridor on the second floor of the Institute of Surveying and Mapping of Beijing University of Civil Engineering and Architecture. In this study, we divided the measured area into a 4 × 104 grid and established a rectangular coordinate system, as shown in Fig. 8.
By the geomagnetic fingerprint collection method in the literature and IndooratAtlas, (25) we designed a relatively simple and easy-to-use geomagnetic fingerprint collection tool (the tool interface is shown in Fig. 9). We used a Nokia 7 phone to run Android 8.0 Oreo system parameters. We collected four rows of geomagnetic data spaced 60 cm apart along the corridor. Smartphones must maintain the same direction while walking while collecting data. The step length is approximately 0.6 m, and the magnetic field is measured every 25 Hz to generate a three-dimensional vector in units of μT. Data are collected for each node in the grid for 10s; that is, to collect ten sets of geomagnetic data values, take the average value to ensure the accuracy of geomagnetic data.
The geomagnetic density fingerprints can be obtained by calculating their modulus values as follows: The original data were preprocessed using MatLab software, and some invalid data were deleted, such as blank data that cannot be captured by the mobile phone sensor at the beginning of the acquisition data and incomplete data that were not collected after the data collection was stopped. The area between the line segment and the line segment is complemented by Kriging (26) linear interpolation; finally, a complete geomagnetic fingerprint library (as shown in Fig. 10) can be obtained.

Comparative experiments with different positioning methods
The experimental design of this study is as follows. At the second floor of the college building, a rectangular path was selected using two different positioning methods. The experimenters collected sensor data along the path, and the path average positioning results were obtained after 20 experiments. In the online phase of the particle matching process, we used 400 particles (we carried out experiments and obtained the results as shown in Ref. 27; 400 particles were used for the least time-consuming matching with optimal accuracy) PDR positioning requires a known initial position, so the initial position of our custom coordinates is given to the PDR during the experiment. Then, the PDR positioning information is used to solve the position coordinates of each step; finally, the positioning results are obtained. Figure  11 shows the pedestrian real path, the path estimated by the PDR method, and the MagPP path estimated on the basis of fusion algorithm.

Experimental analysis
Owing to the single-use geomagnetic matching indoor location algorithm, we have made improvements in Refs. 27 and 28, and obtained the positioning accuracy results in a wide range of experiments, which are directly used as references in this paper. The result is shown in Fig. 12.
It can be seen from Fig. 12 that when using the PDR alone to locate, there is a 79% probability that the accuracy is better than 2 m. When the geomagnetic fingerprint matching method is used alone for positioning, the error results are scattered. When using the fusion algorithm for positioning, there is 97% probability that the accuracy is better than 2 m and 68% probability that the accuracy is less than 1 m. Therefore, the combined positioning method of PDR and geomagnetic matching technology can effectively improve the accuracy of the indoor  Table 2.
We compared the results of our own research with those of the various studies listed in Table 1. Our results showed that the highest accuracy among the studies compared including the above PDR-based studies. Moreover, the Wi-Fi technology used additionally in Ref. 8 is affected by the signal distance. In the method proposed in recent studies, it is difficult to determine the direction of the magnetometer and the simultaneous attachment of the IMU  and the magnetometer to the foot. In addition, the angle between the x-axis direction of the magnetometer and the direction of motion is difficult to correct, which will have an unavoidable effect on the similarity of the measured values.
Although the above methods are feasible in terms of positioning accuracy, the key issue is that they require additional infrastructure such as foot-mounted inertial sensors, wireless APs, pretraining databases, and map information, which are not practical. Experiments show that the fusion algorithm proposed in this paper has the following advantages: (a) The estimated coordinate output by PDR is used as the input of geomagnetic fingerprint positioning in the online phase, which reduces the amount of computation in the search database, improves the robustness of the geomagnetic fingerprint to the environment, and indirectly improves the positioning accuracy. (b) The PDR algorithm will produce a large cumulative error. Therefore, the result of the geomagnetic fingerprinting algorithm is used to modify the PDR algorithm and reduce the accumulated error. (c) The actual test results show that the fusion location algorithm proposed in this paper is 42% better than the PDR algorithm. Compared with a single geomagnetic fingerprint matching algorithm, the positioning accuracy is improved by 57%. The geomagnetic fingerprint positioning algorithm runs on the server side, reducing the pressure on the client.

Conclusions
In this work, we studied the indoor positioning technology of smartphones and focused on the PDR algorithm and geomagnetic fingerprint matching algorithm based on the PF algorithm. Finally, an indoor positioning and tracking algorithm, MagPP, based on geomagnetic and PDR fusion was developed and proposed.
For future work, we plan to improve the current system in several ways. A large number of experiments have been carried out so far in the college building of Beijing University of Civil Engineering and Architecture. In this environment, the positioning accuracy of people is acceptable and is not affected by other people moving around. It would be desirable if the path is more complicated to test the robustness of the proposed algorithm. Therefore, further accuracy verification is required in an open area such as an atrium in a shopping center. Further large-scale trials are planned in different indoor environments to understand the actual usage of the system.