Skip to main content
Advertisement
Browse Subject Areas
?

Click through the PLOS taxonomy to find articles in your field.

For more information about PLOS Subject Areas, click here.

  • Loading metrics

Gyroscope-constrained magnetometer PDR/Wi-Fi indoor positioning algorithm

Abstract

To address the issue of low precision in sensor data measured by smartphones, we propose a gyroscope-constrained magnetometer Pedestrian Dead Reckoning (PDR)/Wi-Fi indoor positioning algorithm, focusing on improving the PDR heading angle. We utilize the heading angle constrained by the gyroscope and magnetometer and enhance fingerprint data using Kriging interpolation, effectively doubling the signal fingerprint density. We combine the optimized PDR algorithm and Wi-Fi fingerprint positioning results through an Extended Kalman Filter. Experimental results show that the traditional PDR algorithm has an average positioning error of 2.02 meters, with 90% of errors below 3.71 meters. The improved PDR algorithm reduces the average positioning error to 1.07 meters, with 90% of errors below 2.12 meters. Integrating Wi-Fi and the improved PDR algorithm further reduces the average positioning error to 0.71 meters, with 90% of errors below 1.42 meters.

1. Introduction

In indoor positioning, each standalone positioning technology offers unique advantages and limitations. Given the complexity of different scenarios and environments, relying on a single method for smartphone positioning presents numerous challenges. Multi-source fusion positioning technology has emerged as an effective solution to fully exploit the strengths of various positioning systems and enhance indoor positioning performance [1,2]. This technology integrates complementary sensor data from multiple sources, significantly improving positioning accuracy [3,4]. By leveraging the advantages of different sensors, it compensates for the deficiencies of individual systems, providing more stable and precise results for indoor positioning. Multi-source fusion technology effectively addresses the complexities and variability of different environments, achieving more reliable and efficient smartphone positioning. Multi-source fusion has become a core direction in the development of indoor navigation technology. In smartphone indoor positioning, fusion methods often encompass a combination of Wi-Fi, Bluetooth [5], geomagnetic [6], and Pedestrian Dead Reckoning (PDR) [7,8]. The integration of these technologies dramatically enhances positioning accuracy and stability. Each technology provides location information through different mechanisms with unique strengths and limitations. Common strategies include Kalman filtering and particle filtering to fully leverage their advantages and mitigate their shortcomings [9,10]. These methods effectively integrate data from various technologies, thereby improving the accuracy and stability of indoor positioning.

In the research on Wi-Fi and PDR fusion positioning, Chen et al. [7] employed Kalman filtering to integrate Wi-Fi fingerprint positioning results with PDR positioning results. This approach reduced the PDR positioning error and enhanced the stability of Wi-Fi positioning. Utilizing the prediction and update mechanisms of Unscented Kalman Filtering more effectively managed the uncertainty and noise in sensor data, significantly improving the accuracy and stability of the fusion positioning. Wang Zhaoyuan et al. [8] integrated Wi-Fi, geomagnetic, and PDR technologies comprehensively. To address the particle degeneration problem, they introduced a sequential particle weighting method. Additionally, they reduced computational complexity by updating particle weights through region partitioning. This fusion positioning method achieved accuracy within one meter in an indoor corridor environment. This method successfully combined the unique advantages of different sensors, significantly improving positioning accuracy and stability. Moreover, the optimized particle filtering algorithm effectively reduced computational load, enhancing both the practicality and stability of the algorithm. Liu Y [6] proposed a three-dimensional floor positioning method based on the fusion of PDR and geomagnetic information. By analyzing acceleration signals together with barometric pressure variations, this method provides a theoretical basis for identifying whether a pedestrian is ascending or descending stairs, thereby supporting the construction of a geomagnetic reference map [11]. Furthermore, the particle filtering technique was used to finely correct the PDR results, ensuring the precision of the pedestrian’s movement trajectory. By combining the advantages of both PDR and geomagnetic information, this method improved the accuracy and stability of floor positioning.

2. Related work

2.1 Wi-Fi indoor positioning algorithm

