*6.2. Compensation Model*

To compensate the effects of the user's body on signal RSSI value, a compensation model is proposed in this study. This model can intensify the signal RSSI values that are being interrupted by the user's body. Thus, the proposed model for correcting the raw RSSI is as follows, which considers the angle between the user's body and the RN:

$$RSSI\_{corr} = RSSI\left(-\frac{\sigma}{d}e^{\frac{-(\theta\_O)^2}{2\theta\_O^2+1}} + 1\right) \tag{14}$$

where *RSSI* and *RSSIcorr*. are the raw and corrected RSSI values, *θO* is the orientation angle between the user and an RN in degrees, *σ* is the intensification parameter, and *d* is the distance between the wearable tag and the edge of the far-ended shoulder. The value of *σ* depends both on the environment and the user orientation with respect to the RN, which needs to be chosen empirically.

However, as observed from Figure 3, the corrected RSSI will be an overestimation when applying the proposed compensation model with the straight LOS direction (e.g., around 0◦ ) between the wearable tag and the RN. Moreover, it will be an underestimation when the signals are being interrupted by the maximum obstacles (e.g., the angle positions just after the angles 90◦ and just before the angle 270◦ ). To resolve this issue, the following rules with different values of the parameter *σ* are chosen for different angles:

$$
\sigma = \begin{cases}
\begin{array}{l}
\sigma\_{1}, & \text{if } \left( 0^{\circ} \le \theta\_{B} \le 45^{\circ} \right) \\
\sigma\_{2}, & \text{if } \left( 45^{\circ} < \theta\_{B} \le 135^{\circ} \right) \\
\sigma\_{3}, & \text{if } \left( 135^{\circ} < \theta\_{B} \le 225^{\circ} \right)
\end{array} \end{cases}
\begin{array}{l}
(315^{\circ} \le \theta\_{B} \le 360^{\circ}), \\
(225^{\circ} < \theta\_{B} \le 315^{\circ}),
\end{array}
\tag{15}
$$

To estimate the values of *σ*, this study first calculates the amount of error (*<sup>e</sup>θ*) as given in Equation (16), for a given range of angles by choosing a value of *σ*. Secondly, the optimum value of *σ* is estimated by adjusting its value untill the smallest *eθ* is obtained.

$$\sigma\_{\theta} = \frac{\sum\_{i=0}^{n} \sqrt{\left(RSSI\_{\theta\_{\text{s}} + i \ast m} - RSSI\_{0^{\circ}}\right)^{2}}}{\theta\_{\text{s}} - \theta\_{\text{s}}} \times 100\% \tag{16}$$

where *RSSIθs*+*i*<sup>∗</sup>*<sup>m</sup>* and *RSSI*0◦ are the RSSI values at angle *θs* + *i* × *m* and 0◦ , respectively, *n* is the total number of angle values considered to collect data within the range *θs* to *θ<sup>e</sup>*, and *m* is the amount of angle considered to rotate in each move. As this study considers collecting RSSI data at every 15◦ rotation, the value of *m* is 15.

## **7. Location Estimation**

Irrespective of the utilised features, a fingerprinting-based localisation problem is mainly a pattern matching problem. During the online phase, a target sends a query fingerprint from an unknown location that needs to be matched with the fingerprints stored in the radio map. It is very unlikely that a radio map will contain a fingerprint with an exact match. Thus, the traditional way is to find *K* different fingerprints closest to the queried one from the radio map, which is known as the K-nearest neighbour (K-NN) method. This study exploits the classical K-NN algorithm for location estimation. Moreover, an improved version of the classical K-NN algorithm, named weighted K-NN (WK-NN), is applied to further improve the localisation accuracy.

Let *ruj* be the body shadowing-compensated mean RSSI collected from RN *j* at unknown target location *u*. Then, the RSSI distance between an RP *i* from the radio map to the target point *u* can be obtained as follows:

$$d\_{\rm ui} = \frac{1}{N\_{RN}} \sqrt{\sum\_{j=1}^{N\_{RN}} \left(r\_{\rm uj} - r\_{\rm ij}\right)^2} \tag{17}$$

where *dui* is the Euclidean distance between the RSSI of the target point and RP, *rij* is the mean RSSI collected from RN *j* at RP *i*, and *NRN* is the total number of RNs considered for a fingerprint. In the case of the K-NN method, *K* RPs from the radio map will be selected that have the smallest distance value with the target. Therefore, the estimated location of the target can be calculated as follows:

$$\text{LOC}(\mathbf{x}\_{\text{i}\prime}, y\_{\text{i}}) = \frac{1}{K} \sum\_{i=1}^{K} \text{LOC}(\mathbf{x}\_{i\prime}, y\_{i}) \tag{18}$$

where (*xi*, *yi*) are the locations of the RPs. Here, the spatial distances between a target location and its neighbouring RPs are usually different. Thus, the WK-NN algorithm also considers the corresponding spatial distances in terms of weight factor when selecting the *K* nearest RPs. As proposed in [33], the weight is inversely proportional to the spatial distance and can be calculated as follows:

$$w\_{ci} = \frac{1/D\_{ci}}{\sum\_{i=1}^{K} 1/D\_{ci}}\tag{19}$$

where *Dci* = (*xc* − *xi*)<sup>2</sup> + (*yc* − *yi*)<sup>2</sup> is the spatial Euclidean distance between the coarse location (*xc*, *yc*) of the unknown target and an RP location (*xi*, *yi*). Therefore, the estimated location will be

*LOC*(*xu*, *yu*) = ∑*Ki*=<sup>1</sup> *wciLOC*(*xi*, *yi*) ∑*Ki*=<sup>1</sup> *wci* (20)

In this study, the coarse location of an unknown target is estimated first to calculate the spatial distance between the RPs and a target location. The coarse location of the target is computed by leveraging the landmark graph and using the same technique proposed in Section 6.1. Therefore, the estimated coarse location is used to calculate the weight for the WK-NN algorithm.
