An Indoor Navigation Algorithm Using Multi-Dimensional Euclidean Distance and an Adaptive Particle Filter

The inertial navigation system has high short-term positioning accuracy but features cumulative error. Although no cumulative error occurs in WiFi fingerprint localization, mismatching is common. A popular technique thus involves integrating an inertial navigation system with WiFi fingerprint matching. The particle filter uses dead reckoning as the state transfer equation and the difference between inertial navigation and WiFi fingerprint matching as the observation equation. Floor map information is introduced to detect whether particles cross the wall; if so, the weight is set to zero. For particles that do not cross the wall, considering the distance between current and historical particles, an adaptive particle filter is proposed. The adaptive factor increases the weight of highly trusted particles and reduces the weight of less trusted particles. This paper also proposes a multidimensional Euclidean distance algorithm to reduce WiFi fingerprint mismatching. Experimental results indicate that the proposed algorithm achieves high positioning accuracy.


Introduction
In open outdoor areas, the global satellite navigation system offers reliable positioning accuracy. For example, Baidu Maps and Google Maps provide navigation and positioning for pedestrians and cars. Yet the transmission of obstacle occlusion signals indoors, in tunnels and in other areas greatly attenuates the wireless signal; therefore, a scheme using satellite navigation cannot deliver reliable positioning accuracy. Scholars have thus begun to study indoor navigation solutions [1,2]. Considering the advantages of the high popularity and ease of carrying of smartphones, researchers have done a lot of research on indoor navigation with the help of smartphone platforms. For indoor pedestrian navigation, the positioning accuracy of the meter level has been within the visible range of users, which meets the positioning needs of most ordinary users. Considering smartphones' popularity and ease of transportation, researchers have carefully considered indoor navigation based on smartphone platforms. The inertial navigation system (INS) is an autonomous navigation system that does not depend on external information and does not radiate energy to the outside. This system can provide continuous and real-time data on the carrier's position, attitude, and speed. Its primary disadvantage is the cumulative effect of position error: the longer the running time, the greater the error. Reference [3] shows that the position error of the two-dimensional plane is proportional to the cubic power of time. Various in-depth investigations have been conducted to address cumulative error. When pedestrians walk in regular corridors, Heuristic drift reduction (HDR) and Heuristic drift elimination (HDE) algorithms [4,5] effectively eliminate cumulative error. Reference [6,7] introduced map information and used a map-aided algorithm to eliminate the direction drift of inertial navigation. Alternatively, one can introduce a magnetic field and use the field's northpointing characteristic to correct the INS's direction.
WiFi wireless signals are widely used for positioning. The signal attenuation model and signal fingerprint matching model are two typical positioning techniques. The attenuation model needs to know the WiFi access point's location in advance and then calculates the user's location via the least squares method according to the received signal strength [8]. WiFi signals fluctuate with time, and a complex indoor environment (e.g., with walking pedestrians or changing obstacles) can quickly lead to deviation in the propagation model's parameter estimation along with poor positioning accuracy. The WiFi fingerprint matching model contains two stages: an offline training stage and online positioning stage. In the first phase, the user stores the received signal and corresponding position in the database; in the second phase, collected fingerprints are matched with fingerprints from the database. The position corresponding to the most similar fingerprint in the fingerprint database is often taken as the pedestrian's position. Considering that WiFi fingerprints are vulnerable to environmental interference, fingerprint mismatching is unavoidable. Magnetic fingerprint matching was introduced in Reference [9], to further reduce position error due to WiFi fingerprint mismatching. Given the two signal sources' complementary characteristics, an adaptive particle filter is proposed in this paper to integrate INS and WiFi.

The Innovation and the New Contributions
Most navigation schemes require infrastructure set up in advance in order to improve positioning accuracy. Unlike these schemes, the one proposed in this paper makes use of existing WiFi and inertial sensors. In an indoor environment, WiFi mismatching due to the "jump" fingerprint is the main problem, so the multi-dimensional fingerprint is introduced. Unlike the multi-dimensional dynamic time warping algorithm in Reference [10], the multidimensional Euclidean distance algorithm is not only simple to calculate but also has the potential to reduce fingerprint mismatching. The particle weight in the process of particle sampling is thought to be related not only to the observation but also to the historical position of pedestrians.
The main innovations of our work are as follows: • Because the improved algorithm does not necessitate additional infrastructure, it is low-cost and simple to update software; • A multi-dimensional Euclidean distance algorithm is proposed to calculate the distance between fingerprints. A multi-dimensional Euclidean distance algorithm using historical fingerprints can reduce the impact of the "jump point" fingerprints, thus reducing fingerprint mismatching; • To solve the problem of particle degradation, the historical position information is introduced, and the adaptive factor is used to improve the weight of high trust particles and reduce the weight of low trust particles; • Two smartphones are used to conduct navigation experiments in two navigation areas.
The experimental results show that the average positioning accuracy is 1.84 m.