Commonly used positioning algorithms are deterministic matching algorithms and probabilistic matching algorithms. For example, NN(Nearest Neighborhood), KNN (K Nearest Neighborhood), WKNN(Weighted K Nearest Neighborhood), and VWKNN(Variation Weighted K Nearest Neighborhood) are typical deterministic matching algorithms. The naive Bayes algorithm and the improved algorithm are probability-matching algorithms. The KNN algorithm uses the mean as the positioning result to ignore the distance between the undetermined point and the different adjacent points [12,13]. The WKNN algorithm weakens the adverse effect of the estrangement point on the final positioning, cannot dynamically determine the value of K, and cannot find the optimal K value [14]. VWKNN [15]considers the degree of signal dispersion at the reference point and calculates the dispersion of each reference point as a weight. The above methods need to consider the influence of the K value on the positioning results. The fixed K value will reduce the mobility and availability of the algorithm. Therefore, this paper chooses to use the EWKNN algorithm for Wi-Fi positioning to provide initial bit value and correction for the PDR algorithm. The EWKNN algorithm flow is shown in Fig 1.

thumbnail
Fig 1. EWKNN algorithm flow chart.

This algorithm can obtain an adaptive dynamic position.

https://doi.org/10.1371/journal.pone.0335277.g001

Fig 1 is the algorithm flow of EWKNN. Based on WKNN, the algorithm selects the number of reference points whose Euclidean distance is less than the threshold distance as n and sorts it to calculate the average distance. D in the image is the distance threshold, and {D1, D2, D3…Dn} are the points with Euclidean distances below the threshold sorted accordingly. By eliminating the points that are more significant than the mean distance, k points whose distance is less than the mean value are obtained. The k value is dynamically adjusted according to the mean value of the distance between each point.

After calculating the weight of each point based on distance weighting, substitute the weight and coordinates of each point into the formula in the graph to calculate the current position coordinates (x, y).

2.2 PDR indoor positioning algorithm

PDR is a relative positioning technology using smartphones’ built-in MEMS inertial measurement unit [16], which can continuously track the two-dimensional position of pedestrians. As an autonomous localization method that does not rely on external signals, PDR calculates and updates the pedestrian’s position at the next moment by combining the position information of the previous moment (Xt, Yt) with the heading and displacement data provided by the inertial sensor (Xt + 1, Yt + 1) [17]. This positioning method mainly depends on the sensor data inside the mobile phone, which realizes the continuous tracking of pedestrian position. The specific process is calculated as follows:

(1)

There, step _ len denotes step length and heading angle. PDR’s core problem lies in step length, step frequency, and heading angle [18,19]. This section will introduce the algorithm principle of three aspects. First, the step frequency is detected by zero-crossing detection and trough pairing principle to improve the accuracy of step frequency detection. A step length calculation method is proposed to consider acceleration and peak valleys in the gait cycle. In addition, the heading is updated using geomagnetic calculation and gyroscope correction.

  1. (1). Step frequency detection

In a complete gait cycle, the acceleration will appear in apparent peaks and troughs, and the two usually appear in pairs. In addition, between the trough and the peak, the acceleration will go through a zero.

Based on this feature, this paper takes the acceleration passing through the trough peak in pairs and the zero crossing as the basis or principle for judging pedestrians to take a step. The algorithm flow is shown in Fig 2. After multiple continuous filtering of the acceleration signal, the above peak-valley and zero-crossing detection algorithms are used for the solution.

thumbnail
Fig 2. Step frequency detection algorithm.

Whether a step is taken is determined by the relationship between the zero-crossing time, peak time points, and trough time points.

https://doi.org/10.1371/journal.pone.0335277.g002

When zero timestamp , peak timestamp , and trough timestamp have the relationship , it is considered a valid trough and peak, completing a step.

  1. (2). Step length calculation

Step length is affected by many factors, such as height, age, gender, and pace [20]. However, in practical applications, it is often impossible to directly obtain the personal information of pedestrians [21]. In order to solve this problem, we can use the characteristics of the sensor data itself to construct the step size model. This way, relatively accurate step length information can be estimated from sensor data, even without additional personal information. The step size will change significantly when the pedestrian’s walking state changes, such as from fast to slow walking. This change will also be reflected in the acceleration characteristics because there is a specific correlation between acceleration and step length. In order to estimate the step size more accurately, we can use the relationship between the acceleration characteristics to model and analyze. This way, even if the pedestrian’s walking state constantly changes, it can accurately understand its movement state. The Weinberg [22] model holds that there is a positive correlation between the pedestrian’s step length and movement amplitude. Meanwhile, the body’s movement amplitude is related to the variation range of body acceleration, which is calculated by the difference between the peak and trough values. The formula is as follows:

(2)

amax is the maximum value of acceleration within a gait cycle, and amin is the minimum value of acceleration within a gait cycle. K is the model parameter, and L is the step length.

