*4.2. Static Positioning*

Knowing the estimate *α*ˆ, we can replace (5) by

$$
\hat{y}(t) = \hat{h}\left(f\_{\xi}^{\mathbf{x}}(t), \hbar\right) + \mathfrak{l}(t). \tag{12}
$$

with *<sup>ι</sup>*ˆ(*t*) ∼ N (0, *<sup>R</sup>*ˆ). We can then obtain an estimate *<sup>x</sup>*ˇ(*t*) of *<sup>x</sup>*(*t*) using the maximum likelihood criterion, i.e.,

$$\text{if } \pounds(t) = \underset{\mathbf{x}}{\text{arg }} \max\_{\mathbf{x}} L\_t(\mathbf{x}), \tag{13}$$

where

$$L\_t(\mathbf{x}) = \log p\left(y(t) | |I\_t^\mathbf{x}(t) = \mathbf{x}\right),\tag{14}$$

denotes the log-likelihood function and

$$p\left(y(t)\middle|\mathcal{J}\_{\boldsymbol{\theta}}^{x}(t)=\mathbf{x}\right) = \mathcal{N}\left(y(t); \hat{h}\left(\mathbf{x}, \mathbf{\hat{a}}\right), \mathbb{R}\right).\tag{15}$$

### *4.3. Dynamic Positioning*

We aim to use a Bayesian tracking method to estimate *ξ*(*t*) based on the model (4), (12), and then obtaining *x*(*t*) from the estimated value of *ξ*(*t*). In principle, this could be done using the typical approaches for Bayesian tracking, namely, extended Kalman filtering (EKF) and particle filtering (PF). However, since EKF is based on linearizing the non-linear measurement Equation (5), its result is inaccurate and it often causes instability of the estimate. On the other hand, while this problem can be solved using PF, which can be made arbitrarily accurate by using enough particles, the number of required particles makes this method impractical for real-time applications. In order to obtain an accurate and numerically tractable Bayesian tracking implementation, we use a method called maximum likelihood Kalman filter [37]. We summarize it below.

We want to compute

$$\begin{split} \dot{\xi}(t) &= \mathcal{E}\left\{ \xi(t) | \mathcal{Y}(t) \right\} \\ &= \int \xi(t) p\left(\xi(t) | \mathcal{Y}(t)\right) d\xi(t), \end{split} \tag{16}$$

where *Y*(*t*) = {*y*(1), ··· , *y*(*t*)}. In order to compute *p* (*ξ*(*t*)|*Y*(*t*)) we alternate two steps, namely, prediction and update, which are described below.

### 4.3.1. Prediction

In this step we assume that *ξ*(*t*)|*Y*(*t*) ∼ N (*μ*(*t*|*t*), Σ(*t*|*t*)), with *μ*(*t*|*t*) and Σ(*t*|*t*) known. We aim to compute *μ*(*t* + 1|*t*) and Σ(*t* + 1|*t*) such that *ξ*(*t* + 1|*t*)|*Y*(*t*) ∼ N (*μ*(*t* + 1|*t*), Σ(*t* + 1|*t*)). We do so using a typical Kalman filtering prediction step, i.e.,

$$\begin{aligned} \mu(t+1|t) &= F\mu(t|t), \\ \Sigma(t+1|t) &= F\Sigma(t|t)F^\top + Q. \end{aligned} \tag{17}$$

### 4.3.2. Update

In this case, we assume that *ξ*(*t*)|*Y*(*t* − 1) ∼ N (*μ*(*t*|*t* − 1), Σ(*t*|*t* − 1)), with *μ*(*t*|*t* − 1) and Σ(*t*|*t* − 1) known. We aim to compute *μ*(*t*|*t*) and Σ(*t*|*t*) such that *ξ*(*t*)|*Y*(*t*) ∼ N (*μ*(*t*|*t*), Σ(*t*|*t*)). In this case, we cannot do a typical Kalman filtering step, because the measurement equation is nonlinear. To go around this, we use the estimate *x*ˇ(*t*) obtained by the static positioning method described in Section 4.2. More precisely, we compute

$$\begin{aligned} \mu(t|t) &= \Sigma(t|t) \left( \Sigma^{-1}(t|t-1)\mu(t|t-1) + \Lambda(t)\lambda(t) \right), \\ \Sigma(t|t) &= \left( \Sigma^{-1}(t|t-1) + \Lambda(t) \right)^{-1}, \end{aligned} \tag{18}$$

