# Collision Avoidance Geographic P2P-RPL in Multi-Hop Indoor Wireless Networks
## 3 Collision Avoidance Geographic Point-to-Point RPL
### IR-UWB-Based Cooperative Multi-Hop Self Localization in LLNs
^{T} \tag{5}\]  
The state vector of each particle contains the two-dimensional location coordinates \(\mathbf{r}_{k}\) and the orientation quaternion \(\mathbf{q}_{k}\). When the B-box state of a smartphone is initialized by the B-box localization module, the particles are sampled uniformly within the B-box region and the entire quaternion state space. The posterior probability of a node position at \(k\) th iteration is described as:  
\[p(\mathbf{s}_{k})\approx\sum_{l=1}^{N_{p}}\omega_{k}^{l}\delta\Big{(}\mathbf{ s}_{k}-\mathbf{s}_{k}^{l}\Big{)} \tag{6}\]  
where \(\delta(\cdot)\) is the Dirac delta function. The Attitude and Heading Reference System (AHRS) continuously tracks the three-dimensional rotation of the smartphone [29]. The update of the particle state is triggered by the detection of step events [30]. When a step event is detected, the moving distance of the step and the rotation between the recent two steps are derived from the IMU output sequence. The particle filter updates the state of the particle set by taking \(N_{p}\) samples from the approximate posterior distribution of the measured step length \(\Delta\lambda_{k}\) and rotation \(\Delta\mathbf{q}_{k}\)[31; 32]. The samples are labeled with superscripts as \(\left\{\left\langle\Delta\lambda_{k}^{1},\Delta\mathbf{q}_{k}^{1}\right\rangle, \ldots,\left\langle\Delta\lambda_{k}^{N_{p}},\Delta\mathbf{q}_{k}^{N_{p}} \right\rangle\right\}\). By the sampled rotation estimates, the quaternion state of each particle is updated as [33]:  
\[\mathbf{q}_{k+1}^{l}=\Delta\mathbf{q}_{k}^{l}\otimes\mathbf{q}_{k}^{l} \tag{7}\]  
where  
\[\mathbf{q}\otimes\mathbf{q}^{\prime}= \begin{bmatrix}q_{0}&-q_{1}&-q_{2}&-q_{3 }\\ q_{1}&q_{0}&-q_{3}&q_{2}\\ q_{2}&q_{3}&q_{0}&-q_{1}\\ q_{3}&-q_{2}&q_{1}&q_{0}\end{bmatrix}\begin{bmatrix}q_{0}^{\prime}\\ q_{1}^{\prime}\\ q_{2}^{\prime}\\ q_{3}^{\prime}\end{bmatrix} . \tag{8}\]  
To calculate the 2D translational movement of the pedestrian, the 3D attitude state is projected in the 2D heading direction \(\psi\) as follows:  
\[\psi_{k+1}^{l}=arctan\frac{2\left(q_{0,k+1}^{l}q_{3,k+1}^{l}+q_{1,k+1}^{l}q_{ 2,k+1}^{l}\right)}{1-2\left\{\left(q_{2,k+1}^{l}\right)^{2}+\left(q_{3,k+1}^{ l}\right)^{2}\right\}}. \tag{9}\]  
Finally, the location state of each particle is updated according to the two-dimensional pedestrian motion model. \[\mathbf{r}_{k+1}^{l}=\mathbf{r}_{k}^{l}+\Delta\lambda_{k}^{l} \begin{bmatrix} cos\left(\psi_{k+1}^{l}\right)\\ sin\left(\psi_{k+1}^{l}\right)\end{bmatrix} . \tag{10}\]  
When the B-box localization module observes the B-box constraints of neighboring nodes, particles with a state contrary to the radio observation are removed, and the total weights of the particles are normalized. To prevent the situation where the weight of a small number of particles dominate the rest of the particles [34], it uses a deterministic resampling method that avoids uncensored discarding of low-weighted particles [35]. The B-box localization module of a smartphone uses the smallest rectangle containing all surviving particles as the B-box state. Since smartphones move the network deployment space, spatial diversity leads to improvement in the overall localization performance of the network.