The Kim [23] model is an estimation model that takes into account all acceleration information within a single step of a pedestrian. Compared with the Weinberg model, it reduces a certain amount of acceleration noise interference. The formula is as follows:

(3)

Among them, ai represents the acceleration at each sampling point within a gait cycle, N denotes the number of sampling points, K is the model parameter, and L stands for the step length.

Article [18] makes improvements based on Weinberg’s (model/theory) and optimizes the error problem caused by fixed coefficients. The formula is as follows:

(4)

Among them, L is the improved estimated step length, amax and amin are the maximum and minimum values of the resultant acceleration in each step, and m and k are coefficients.

In this paper, an adaptive step size estimation model is proposed. This model combines multiple factors, including stride frequency, the ratio of the sum of accelerations in the gait cycle to stride frequency, and the difference between the peak and trough of acceleration.

This adaptive feature makes the step size estimation more accurate and improves the robustness of the model in the face of different walking modes. The formula is as follows:

(5)

Among them, Len is the step length, sf is the step frequency, is the sum of the acceleration ratio frequency in a gait cycle, and Acc _ diff is the difference between the acceleration peaks and valleys in a gait cycle. The coefficients of each characteristic parameter in the equation of a, b, c, d. The coefficients were obtained via multiple linear regression.

  1. (3). Heading angle estimation

This paper proposes a heading estimation algorithm for gyroscope correction geomagnetic. It is proposed that the heading angle of magnetic calculation be corrected by using the variation of the gyroscope in a short time. The algorithm flow is shown in Fig 3.

thumbnail
Fig 3. Heading angle estimation algorithm.

A real-time heading angle is provided by the magnetometer, and the accurate heading angle is obtained by constraining the variation of the magnetometer with the gyroscope.

https://doi.org/10.1371/journal.pone.0335277.g003

This method uses a gyroscope to correct the heading of the magnetometer, comparing the differential calculation between the change in the magnetometer () and the change in the gyroscope () with the change in the actual heading angle (), where is the difference in the actual heading angle between the last two moments. When the difference between the magnetometer and the gyroscope is less than the actual change in heading angle, it is considered that the magnetometer is not disturbed and directly outputs the result as the actual heading angle. When it is greater than the actual change in heading angle, it is considered that the magnetometer is abnormal, the calculated heading is inaccurate, and the magnetometer’s heading angle from the previous moment is output as the actual heading angle.

In pedestrian walking, the gyroscope is reset once every ten seconds to provide more accurate gyroscope data for the heading angle calculated by the constraint magnetometer. The gyroscope only needs to detect the change in the pedestrian heading angle and does not need to carry out complex coordinate transformation. Since a single gyroscope has an empty window period of not less than 4s after reset and before stable output, the gyroscope will not be able to constrain the heading angle of the magnetic force during the geomagnetic mutation and pedestrian heading angle change during the empty window period. It is improved to the heading angle calculation of the magnetometer constrained by double gyroscopes to ensure that there is a gyroscope that can be used to constrain the heading angle of the magnetic solution at any time. The working sequence of the magnetometer and gyroscope is shown in Fig 4.

As shown in Fig 4, the operation of gyroscope 2 is delayed by 4s so that at least one gyroscope can constrain the operation of the magnetometer for all working hours. Each gyroscope adopts the constraint algorithm shown in Fig 3. When only gyroscope 1 works, gyroscope 1 is used for constraint. When two gyroscopes are working, gyroscope 1 is still used. When only gyroscope 2 is used, gyroscope 2 is used for constraint.

  1. (4). The position model proposed in this paper

This paper proposes an indoor positioning technology based on Wi-Fi/ PDR fusion. In the case of plane walking, the positioning results of Wi-Fi signals [24] are used to fuse the improved PDR (Pedestrian Dead Reckoning)algorithm to achieve accurate position estimation. As shown in Fig 5:

By using EKF(Extended Kalman Filter), the nonlinear PDR positioning model is expanded by the Taylor series [25,26], and the terms above the second level are omitted to obtain an approximate linearized model to obtain the fusion positioning of PDR and WiFi positioning results. The dynamic position information model is established as follows:

  1. ①. State transition equation:
(6)

Where is the process noise of non-Gaussian distribution of the state transition equation; is the fusion positioning result of the nth step, is the fusion positioning result of the n-1th step, is the heading angle of the nth step, is the heading angle of the n-1th step, and is the estimated increment of the direction angle.

  1. ②. Observation equation:
(7)

Among them, r2 is the observation noise, is the Wi-Fi fingerprint positioning result, and is the observation step size.

  1. ③. Initial state:

The initial position is the positioning result obtained by the EWKNN positioning model, and the initial covariance is P1. Then the priori estimate of the system is:

(8)(9)

where, is the state transition matrix, and R1 is the covariance matrix of process noise r1.

  1. ④. Update phase:

The updated Kalman gain of step n is as follows:

(10)

where H is the observation matrix and R2 is the covariance matrix of process noise r2.

  1. ⑤. Output results:

The state and covariance matrix are updated by the observation variable Yn, and the posteriori estimation of the system is shown as follows:

(11)(12)

The output Xn is updated circularly to obtain the fusion positioning coordinate position .

3. Experimental setup

  1. (1). Establish a Wi-Fi signal database

Four APs are deployed in the lobby of the first floor of the experimental building, and the acquisition grid is divided into 0.6 * 0.6m grids as the acquisition points. The data acquisition method of each AP at the reference point is shown in Fig 6. Each red point is a reference point, and the black is the random test point. Each reference point continuously collects one minute of data at a frequency of 1 Hz. After Gaussian filtering, the average value is recorded as the fingerprint of the point, and the location fingerprint(LF) database structure is Equation (1)

(13)

In the formula, LF is an offline fingerprint database, which contains the coordinates of each reference point and the RSS value of each AP at that point, and (xm,ym) is the physical location of the mth point. is the signal strength of the nth AP received at the mth reference point.

  1. (2). WiFi Fingerprint Data Augmentation

The Wi-Fi signal acquisition mentioned in the previous section is a fingerprint database collected at an interval of 0.6m in the indoor environment. At present, there are two main ways to improve the accuracy of positioning. One is to optimize the fingerprint algorithm, and the other is to optimize the fingerprint data, filter the fingerprint data of each AP, or interpolate the data to improve the data density. This study will interpolate the original data to improve the fingerprint density. The commonly used interpolation algorithms include nearest neighbor interpolation, inverse distance weighted interpolation, and Kriging interpolation. The Wi-Fi fingerprint database is arranged in physical coordinates, and the Wi-Fi fingerprint database diagram is established by different interpolation methods. By calculating the index parameters of the above three interpolation algorithms, a reasonable choice is made.

The appropriate algorithm is selected by quantitative analysis of the characteristics of the three. In order to obtain the difference between the data sets before and after interpolation processing, the two data sets are compared. These two data sets are the original data set (including the Wi-Fi signal strength of the original measurement) and the interpolated data set. The Wi-Fi signal strength values of each corresponding position in the two data sets are subtracted, and the difference is calculated. The difference is the residual deviation value based on the received signal strength. In addition, in order to quantify this degree of deviation, the standard deviation of these deviation values is calculated, and the maximum deviation and the minimum deviation are compared in dBm. The results are shown in Table 1.

From the data in Table 1, it can be observed that the Kriging interpolation method demonstrates more pronounced data deviation compared to the Inverse Distance Weighting interpolation method and the Nearest Neighbor interpolation method. This suggests that the raster data generated by Kriging interpolation may be slightly less effective in terms of the concentration and dispersion of values. However, in contrast to Inverse Distance Weighting and Nearest Neighbor methods, it exhibits more intuitive and easily identifiable characteristics, making the data more conducive to feature matching.

  1. (3). Real-Time Inertial Data Acquisition and Test Path

The experimental scene is the first-floor hall of the experimental teaching building of the school. The indoor environment is shown in Fig 7, using the accelerometer, magnetometer, and gyroscope integrated with the Glory V30 mobile phone. Using phyphox data acquisition software, data output for CSV and EXCEL two data formats. The software interface is shown in Fig 7(a):

thumbnail
Fig 7. Phyphox interface and collection route.

(a) phyphox user interface. (b) Pedestrian actual data collection route.

https://doi.org/10.1371/journal.pone.0335277.g007

In the data acquisition stage, the software collects pedestrian motion state information, and the frequency is set to 50 Hz. The pedestrian movement trajectory is shown in the Fig 7(b) The pedestrian’s handheld mobile phone walks along the established route to collect data and saves the data in EXCEL format for the simulation platform. The hardware configuration of the simulation platform is AMD Ryzen7 5800H CPU 16G memory, NVIDIA GeForce RTX3060Ti 8GB GPU, and the software configuration is 64-bit Windows 10 professional version and Matlab 2019.

4. Results

4.1 Wi-Fi fingerprint positioning results