where

$$\begin{aligned} \lambda(t) &= J^\top \pounds(t), \\ \Lambda(t) &= J^\top \pounds(t) J\_{\nu} \end{aligned}$$

and

$$
\hat{\mathbf{C}}(t) = -\nabla^2 L\_t \left( \vec{\mathbf{x}}(t) \right),
$$

with ∇2*Lt* (*x*) denoting the Hessian of *Lt* evaluated at *<sup>x</sup>* (recall that *<sup>x</sup>*ˇ(*t*) is computed from (13)).

### 4.3.3. Final Step

Using the above, at each *t*, we can compute *μ*(*t*|*t*) and Σ(*t*|*t*) such that *ξ*(*t*)|*Y*(*t*) ∼ N (*μ*(*t*|*t*), Σ(*t*|*t*)). Then, using (16), we obtain

$$
\hat{\xi}(t) = \mu(t|t),
\tag{19}
$$

and finally

$$
\hat{x}(t) = J\mu(t|t). \tag{20}
$$

### **5. Experiments**

### *5.1. Static Positioning*

In this section, we will experimentally compare our proposed method with three rival methods, namely, the FILA method [21], the DeepFi method [22] (amplitude-based fingerprinting), and the PhaseFi method [26] (Phase-based fingerprinting), described in Section 1. We use TP-Link WDR4310 routers, having the OpenWrt platform installed, and working at a package rate of 100 packets per second. We obtain CSI measurements from the Atheros CSI Tool [40]. For every AP/receiving antenna pair, this tool produces a complex vector whose entries are the amplitude and phase of certain subcarriers from the IEEE 802.11n standard. More precisely, for a 20 MHz channel, values are available for 56 subcarriers; for a 40 MHz channel, values are available for 114 subcarriers. 10 bits are used to represent both, the real and imaginary parts of each subcarrier's gain. The ground truth position of the receiver is obtained using a motion capture camera, which we believe to be sufficiently reliable for our testing purposes.

We use two experimental setups. The first one is an empty room. This setup permits evaluating the positioning performance of the different methods in the ideal situation in which fingerprints used for positioning are as similar as possible to those used during the initialization stage. The setup is depicted in Figure 3, showing the wireless access point in a corner. The figure also shows the *I* = 70 positions (marked as initialization points) used as ground truth positions for constructing the fingerprint model. In addition, there are 26 points for testing the static and dynamic positioning algorithms. Figure 4 shows the first entry of the averaged fingerprints *g*¯*<sup>i</sup>* at each initialization point *pi*, *<sup>i</sup>* <sup>=</sup> 1, ··· , *<sup>I</sup>*, together with the value yield by the estimated model <sup>ˆ</sup> *h*(*p*, *α*ˆ).

The second setup is an office including people as well as objects like desks, chairs and lab benches. This setup permits evaluating the robustness of the different methods, in the sense of how the performance deteriorates when fingerprints differ from those used to build the model during initialization. The setup is depicted in Figure 5, showing desks represented by rectangles, the wireless access point, the positions of the *I* = 56 initialization points and 24 testing points.

**Figure 3.** Empty room layout for method comparison. The wireless access point is placed in the lower-left corner.

**Figure 4.** First entry of the averaged fingerprint *g*¯*<sup>i</sup>* (dots) and the value yield by the model ˆ *h*(*p*, *α*ˆ).

**Figure 5.** Office layout for method comparison. The wireless access point is placed in the upper-right corner, and rectangles represent desks.

Figures 6 and 7 show the cumulative distribution function (CDF) of the positioning error (in meters), (i.e., the relative number of points at which the localization error is smaller than each distance error in the horizontal axis) for the aforementioned four methods and the two setups. Tables 1 and 2 show the minimum and mean positioning errors also for the four methods and both setups. These results show that our proposed method significantly outperforms the FILA, DeepFi and PhaseFi methods in both scenarios.

**Figure 6.** Positioning error CDF (empty room).

**Figure 7.** Positioning error CDF (office).




**Table 2.** Positioning error (office).

#### *5.2. Dynamic Positioning*

The dynamic positioning method makes use of the state-transition Equation (4). In order to design this state equation, we use the following model

$$\begin{aligned} p\_x(t+1) &= p\_x(t) + Tv\_x(t) + w\_x(t), \\ p\_y(t+1) &= p\_y(t) + Tv\_y(t) + w\_y(t), \\ v\_x(t+1) &= v\_x(t) + \iota\_x(t), \\ v\_y(t+1) &= v\_y(t) + \iota\_y(t), \end{aligned} \tag{21}$$

