Robust Local Weighted Regression for Magnetic Map-Based Localization on Smartphone Platform

The magnetic information measured on the smartphone platform has a large fluctuation and the research of indoor localization algorithm based on smartphone platform is less. Indoor localization algorithm on smartphone platform based on particle filter is studied. Robust local weighted regression is used to smooth the original magnetic data in the process of constructing magnetic map. Use moving average filtering model to filter the online magnetic observation data in positioning process. Compare processed online magnetic data with processed magnetic map collected by smartphone platform and the average matching error is 0.3941uT. Average positioning error is 0.229 meter when using processed online and map data.


Introduction
Localization system has become an indispensable tool in life and work, we usually use GPS or Beidou to complete the localization function in outdoor environment, but when entering the indoor environment, the GPS signal become weakened and even unable to achieve positioning function.Based on people's demand for indoor localization services, indoor localization technology in recent years has been a great development.[1] proposed RSSI-based indoor positioning method for concrete hydropower station to provide security for workers; [2] proposed a technology for providing indoor positioning of hospital medical supplies; [3] proposed WIFI-based indoor localization using of sub-regional and curve fitting algorithm with positioning accuracy of 2 meters to 2.5 meters; [4] proposed the use of ZigBee indoor localization, compared to its reference indoor localization system based on WIFI, it has 85% reduction in power and 87% on accuracy.
Localization technology proposed in the past mainly based on ZigBee, Bluetooth, ultrasound, geomagnetism, UWB, RFID, WiFi.Indoor localization algorithms based on ZigBee, Bluetooth [5] [6] and WiFi [3] [7] almost use RSSI technology which needs to add some infrastructure and their accuracy is similar, about 2 meters [3] [4] [5].Positioning accuracies employing of RFID [8] [9], UWB [10] [11] and ultrasonic [12] [13] are much higher, but they require increasing emission and receiving equipment which also cost much more.Localization system based on geomagnetism [14] [15] has more advantages that it doesn't need additional equipment support, only relying on magnetic sensor carried by mobile platform, its accuracy can reach 1m in special condition [15].
The magnetic distribution in the indoor environment is mainly caused by the superposition of natural geomagnetism and manmade geomagnetism.Reinforced concrete structure interferes with the indoor magnetic environment, which makes the magnetic information become rich.It is the rich magnetic information that makes indoor localization based on magnetic field come true [16] [17].
In the past, magnetic indoor localization algorithm mostly concentrated on the particle filter algorithm [14] [15].Most indoor localization experimental platforms are mobile robot equipped with magnetic sensor, and the magnetic information is rarely processed.Equipped with gyroscopes, accelerometers and magnetic sensor, android smartphone makes a good localization platform.But the magnetic sensor is often affected by hard and soft-iron effects, resulting in large fluctuations [18].This paper analyzes the magnetic information of the mobile platform, and makes use of the robust local weighted regression algorithm to smooth the magnetic original data, which makes the established map more stable and accurate.Online stage moving average filtering model is used to filter the magnetic data which rely by particle filter as observation in the process of indoor localization and the data filtering makes online magnetic data more accuracy.

Magnetic Data Smoothen by Robust Local Weighted Regression Algorithm
The robust local weighted regression algorithm which is proposed by Cleveland After T times of repeats we can get the final fitted value  i y which is called robust local weighted regression fitted value.
Percentage f represents the window size, r fn = is the number of points occupied by the window, i h is the rth smallest value in , 1, 2, , In this paper, i x is coordinate point and i y is the corresponding magnetic energy value.Steps of calculating  i y are as follows: (1) For each magnetic data { } x y , compute the corresponding estimated parameters of d degree polynomial regression:  ( ) (2) Define the bisquare weight function as below: e y y = − be the residual of the fitted value, and s be the median of i e .Define the robustness weights: (3) Compute new  i y by fitting a th d degree polynomial using weighted least squares with weight ( ) (4) Repeatedly carry out steps 2 and 3 for T times, the final  i y is the mag- netic fitted value corresponds to point i x , and this process is called robust local weighted regression.

Online Magnetic Data Filtering by Moving Average Filtering Model
The moving average filtering model gets the filtered result ( ) t n  by averaging the N-1 points before ( ) t n and itself.For the magnetic observation data of the smartphone platform fluctuates violently that can reach 2uT , which is beyond the tolerance range of the magnetic-based particle filter location algorithm.
Moving average filtering model is used to filter online magnetic data and the filtering algorithm model is described below: where N is the number of moving average points, [ ] t n is the online magnetic data at time n .

Particle Filter Localization Algorithm
Particle Filter algorithm is usually utilized in indoor magnetic localization to estimate the position of user.We use particles { , }