In Wi-Fi fingerprint positioning, the EWKNN algorithm is used to locate the fingerprint. In order to verify the algorithm, 160 points are randomly collected in the environment of collecting fingerprint database by the same method, and the four indexes of maximum error, minimum error, average error, and cumulative distribution function (CDF) of 160 points are calculated. The advantages and disadvantages of KNN, WKNN, and EWKNN are compared. In another set of experiments, the positioning performance of KNN, WKNN, and EWKNN algorithms after interpolation is compared using the same test points.

It can be seen from Table 2 that KNN, WKNN, and EWKNN positioning errors, KNN positioning error is the largest, WKNN positioning error is more minor than KNN, EWKNN positioning error is the smallest, and KNN and WKNN results are optimal when K = 4.

thumbnail
Table 2. Error of different positioning algorithms under raw data.

https://doi.org/10.1371/journal.pone.0335277.t002

The error probability statistical analysis of the above three algorithms is carried out, and the cumulative distribution of positioning error is shown in Fig 8. It can be seen from the figure that the probability that the positioning accuracy of the EWKNN algorithm is better than 2.5m is 88%, and the probability that the accuracy of WKNN and KNN algorithms is better than 2.5m is 76% and 69%, respectively.

thumbnail
Fig 8. The cumulative distribution function of the original fingerprint error.

https://doi.org/10.1371/journal.pone.0335277.g008

In order to better verify the conclusion in 2.1, the EWKNN algorithm is tested on the fingerprint database enhanced by three different interpolation algorithms. Table 3 shows the experimental results.

thumbnail
Table 3. The positioning error of EWKNN in different fingerprint databases.

https://doi.org/10.1371/journal.pone.0335277.t003

The EWKNN algorithm is positioned in the fingerprint database and enhanced by the above three interpolation algorithms, and the error probability of the result is statistically analyzed. The cumulative probability error is shown in Fig 9.

thumbnail
Fig 9. Localization error cumulative distribution function graph of EWKNN under different fingerprint databases.

https://doi.org/10.1371/journal.pone.0335277.g009

Taking the EWKNN algorithm as an example, the fingerprint database enhanced by different interpolation algorithms is located respectively. The results are shown in Fig 9. The positioning error of the Kriging interpolation algorithm is significantly reduced after enhancement, and the effect of the nearest neighbor interpolation algorithm is not apparent. The minimum error positioning result is 0.72m, which is greater than the original fingerprint error. Therefore, this paper chooses the Kriging interpolation algorithm to enhance the fingerprint database.

The Kriging interpolation is used, and the interval size of the fingerprint database is 0.3 m after one interpolation. The same test points are used to test the above fingerprint database and database. Table 4 shows the performance of the above algorithms after interpolating the fingerprint database, and the K value is consistent with the above.

thumbnail
Table 4. Positioning error after fingerprint interpolation.

https://doi.org/10.1371/journal.pone.0335277.t004

It can be seen from Table 4 that after one interpolation, the positioning errors of the above three algorithms are improved. The average positioning error of the KNN algorithm is reduced by 16.5%, the average positioning error of the WKNN algorithm is reduced by 12.6%, and the average positioning error of the EWKNN algorithm is reduced by 21.4%. After one interpolation, the positioning results are improved due to increased fingerprint database density.

After interpolation, the error probability statistical analysis of the above three algorithms is carried out, and the cumulative distribution of positioning error is shown in Fig 10. According to Fig 10, the probability of EWKNN algorithm positioning accuracy better than 1.7m is 96%, and the probability of WKNN and KNN algorithm accuracy better than 2m is 89% and 73%, respectively.

thumbnail
Fig 10. Cumulative distribution function of different algorithms after interpolation.

https://doi.org/10.1371/journal.pone.0335277.g010

4.2 Step frequency detection and step size estimation

In the experiment, the tester horizontal hand-held mobile phone parallel to the ground; the experiment was carried out a total of 5 times, every 100 steps, calculate the average error, accuracy and test steps, walking estimation error by the formula (11) to calculate:

(14)

Among them, Error is the detection error rate, teststep is the number of steps detected by the detection algorithm, and turestep is the actual number of steps.

The step results obtained by the peak detection, zero-crossing detection, and the detection algorithm in this paper are tested. The step results of the three algorithms are as follows: Table 5 shows:

thumbnail
Table 5. Step frequency detection results The detection results of different step frequency detection algorithms.

https://doi.org/10.1371/journal.pone.0335277.t005

