An Improved Particle Filter Algorithm for Geomagnetic Indoor Positioning

Geomagnetic indoor positioning is an attractive indoor positioning technology due to its infrastructure-free feature. In the matching algorithm for geomagnetic indoor localization, the particle filter has been the most widely used. The algorithm however often suffers filtering divergence when there is continuous variation of the indoor magnetic distribution. The resampling step in the process of implementation would make the situation even worse, which directly lead to the loss of indoor positioning solution. Aiming at this problem, we have proposed an improved particle filter algorithm based on initial positioning error constraint, inspired by the Hausdorff distance measurement point set matching theory. Since the operating range of the particle filter cannot exceed the magnitude of the initial positioning error, it avoids the adverse effect of sampling particles with the same magnetic intensity but away from the target during the iteration process on the positioning system. The effectiveness and reliability of the improved algorithm are verified by experiments.


Introduction
With the rapid development of location-based services, indoor positioning is receiving increased attention.Indoor positioning technology can be applied to public security, location tracking, intelligent transportation, and so forth.For example, a hospital can locate and monitor patients using indoor positioning technology.Indoor positioning can solve the problem of finding cars in large complexes and underground parking lots; it can also quickly find an optimal shopping route in large shopping malls.Indoor positioning is currently based on technologies such as Wi-Fi, RFID, Bluetooth, UMB, and geomagnetism.Among different technologies for indoor positioning, the geomagnetic indoor positioning approach has broad application prospects because it is infrastructure-free and has geomagnetic signal stability [1].
As early as the 1950s, the geomagnetic positioning technology based on geomagnetic field vector matching was applied to large-scale outdoor environment navigation, including those of surface ships, submarines, and missiles.In the past, the geomagnetic positioning techniques typically used the correlation matching algorithms [2][3][4] or the recursive filtering algorithms [5,6].More recent use of the geomagnetic positioning technology in the indoor environment is considered an important breakthrough.The geomagnetic field in a modern building is disturbed by the steelreinforced concrete, steel structure, power systems, electronic equipment, and other artificial sources, which forms a unique and spatially continuous geomagnetic signature [7,8].The indoor magnetic field can be collected to construct a fingerprint model based on Wi-Fi fingerprint technology.In general, the construction of geomagnetic perturbation fingerprint model can use a variety of characteristic variables, including a single variable (total geomagnetic intensity), double variables (H and V direction magnetic field components), or three variables (X, Y, and Z direction magnetic field components).The more characteristic variables are included for the position determination, the more improvement can be made on the positioning accuracy [9].The indoor positioning technology based on the magnetic field matches the magnetic field intensity, which is obtained by the indoor moving carrier, with the geomagnetic disturbance fingerprint model to enable indoor positioning.
At present, the particle filter algorithm, k-nearest neighbor [10], and extended Kalman filter (EKF) [11] have been applied in indoor positioning systems based on a fingerprint model.The particle filter developed by Monte Carlo techniques has been widely used as one effective matching algorithm, because of its advantages of broad adaptability in nonlinear and non-Gaussian systems [12][13][14].Grand and Thrun [12] presented a real-time indoor localization method that utilizes a single 3-axis magnetometer to estimate the position of a handheld device.Using a particle filter, a localization accuracy of 0.7 meters in position and 25 degrees in orientation was achieved for a simple straightline trajectory.Haverinen and Kemppainen [13] equipped a robot with a single magnetic sensor that measured three planes.They ran their robot through a corridor, had it collect data at a set of locations to create a map of the hallway, and used Monte Carlo localization (a particle filter) to accurately determine its location from any starting point.The maximum error was about 28 centimeters, but the robot needed to travel 25 meters in order to localize itself in general.Kim et al. [15] proposed an indoor positioning system using smartphones.They used a particle filter to estimate the users' location based on geomagnetic anomalies [15] and used the distance between the user and the wall as a conditional constraint.The experimental results in the corridor showed that the positioning accuracy is within 3 meters.
The use of particle filters requires the carrier to complete a continuous recursive filter location over a period of time, and it suffers the problem of filtering divergence [16].The filter convergence however is affected by the distribution of indoor geomagnetic, and a divergence would occur if it lacks indoor geomagnetism signatures.The sparser the characteristics of the indoor geomagnetic field, as many locations have similar magnetic field patterns, the more likely the divergence of the particle filter algorithm occurs, which eventually leads to excessive positioning error.
In response to this challenge, this paper proposes the use of point set matching in the Hausdorff distance measurement method to improve the particle filter algorithm as well as the method of positioning error constraints.In the new particle filter algorithm, the initial positioning error is used as the distance constraint, only allowing particles that meet the constraints to iterate, and resampling.Coupled with the convergence characteristics of the resampling step, we can suppress the effect of persistent divergence.The main contributions of this work include (1) the development of a geomagnetic data acquisition platform, (2) an improved particle filter algorithm to prevent filter divergence, and (3) the design of an offline test system to estimate the location of mobile robots carrying magnetic sensors.
The paper is organized as follows.The classical particle filter algorithm is described in Section 2.1.Section 2.2 briefly outlines the improved algorithm based on the Hausdorff distance.In Section 3, the data acquisition robot is first briefly described, then the data collection is presented, and finally the analysis of the positioning results is provided.The conclusion is given in Section 4.

