Indoor Positioning Method Using WiFi RTT Based on LOS Identiﬁcation and Range Calibration

: WiFi-based indoor positioning methods have attracted extensive attention due to the wide installation of WiFi access points (APs). Recently, the WiFi standard was modiﬁed and introduced into a new two-way approach based on round trip time (RTT) measurement, which brings some changes for indoor positioning based on WiFi. In this work, we propose a WiFi RTT positioning method based on line of sight (LOS) identiﬁcation and range calibration. Given the complexity of the indoor environment, we design a non-line of sight (NLOS) and LOS identiﬁcation algorithm based on scenario recognition. The positioning scenario is recognized to assist NLOS and LOS distances identiﬁcation, and gaussian process regression (GPR) is utilized to construct the scenario recognition model. Meanwhile, the calibration model for LOS distance is presented to correct the measuring distance and the scenario information is utilized to constrain the estimated position. When there is a positioning request, the positioning scenario is identiﬁed with the scenario recognition model, and LOS measuring distance is obtained based on the recognized scenario. The LOS range measurements are ﬁrst calibrated and then utilized to estimate the position of the smartphone. Finally, the positioning scenario is used to constrain the estimation location to avoid it beyond the scenario. The experimental results show that the positioning e ﬀ ect of the proposed method is far better than that of the Least Squares (LS) algorithm, achieving a mean error (ME) of 0.862 m and root-mean-square error (RMSE) of 0.989 m.


Introduction
Indoor positioning technology has attracted wide attention because of its massive market demand and huge economic prospects. As we know, the global navigation satellite system (GNSS) [1] can realize high-precision positioning in the outdoor environment, which can provide location-based services (LBS) for outdoor users, such as user positioning and navigation, vehicle navigation, emergency rescue, and protection against theft. However, sometimes the GNSS signals cannot arrive in an indoor environment and achieve positioning, or the arrived GNSS signals are too weak to realize high precision positioning [2]. It is thus necessary for indoor users requiring LBS to find a replacement to realize the high accuracy positioning.
Researchers have proposed many indoor positioning technologies, which mainly include ultra-wideband (UWB) [3,4], Bluetooth [5,6], Wireless Fidelity (WiFi) [7][8][9], Radio Frequency Identification (RFID) [10,11], Computer Vision [12], Ultrasonic [13], Inertial Navigation System (INS) [14,15], (1) We propose a NLOS and LOS identification method based on scenario recognition. In the proposed NLOS and LOS identification approach, the current positioning scenario needs to be recognized, and then the LOS measuring distance will be obtained by the recognized scenario, which avoids the impact of NLOS distances on positioning accuracy. (2) A scenario recognition method based on GPR is proposed to recognize the positioning scene, which has no need to collect training data and uses the real distances between smartphones and access points (APs) as the training data. (3) An easy range calibration model is established to correct the range measurement in the LOS condition, and the position of the smartphone is estimated by these calibrated distances.
Then, with the position information of the positioning scenario, the estimated position beyond the scenario is restrained to ensure that it is located in the positioning scene.

of 19
The rest of this paper is organized as follows. Section 2 introduces the related work of WiFi RTT. Section 3 describes the FTM framework and the ranging principle of WiFi RTT in detail. Section 4 presents the construction principle of the scenario recognition method based on GPR and the establishment method of the ranging calibration model. Section 5 introduces the indoor positioning method based on LOS identification and range calibration. Section 6 describes the experimental environment and method, and shows and analyzes the experimental results. In Section 7, we conclude this paper and point out future work.

Related Work
The WiFi standard had some modifications to meet the needs of indoor positioning. It can be found that a new two-way ranging approach is introduced into the 802.11-REVmc2 protocol, which is built on a new packet type called the fine timing measurement (FTM) frame [40]. The distance between the transmitter and receiver is estimated by round trip time (RTT) measurement [41]. Besides, Google announced that its Android 9 operating system would support RTT technology and provided the corresponding application programming interface (API) [42], and released several smartphones that supported WiFi RTT. A very important advantage of WiFi RTT is that there is no need for clock synchronization [43], which can enhance the availability of the indoor positioning system based on WiFi. The other advantage of WiFi RTT is that the ranging accuracy can achieve one-meter and can support the achievement of high precision indoor positioning [44]. Therefore, indoor positioning based on WiFi RTT has become a new research hotspot [43][44][45][46][47][48][49].
However, the studies on WiFi RTT are few for the moment. For example, the meter-level ranging accuracy can be achieved and proved in a low multipath environment [44]. Fingerprinting was combined with ranging-based techniques to overcome the different challenges of the indoor environment, and the propagation time of received signal strength (RSS) was employed to address multipath, non-line of sight (NLOS) signal attenuation, and interference challenges of the indoor environments [45]. Machine learning was utilized to resist the multipath in order to improve the range accuracy [46]. The distance estimation error model was established with the Gaussian mixture model and calibrated the measuring distances, and then the calibrated distances were utilized to estimate the position [47]. Yu [48] presented a real-time ranging model based on WiFi RTT, which can reduce the ranging error caused by NLOS, multipath, etc. Guo [43] proposed a calibration method eliminating the RTT range offset at the transmitter end and improved the ranging accuracy. The NLOS or LOS signals were identified by the hypothesis test framework and support vector machine (SVM), and divided as low-and high-quality signals according to the degree of multipath error [49]. We can conclude that NLOS and LOS identification is an important way to enhance positioning accuracy. However, the above methods had some limitations. Although the ranging accuracy of WiFi RTT could reach one meter, one-meter ranging accuracy could be only realized in low multipath or LOS conditions and could not be achieved in a complex indoor environment [44]. The RSS could assist in restraining the impact of multipath, NLOS, etc. on positioning accuracy, but the disadvantage was that the fluctuation of RSS values would lead to poor results [45]. The multipath inhibition model based on machine learning needed to collect large amounts of training data and could not be used for smartphones [46]. The distance estimation error model had a relatively small effect for restraining ranging errors, and the collection of the fingerprint was labor intensive [47]. The real-time ranging model [48] had a limited effect on ranging error suppression, and the improvement of positioning accuracy mainly depended on the combination with robust pedestrian dead reckoning (PDR) [48]. Although the authors of [49] constructed a NLOS and LOS identification model and evaluated the signal quality, the structure of the method was too complex for it to be applied to smartphones.

