# A Real-Time BLE/PDR Integrated System by Using an Improved Robust Filter for Indoor Position
## 3 Materials and Methods
### BLE/PDR Integrated System Based on EKF  
PDR is a self-contained algorithm that can provide accurate position information at a short distance but it suffers accumulated errors. BLE fingerprint position accuracy is poor without cumulative error. The positioning result obtained by the BLE fingerprint method at present will not be affected by the previous result. To improve the positioning accuracy, continuity, and stability of the system, two positioning methods are often combined as an integrated system based on the Kalman filter (KF). Since the PDR position method is a non-linear algorithm, the Extended Kalman filter (EKF) is often utilized to replace the KF method to fuse two positioning methods. The hybrid position model mainly includes two models, one is the state transition model and the other is the observation model. The state transition model is mainly to estimate the state vector which is composited of position coordinates, step length, and heading angle. The state vector is expressed by Equation (20):  
\[X=[N,E,s,\psi] \tag{20}\]  
Figure 6: The curve of different motion states between the raw standard deviation of acceleration modulus and the standard deviation of acceleration modulus after MAF. The state transition model is expressed by Equation (21) at time \(k\):  
\[\left\{ \begin{array}{ll}&N_{k}=N_{k-1}+s_{k-1}\cdot cos\psi_{k-1}+\omega_{N}\\ &E_{k}=E_{k-1}+s_{k-1}\cdot sin\psi_{k-1}+\omega_{E}\\ &s_{k}=s_{k-1}+\omega_{s}\\ &\psi_{k}=\psi_{k-1}+\omega_{\psi}\end{array} \right. \tag{21}\]  
where \(N_{k}\) and \(E_{k}\) are the position coordinates of the PDR position method in the north and east, respectively. \(s_{k}\) and \(\psi\) are the step length and the heading angle calculated by the PDR method at time \(k\). Further, \(\omega_{N}\), \(\omega_{E}\), \(\omega_{s}\), \(\omega_{\psi}\) are the corresponding process noise of the state vector. They conform to Gaussian distribution, and their variances are denoted by \(\delta_{N}^{2}\), \(\delta_{E}^{2}\), \(\delta_{s}^{2}\), \(\delta_{\psi}^{2}\), respectively. The state transition matrix \(A_{k}^{-}\) is expressed as Equation (22):  
\[A_{k}^{-}=\left[ \begin{array}{ccc}1&0&cos\psi_{k-1}&0\\ 0&1&sin\psi_{k-1}&0\\ 0&0&1&0\\ 0&0&0&1\end{array} \right] \tag{22}\]  
The Jacobi matrix \(A_{k}\) of \(A_{k}^{-}\) is expressed as Equation (23):  
\[A_{k}=\left[ \begin{array}{ccc}1&0&cos\psi_{k-1}&-s_{k-1}\cdot sin\psi_{k-1} \\ 0&1&sin\psi_{k-1}&s_{k-1}\cdot cos\psi_{k-1}\\ 0&0&1&0\\ 0&0&0&1\end{array} \right] \tag{23}\]  
The observation model is mainly to estimate the observation vector which is composited of position coordinates of BLE fingerprint position. The observation vector is expressed by Equation (24):  
\[Z=\left[N^{\prime},E^{\prime}\right] \tag{24}\]  
The observation model is expressed as follow (25):  
\[\left\{ \begin{array}{ll}N_{k}^{\prime}=N_{k-1}^{\prime}+\omega_{N^{\prime}} \\ E_{k}^{\prime}=E_{k-1}^{\prime}+\omega_{E^{\prime}}\end{array} \right. \tag{25}\]  
where \(N_{k}^{\prime}\) and \(E_{k}^{\prime}\) are the position coordinates of the BLE fingerprint method in the north and east, respectively, \(\omega_{N^{\prime}}\) and \(\omega_{E^{\prime}}\) are the corresponding observation noise that conforms to Gaussian distribution and their variances are \(\delta_{N^{\prime}}^{2}\), \(\delta_{E^{\prime}}^{2}\). The observation matrix \(H_{k}\) is expressed as Equation (26):  
\[H_{k}=\left[ \begin{array}{ccc}1&0&0&0\\ 0&1&0&0\end{array} \right] \tag{26}\]  
When the state vector and observation vector are obtained by BLE fingerprint and PDR methods, respectively, the EKF estimation is employed to update the state parameters through time as well as the observation parameters.