It can be seen from Table 5 that the average step frequency detection accuracy of the peak and trough after five-step counting experiments is 91%. The zero-crossing detection algorithm’s average step frequency detection accuracy is 96.8%. The average step frequency detection accuracy of this method is 99.2%. The peak-valley step frequency detection algorithm has the lowest accuracy, mainly because the acceleration peak has pseudo-peaks and pseudo-valleys that the filter does not filter due to noise. The accuracy of the zero-crossing detection algorithm is high, and there is a specific error. This is because there are other zero-crossing moments when the acceleration signal fluctuates wildly when the pedestrian begins to walk. The detection method in this paper has higher accuracy and meets the requirements of indoor positioning for step frequency detection.

The Weinberg [22] model, Kim [23] model, improved Weinberg model [18] and the model proposed in this paper are compared in the step size estimation experiment. In the experiment, a pedestrian walked 50 steps at a fixed length of 60 cm with a mobile phone in front of his chest parallel to the ground. By comparing the experimental results, the model proposed in this paper shows higher stability and minor errors in step size estimation. Specifically, compared with the Kim step model, the average error of the proposed model is reduced by 4.52%. Compared with the Weinberg step size model, the average error is reduced by 3.07%. Compared to the improved Weinberg model, the average error is reduced by 1.13%.These data show that the model in this paper has certain advantages over other models in step size estimation in pedestrian dead reckoning.

Fig 11 shows the step size of each algorithm by comparing the step size of each step. Fig 12 shows the average error results of each step experiment obtained by 20 experiments of different models. The algorithm in this paper is more stable than the other two algorithms. The average error of the algorithm in this paper is 2.84 cm 20 times, 3.03 cm for the Kim model, 2.95 cm for the improved Weinberg model, and 2.96 cm for the Weinberg model.

thumbnail
Fig 11. Comparison of the results of one experimental step length.

The step length results of four models in one experiment.

https://doi.org/10.1371/journal.pone.0335277.g011

thumbnail
Fig 12. Step error statistical chart.

Demonstration of step length errors of four models obtained through 20 experiments.

https://doi.org/10.1371/journal.pone.0335277.g012

4.3 Heading estimation experiment

In this paper, the gyroscope’s high precision n in a short period is used to constrain the heading angle obtained by the magnetometer and the acceleration. Since the gyroscope’s direct calculation is that the carrier coordinate system needs to be transformed through the coordinate system to obtain the angle in the navigation coordinate system, this paper proposes to use the variation of the gyroscope in a short period to correct the heading angle calculated by the magnetic force. The gyroscope detection time window is 1 second, and the heading angle calculation result is shown in Fig 13.

thumbnail
Fig 13. Comparison of heading-angle calculation results.

Comparison of heading-angle changes before and after correction.

https://doi.org/10.1371/journal.pone.0335277.g013

Fig 14 shows that the magnetometer may be distorted when the magnetic force is disturbed when calculating the heading angle, which will cause a significant error in the calculation results and affect the positioning results. The heading angle corrected by the gyroscope is relatively stable, providing stable heading data for PDR.

thumbnail
Fig 14. Heading-angle error statistics.

Comparison of heading-angle errors before and after correction.

https://doi.org/10.1371/journal.pone.0335277.g014

In order to quantitatively compare the advantages and disadvantages between the algorithm in this paper and the heading angle calculated only by magnetometer, this paper uses Formula (12) to compare the two. The principle of comparison is to extract the absolute value of the difference between the two algorithms and the actual heading angle at different times and compare the maximum error, minimum error, mean value, and standard deviation of the absolute value of the difference to describe the advantages and disadvantages of the two quantitatively.

(15)

Among them, Δ yawi is the heading angle difference of each point, is the actual heading angle of each point, and is the detection heading angle of each point. Fig 15 shows the heading angle error of each point. It can be seen that the algorithm in this paper has a certain inhibitory effect on the magnetometer error. The x-axis is the walking time, and the y-axis is the absolute value of the heading angle error.

thumbnail
Fig 15. Fusion-based positioning trajectory map.

It shows the changes in pedestrian movement trajectories of different algorithms.

https://doi.org/10.1371/journal.pone.0335277.g015

The heading angle error fluctuation after the gyroscope constraint is more concentrated. Table 6 compares the performance of the two solution methods from the four aspects of maximum error, minimum error, mean value, and standard deviation. The gyroscope has a good effect on suppressing the heading angle error caused by the abnormal fluctuation of the magnetometer. The mean error is reduced by 40.79%, and the standard deviation of the error is reduced by 45.40%.

thumbnail
Table 6. Performance comparison of different solution methods Comparison of Heading Angle Errors Before and After Constraints.

