# Seamless Indoor-Outdoor Localization Through Transition Detection
## 4 Positioning Engines  
### Indoor Positioning Engine  
In indoor environments where GNSS signals are obstructed, wireless-signal-based positioning technologies have gained significant attention. An unsupervised WiFi RSSI positioning model using a particle filter to fuse WiFi and AI-IMU location estimates for trajectory tracking was proposed in our previous work [18]. As an AI-IMU tracking model, we use RoNIN [7] in this paper.  
The scanned RSSI data are dimensionality-reduced in a similar manner to Equations (3) and (4) but considering only WiFi results and thus excluding the BLE. The learning model \(h(\cdot)\) predicts the position at a given RSSI feature vector \(X_{k}^{WiFi}\).  
\[h:X_{k}^{WiFi}\in\mathbb{R}^{d}\mapsto(p_{k}^{x},p_{k}^{y}) \tag{16}\]  
The sensing frequency of the WiFi RSSI is relatively low compared to the IMU. Furthermore, the absolute location is estimated from the WiFi RSSI while the relative location is estimated from the AI-IMU. To address this issue, a particle filter was employed for the sensor fusion.  
The state of the particle is defined as below:  
\[Y_{i}=\begin{bmatrix}p_{k}^{x,i}&p_{k}^{y,i}&\theta_{k}^{i}\end{bmatrix}^{T} \tag{17}\]  
The prior for the indoor positioning is set by the existence of a wall.  
\[p(x_{k}|x_{k-1})=\begin{cases}0&\text{, if a particle crossed a wall}\\ 1&\text{, if a particle did not cross a wall}\end{cases} \tag{18}\]  
The transition function \(g(\cdot)\) from location \(k-1\) to \(k\) of the \(i\)th particle is modeled as below:  
\[\begin{array}{c}p_{k}^{x,i,aimu}=p_{k-1}^{x,i,aimu}+\hat{l}_{k}\cos(\theta_{ k-1}^{i,aimu}+\hat{\theta}_{k})\\ p_{k}^{y,i,aimu}=p_{k-1}^{y,i,aimu}+\hat{l}_{k}\sin(\theta_{k-1}^{i,aimu}+\hat{ \theta}_{k})\\ \theta_{k}^{i,aimu}=\theta_{k-1}^{i,aimu}+\hat{\theta}_{k}\end{array} \tag{19}\]  
\[\begin{array}{c}p_{k}^{x,i,WiFi}=p_{k-1}^{x,i,WiFi}+\sum_{i=k-n+1}^{k}\hat{l }_{k}\cos(\theta_{k-1}^{i,aimu}+\sum_{j=k-n+1}^{i}\hat{\theta}_{j})\\ p_{k}^{y,i,WiFi}=p_{k-1}^{y,i,WiFi}+\sum_{i=k-n+1}^{k}\hat{l}_{k}\sin(\theta_{ k-1}^{i,aimu}+\sum_{j=k-n+1}^{i}\hat{\theta}_{j})\\ \theta_{k}^{i,WiFi}=\theta_{k-1}^{i,WiFi}+\sum_{j=k-n+1}^{k}\hat{\theta}_{k} \end{array} \tag{20}\]  
where \(\hat{l}_{k}\) and \(\hat{\theta}_{k}\) are the position and angular displacement estimations from the AI-IMU.  
The likelihood for particles corresponding to the AI-IMU is defined to measure the distance error of a particle to an average, while the likelihood for the particles corresponding to the WiFi positioning model is defined to measure distance error of a particle to the estimated position from the learning model \(h(\cdot)\),  
\[p(X_{k}|Y_{k}^{i,aimu})\sim\mathcal{N}(|Y_{k}^{i,aimu}-\frac{1}{N_{p}^{aimu}} \sum_{i}^{N_{p}^{aimu}}[p_{k}^{x,i,aimu},p_{k}^{y,i,aimu}]|,\sigma^{2}) \tag{21}\]  
\[p(X_{k}|Y_{k}^{i,WiFi})\sim\mathcal{N}(|Y_{k}^{i,WiFi}-h(X_{k}^{WiFi}),\sigma ^{2}), \tag{22}\]  
where the number of particles \(N_{p}^{aimu}\), \(N_{p}^{WiFi}\), and measurement error variance \(\sigma^{2}\) are manually tuned parameters.  
Both AI-IMU and WiFi particles are used for the resampling step of the particle filter to compensate for the bias error of the AI-IMU estimations at the WiFi particle update.  
The pseudo-code of the indoor positioning algorithm is shown below in Appendix A.