Related Work
At present, popular localization algorithms include Dead Reckoning (DR) [11], and the geometric algorithm [12], fingerprint algorithm [13], and image algorithm [14]. Different indoor positioning technologies possess unique characteristics. DR based on inertial sensors can provide continuous navigation and positioning but suffers from cumulative error. Geomagnetism exists in nature; thus, no infrastructure needs to be deployed in advance. Geomagnetism can provide navigation direction but is readily disturbed by metal equipment and can easily lead users in the wrong direction. Meanwhile, fingerprint mismatching is a key concern in fingerprint matching. The image algorithm is similarly problematic: it requires intensive computation and is plagued by visual blind spots.
Although a single positioning signal source carries inherent benefits and drawbacks, its positioning performance can be improved by integrating the complementary charac-teristics of multiple signal sources. For example, several scholars have studied the hybrid positioning fusion algorithm [15,16]. Reference [17] presented a short-range radio frequency and map to eliminate DR's cumulative error. Reference [18] used an unscented Kalman filter to fuse DR and Ultra Wide Band (UWB). Kang [19] proposed SmartPDR, which adaptively selects a trusted direction source for a magnetometer and a gyroscope. Li [20] applied an adaptive Kalman filter to fuse an INS and magnetic field matching system; the fusion algorithm effectively reduced cumulative error. Furthermore, Reference [21] used an adaptive unscented Kalman filter to integrate the inertial measurement unit, magnetometer, and floor plan to reduce cumulative error. Yu [22] introduced map information and devised a map-based indoor pedestrian navigation algorithm that incorporated map assistance and map-matching algorithms to eliminate cumulative error.
Another common method involves WiFi signals. Using a DR error model as the state equation with WiFi positioning results and DR as observation equations, Li [23] presented an adaptive and robust Kalman filter to integrate DR and WiFi. Zhuang [24] proposed a tightly coupled extended Kalman filter to fuse DR and WiFi signals; this algorithm could effectively eliminate cumulative error in pedestrian navigation. By adding equality constraints and expanding the distribution of observation noise, a robust constrained Kalman filter has also been proposed to improve DR and WiFi indoor positioning [25].
Inspired by the above work, this paper presents an improved particle filter algorithm combining DR and WiFi. The DR model is taken as the state equation, and the difference between WiFi and DR represents the observation equation for the particle filter. An adaptive particle filter is also proposed to mitigate particle degradation in the traditional particle filter.

Framework Description
The gyroscope and accelerometer of the smartphone collect angular velocity and acceleration. Using the integral technique obtains the attitude angle. Using the gait technique obtains the pedestrian step length. DR based on direction and step length is used to estimate the position of pedestrians. The process of WiFi fingerprint localization can be divided into the offline fingerprint database construction stage and the online fingerprint matching stage. The reference points of the positioning area are calibrated in advance, and the fingerprints corresponding to the reference points are collected at the same time. The interpolation technology is used to construct the fingerprint database in the positioning area. In the online phase, MED is used to calculate the distance between the WiFi fingerprints collected online and the fingerprints in the database. The weighted K nearest neighbor (WKNN) algorithm further improves the positioning performance by selecting K WiFi matching results. The DR model is used as the state transfer equation of the particle filter, and the difference between the positioning results of WiFi and inertial navigation is used as the observation equation. An adaptive factor is proposed to improve the weight of highly trusted particles. At the same time, map information is introduced as an auxiliary means to eliminate particles crossing the wall. If the particle crosses the wall, its corresponding weight is set to zero. Finally, map matching is used to further reduce the pedestrian position error. The algorithm framework of MED and APF is shown in Figure 1. When the gyroscope obtains the angular velocity, the increment of the three-axis angular velocity [∆θ x k , ∆θ y k , ∆θ z k ] velocity can be calculated as follows [26]: represents the angular velocity of the three axes, respectively; and T s represents the sampling interval.
∆Θ is calculated as follows: Once the quaternions are updated, the direction cosine matrix is calculated as follows: where C n b,k+1 represents the direction cosine matrix at the (k + 1)th time. The function of C n b,k+1 is to convert the acceleration and angular velocity in the carrier coordinate system to the navigation coordinate system.
After the direction cosine matrices have been updated, the attitude angle can be calculated as follows [26]: where ϑ k+1 , φ k+1 , ψ k+1 denote the pitch, roll, and yaw at the (k + 1)th time, respectively.