An Improved Particle Filtering Algorithm
2.1.Classical Particle Filter Algorithm.The particle filter algorithm is an optimal Bayesian estimation method based on Monte Carlo's idea [17].It is often used to estimate the position of a target moving along the corridor from an unknown location.The particle filter uses Monte Carlo localization (MCL) method to approximate the posterior probability distribution p x t |z t when it is too complex to directly sampled, but the prior probability density p x t |x i t−1 can be sampled and the measurement density p z t |x i t can be evaluated, where x t represents the target positioning, x i t represents the particle positioning, and z t is the observation.The entire particle filtering process consists of three steps, namely, forecasting, updating, and resampling.
The particle filter algorithm follows the general framework of a sequential importance sampling (SIS) algorithm, and it adds the sampling importance resampling (SIR) to solve the sample impoverishment caused by the iterative process.It first generates a set of samples with N particles from the prior probability density and then generates the weight w i according to the measurement density p z t |x i t of each particle.The weights are normalized to make their sum equal to one before the resampling.The basic idea of resampling is to remove particles with small weight and concentrate on particles with large weight.Due to easy implementation, the particle filter widely uses such resampling algorithm.The two-dimensional motion model is given by where l ∼ U 0, L , U 0, L which obeys a uniform distribution; L is the moving distance; and , θ is the moving direction.We can roughly choose the size of L according to the length of the person's step.The measurement density p z t |x i t is based on the single variable Gaussian probability density function, which is given by where σ r is the covariance of the observation z t .The function f x i t returns the magnetic field intensity of the position x i t in 2 Journal of Sensors the fingerprint model.Finally, the position xt of the target is estimated based on the weight w of the sample particles, which is given by and the positioning error is given by For geomagnetic indoor positioning based on the particle filter, the particle weight is determined by (3) according to the magnetic field intensity of the target and particle in which the closer the geomagnetic intensity, the greater the weight.After removing the particles with the small weights, the estimated position is then calculated by (4).When the difference in the weight of the particle is not large, the deviation of the distance between the particle position x i t and the target position is large [16].If the particle position is far from the target position, the error between the estimated position and the target position is large.In other words, the estimated position is obtained by weighted sum of the individual particle positions.The greater the value of the Euclidean distance d h between the target and particles with large weight, the greater the value of xt .Finally, it will cause greater positioning error as shown by (5).We have further explained it in Section 3.2 by an example.