WiFi RTT
We need to review the existing knowledge on the WiFi FTM protocol before introducing WiFi RTT because WiFi RTT is built on the FTM framework. WiFi Alliance launched the interoperability certification project to enable WiFi to support the indoor positioning function in 2016. The WiFi certification positioning function is included in the IEEE 802.11 standard [50], aiming to provide the accuracy of meter-level for indoor equipment positioning.
The principle of the FTM protocol is shown in Figure 1; it is a ping-pong approach that is a time measurement of the signal round trip. In this protocol, the smartphone first needs to send an FTM request to the RTT access point [42]. Then, the AP and smartphone start to send the FTM message and record its transmission timestamp, and wait for its acknowledgment packet and record its reception timestamp. Thus, the time of arrival (ToA) and time of departure (ToD) can be obtained and used to calculate the time of flight (ToF) of signal from the transmitter to the receiver. The separation between the AP and the smartphone is estimated based on ToF. certification positioning function is included in the IEEE 802.11 standard [50], aiming to provide the accuracy of meter-level for indoor equipment positioning. The principle of the FTM protocol is shown in Figure 1; it is a ping-pong approach that is a time measurement of the signal round trip. In this protocol, the smartphone first needs to send an FTM request to the RTT access point [42]. Then, the AP and smartphone start to send the FTM message and record its transmission timestamp, and wait for its acknowledgment packet and record its reception timestamp. Thus, the time of arrival (ToA) and time of departure (ToD) can be obtained and used to calculate the time of flight (ToF) of signal from the transmitter to the receiver. The separation between the AP and the smartphone is estimated based on ToF. Considering that the Android operation system has the RTT API, therefore the smartphone can obtain the flight time of signal based on RTT measurement, which can be calculated as follows: where t ToA ( =1, 2) and t ToD ( =1, 2) represent the ith ToA and ith ToD measurements, respectively.
is the fight time of the signal from the AP to the smartphone. The smartphone can connect to multiple APs at same time and obtain the measured distances to them.
The speed of the electromagnetic waves is the same as the speed of light. Therefore, the range between transmitter and smartphone is estimated with and speed of light, as shown in equation (2).
where represents the speed of light and is the measuring distance that is calculated based on the flight time and speed of the signal.

Least Square Algorithm
Least square (LS) is a classic positioning algorithm for multilateration [51,52]. It was often utilized for indoor positioning technology, such as UWB, pseudolite, and ultrasonic. Thus, we have chosen the LS algorithm as the positioning algorithm in this paper. LS is a classic optimization Considering that the Android operation system has the RTT API, therefore the smartphone can obtain the flight time of signal based on RTT measurement, which can be calculated as follows: where t ToA i (i= 1, 2) and t ToD i (i = 1, 2) represent the ith ToA and ith ToD measurements, respectively. ToF is the fight time of the signal from the AP to the smartphone. The smartphone can connect to multiple APs at same time and obtain the measured distances to them.
The speed of the electromagnetic waves is the same as the speed of light. Therefore, the range between transmitter and smartphone is estimated with ToF and speed of light, as shown in equation (2).
where c represents the speed of light and d rtt is the measuring distance that is calculated based on the flight time and speed of the signal.