Step Length
Gait-based step length estimation has been successfully applied in low-end inertial sensors [28]. Vertical displacement is periodic while a pedestrian walks, as illustrated in Figure 2. The vertical displacement of pedestrians during walking is calculated as follows [29]: where h(k) and V z denote the vertical displacement and vertical speed at the kth time, respectively. According to the literature [29], step length can be calculated as follows: where SL(k) represents the leg length at the kth time.

The Extended Kalman Filter for Accelerometer and Gyroscope Drift
In the process of walking, when a pedestrian's foot hits the ground, their vertical speed should be zero. Using this observation information, EKF can be constructed to filter out walking noise. The corresponding system model is written as follows [29]: where Z(k) and V z (k) represent the vertical displacement and vertical velocity, respectively; and Roll(k), Pitch(k), Yaw(k) represents the attitude angle. The vertical velocity and vertical displacement of the transition model is as follows [29]: where T s represents the sampling interval and a x , a y , a z represents the tri-axis acceleration, respectively. EKF is triggered while the time moves to the moment where Zero Velocity Update (ZUPT) detects zero vertical velocity; the vertical velocity is then updated to zero. The algorithm flowchart for the EKF module is shown in Algorithm 1.

Algorithm 1 The EKF module.
Input: Accelerometers and gyroscopes collect acceleration and angular velocity data 1. Extract the vertical acceleration from acceleration. 2. Estimate the zero-velocity point using vertical acceleration. 3. Compensate for acceleration and angular velocity errors. 4. Use acceleration to calculate the quaternion. 5. Obtain the attitude angle from the quaternion. 6. Filter noise using EKF.

DR
Based on the step length, direction, and position at the kth time, the pedestrian position at the (k + 1)th time is calculated as follows: where x(k) and y(k) denote the pedestrian's position at the kth moment.

Multi-Dimensional Euclidean Distance for WiFi Matching
Single-point fingerprint matching is a common algorithm in WiFi fingerprint matching [10].Yet single-point matching suffers from a "jump point" problem, mainly due to large WiFi fluctuations. As shown in Figure 3, a "jump point" occurs when a pedestrian's position is estimated. Each triangle represents the fingerprint matching position after WiFi fingerprint matching. The fourth triangle's far distance from the other three triangles indicates an unreliable WiFi matching position. A multidimensional fingerprint algorithm is proposed here to solve the jump point problem. By increasing the amount of historical fingerprint information and reducing the impact of single fingerprint matching, the fingerprint matching algorithm becomes more stable. In this case, n represents the number of WiFi access points collected simultaneously; the square represents the RSS of the access point; and k denotes the kth time at which the WiFi fingerprint was collected; see Figure 4.
k-2,n k-1,1 k-1,j k-1,2 k-1,n k,1 k,j k,2 k,n The received signal strength (RSS) of each WiFi access point is used as an element of a one-dimensional fingerprint. Multiple access points form a one-dimensional fingerprint at the same time. Multiple access points at different times constitute multi-dimensional WiFi fingerprints. Compared with a one-dimensional WiFi fingerprint, a multi-dimensional fingerprint can effectively reduce the occurrence of "jump points" in fingerprint matching results. The traditional Euclidean distance is only suitable for one-dimensional WiFi fingerprints. For multi-dimensional WiFi fingerprints, the traditional Euclidean distance needs to be modified. Considering the multi-dimensional attribute of WiFi fingerprint, the corresponding MED is proposed, which is calculated as follows: where RSS(i, j) denotes the jth access point value at the ith time in the online stage, and RSS db (i, j) denotes the jth access point value at the ith time in the offline stage. After calculating the fingerprint distance, WKNN is used to estimate the WiFi fingerprint matching position. This process is described in detail in Reference [20].

System Equation for the Adaptive Particle Filter
Different from the Kalman filter, the particle filter provides a nonlinear system state estimation technique [30]. Because particle filter technology is independent of the system model, this filter has been widely applied in various nonlinear and non-Gaussian system models. The state equation and observation equation of the particle filter are written as follows: where f (·) and h(·) represent known processes and observation equations, respectively; X k and Z k represent the process state and the observed state at the kth moment, respectively; and ω and ν represent the process noise and observation noise, respectively. In DR, the step length, direction, and estimated position each contain a certain error. It is assumed that the step length noise, direction change noise, and pedestrian position noise obey the Gaussian distribution of zero mean. Based on DR, the process equation for the particle filter is defined as follows: where L k−1 and θ k−1 represent the step length and direction at the (k − 1)th time. (x k−1 , y k−1 ) represents the pedestrian's estimated position at (k − 1)th time; and ∆L and ∆θ represent the pedestrian's step length and direction change, respectively. The WiFi positioning system can provide positioning results as a pedestrian walks. Combined with DR, the observation equation is written as follows: where [x DR , y DR ] T represents the positioning result of DR and [x W IFI , y W IFI ] T represents the positioning result of WiFi fingerprint matching.