An Improved Algorithm Based on Hausdorff Distance.
Increasing the characteristic elements of the geomagnetic matching can effectively solve the divergence problem in the particle filter algorithm, but it will also greatly increase the complexity of the original algorithm and the time required for positioning.Inspired by the Hausdorff distance matching, an improved particle filter algorithm based on the Hausdorff distance is proposed and described in the following.
We know that the magnetic field at any point is stable in the static environment and it is unique within a certain range.If the particle filter starts within a reasonable range, the deviation of estimated position will be reduced.The Hausdorff distance can then be applied to determine this reasonable range for the particle filter.The Hausdorff distance is the maximum value of the distance between the two sets of points in space which is defined as follows [4]: In general, in the geomagnetic feature matching based on classical particle filtering, we can control the weight of the particles that participate in calculating the estimated position in (4) when their weight becomes large.However, d h is difficult to control, once its value becomes too large.This will cause filtering divergence.Since d H is the maximum distance between each particle and the target, it can be controlled.As a result, if this maximum value can be controlled within a reasonable range, we can avoid the problem that d h becomes large.In order to avoid the effect of human factors, we use the positioning system to estimate the initial position of the target.The constraint to be applied is the initial positioning error between the estimated initial position and the true position of the target in the measurement environment.Let the initial positioning error as d H ; the following initial positioning error constraint can be established: The position xt of the target estimated based on the weight w of the sample particles in (4) must satisfy the condition in (7).Using the improved particle filter algorithm, the divergence problem can be avoided because we have removed those particles that had a larger weight but were far from the target.As a result, the positioning results of the positioning system can converge more quickly.The implementation steps of the improved algorithm is given in Algorithm 1 and the flowchart of the implementation process is given in Figure 1.
Step 1. Initialization: t = 0, draw particles x i 0 uniformly with w i = 1/N Step 2. Calculate the positioning error: t = 1, the initial positioning error is treated as the d H Step 3. Particle iteration: For time steps t = 1, 2, … For particle numbers i = 1: The particle state is shifted: Get mobile vector online observations: z t Weight update: Make CDF of w i t and For particle numbers i = 1: Step 5. Output the weighted position:

Data Collection System Development: A Geomagnetic
Data Acquisition Robot.The construction of a geomagnetic fingerprint model is a prerequisite for geomagnetic indoor positioning technology.In order to quickly and effectively establish a fingerprint model, a data acquisition robot has been developed by Urban Surveying and Mapping Institute which includes data acquisition module and control module as shown in Figure 2 [18].The robot is loaded with a HMC5983 three-axis magnetic sensor placed at a height of 1.3 meters above the floor.The placement of sensor at such a height is to separate the magnetic sensor to avoid interference by the robot itself.The robot is controlled by the control module.Data through the USB cable real-time are imported to the computer, through openMAT software to save geomagnetic data and record, while the magnitude was calculated.Finally, we use the MATLAB-based software to conduct position determination in the computer.Since the magnetic sensor itself will produce a relatively stable interference field when energized [19], we must correct the HMC5983 magnetic sensor  4 Journal of Sensors in the data acquisition module to ensure the authenticity of the data before collecting data.The rotation of the magnetic sensor around the z-axis of its own coordinate system will generate the corresponding circle based on the magnitude of the x-axis and the y-axis magnetic field.However, due to the presence of an interference field, the location of the center of the circle will move a short distance.The interference can be eliminated by adding a fixed value to the output value of the magnetic sensor, as shown in Figure 3.
The method to correct the value x sf , y sf of the HMC5983 magnetic sensor and the x-axis and y-axis magnetic field offset x of f , y of f is given as follows: x sf = max 1, y max − y min x max − x min , 5 Journal of Sensors where x max , x min and y max , y min are the maximum and minimum values, respectively; h x , h y is the original magnetic field value on the x-axis and y-axis; and x υ , y υ is the compensation of the x-axis and y-axis direction of the magnetic field value.

Experimental Data Collection and Fingerprint Model
Construction.The experimental data acquisition was conducted in the 2nd floor of the Institute of Surveying and Mapping at Beijing University of Civil Engineering and Architecture (BUCEA).The frames the building are reinforced concrete.Figure 4 shows a simple plan of the corridor with a total length of 68 meters.The magnetic field was measured every 25 Hz producing a three-dimensional vector m = m x , m y , m z , in units of μT.
In order to prove the defect of particle filter algorithm, we randomly collected a row of data in the corridor.Figure 5 shows the magnetic field distribution in the corridor which is linear and continuous, and the magnetic field intensity of different locations is likely to be the same.This proves that when the particle position x i t is far from the target, it will lead to biased estimate xt in the particle filter algorithm.An example is shown in Figure 6.
In the corridor, we collected geomagnetic data along four lines of 60 cm apart.For building the fingerprint model, we control the acquisition robot along the planned route to move forward which the step length of robot is 0.2 m with geomagnetic data measurement at a sampling rate of 5 Hz.To perform localization, we use the norm of the magnetic field m = m x , m y , m z as the observation, because magnetic field intensity m is a rotation invariant scalar quantity.The m is given by The final fingerprint model is created by applying a linear interpolation to the magnetic field intensity using a 0.02 m step size in the computer, as shown in Figure 7, and the map adds the grid coordinates as its relative coordinate frame after it is generated.