Least Square Algorithm
Least square (LS) is a classic positioning algorithm for multilateration [51,52]. It was often utilized for indoor positioning technology, such as UWB, pseudolite, and ultrasonic. Thus, we have chosen the LS algorithm as the positioning algorithm in this paper. LS is a classic optimization algorithm, which aims to find the optimal function matching of data by minimizing the sum of squares of errors. An example is shown in Figure 2 to present the principle of the LS algorithm that is used for WiFi RTT positioning. Supposing that there are four APs in the indoor environment, a smartphone is regarded as the receiver and obtains the range measurements. The measuring distance between each AP and the smartphone can draw a circle. In theory, all the circles will intersect at one point, which is the location of the smartphone. Based on the above theory, the positioning based on the LS algorithm can be realized by solving the position of the intersection point. is used for WiFi RTT positioning. Supposing that there are four APs in the indoor environment, a smartphone is regarded as the receiver and obtains the range measurements. The measuring distance between each AP and the smartphone can draw a circle. In theory, all the circles will intersect at one point, which is the location of the smartphone. Based on the above theory, the positioning based on the LS algorithm can be realized by solving the position of the intersection point. When the measuring distances between multiple transmitters and the smartphone are gathered, the equation can be established as follows. Each measuring distance can be utilized to produce the equations of a circle.
The equation (4) can be expressed with a simpler form, as shown in equation (5).
where and are n−1 by 2 matrix and n−1 dimensional column vector, respectively, and X is the estimated position that can be shown as [ , ] . The matrix and vector can be represented by Equation (6). When the measuring distances between multiple transmitters and the smartphone are gathered, the equation can be established as follows. Each measuring distance can be utilized to produce the equations of a circle.
where (X i , Y i ) {i = 1, 2, · · · , n} and (x, y) represent the position of the ith AP and smartphone, respectively, n is the number of APs, and d i {i = 1, 2, · · · , n} is the measured distance between the smartphone and ith AP. In order to solve the position of the intersection point, the equation needs to be simplified by subtracting the last formula, and the simplified equation is expressed as The Equation (4) can be expressed with a simpler form, as shown in Equation (5).
where A and b are n−1 by 2 matrix and n−1 dimensional column vector, respectively, and X is the estimated position that can be shown as [x, y] T . The matrix A and vector b can be represented by Equation (6).
Finally, the positioning result based on the LS algorithm can be expressed as

Scenario, NLOS and LOS Definition
In the paper, the scenario is defined as an enclosed and independent indoor space that is separated from other indoor spaces, and the positioning scenario is a scenario where the smartphone is located. Figure 3 gives examples of the positioning scenario, NLOS, and LOS. In this figure, there are two scenarios that are named Scenario A and B, and they are independent spaces, separated by a wall. We can see that the signal of AP, in a scenario, needs to pass through the wall to reach another scenario. Thus, when the positioning scene is scenario A, we assumed that the signals from the AP in Scenario A and B should be the LOS and NLOS signals, respectively. In other words, if the positioning scenario is known, the LOS and NLOS signals can be easily identified. Finally, the positioning result based on the LS algorithm can be expressed as

Scenario, NLOS and LOS Definition
In the paper, the scenario is defined as an enclosed and independent indoor space that is separated from other indoor spaces, and the positioning scenario is a scenario where the smartphone is located. Figure 3 gives examples of the positioning scenario, NLOS, and LOS. In this figure, there are two scenarios that are named Scenario A and B, and they are independent spaces, separated by a wall. We can see that the signal of AP, in a scenario, needs to pass through the wall to reach another scenario. Thus, when the positioning scene is scenario A, we assumed that the signals from the AP in Scenario A and B should be the LOS and NLOS signals, respectively. In other words, if the positioning scenario is known, the LOS and NLOS signals can be easily identified.

NLOS and LOS Identification Method Based on Scenario Recognition
This paper utilizes GPR to construct a scenario recognition model that aims to identify the NLOS and LOS signals. The important advantage of the scenario recognition method based on GPR is that there is no need to collect training data. In this paper, we use the position of APs to obtain the positions of some points belonging to different scenarios and calculate the real distance between them and the APs, and these real distances are regarded as the input data of GPR training, which can be expressed as { , , ⋯ , } , and the corresponding scenario indexes are the output data for training, which can be expressed as { , , ⋯ , }. There should be a mapping between the input and output data, as follows: where is the gaussian noise with zero mean and variance, , i.e., ~( , ). represents the number of training data.

