Abstract
In order to improve the positioning accuracy and reduce the impact of indoor complex environment on WiFi positioning results, an improved fusion positioning algorithm based on WiFi–pedestrian dead reckoning is proposed. The algorithm uses extended Kalman filter as the fusion positioning filter of WiFi–pedestrian dead reckoning. Aiming at the problem of WiFi signal strength fluctuation, Bayesian estimation matching algorithm based on
Introduction
With the development of the times, people are increasingly demanding positioning technology. Constantly improving the accuracy of positioning has been a hot area of research. 1 Global Positioning System (GPS) is a typical representative of outdoor positioning. The widely used GPS has changed the way of outdoor vehicle and pedestrian navigation, while its performance may deteriorate dramatically in the underground or indoor environment due to the existence of serious signal blocking and complicated multipath fading, 2 China began to develop the Beidou satellite navigation system in 1994 independently. The Beidou satellite navigation system is superior than the GPS, especially in the message function. The message function is that two-way communication can be performed between the Beidou satellite service station and the user, but the GPS can only accept the information from satellites. 3 In the first half of this year, China has launched Beidou-3 satellite into space in the form of a double satellite arrow. The construction of Beidou Global Navigation System has taken a solid step. Today, outdoor positioning technology is steadily maturing. Various GPS-based outdoor navigation systems have been widely used to provide convenient services for everyday life. 4 Due to the deteriorated performance or even with no assistance to localization in structure-complex indoor environment, the GPS cannot provide high-enough localization accuracy for indoor location-based service (LBS). In this circumstance, there are many other available techniques selected as the candidate solutions to indoor localization, such as ZigBee technology, wireless local area network (WLAN) technology, machine learning, radio-frequency identification (RFID), infrared, and other technologies. 5 WiFi positioning technology is widely used because of its low cost, simple erection, and high accuracy. However, this technology has some drawbacks cannot be avoided. First, under the influence of non-line of sight (NLOS) transmission of WiFi signals and complex indoor environment in different environment, the effect of WiFi fingerprint positioning is not ideal. Second, the pedestrian’s movement will affect the strength of the received WiFi signal. The fluctuation of the WiFi signal strength has a great influence on the positioning accuracy. 6 Therefore, how to adjust the fluctuation strength of signals is the primary problem to improve the positioning accuracy, and the single WiFi fingerprint positioning system cannot make the pedestrian’s trajectory positioned accurately. So, in the process of WiFi positioning, filter system is addded to reduce the interference of other factors on the strength of WiFi signal, so as to reduce the impact of fluctuation of signal strength on positioning accuracy. 7 The pedestrian dead reckoning (PDR) positioning method uses the inertial sensor to measure the step size, acceleration, and heading angle to complete the track position estimation. However, with the passage of time, a large inertia accumulation error will occur. In order to solve the error problem of the single algorithm in the implementation process, many scholars propose a fusion positioning algorithm based on WiFi-PDR, which reduces the error caused by the two algorithms alone, but the fusion algorithm is different, and the algorithm’s error value is also different. 8 They just improved the original algorithm, but at the meanwhile some have certain problems. These problems will be better solved with the continuous development of science and technology, in order to facilitate indoor positioning technology to better serve for the modern society.
Nowadays, there are more and more algorithms for indoor positioning technology, and the positioning accuracy is constantly improving. These algorithms have different advantages, but they also have their own limitations, so that a single technology cannot meet these challenges.
9
At present, the trend of indoor positioning technology development is to adopt the integration of multiple technologies in order to give full play to the advantages of a single technology and make up for each other’s shortcomings, increasing the number of devices in wireless networks can result in high device density, therein presenting both opportunities and challenges simultaneously.
10
The Internet of Things (IoT) has gradually changed the way of people’s lives due to its ability of connecting everything together, and meanwhile, the accurate location sensing plays a crucial role in achieving this goal. Up to now, the GPS has been widely used as one of the most representative outdoor localization systems, but its performance may be dramatically declined in indoor environment due to the serious multi-path effect and signal attenuation caused by the complicated indoor structure.
11
Its principle can be summarized as follows. First, it identifies the object attributes, which include static and dynamic attribute.
12
Static attribute can be stored directly in tags. Dynamic attribute needs to be detected by sensors in real time. Second, it needs to identify devices to read the object attribute and convert the information into data formats suitable for network transmission.
11
Then, the information of the object is transmitted to the information processing center through the network, and the related calculation of the object communication is completed by the processing center.
13
The processing center may be distributed, such as the computer or mobile phone, or it may be centralized, such as the Internet data center of the telecommunication operator. IoT is mainly used in medical, transportation, agriculture, and so on.
14
Among them, the most important is the application of indoor positioning. The development of IoT technology promotes the development of positioning technology and also provides well conditions for the development of indoor positioning technology.
15
Indoor positioning technology is the current research hotspot, and it is recognized by people because of its advantages in all aspects.
16
However, with the increasing popularity of smart phone applications, simple communication services have been unable to meet people’s requirements.
17
As people’s work and lifestyle continue to change, the functions of mobile terminals are also optimized and updated. In today’s society, people’s life and learning is more completed indoors, so research based on positioning service is also deepening. However, the traditional satellite positioning system is prone to signal attenuation or shielding in indoor condition. This leads to unsatisfactory positioning results on the basis of indoor positioning and IoT technology. The concept of smart city is put forward, and smart city is an effective method proposed to handle the above-mentioned city problems, in which the massive infrastructure components and services including transportation, energy, building, health care, education, real estate, and utilities can be effectively combined.
18
The high coincidence of the characteristics of the IoT and the smart city proves that the smart city is a platform for the centralized application of the IoT and a model for the integrated application of the IoT technology.
19
It is a larger demonstration project composed of
WiFi positioning and PDR positioning
Development status and main techniques of interior positioning
With the application and popularization of smart phones, its functions are gradually expanding and its performance is constantly improving. Now the rhythm of life changes, and also constantly the mobile phone function changes. At present, people’s life learning is more done indoors, so research based on location services is also deepening. As a result, the positioning result is not ideal. Therefore, more indoor positioning technology is needed to meet people’s requirements. In Du’s paper,
21
an indoor PDR algorithm based on received signal strength indicator (RSSI) ranging and positioning is proposed. The step detection is based on dynamic window, peak detection, and zero-crossing method.
22
The advantage is that, it can improve the positioning accuracy and reduce the positioning error range. The amount of calculation is complex, and the implementation time of this algorithm is too long. In the literature,
23
the adaptive linear feedback process is added in the fusion algorithm, which also improves the positioning accuracy to some extent, but the change is neither obvious nor easy to achieve.
24
In Qin and Xin’s paper,
23
the support vector machine (SVM) classification and regression analysis are combined into the WiFi positioning algorithm. The state transition is used to identify the walking cycle for the step counting, but the cumulative error of the PDR algorithm cannot be reduced.
23
In the literature,
25
an indoor positioning algorithm based on inertial measurement is proposed. By measuring the step size and acceleration of the movement to judge the movement state of pedestrians, the measurement of the step size and frequency is disturbed by external signals.
25
The measurements suffer from low precision, and the error area is expanded. Although the above literature improves the performance of a single positioning system through a fusion algorithm, there are still problems such as unreasonable WiFi matching weights and excessive PDR accumulation errors. The indoor positioning algorithm based on
WiFi positioning algorithm and improvement
The WiFi positioning method adopted in this article is KNN algorithm. The principle of KNN algorithm is, first, the fingerprint database is established in the offline phase.
28
Several reference points are selected in the positioning area, and the signal strength and position information of the reference point are recorded. An AP anchor is placed in each of the four corners of the room, and the number of selected reference points is
At present, the research on WiFi positioning technology mainly focuses on improving the positioning accuracy. The methods for enhancing the positioning accuracy are generally divided into two types, one is to change the positioning algorithm and the other is to filter the points in the fingerprint library to improve the fingerprint library. The accuracy of the fingerprint can narrow the error range of the positioning. If there are more points in the fingerprint database, the computation of the algorithm will be increased and the time consumption of the algorithm will be increased in the process of location. Therefore, it is necessary to filter and process these points in the fingerprint database. The implementation of KNN algorithm is to calculate the Euclidean distance between RSS samples measured in real time and RSS mean values corresponding to fingerprints in fingerprint database, and then find
where
The principle of Bayesian estimation is that in the online positioning stage, the posterior probability
where
The KNN algorithm is relatively simple to implement, but the accuracy is low and cannot meet the requirements of precise positioning. Bayesian estimation is also difficult to use because of the cumbersome calculation and large amount of data. Therefore, this article proposes a method that not only reduces the Bayesian calculation but also improves the KNN positioning accuracy. First,
where
PDR positioning algorithm
The principle of pedestrian track estimation is to use the initial position information and motion state of the pedestrian and to calculate the position, velocity, and direction angle at a certain moment according to the changing state of the walking direction and the position to complete the positioning.
30
In this article, the WiFi positioning result is the initial value of PDR positioning, which is recorded as (
In this article, the peak detection method is used to detect the number of steps.
31
With the built-in accelerometer of smart phone, the three-axis accelerometer can be used to measure the accelerometer, which can better adapt to the change of the mobile phone at any time and position. In order to better restore the original signal, a low-profile finite impulse response (FIR) digital filter is added in the front of the algorithm to filter out interference noise and spikes. The cut-off frequency can be adjusted according to the actual situation. After smoothing the raw acceleration data, the algorithm will search for the peaks and troughs of the waveform to identify different steps. Two thresholds, ACC and TIME, are set to filter false peaks caused by acceleration jitter that are too small or too short in duration. For the step count detection, it is expected that a similar waveform will be repeated at every other step in consideration of the user’s alternate left and right feet during normal walking. Based on this feature, we design a dynamic time warping (DTW) verification algorithm to determine whether the steps detected by peak value are real steps. DTW verification works as follows:
32
assume that peak detection produces a series of detected steps [
The step detection has a great influence on the accuracy of PDR positioning. The traditional step calculation method is based on the linear model. The coefficients in the linear model are obtained through offline learning.33,34 However, the training samples do not take the differences between many individuals into account, so the scope of application is limited. In this article, a non-linear model is used to estimate the step size. The formula is as follows
where
A common feature often found in most buildings is that buildings are constructed in a manner similar to squares or rectangles, or both. Moreover, the rooms and corridors inside these buildings tend to be aligned with the exterior of the building.35,36 Although not all buildings are constructed in this way, many buildings are like this. Therefore, most people walking in such buildings are restricted to only follow this characteristic. Therefore, in the PDR algorithm, we make the following provisions: suppose the heading angle of the pedestrian at time
It is considered that there is no change in the walking direction, and the pedestrian walks in a straight line. If
Extended Kalman filter–based fusion positioning algorithm
Principle of extended Kalman filter algorithm
Because the system model in this article is non-linear, extended Kalman filter (EKF) is used for processing. The core idea of EKF is to linearize the non-linear system and then perform Kalman filtering. EKF is a suboptimal filter.37,38 Subsequently, the proposed application of a variety of second-order generalized Kalman filtering methods further improves the estimation performance of Kalman filtering for non-linear systems. The second-order filtering method considers the quadratic term of Taylor series expansion, thus reducing the estimation error caused by linearization, but the amount of computation is greatly increased. Therefore, the first-order EKF is not widely used in practice. In summary, the first order of state estimates for non-linear models is to be obtained.39,40 Taylor expands and applies the linear Kalman recursion formula. Thus, the local optimal solution is obtained. The EKF algorithm flow is as follows: 41 set the state equation and measurement equation of the non-linear system to
and
The non-linear function
Expanded to
if
then the formula can be converted to
in the same way
Fusion algorithm and post-correction module
The EKF fusion algorithm flow is shown in Figure 1. The WiFi positioning result is used to set the initial value of the filter start value and PDR positioning. Gait detection is used to judge whether the pedestrian walks one step according to the acceleration, and the orientation is obtained according to the gyroscope, the direction sensor, and the map information. When the pedestrian completes the one-step walking action, the WiFi processing module is notified by the synchronization control module to perform the WiFi positioning solution, the iterative calculation of the measurement update, and the status update is started. In the post-correction module, the input information is the positioning result obtained by fusion, and then the matching probability of this point is calculated using Bayesian algorithm. If the matching probability is higher than the maximum matching probability of WiFi positioning alone, the fusion positioning result is the final positioning result. If the matching probability is lower than the maximum matching probability of WiFi location, the positioning result shall be saved first and the secondary positioning should be carried out. If the secondary positioning result is higher than the maximum probability, it shall be the final result, otherwise, the mean value of this result and last saved result shall be taken as the final result. The maximum matching probability is the maximum posterior probability. According to the posterior probability formula, we need to know the signal strength of the location point and the prior probability of the point. The prior probability generally obeys the uniform distribution. In the post-correction module, the result of fusion positioning is input. After obtaining the fixed-point coordinates, the corresponding

Structure flow chart of EKF-based fusion correction positioning algorithm.
Experimental results and analysis
In the choice of experimental scenes, relatively open indoor is helpful for the comparison and observation of experimental results. The placement of indoor APs is also an important factor affecting the experimental results. After comparison, the first floor of the main building is selected as the experimental environment for indoor positioning, and the position of the wireless AP is shown in Figure 2. The OPPO R7 mobile phone is selected as the acquisition tool of WiFi signal strength and PDR data, and the positioning algorithm proposed in this article is used for experiments. In the course of the experiment, in order to prevent errors caused by signal interference, the data in the experimental scene should be measured and collected multiple times.

Floor plan of the positioning area and the layout diagram of AP.
Comparing the traditional KNN algorithm with the improved KNN algorithm through experiments, the cumulative error chart is drawn. As can be seen from Figure 3, the cumulative probability of the improved algorithm within 1 m is about 46%, which is about 5% higher than the traditional algorithm. The cumulative error probability within 1.5 m is greater than the original algorithm, and the cumulative probability of the improved algorithm within 2 m can reach 90%. It can be seen that the improved algorithm is lower than the traditional algorithm in terms of average error and maximum error, and the positioning accuracy is significantly improved.

Cumulative probability of the original KNN algorithm.
It can be seen from Figures 3 and 4 that the KNN algorithm has a large error, and the degree of fluctuation of the data is large, which is not conducive to improve the accuracy of indoor positioning. Although the new algorithm improves the positioning accuracy to a certain extent, it is not enough to meet the actual needs of life. Therefore, the concept of fusion algorithm is proposed to further improve the positioning accuracy. The accuracy of the algorithm highlights the fusion positioning algorithm based on WiFi and PDR and deals with the problems encountered in the implementation of the positioning system and analyzes the algorithm error.

Cumulative probability of improved KNN algorithm.
Figure 5 shows the location trajectory obtained using three algorithms, respectively. The first curve represents the actual walking path of pedestrians. The second curve represents the estimated path obtained by a separate WiFi localization algorithm. The third curve represents the location result of a separate PDR algorithm. The fourth curve represents the experimental results of the improved fusion localization algorithm. It can be seen from the figure that the error of WiFi positioning is higher than that of the other two algorithms. This is because the change in signal strength has a great influence on the positioning result, and the signal grab is easily affected by environmental factors, so there is a lot of volatility. The PDR positioning algorithm has little difference with the precision of the fusion correction algorithm at the beginning, and as time goes by, the cumulative error of the PDR algorithm gets larger and larger, and the precision gradually decreases. By correcting the localization result, the fusion localization algorithm can control the error within 1.5 m, which greatly improves the localization result.

WiFi, PDR positioning, and fusion correction positioning algorithm trajectory.
For a clearer analysis of the error, we plot Figure 6. In this figure, the error of using the WiFi algorithm alone is large, the maximum error is nearly 4 m, and the cumulative error reaches 1 corresponding error distance that is larger than the other two algorithms, and the effect is not satisfactory. The second line is the error of PDR algorithm used alone. Since the PDR algorithm is a process of speculative estimation, the error of the PDR algorithm will become larger and larger with time, which is similar to the multiple use of rounding in the calculation process. When the process is used many times, there will be a large difference between the calculation result and the real result. The third line describes the cumulative error of the fusion algorithm. The result of WiFi positioning is used to initialize the PDR algorithm, which avoids the excessive accumulation error of the PDR algorithm, also improves the accuracy of the single WiFi algorithm to a certain extent. The error accumulation probability of the fusion algorithm is smaller than the distance corresponding to the other two algorithms. It can be clearly seen that the fusion algorithm is superior to the accuracy of the WiFi and PDR algorithms alone in the accuracy and error range of the positioning.

Comparisons of cumulative errors of three algorithms.
Finally, comparing the maximum, minimum, and average error values of the fusion algorithm with other algorithms, the minimum error of the PDR algorithm and the fusion algorithm is similar in three ways, but the maximum and the average errors are different, they are all higher than the fusion algorithm, and the cumulative error of the PDR algorithm is gradually increased, and the maximum has exceeded 2.5 m. However, the maximum error of the fusion positioning algorithm is controlled within 2 m, and the average error is about 1.39 m. It is shown that the improved fusion algorithm outperforms the results of the two algorithms alone in the error range, and the improved algorithm can suppress the occurrence of large errors to some extent.
The histograms of three error numerical comparisons are drawn. First, the maximum error of one algorithm is analyzed separately, and then the error values of three algorithms are compared and analyzed. The effect of the improved algorithm is observed by the difference in the errors between the algorithms.
Then, the maximum, minimum, and average error of the three algorithms are compared. As can be seen from Figures 7–9, the difference between the three algorithms in the minimum error is not obvious. The minimum error of the WiFi algorithm is slightly higher than the error of the PDR algorithm alone and the error of the fusion algorithm. However, at the maximum value of the error, the maximum error of the single WiFi algorithm and the PDR algorithm is significantly higher than the error of the fusion algorithm, wherein the maximum error of the WiFi algorithm is higher than the maximum value of the fusion algorithm about 1.3, and the maximum error of the PDR algorithm is about 1 m higher than the fusion algorithm. In terms of average error, the error of the fusion algorithm is also lower than that caused by the other two algorithms alone. The error mean of the fusion algorithm is about 0.5 m lower than the average error of the WiFi algorithm and 0.3 m lower than the average error of the PDR algorithm. It can be seen that the three errors have been improved in numerical value.

Maximum, minimum, and average error of WiFi algorithm.

Maximum, minimum, and average error of PDR algorithm.

Maximum, minimum, and average error of fusion algorithm.
In order to compare the errors of the three algorithms more clearly, the maximum and average errors of the three algorithms are drawn together. As shown in Figure 10, it can be seen that the fusion algorithm is lower than the other two algorithms in three values, and the positioning accuracy is obviously improved. The difficulty in implementation and the running time of the improved algorithm are obviously ameliorated, which is the result that the other two algorithms cannot surpass when they are used alone. Kalman filtering algorithm can get local optimal solution, which can improve positioning results significantly.

Error comparison of three positioning algorithms.
Conclusion
Smart city construction should embody the people-oriented development concept and solve the problems faced by cities using modern science and technology development and information technology. To improve the accuracy of positioning, this article proposes an indoor positioning algorithm based on WiFi and PDR fusion, which not only solves the problem of large fluctuation of WiFi signal strength and environmental impact but aslo reduces the cumulative error of PDR algorithm to some extent. In order to reduce the influence of signal fluctuation on the indoor positioning accuracy, first, the signal intensity is filtered, and then the points which are too different from the average strength are filtered out to reduce the positioning error. It can also reduce the amount of calculation in the process of establishing fingerprint database.
In the process of realizing the positioning system, KNN algorithm is used to filter the points needed for positioning, which further simplifies the calculation. In this article, Bayesian algorithm served as filter to those points with high probability of matching, which improves the positioning accuracy of WiFi. The way of PDR is accomplished by measuring the step size, stride, and direction angle base on smart phones. Finally, the fusion of the two algorithms is completed by EKF, and the final location result is output by the post-correction module. It is shown in experimental verification that the positioning error can be reduced and the positioning accuracy can be improved to a smaller scope. This article makes use of the built-in device of the smart phone to determine the step size, frequency, and direction angle of pedestrians. However, as pedestrians carry smart phones in different ways, the detection result will inevitably be affected. In actual life, when people walking, their mobile phones are placed in the pocket, or are calling, sending, and receiving text messages. Different placement methods have diverse effects on the direction of pedestrian walking, and moreover results in another detection result. The placement of these mobile phones will make a deviation between the direction of mobile phones and the direction of pedestrians walking. How to reduce the influence of this deviation to meet the positioning requirements under different phones placement conditions is a problem that needs to be solved in the future.
Footnotes
Handling Editor: Paolo Barsocchi
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported in part by the National Natural Science Foundation of China (Grant No. 61871348) and Open Foundation of Laboratory (No. 2018JYWXTX02).