Particle Weight Technique
In nonlinear systems, it is difficult to discern an analytical solution for a posteriori particle filter distribution. One feasible approach is to use the approximate solution instead of the analytical solution. A large number of particles are used to describe a posteriori distribution. A resampling technique has been introduced [31] to mitigate the sampling problem in a posteriori distribution: The recursive formula for calculating the importance weight of each generation of particles is: where Z * represents the estimated observation; X − k,i represents the priori estimated state vector; m represents the vector dimension; and R represents the observation noise.
In the improved particle filter, the weight of particles depends not only on the observation but also on the distance between the particles at the current moment and the historical moment. Considering that the pedestrian walking speed is usually 1 m/s to 1.5 m/s, the pedestrian position is constrained by the walking speed. The position of the previous moment is the center of the circle, and the distance between the position of the current moment and the position of the previous moment is the radius of the circle, forming a circle, as shown in Figure 5. As you can see from the figure, when the particles are in the circle, the weight of the particles should be higher. When the particles are outside the circle, the farther away the particles are, the lower the weight of the particles is. As such, an adaptive factor is proposed to calculate particles' weight: where x est y est i k represents the ith particle position at the kth moment.
x y represents the previous moment's estimated particle position. · represents the norm. dist represents the distance between the position of the previous moment and the position of the current moment. ω2 represents the particle weight. Upon combining the two particle weight calculation methods, the new particle weight ω can be calculated as follows:

Map Assistance
In the offline phase, floor structure map information is stored in the map database in advance. Newly generated particles need to be tested for effectiveness in the online phase. If a particle crosses the wall, then its weight is set to zero; if a particle does not cross the wall, then its original weight is used. The map assistance algorithm is described further in [22].

Experimental Scene
The walking experiment was carried out in office buildings A and B. The test scene included metal, wood, and concrete structures. An adult male with a height of 1.7 m holds a smartphone to collect data and walks at a speed of 1 m/s to 1.4 m/s. The tester opens the software at the starting point and clicks the "Start Saving a Log File" button to start collecting data. Click the "Stop Saving" button at the endpoint to save the data. The mapper's actual position was measured using a laser rangefinder. In the offline phase, the tester walked from the starting point to the end point while holding the smartphone while the smartphone's WiFi chip collected the RSS value of AP. The WiFi fingerprint database was established based on the laser rangefinder and the corner of the used corridor. In the online phase, each test pedestrian held a smartphone which obtained the RSS value of AP at normal walking speed. The experimental walking distance in office buildings A and B was 123 m and 138 m, respectively. The real trajectory is shown in Figure 6. The circle represents the reference point. These reference points are used to calculate errors and evaluate the performance of the algorithm.

Acceleration and Gyroscope Data
The parameters of the smartphone are shown in Table 1, and the sampling frequency is set to 50Hz. Acceleration and angular velocity data obtained in office buildings A and B are depicted in Figures 7 and 8, respectively. The acceleration was approximately periodic. The gait model was adopted to obtain pedestrians' step length. Angular velocity clearly increased at the turning point.

WiFi Fingerprint Database
Limited by the size of the smartphone, the battery capacity is limited. To reduce battery consumption, smartphones scan WiFi relatively less frequently. Taking a Nexus 5X used to construct a fingerprint database as an example, the sampling frequency is 0.25 Hz. Spatial interpolation is an effective way to improve the spatial resolution of the WiFi fingerprint database. The spatial resolution of the fingerprint is improved to 0.1Hz by interpolation. The positioning errors of the original fingerprint database and the interpolated fingerprint database are shown in Table 2.

Average Error
The original fingerprint database 5.77 The interpolated fingerprint database 1.98