NLOS and LOS Identification Method Based on Scenario Recognition
This paper utilizes GPR to construct a scenario recognition model that aims to identify the NLOS and LOS signals. The important advantage of the scenario recognition method based on GPR is that there is no need to collect training data. In this paper, we use the position of APs to obtain the positions of some points belonging to different scenarios and calculate the real distance between them and the APs, and these real distances are regarded as the input data of GPR training, which can be expressed as X{x 1 , x 2 , · · · , x S }, and the corresponding scenario indexes are the output data for training, which can ISPRS Int. J. Geo-Inf. 2020, 9, 0627 7 of 19 be expressed as Y y 1 , y 2 , · · · , y S . There should be a mapping between the input and output data, as follows: where γ is the gaussian noise with zero mean and variance, δ 2 , i.e., γ ∼ N 0, δ 2 . S represents the number of training data. GPR is a non-parametric model; it aims to use the Gaussian process priors to perform regression analysis on data and establish the mapping relationship for the objective function. In the GPR, the Gaussian process is a set of random variables that are subject to a joint Gaussian distribution, which is determined by a mean function and covariance function, as shown in Equation (9): where f (X) represents the Gaussian process, m(X) is the mean function that can be seen as zero without loss of generality, E(·) indicates the expectation operator, K(X, X) is the covariance matrix, and k x i , x j is the covariance function. The kernel function in this work is expressed in Equation (13), which is a gaussian kernel function. Hyperparameters δ f and l represent the ranging standard deviation and length-scale, respectively, and x i is a set of real distances between the ith point and APs. This paper chose the Euclidean distance to calculate k x i , x j , which is represented by The prediction scenario index y * and training scenario index Y follow a multivariate Gaussian distribution jointly as follows: where X * and X are the test data and training data, respectively. The posterior distribution p(y * Y) can be expressed as Therefore, when the actual range measurement is obtained, they can be regarded as the test data that is input data of the model. Then, the output of the model can be used to determine the positioning scenario, and the measuring distance between the smartphone and AP belonging to the positioning scenario is the LOS distance. In the positioning estimation, the recognized scenario assists in identifying the LOS distance, and the LOS distance is utilized to estimate the position of the smartphone.

Position Constraint Based on Scenario Recognition
In the case of a known scenario, we can use the scenario information to correct the estimated position to prevent it from jumping out of the scenario. When the estimated position is located in the current positioning scene, it is indicated that the estimated position does need any constraint. Otherwise, the estimated location should be constrained to the positioning scenario, as shown in Figure 4.

The Range Calibration Model for LOS Distance
This paper used nonlinear least-squares fitting to establish the range calibration model for LOS distance. In order to establish the range calibration model, we first built a nonlinear polynomial function that represented the mapping relation between the ranging error and measuring distance, as shown in Equation (17). The calibrated distance should be the sum of the predicted error and original distance, as shown in Equation (18).
where and are the ranging error and range measurement, [ , , , ] are the unknown model parameters, and is the calibrated distance. Nonlinear least-squares fitting aims to find a group of parameters that can minimize the sum of squares of residuals of the model according to known data and . The minimum sum of squares of residuals can be presented with Equation (19).
where represents the sum of squares of residual, (•) represents the minimum value, and is the size of the input and output data. The way to solve the model parameters by nonlinear leastsquares fitting is an iterative approach. The optimal model parameters can be solved in the incessant The method of position constraint is shown in Equation (16).
where (x p , y p ) represents the position beyond the location scenario, (minX, minY) and (maxX, maxY) are the maximum and minimum positions of the positioning scenario, respectively, and dx and dy are the correction values, both of which are 0.2 m in this paper, which is the wall thickness.
When the X coordinate of the estimated location is bigger than maxX or lower than minX, the X coordinate should be replaced with the maxX or minX and subtracted or added the wall thickness. The way to correct the Y coordinate is the same as the method of X correction.

The Range Calibration Model for LOS Distance
This paper used nonlinear least-squares fitting to establish the range calibration model for LOS distance. In order to establish the range calibration model, we first built a nonlinear polynomial function that represented the mapping relation between the ranging error and measuring distance, as shown in Equation (17). The calibrated distance should be the sum of the predicted error and original distance, as shown in Equation (18).
where e and d rtt are the ranging error and range measurement, [c 1 , c 2 , c 3 , c 4 ] are the unknown model parameters, and d c is the calibrated distance. Nonlinear least-squares fitting aims to find a group of parameters that can minimize the sum of squares of residuals of the model according to known data e and d rtt . The minimum sum of squares of residuals can be presented with Equation (19).
where Q represents the sum of squares of residual, min(·) represents the minimum value, and M is the size of the input and output data. The way to solve the model parameters by nonlinear least-squares fitting is an iterative approach. The optimal model parameters can be solved in the incessant iterative process. However, there may be outliers in the training data due to multipath, NLOS, and so on. These outliers may be far away from real values. It is thus necessary to eliminate the outliers in the training data, and the Hampel filtering method was used to detect and eliminate the outliers.
In the Hampel filtering method, the mid-value of the sample with the length of K is calculated and used to estimate the standard deviation of each sample with respect to the absolute value of the mid-value. If the difference between the sample and mid-value is more than three standard deviations, this sample is recognized as an outlier and needs to be replaced with the mid-value. In other words, the selected range measurement should be in the interval [µ − 3σ, µ + 3σ], where µ is the mid-value and σ is the standard deviation.