where *p<sup>ζ</sup>* and *v<sup>ζ</sup>* , *ζ* ∈ {*x*, *y*}, denote the position and velocity, respectively, in the *ζ* axis. We choose *<sup>T</sup>* <sup>=</sup> 1 (seconds). We assume that *wx*, *wy*, *<sup>ι</sup><sup>x</sup>* and *<sup>ι</sup><sup>y</sup>* are mutually independent, *wx* <sup>∼</sup> *wy* ∼ N 0, *σ*<sup>2</sup> *p* , with *σ*<sup>2</sup> *<sup>p</sup>* <sup>=</sup> <sup>10</sup><sup>−</sup>4, and *<sup>ι</sup><sup>x</sup>* <sup>∼</sup> *<sup>ι</sup><sup>y</sup>* ∼ N 0, *σ*<sup>2</sup> *ι* , with *σ*<sup>2</sup> *<sup>ι</sup>* = 2.5 × <sup>10</sup><sup>−</sup>4. We therefore have

$$F = \begin{bmatrix} 1 & 0 & T & 0 \\ 0 & 1 & 0 & T \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}, \text{ and } Q = \text{diag}\left(\sigma\_{p'}^2 \sigma\_{p'}^2 \sigma\_{\iota}^2 \sigma\_{\iota}^2\right).$$

To evaluate this performance, we moved the receiver over a trajectory that is well modeled by this equation. This trajectory is shown in red in Figures 8 and 9. Figure 8 shows the trajectory estimated by our static positioning method. Figure 9 shows the one estimated using a particle filter [41], and the one estimated by our proposed dynamic positioning method based on the maximum likelihood Kalman filter. Table 3 shows the maximum tracking errors, as well as their means, given by the three methods. We see that the proposed dynamic positioning method offers a significant accuracy improvement over its static counterpart, as well as over particle filtering.

**Table 3.** Tracking Result.


**Figure 8.** Static positioning result.

**Figure 9.** Comparison of the dynamic positioning results yield by particle filtering and our proposed dynamic positioning method.

#### **6. Conclusions**

We proposed a new fingerprint-based method for indoor localization based on CSI. The proposed method uses unwrapped calibrated phase differences as fingerprints, and consists of three stages. In the first one (fingerprint modeling), a model of the room's fingerprints is constructed. In the second stage (static positioning) we use this model, together with the maximum likelihood criterion,

to obtain a preliminary position estimate based only on the fingerprint measured at the receiver. Finally, in the third stage (dynamic positioning), we use a maximum likelihood Kalman filter to combine this preliminary estimate with a dynamic model for the receiver's motion, to obtain the final estimate. We present experimental results comparing the localization accuracy of the proposed method with that of other rival methods. This is done in two scenarios, namely, in the ideal one in which fingerprints used for localization are similar to those used for initialization, and in a more realistic scenario, in which these fingerprints differ due to alterations in the environment. Our experiments show that our method is more accurate than its rivals in both situations.

The proposed three-stage technique also applies to other types of measurements. A future research direction is to find out how much improvement this technique brings to measurements using Bluetooth and ultra-wideband signals. How to fuse different types of measurements, and how much additional improvement this may bring, will be of interest too. The maximum likelihood Kalman filter method that we use in the dynamic positioning stage is only valid if the motion model of the receiver is linear and Gaussian. However, non-linear motion models are sometimes used, particularly in robotics. An extension of the proposed method consists in modifying the dynamic localization stage so as to handle these kinds of non-linear models. While this is out of the scope of the present work, it is a future research direction as well.

**Author Contributions:** Conceptualization, D.M. and M.F.; methodology, D.M.; software, W.W.; validation, W.W.; formal analysis, D.M.; investigation, W.W. and D.M.; resources, M.F.; data curation, W.W.; writing—original draft preparation, W.W.; writing—review and editing, D.M. and M.F.; visualization, W.W. and M.F.; supervision, D.M. and M.F.; project administration, M.F.; funding acquisition, M.F. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the National Natural Science Foundation of China grant numbers 61633014, 61803101 and U1701264, Guangdong Basic and Applied Basic Research Foundation grant number 2020A1515011505, and the Argentinean Agency for Scientific and Technological Promotion grant number PICT-201-0985.

**Conflicts of Interest:** The authors declare no conflict of interest.