https://doi.org/10.1371/journal.pone.0335277.t006

4.4 Fusion positioning experiment

The obtained step length, step frequency, and heading angle data can be applied to the PDR algorithm for pedestrian position estimation. In order to reduce the error of PDR, the PDR algorithm in this paper is fused with Wi-Fi fingerprint positioning. The heading angle is calculated using the heading angle calculation method introduced in Section 4.3, the magnetometer combined with the gyroscope azimuth angle calculation, and the average error and cumulative distribution function are used to evaluate the positioning performance.

The tester walked along the established reference route, recorded the inertial data, calculated the PDR positioning results, and recorded the Wi-Fi signal. The Wi-Fi signal was used to provide the initial position and drift suppression for the PDR and repeated several times to reduce the random error. Fig 15 compares the positioning trajectory results of the conventional PDR, the improved PDR, fusPDR, and the proposed WiFi/PDR algorithm.

The PDR algorithm has inherent systematic errors in estimating step length and frequency. These errors will accumulate with the increase in walking distance, resulting in an increasing deviation between the calculated and actual walking trajectories. However, this paper combines the Wi-Fi fingerprint positioning results into the PDR by combining the extended Kalman filter (EKF), which significantly reduces the error accumulation and makes the estimated trajectory closer to the natural walking trajectory, thus improving the accuracy of trajectory estimation. This method that combines Wi-Fi positioning results effectively reduces error accumulation and improves the accuracy of trajectory estimation.

Fig 16 is the cumulative distribution curve of positioning error of the Wi-Fi fusion PDR algorithm, improved PDR, fusPDR and traditional PDR algorithm in the positioning process.

thumbnail
Fig 16. Error comparison of different positioning methods.

Cumulative distribution function (CDF) comparing four algorithms.

https://doi.org/10.1371/journal.pone.0335277.g016

According to the statistical data, the average positioning error of the traditional PDR algorithm is 2.02 meters, and 90% of the positioning error is less than 3.71 meters. The average positioning error of the improved PDR algorithm is 1.07 meters, and 90% of the positioning error is less than 2.12 meters. The fusPDR [8] algorithm achieves an average positioning error of 0.89 m, with 90% of positioning errors being less than 1.8 m. The average positioning error of the Wi-Fi and improved PDR fusion indoor positioning algorithm is reduced to 0.71 meters, and 90% of the positioning error is less than 1.42 meters. This shows that the Wi-Fi-corrected PDR algorithm significantly improves positioning accuracy and stability.

5. Conclusion

This paper proposes a fusion algorithm that integrates Wi-Fi fingerprint positioning with an improved Pedestrian Dead Reckoning (PDR) method to enhance indoor positioning accuracy. The algorithm incorporates a dual-gyroscope constrained magnetometer approach, which improves the robustness and stability of heading angle estimation even under magnetic disturbances. In addition, an improved step frequency detection method based on acceleration zero-crossing and peak-valley pairing, together with Kriging interpolation of the fingerprint database, enables high-precision step counting and enhances the performance of KNN, WKNN, and EWKNN algorithms. Compared with traditional PDR and existing models such as Weinberg and Kim, the proposed method significantly reduces the average positioning error. The final experimental results demonstrate that the fusion algorithm achieves noticeable improvements in both accuracy and stability, validating its effectiveness and highlighting its potential for high-precision smartphone-based indoor positioning applications.

Supporting information

S1 File. Supplementary experimental data and MATLAB simulation results supporting the Wi-Fi/PDR fusion algorithm.

https://doi.org/10.1371/journal.pone.0335277.s001

(ZIP)