Indoor Localization Algorithm Based on LOS Identification and Range Calibration
The indoor localization algorithm based on LOS identification and range calibration mainly includes two parts: one is the construction of the range calibration model, and the other is the location estimation, as shown in Figure 5. In the stage of the model construction, the RTT range measurements on different distances in the LOS condition are gathered. With these range measurements, the range calibration model for LOS distance is built.
One of the main contributions of the proposed method is its use of the recognized scenario to assist in the identification of the NLOS and LOS distance. Then, the LOS distances are chosen to estimate the position of the smartphone. The LOS range calibration model is used to correct the range measurement, and the position of the smartphone will be solved with the corrected LOS distances. The LS algorithm is chosen as the positioning algorithm.
The other advantage of the proposed method is that the positioning scene can be utilized to constrain the estimated location. When the estimated position is outside of the positioning scene, the scene information can constrain the position to ensure that it is located in the scenario. However, there is no correction if the estimated position is located in the positioning scenario. measurement, and the position of the smartphone will be solved with the corrected LOS distances. The LS algorithm is chosen as the positioning algorithm.
The other advantage of the proposed method is that the positioning scene can be utilized to constrain the estimated location. When the estimated position is outside of the positioning scene, the scene information can constrain the position to ensure that it is located in the scenario. However, there is no correction if the estimated position is located in the positioning scenario.

Experimental Environment
The experimental environment in this paper included two rooms with different layouts, length, and so on, which could be seen as two scenarios, and they were named as E and F. Figure 6 showed the layouts of the experimental area in this paper. The red star represents the test point (TP) with known coordinates. The position of AP is presented with the gray antenna. The other objects in the indoor environment were also shown in this Figure, which can be understood according to the legend. 6. Experiment

Experimental Environment
The experimental environment in this paper included two rooms with different layouts, length, and so on, which could be seen as two scenarios, and they were named as E and F. Figure 6 showed the layouts of the experimental area in this paper. The red star represents the test point (TP) with known coordinates. The position of AP is presented with the gray antenna. The other objects in the indoor environment were also shown in this Figure, which can be understood according to the legend.
The length and width of the experimental environment were 19.5 and 5.84 m, respectively. Its area was almost 113.88 square meters. In the experimental environment, there are eight APs in total and four APs in each room. The distribution of APs in scenario E is also different from that of scenario F. To test the performance of the proposed method, the range measurements on 129 TPs were gathered and regarded as the test data. Thus, there are 129 groups of test data in the whole experiment. Besides, we chose a Google Pixel 3 smartphone that supports the Android RTT API as the receiver to collect the range measurements.
There are two approaches to determine whether an experimental environment is complex or not: one is to use the precision of evenly distributed sampling data as judgment criteria, and the other depends on the complex degree of indoor layout, the interference extent from other signals, crowed density, reflection degree of material, etc. Considering only the spatial configuration, we can employ the spatial density of the interior layout as a criterion to determine whether an indoor environment is complex.

Range Calibration Model Construction
To establish the range calibration model, the RTT range measurements in the different distances were collected. For each distance, the acquisition time was 30 s, and the acquisition frequency was 1 Hz. When all the data of model construction were obtained, the outliers in the data needed to be eliminated to increase the reliability. Therefore, we chose Hample filtering to process the original range measurements. Figure 7 shows the filtering effect of a group of range measurements. The range measurements became smoother after Hample filtering. The length and width of the experimental environment were 19.5 and 5.84 m, respectively. Its area was almost 113.88 square meters. In the experimental environment, there are eight APs in total and four APs in each room. The distribution of APs in scenario E is also different from that of scenario F. To test the performance of the proposed method, the range measurements on 129 TPs were gathered and regarded as the test data. Thus, there are 129 groups of test data in the whole experiment.
Besides, we chose a Google Pixel 3 smartphone that supports the Android RTT API as the receiver to collect the range measurements.
There are two approaches to determine whether an experimental environment is complex or not: one is to use the precision of evenly distributed sampling data as judgment criteria, and the other depends on the complex degree of indoor layout, the interference extent from other signals, crowed density, reflection degree of material, etc. Considering only the spatial configuration, we can employ the spatial density of the interior layout as a criterion to determine whether an indoor environment is complex.

Range Calibration Model Construction
To establish the range calibration model, the RTT range measurements in the different distances were collected. For each distance, the acquisition time was 30 s, and the acquisition frequency was 1 Hz. When all the data of model construction were obtained, the outliers in the data needed to be eliminated to increase the reliability. Therefore, we chose Hample filtering to process the original range measurements. Figure 7 shows the filtering effect of a group of range measurements. The range measurements became smoother after Hample filtering. The mean of the processed range measurements on each distance was regarded as the final measuring distance, which was regarded as the input data of the model. The ranging errors were calculated by measuring distances and real distance and seen as the output data of the model. Then, nonlinear least-squares fitting was utilized to establish the mapping relation between the range measurement and ranging error, which was the optimal solution of parameters of the model presented in Equation (17). The model parameters were [−0.0084, 0.0721, −0.0973, 1.0427], and the range calibration model in this paper could be expressed as follows: The model construction only needs to collect a small amount of the range measurement, and the construction method is very easy to implement. Besides, the range calibration model has low complexity. We can see that the range model has strong usability in real-time applications due to its low complexity and easy implementation.