Positioning Results
The acquisition robot used to take measurements was controlled to travel straight along the corridor, with a step length of 0.6 m.It recorded data every second, iteration times t = 16.In the positioning system, the number of sample particles N is set to 400; each test set was conducted using the same value of the standard deviation of the measurement model σ r = 5 0μT, and a total of 20 time tests.The SIS algorithm and the particle filter algorithm with the SIR algorithm are used to investigate the geomagnetic matching precision and the degree of continuous filtering divergence.
The burr in Figure 8 shows that the SIS algorithm has the problem of filtering divergence and geomagnetic matching instability in the geomagnetic matching process.Although the positioning error shows an overall decreasing trend, there is no convergence.
As shown in Figure 9, the addition of the SIR algorithm makes the filtering divergence more serious, and the continuous filtering divergence phenomenon results in the loss of positioning (see ①, ②, ③ in Figure 9).Most of the experiments began to converge after t = 5.The average matching accuracy was 1.78 m and the average run time was 10.9 s.We can see from the comparison of Figures 8  and 9 that after the SIR algorithm is added, the particle is convergent after iteration calculation for a period of time due to its resampling step.The matching accuracy is far superior to that of the SIS algorithm, although positioning loss is also inevitable.
The idea of the positioning error constraint method is shown in Figures 10 and 11.In Figure 10, the dots indicate the sample particles that are randomly selected in the positioning area; the hollow circle represents the initial position of the weighted position and the * sign indicates the position of the moving carrier at time t = 1.In Figure 11, the circle which is deformed due to the limitation of the geomagnetic fingerprint model range represents the initial positioning   4), we find that if the w of number 1 is the same as that of number 2, but the distance between number 1 and the true position is very far, will cause the estimated position away from the true position.6 Journal of Sensors error range.It can be concluded from Figures 10 and 11 that with the establishment of the positioning error constraint after the initial positioning, the sampling particles have a restriction on their maximum distance d H .It does not use the particles which are far from the true location of target in the positioning process.Due to the reduction in the number of particles, the time of the whole system iterating 16 times is saved (the average running time is 9.1 s).
Figure 12 shows that initial positioning errors are all within 10 m, which is acceptable for indoor positioning.The experimental results and the positioning error analysis based on the improved particle filter algorithm are shown in Figure 13.In the experiments using the improved algorithm, most particles began to converge at t = 2 and have no loss of positioning as in Figure 9, with an average matching accuracy improved to 0.62 meters.Compared to the particle filter with the SIR algorithm, the improved algorithm can effectively prevent the filter divergence, eliminating location losses.Its convergence rate is faster than that of the classic particle filter algorithm, with an average running time of the whole system iterating 16 times is reduced by 16.15%.

Conclusions and Future Work
Indoor geomagnetic disturbance prevents the classical particle filter algorithm from stably finding the location in real time.Although the particle filter algorithm has a strong convergence in the matching accuracy, the particle iteration  7 Journal of Sensors process is accompanied by the loss of positioning.In this paper, we add the position error constraint to the particle filter algorithm and compare and analyze the advantages and disadvantages of the classical particle filter algorithm with the improved algorithm in matching accuracy, running time, and other aspects by real-field test.The results show that the improved algorithm can solve the persistent divergence problem in the particle filter and avoid the loss of positioning.Under the premise of the single variable feature, it can improve the indoor positioning speed and effectively solve the technical defect in geomagnetic matching.In the future work we will try to combine WLAN and other technologies to achieve effective initial positioning accuracy better than 5 meters.Journal of Sensors

A , 6
where d h represents the maximum distance between a i and b i in the two point sets of d h A, B = max a∈A min b∈B a − b and d h B, A = min b∈B max a∈A b − a , • is a distance norm, A = a 1 , a 2 , … , a p and B = b 1 , b 2 , … , b q represent two finite sets of points.The Hausdorff distance represents the degree of matching between A and B.

Figure 4 :Figure 3 :
Figure 4: Floor map of the Institute of Surveying and Mapping.

Figure 5 :
Figure 5: Distribution of the magnitude of the magnetic field in a row of the corridor.Blue spots indicate points with the same magnetic field intensity.

Figure 6 :
Figure 6: According to (4), we find that if the w of number 1 is the same as that of number 2, but the distance between number 1 and the true position is very far, will cause the estimated position away from the true position.

Figure 13 :
Figure 13: Positioning errors based on improved algorithm.