Experiment
Experiments are conducted on the 3rd floor of keji building where is 27 meters long and 7 meters wide in Guilin University of Electronic Technology.The experimental environment is shown in Figure 1 and it is a corridor.Besides the corridor there is student lab in which a large number of experimental instruments help increase the richness of magnetic information.Experimental platform is smartphone Honor7.In the process of magnetic information acquisition and online localization, their directions are set to be the same.In the Y direction, we use 5 meters for a section and keep walking in the sampling process.Corresponding to the X direction, we choose 0.5 meters for interval and the whole sampling process example is shown in Figure 2.After sampling by the phone, each 5-metersmagnetic data are smoothed and mapped in 5 meters long coordinate with interval of 0.1 meter.Finally, two-dimensional plane interpolation is carried out to get total magnetic map with interval of 0.1 meter in both X and Y direction.

Simulation of Robust Local Weight Regression
In the process of smoothing, numbers of iterations T is set as empirical value of 5 and polynomial degree as 2 which means the local fitting objective function is  .Windows size f need to adjust the amount change of mag- netic data for there is not available empirical value.So we only discuss the size of window f and set f be 0.01, 0.06 and 0.15.Simulation results show Figure 3.
Magnetic data of 5 meters long are used to simulation.From the simulation results, when 0.01 f = , due to the window size is too small, there has been overfitting phenomenon.When 0.06 f = , the window size is set properly, so the fitting result is better.When 0.15 f = , due to the window size is too large, the fitting is in underfitting state and the fitting curve can't represent the original data.

Simulation Moving Average Filter Model
As the indoor localization has high demand of real-time, so in the process of filtering magnetic data, both filtering time and data stability have to be considered.
Limited by experimental phone's sampling frequency 100 HZ and the real-time is difficult to present by simulation, so the algorithm is only validated by simulation and there is no analysis about the number of moving average points.Set average number 50 N = , final magnetic observation is made by filtering the magnetic data within 0.5 seconds before the time point.We sample single point for 60 seconds and obtain 6000 sets of magnetic data.Moving average filtering model is used to filter the obtained data, simulation result is shown in Figure 4.
From the simulation results, filtered data have great improvements compared to the original data in stability.Although there are still fluctuations, taking into account the real-time factors, these fluctuations can be acceptable.

Online Measurement Data and Map Data Comparison
Construct magnetic map by robust local weighted regression algorithm and compare the map with online magnetic observation processed by filter model to validate the two methods.Figure 5 shows the matching result of the map created by the smoothing process and the online processed magnetic data.Figure 6 shows the matching result of the map created by original magnetic data and original online magnetic data.Figure 5 shows a better match error of 0.3941uT and Figure 6 shows match error of 0.846uT relatively.Matching result indicates that the processed magnetic data are more stable and have higher matching degree.

Online Simulation of Particle Filter
Through the above process, we get the magnetic map and online observation data which are used to simulate on platform MATLAB.The step length in walking and simulation are set the same of 0.5 meter, the variance of the weight func-   tion is 2 5 r σ = , number of particles is 100, initial distribution is evenly distri- buted in the range of (0 cm, 0 cm) to (100 cm, 2700 cm).Particle filter simulation results by processed data and unprocessed data are shown in Figure 7 and the localization errors are shown in Figure 8.
After the particles converge, the positioning results are analyzed as follows.
Simulation result by unprocessed data is lower in stability and accuracy than the processed data.The average error using processed data is 0.229 meter compared to the unprocessed data's 0.394.96.9% of the localization errors are lower than 0.5 meter by processed data but unprocessed data's 77.3%.

Conclusion
In this paper, robust local weighted regression algorithm is used to smooth the magnetic original data.Online magnetic observation data are filtered by moving average filter.Compare processed magnetic map and online processed magnetic observation, the average error of data matching is 0.3941uT.Indoor localization based on particle filter using processed map and online observation shows ave-   rage positioning error of 0.229 meter which is relatively better.But the problem is also exists, this result is in experimental environment.In the procedure of map construction and online data obtained, the height and direction of smartphone are same.We have to solve these problems by adding other algorithm such as magnetic sensor calibration algorithm or using magnetic variation as observation.The err

[ 19 ]
makes use of local data to fit the points by polynomials weighted fitting and the polynomial coefficient is estimated by the least square method.In local weighted regression algorithm, for each point i x , the weight ( ) k i w x is ob- tained from the weight function.Fitted value  i y is got by d degree poly- nomial fitting using the weighted least squares method with weight ( ) k i w x to fit i x .Then we can get i δ from residual  i i y y − and use new weight ( ) state.When the direction and observation is known, position of user can be estimated by Particle Filter algorithm which is used in the condition that the distribution ( | ) t t p x z cannot be measuring but prior ( ) t p x .When the al- gorithm beginning, initial distribution of particles is uniformly and randomly sampled from prior ( ) t p x .Then for every particle we calculate the weight tends to equal to ( | ) t t p x z .The main steps are shown below.noise is two dimensional Gaussian noise. ( )p x y subjects to the Gaussian distribution with y as the mean and 2 r σ as the variance:

Figure 4 .
Figure 4. Filter result by moving average filter with window size of 50 points.

Figure 5 .
Figure 5. Matching result by processed data.

Figure 6 .
Figure 6.Matching result by original data.

Figure 8 .
Figure 8.Localization error comparison between different data and the red line is localization error by original data and blue line is by processed data.