The Effect of the Range Calibration Model
The range calibration model aims to reduce the error of the LOS range measurement in order to improve the positioning effect. In the test of this section, we chose scenario E as the experimental area The mean of the processed range measurements on each distance was regarded as the final measuring distance, which was regarded as the input data of the model. The ranging errors were calculated by measuring distances and real distance and seen as the output data of the model. Then, nonlinear least-squares fitting was utilized to establish the mapping relation between the range measurement and ranging error, which was the optimal solution of parameters of the model presented in Equation (17). The model parameters were [−0.0084, 0.0721, −0.0973, 1.0427], and the range calibration model in this paper could be expressed as follows: The model construction only needs to collect a small amount of the range measurement, and the construction method is very easy to implement. Besides, the range calibration model has low complexity.
We can see that the range model has strong usability in real-time applications due to its low complexity and easy implementation.

The Effect of the Range Calibration Model
The range calibration model aims to reduce the error of the LOS range measurement in order to improve the positioning effect. In the test of this section, we chose scenario E as the experimental area to show the effect of the range calibration. The range measurements on one TP were collected, and the acquisition time and frequency were 30 s and 1 Hz, respectively. The range errors of actual measuring distances and calibrated distances between the smartphone and four APs in the E scenario were analyzed to see the effect of the range calibration. Figure 8 shows the mean values and standard deviations of the ranging errors of original range measurements and calibrated range measurements of four APs on one TP. The accuracy had some improvement when the range measurement was calibrated; the ranging errors of the calibrated distances were lower than those of the actual range measurements. To study the improvement in the positioning effect with the range calibration model used, we conducted a test; scene E was chosen as the experimental area. In this test, the range measurements between the smartphone and all APs installed in scene E were calibrated with the range calibration model, and then the calibrated distances were used to estimate the location. The LS algorithm was the positioning algorithm. Figure 9 showed the experimental results, which were the histograms of positioning errors of no range calibration and range calibration. To study the improvement in the positioning effect with the range calibration model used, we conducted a test; scene E was chosen as the experimental area. In this test, the range measurements between the smartphone and all APs installed in scene E were calibrated with the range calibration model, and then the calibrated distances were used to estimate the location. The LS algorithm was the positioning algorithm. Figure 9 showed the experimental results, which were the histograms of positioning errors of no range calibration and range calibration.
The positioning effect based on range calibration was better than that without range calibration, as shown in Table 1. The ME of range calibration was 0.864 m, and the ME was 1.067 m without the range calibration model. The positioning accuracy had an improvement of 0.203 m when the range measurements were corrected. In addition, compared with range calibration, the RMSE increased by 0.18 m when the range measurements were not calibrated. The range calibration model can improve the accuracy of range measurement, and thus increase the positioning precision. To study the improvement in the positioning effect with the range calibration model used, we conducted a test; scene E was chosen as the experimental area. In this test, the range measurements between the smartphone and all APs installed in scene E were calibrated with the range calibration model, and then the calibrated distances were used to estimate the location. The LS algorithm was the positioning algorithm. Figure 9 showed the experimental results, which were the histograms of positioning errors of no range calibration and range calibration. The positioning effect based on range calibration was better than that without range calibration, as shown in Table 1. The ME of range calibration was 0.864 m, and the ME was 1.067 m without the range calibration model. The positioning accuracy had an improvement of 0.203 m when the range measurements were corrected. In addition, compared with range calibration, the RMSE increased by 0.18 m when the range measurements were not calibrated. The range calibration model can improve the accuracy of range measurement, and thus increase the positioning precision.

The Effect of Position Constraint
This paper utilized the scenario information to constrain the estimated position, which avoided the appearance of the estimated location beyond the positioning scenario. Therefore, we studied the effect of position constraint on the positioning by one test in this section. Scene F was chosen as the experimental area to study the effect of position constraint, which meant that the positioning scene was already known. In this test, the NLOS and LOS identification method would not be used for assisting indoor positioning, and only position constraint was used for indoor positioning.
The measuring distances of all APs were utilized to estimate the location of the smartphone, and the LS algorithm was chosen as the positioning algorithm. Then, the estimated location was corrected by the information of scenario F. The experimental results were shown in Figure 10. When the positioning scenario was known, the positioning effect was improved with the position constraint used. The estimation location that was beyond the positioning scene was corrected to ensure it is located in this scene, which improved the positioning effect.

The Effect of Position Constraint
This paper utilized the scenario information to constrain the estimated position, which avoided the appearance of the estimated location beyond the positioning scenario. Therefore, we studied the effect of position constraint on the positioning by one test in this section. Scene F was chosen as the experimental area to study the effect of position constraint, which meant that the positioning scene was already known. In this test, the NLOS and LOS identification method would not be used for assisting indoor positioning, and only position constraint was used for indoor positioning.
The measuring distances of all APs were utilized to estimate the location of the smartphone, and the LS algorithm was chosen as the positioning algorithm. Then, the estimated location was corrected by the information of scenario F. The experimental results were shown in Figure 10. When the positioning scenario was known, the positioning effect was improved with the position constraint used. The estimation location that was beyond the positioning scene was corrected to ensure it is located in this scene, which improved the positioning effect. The ME and RMSE of the positioning without position constraint were 2.86 and 3.453 meters, respectively. The ME and RMSE were 2.002 and 2.327 meters, respectively, when the estimated location was restrained. Compared with the positioning without position constraint, the ME and RMSE of positioning based on position constraint were improved by 0.858 meters and 1.125 meters, respectively. The positioning effect will be improved when the estimation location is constrained by the scenario information. The ME and RMSE of the positioning without position constraint were 2.86 and 3.453 m, respectively. The ME and RMSE were 2.002 and 2.327 m, respectively, when the estimated location was restrained.