Multidimensional WiFi Fingerprint
Different values of WiFi fingerprint dimensions were simulated; the average error is listed in Table 3. The minimum position error was obtained via MED when using two-dimensional WiFi fingerprints. The error caused by abnormal fingerprints could be reduced by expanding the fingerprint dimensions.  Figure 9 shows the relationship between position error and cumulative distribution function (CDF). Compared with traditional ED, MED uses multidimensional fingerprints to effectively reduce the error caused by abnormal fingerprints.  Figure 10 displays the position error of the traditional particle filter (PF) and adaptive PF. The APF positioning error tended to be lower than that of the traditional PF. APF uses map topology to constrain the particle range. In addition to being determined observationally, the particle weight is related to the distance between particles' current and historical positions: the farther the distance, the lower the reliability.

Office Building A
Pedestrians walked on the predetermined trajectory in office building A with a Nexus 5 smartphone in hand. Figures 11 and 12 show the positioning trajectories and cumulative distribution function (CDF) for DR, WiFi, PF, and MED+APF, respectively. As listed in Table 4, the average error for DR, WiFi, PF, and MED+APF was 8.03 m, 1.98 m, 3.45 m, and 1.51 m, respectively; the respective root mean square error was 10.02 m, 2.43 m, 4.82 m, and 1.92 m. The positioning trajectory was initially along the y-axis with a high positioning accuracy. As the pedestrians' walking time lengthened, the positioning trajectory shifted well to the right, and the position error increased. DR reflected cumulative error in that the longer the pedestrian's walking time, the larger the error. No cumulative error was found in WiFi fingerprint matching; however, fingerprint mismatching occurred. PF was thus adopted to integrate DR and WiFi. Aiming at the fingerprint mismatching caused by a "jump point" fingerprint, the multi-dimensional Euclidean distance algorithm introduces historical fingerprint information to reduce the position error. To solve the problem of particle degradation, the historical position information is introduced, and APF uses the adaptive factor to improve the weight of high trust particles and reduce the weight of low trust particles. These algorithms collectively improve the accuracy of pedestrian localization.   An adult man held a Nexus 5X smartphone that collected acceleration, angular velocity, and WiFi signals. Auxiliary value particle filter (AVPF) uses maps to determine particle weights [32]. If the particle crosses the wall, set its corresponding particle weight to zero. DR, WiFi, AVPF [32], and MED+APF positioning trajectories appear in Figure 13. the CDF of error is listed in Figure 14. DR exhibited an obvious cumulative error: the longer the running time, the greater the position error. The longer the running time, the greater the position error. The pedestrians' position error was small when first walking, yet as their walking time increased, the position error deviated clearly from their actual position. The WiFi signal also fluctuated because fingerprint acquisition and matching occurred at different times, leading to mismatched WiFi fingerprint matching. Mismatching caused a particularly prominent error in the corridor corner. AVPF uses map assistance to detect particles' validity and sets the particle weight to zero if the particle crosses the wall. Meanwhile, the map-matching algorithm further reduces position error. By adding dimension-related information from historical WiFi fingerprints, this work first employed MED to calculate the distance between WiFi online fingerprints and fingerprints in the fingerprint database. Then, considering the distance relationship between particles' current and historical positions, an APF algorithm was proposed by introducing an adaptive factor. The DR, WiFi, AVPF [32], and MED+APF position error appear in Table 5. Compared with DR, WiFi, and AVPF [32], the average error of MED+APF declined by 65.23%, 27.05%, and 13.17%, respectively; the root mean square error fell by 62.01%, 29.97%, and 26.37%, respectively. The best positioning algorithm was that proposed in this paper: MED+APF.

The Significance of the Proposed Method
This paper proposes a positioning algorithm that combines inertial sensors and WiFi based on existing WiFi access points. It is simple to update the software of the smart terminal, which is popular among consumers. Simultaneously, the multi-dimensional WiFi fingerprint algorithm is advantageous in reducing the occurrence of fingerprint mismatching and improving the accuracy of the fingerprint matching algorithm. Finally, the addition of DR historical position information alleviates the particle degradation problem.

Conclusions
The INS is less influenced by external interference and possesses high short-term positioning accuracy. However, DR error has a cumulative effect and larger long-term position error. Fingerprint mismatching occurred despite the lack of cumulative error, associated with WiFi fingerprint matching. This paper proposes an MED and an APF. MED uses multidimensional WiFi fingerprints to reduce fingerprint mismatching; APF uses an adaptive factor to increase the weight of highly trusted particles while reducing the weight of less trusted particles. These two methods can effectively reduce indoor position error.
Certain problems remain to be addressed in future work. First, the proposed algorithm must be applied in additional scenario tests to determine its robustness. Second, the particle filter requires extensive calculation; it is therefore necessary to consider how to reduce this computational burden. Third, more sensors can be integrated in the future to further reduce position error.