References

  1. 1. Yan D, Song W, Wang X. An overview of the current status of domestic indoor positioning technology development. J Navig Positioning. 2019;7(4):5–12.
  2. 2. Qing TT. Research on indoor positioning technology based on Wi-Fi and geomagnetic signal fusion. Guangzhou: South China University of Technology; 2018. p. 18–47.
  3. 3. Han L, Dai P, Yang Y. An indoor positioning method for multi-source information fusion. Sens Microsyst. 2020;39(7):21–4.
  4. 4. Zhang Z, Gao T, Ding Z, et al. Research on multi-sensor fusion indoor positioning technology based on UWB and IMU. Ind Control Comput. 2022;35(4):45–8.
  5. 5. Wang Q, Fu M, Wang J, Luo H, Sun L, Ma Z, et al. Recent advances in floor positioning based on smartphone. Measurement. 2023;214:112813.
  6. 6. Liu Y, Cai C, Wei Z. A floor positioning method based on the fusion of PDR and geomagnetic matching. J Sens Technol. 2020;33(4):557–63.
  7. 7. Chen G, Meng X, Wang Y, Zhang Y, Tian P, Yang H. Integrated WiFi/PDR/Smartphone using an unscented Kalman filter algorithm for 3D indoor localization. Sensors (Basel). 2015;15(9):24595–614. pmid:26404314
  8. 8. Wang Z, Gao J, Li Z. An indoor positioning method fusing WiFi/geomagnetic/PDR. Sur Mapp Bull. 2020;6:17–21.
  9. 9. Liu YC. Research on indoor positioning algorithm based on fusion of PDR and geomagnetic matching. Guilin: Guilin University of Electronic Science and Technology; 2021. doi: https://doi.org/10.27049/d.cnki.ggldc.2021.000900
  10. 10. Nguyen-Huu K, Lee S-W. A multi-floor indoor pedestrian localization method using landmarks detection for different holding styles. Mob Inf Syst. 2021;2021:1–15.
  11. 11. Fetzer T, Ebner F, Deinzer F, Grzegorzek M. Using barometer for floor assignation within statistical indoor localization. Sensors (Basel). 2022;23(1):80. pmid:36616678
  12. 12. Liu Y, Hu ZQ. A machine learning-based precise positioning system. J Huazhong Univ Sci Technol (Nat Sci Ed). 2023;51(5):33–9.
  13. 13. Zhou J, Wei G, Tian X. A novel indoor positioning algorithm fusing UWB and IMU data. Small Microcomput Syst. 2021;42(8):1741–6.
  14. 14. Xu S, Chen C-C, Wu Y, Wang X, Wei F. Adaptive residual weighted K-nearest neighbor fingerprint positioning algorithm based on visible light communication. Sensors (Basel). 2020;20(16):4432. pmid:32784420
  15. 15. Xu T, He JS, Zhu NF, et al. VWKNN location fingerprint positioning algorithm based on discrete coefficient improvement. J Beijing Univ Aeronaut Astronaut. 2022;48(7):1242–51.
  16. 16. Pratama AR, Hidayat R. Smartphone-based pedestrian dead reckoning as an indoor positioning system. 2012 International Conference on System Engineering and Technology (ICSET). IEEE; 2012. p. 1–6. doi: https://doi.org/10.1109/ICSEngT.2012.6339316
  17. 17. Hao Z, Dang J, Cai W, Duan Y. A multi-floor location method based on multi-sensor and WiFi fingerprint fusion. IEEE Access. 2020;8:223765–81.
  18. 18. Wan PB, Li XQ, Tang YQ. Research on an improved pedestrian dead reckoning algorithm. Electron Meas Technol. 2024;47(11):69–77.
  19. 19. Wang ZY, Wang SW, Yang ZY, et al. PDR positioning algorithm based on improved FSM gait detection. J Chin Inertial Technol. 2025;33(2):133–9.
  20. 20. Kim JW, Jang HJ, Hwang D-H, Park C. A step, stride and heading determination for the pedestrian navigation system. J of GPS. 2004;3(1 & 2):273–9.
  21. 21. Scarlett J. Enhancing the performance of pedometers using a single accelerometer. Appl Note Analog Devices. 2007;41.
  22. 22. Shin SH, Park CG, Kim JW, et al. Adaptive step length estimation algorithm using low-cost MEMS inertial sensors. 2007 IEEE Sensors Applications Symposium. IEEE; 2007. p. 1–5. doi: https://doi.org/10.1109/SAS.2007.374406
  23. 23. Weinberg H. Using the ADXL202 in pedometer and personal navigation applications. Analog Devices AN-602 Appl Note. 2002;2(2):1–6.
  24. 24. Bylemans I, Weyn M, Klepal M. Mobile phone-based displacement estimation for opportunistic localisation systems. 2009 Third International Conference on Mobile Ubiquitous Computing, Systems, Services and Technologies. IEEE; 2009. p. 113–8. doi: https://doi.org/10.1109/UBICOMM.2009.23
  25. 25. Han L, Jiang L, Kong Q, Wang J, Zhang A, Song S. Indoor localization within multi-story buildings using MAC and RSSI fingerprint vectors. Sensors (Basel). 2019;19(11):2433. pmid:31141928
  26. 26. Zhao M, Qin D, Guo R, Wang X. Indoor floor localization based on multi-intelligent sensors. IJGI. 2020;10(1):6.