Indoor Localization Algorithm Based on LOS Identification and Range Calibration
Compared with the positioning without position constraint, the ME and RMSE of positioning based on position constraint were improved by 0.858 m and 1.125 m, respectively. The positioning effect will be improved when the estimation location is constrained by the scenario information.

Indoor Localization Algorithm Based on LOS Identification and Range Calibration
This section mainly introduced the positioning effect of the indoor localization algorithm based on LOS identification and range calibration. To evaluate the performance of the proposed method, some tests were conducted. In the first test, two positioning methods were used to estimate the position of the smartphone: one was an LS algorithm based on LOS identification, and the other was an LS algorithm directly that used the original measurements to obtain the position. Scenario E and F were chosen as the experimental area for the test, and there were 129 groups of test data. The positioning errors of the two positioning methods are shown in Figure 11.  Figure 11. In order to analyze the positioning effects of two methods in more detail, the cumulative distribution functions (CDFs) of positioning errors of the two methods are shown in Figure 11. We can see that the positioning effect of the proposed method was far better than that of the LS algorithm. This indicated that the application of NLOS and LOS identification could efficiently obtain the reliable range measurements, and the positioning effect was greatly improved when using the LOS distances. To study the computational efficiency of the proposed method, a computer with an Intel 7 CPU, 8 GB memory and a Windows 10 operating system was chosen as the testbed to obtain the running time. The simulation was performed on the MATLAB 2016, and the number of tests was 100. The mean of the running time of LS algorithm was 0.17 milliseconds, and those of LS based on LOS and the proposed method were 0.4 and 0.44 milliseconds, respectively. Although the proposed method has a larger computation time than the LS and LS based on LOS algorithms, the proposed method has an extremely close computation efficiency to that of LS based on LOS, and the mean running time of the proposed method was only 0.27 milliseconds slower than the LS algorithm. This could also indicate that the proposed method had a good computation efficiency.
The positioning effects of the LS algorithm, LS based on LOS and the proposed method were illustrated in Figure 12. We could also see that the positioning effect of the proposed method was far better than those of the LS algorithm and better than that of the LS algorithm based on LOS identification. This indicated that the combination of NLOS and LOS identification, range calibration, and position constraint could increase the positioning accuracy and obtain a good positioning effect. Among them, LOS identification had the most obvious effect on the improvement of the positioning effect. The maximum positioning error of the proposed method was 2.829 meters, and those of the LS algorithm and the LS algorithm based on LOS were 3.205 and 7.870 meters, respectively. It can be seen in Figure 12 that the LS algorithm had more outliers than the proposed method, which indicated that the proposed method was better than the LS algorithm.
Cumulative error probability /% In order to analyze the positioning effects of two methods in more detail, the cumulative distribution functions (CDFs) of positioning errors of the two methods are shown in Figure 11. We can see that the positioning effect of the proposed method was far better than that of the LS algorithm. This indicated that the application of NLOS and LOS identification could efficiently obtain the reliable range measurements, and the positioning effect was greatly improved when using the LOS distances. To study the computational efficiency of the proposed method, a computer with an Intel 7 CPU, 8 GB memory and a Windows 10 operating system was chosen as the testbed to obtain the running time. The simulation was performed on the MATLAB 2016, and the number of tests was 100. The mean of the running time of LS algorithm was 0.17 milliseconds, and those of LS based on LOS and the proposed method were 0.4 and 0.44 milliseconds, respectively. Although the proposed method has a larger computation time than the LS and LS based on LOS algorithms, the proposed method has an extremely close computation efficiency to that of LS based on LOS, and the mean running time of the proposed method was only 0.27 milliseconds slower than the LS algorithm. This could also indicate that the proposed method had a good computation efficiency.
The positioning effects of the LS algorithm, LS based on LOS and the proposed method were illustrated in Figure 12. We could also see that the positioning effect of the proposed method was far better than those of the LS algorithm and better than that of the LS algorithm based on LOS identification. This indicated that the combination of NLOS and LOS identification, range calibration, and position constraint could increase the positioning accuracy and obtain a good positioning effect. Among them, LOS identification had the most obvious effect on the improvement of the positioning effect. The maximum positioning error of the proposed method was 2.829 m, and those of the LS algorithm and the LS algorithm based on LOS were 3.205 and 7.870 m, respectively. It can be seen in Figure 12 that the LS algorithm had more outliers than the proposed method, which indicated that the proposed method was better than the LS algorithm.   Table 2 showed the mean errors and root-mean-square errors (RMSEs) of LS, LS based on LOS, and the proposed method. The ME of the proposed method is 0.868 meters, which was the lowest of the three methods, and the ME of the LS algorithm 2.031 meters. Compared with the LS algorithm, the proposed method had great improvement, and its ME was reduced by 1.169 meters. The RMSEs of the LS algorithm and the proposed method were 2.606 and 0.989 meters, respectively. Compared with the LS algorithm, the RMSE of the proposed method was reduced by 1.617 meters. Because the RMSE could present positioning stability to a certain extent, the positioning stability of the proposed method was far better than that of the LS algorithm.
The RMSE and ME of LS based on LOS were 1.245 and 1.11 meters, respectively. Compared with LS based on LOS, the ME of the proposed method was improved by 0.248 meters, and the RMSE of that was reduced by 0.256 meters. It indicated that the improved effects of range calibration on positioning accuracy and stability were weaker than that of LOS identification. It was, however, still a good approach to increase the positioning accuracy and stability due to the easy establishment and lower computation of the range calibration model. It can be seen that the proposed method had the best positioning effect and the smallest ME and RMSE among the three methods.
Besides, the positioning errors corresponding to some of the main cumulative probabilities can also be seen in this table. The corresponding positioning errors of the proposed method were still the lowest among the three methods when the cumulative error probabilities were 50%, 70%, and 90%. Thus, we obtained a conclusion that the proposed method could effectively improve the accuracy and stability of positioning using WiFi RTT.
The proposed method has some superiorities in real-time applications. First of all, the proposed method builds the scenario identification model without collecting the training data, which saves resources and increases the availability of this method. Secondly, the proposed method builds a range calibration model with low complexity and easy implementation, which has strong usability. Finally, the proposed method only needs the range measurement to realize the acquisition of LOS distance, which has huge extensibility.  Table 2 showed the mean errors and root-mean-square errors (RMSEs) of LS, LS based on LOS, and the proposed method. The ME of the proposed method is 0.868 m, which was the lowest of the three methods, and the ME of the LS algorithm 2.031 m. Compared with the LS algorithm, the proposed method had great improvement, and its ME was reduced by 1.169 m. The RMSEs of the LS algorithm and the proposed method were 2.606 and 0.989 m, respectively. Compared with the LS algorithm, the RMSE of the proposed method was reduced by 1.617 m. Because the RMSE could present positioning stability to a certain extent, the positioning stability of the proposed method was far better than that of the LS algorithm. The RMSE and ME of LS based on LOS were 1.245 and 1.11 m, respectively. Compared with LS based on LOS, the ME of the proposed method was improved by 0.248 m, and the RMSE of that was reduced by 0.256 m. It indicated that the improved effects of range calibration on positioning accuracy and stability were weaker than that of LOS identification. It was, however, still a good approach to increase the positioning accuracy and stability due to the easy establishment and lower computation of the range calibration model. It can be seen that the proposed method had the best positioning effect and the smallest ME and RMSE among the three methods.
Besides, the positioning errors corresponding to some of the main cumulative probabilities can also be seen in this table. The corresponding positioning errors of the proposed method were still the lowest among the three methods when the cumulative error probabilities were 50%, 70%, and 90%. Thus, we obtained a conclusion that the proposed method could effectively improve the accuracy and stability of positioning using WiFi RTT.
The proposed method has some superiorities in real-time applications. First of all, the proposed method builds the scenario identification model without collecting the training data, which saves resources and increases the availability of this method. Secondly, the proposed method builds a range calibration model with low complexity and easy implementation, which has strong usability.
Finally, the proposed method only needs the range measurement to realize the acquisition of LOS distance, which has huge extensibility.

Conclusions
This paper proposes an indoor positioning method based on LOS identification and range calibration, which can recognize the positioning scene and identify the LOS distances based on the identified scenario. Considering the error of LOS distance, the range calibration for LOS distance was constructed to correct the LOS distance in this paper. The measuring distances in the LOS condition are chosen to be calibrated in order to reduce the ranging errors. Moreover, based on the information of the scenario, the positioning result beyond the positioning scene can be restricted to the scenario.
The experimental results showed that the positioning effect of the proposed method was better than those of the LS algorithm and the LS algorithm based on LOS. The ME and RMSE of the proposed method were 0.862 and 0.989 m. Compared with some positioning technologies, such as WiFi fingerprint, Bluetooth fingerprint, and ranging-based RSS, the positioning based on WiFi RTT can reach submeters and thus have better accuracy. The main contribution of positioning based on WiFi RTT is that it can reach sub-meter accuracy. The proposed method does not need to gather the data for model training data, which is a huge advantage in real-time application. It employs the low complexity range calibration model to correct the range measurement, and does not add much computation cost.
In the future, we will focus on three-dimensional positioning based on the WiFi RTT because it might be the case that the LOS identification in the multi-story indoor environment needs to know the current floor. Thus, the future research points will be the positioning algorithms of three-dimensional positioning, the combination of RTT positioning and other elevation positioning methods, and so on.