# Intelligent Fusion Structure for Wi-Fi/BLE/QR/MEMS Sensor-Based Indoor Localization
## 3 Mems Sensor-Based Localization, Optimization, and Evaluation Framework
### Observations and Trajectory Optimization  
Limited by the cumulative errors from the built-in sensors of low-cost terminals, a single pre-integrated INS cannot realize accurate 3D indoor positioning by itself. In this section, multi-level observations are proposed to reduce the cumulative errors of pre-integrated INS systems by comprehensively considering environmental factors. (1) Quasi-static magnetic field (QSMF) recognition: In indoor scenes containing complex artificial interference, detection of the disturbed local magnetic fields is required to improve heading-estimation performance [24]. The local magnetic fields of pedestrians during straight indoor travel are collected for QSMF detection:  
\[M_{\text{refer}}^{n}=C_{b,1}^{n}\cdot M_{k,1}^{b} \tag{6}\]  
where \(M_{k,1}^{b}\) denotes the first magnetic output epoch under the recognized QSMF period and \(C_{b,1}^{n}\) indicates the attitude matrix at the current moment. \(M_{\text{refer}}^{n}\) denotes the calibrated local magnetic vector, applied as the reference magnetic field:  
\[\delta z_{M}^{n}=C_{b,k}^{n}\cdot M_{k}^{b}-M_{\text{refer}}^{n} \tag{7}\]  
where \(M_{k}^{b}\) indicates the magnetometer collected at other epochs of the detected QSMF period and \(C_{b,k}^{n}\) indicates the pose matrix at other QSMF moments. (2) External acceleration observation: In the case of complex motion models of pedestrians, external acceleration can degrade the performance of roll- and pitch-angle estimation in the calculated attitude matrix [25]. In this section, external acceleration values are modeled as an observation equation:  
\[ \begin{array}{ll}\delta f^{n}&=\mathbf{f}^{n}-\hat{C}_{b}^{n}\mathbf{f}\\ &\approx\mathbf{f}^{n}-(\mathbf{I}-\{\psi\times\})\mathbf{C}_{b}^{n}\mathbf{f}^{b}+C_{b}^ {n}\mathbf{n}_{a}\\ &=[\mathbf{\psi}\times]\mathbf{f}^{n}+\mathbf{C}_{b}^{n}\mathbf{n}_{a}\\ &=[\mathbf{f}^{n}\times]\mathbf{\psi}+C_{b}^{n}\mathbf{n}_{a}\end{array}  \tag{8}\]  
where \(\mathbf{f}^{n}\) represents the reference local gravity, \(\hat{\mathbf{f}}^{b}\) represents the accelerometer output, and \(\mathbf{\psi}\times\) indicates the skew-symmetric matrix derived from the error vector-attitude vector \(\mathbf{\phi}_{b_{n+1}}^{b_{n}}\). The measurement noise \(\mathbf{n}_{a}\) is adaptively adjusted to the context of the calculated external acceleration:  
\[\mathbf{n}_{a}=\left\{ \begin{array}{ll}\sigma_{a},\gamma\leq\sigma_{1}\\ (\gamma^{2}/P)\sigma_{a},\sigma_{1}<\gamma\leq\sigma_{2}\\ \infty,\gamma>\sigma_{2}\end{array} \right. \tag{9}\]  
where \(\gamma=\sqrt{\left|norm(\mathbf{f}^{b})-\mathbf{g}\right|}\) is the estimated external acceleration value, \(\sigma_{a}\) is the bias stability of the accelerometer, and \(P\) is the covariance matrix in the RUKF. The parameter \(\sigma_{1}\) is calculated by \(\sqrt{\sigma_{a_{x}}^{2}+\sigma_{a_{y}}^{2}+\sigma_{a_{z}}^{2}}\), \(\sigma_{a_{x}}\), \(\sigma_{a_{y}}\), and \(\sigma_{a_{z}}\) represents the bias stability originated from the accelerometer. The parameter \(\sigma_{2}\) is calculated by \(s\cdot|\mathbf{g}|\) and the scale parameter \(s\) needs to be turned according to the design requirement of the applications. (3) The PDR mechanization can provide the relative step-length originated walking speed and the location increment to constrain the drift error of the pre-integrated INS solution:  
\[\delta z_{v}^{n}=\mathbf{v}_{Step}^{n}-\mathbf{v}_{INS}^{n} \tag{10}\]where \(\mathbf{v}_{Step}^{n}\) represents the calculated gait length value provided in [6] and \(\mathbf{v}_{INS}^{n}\) is the velocity information provided by the pre-integrated INS solution. The observed residuals of two vectors are described as:  
\[\delta\mathbf{z}_{p}^{n}=\mathbf{p}_{Step}^{n}-\mathbf{p}_{INS}^{n} \tag{11}\]  
where \(\mathbf{p}_{Step}^{n}\) represents the calculated 2D position results using PDR mechanization and \(\mathbf{p}_{INS}^{n}\) indicates the inertial mechanization based on location estimation result.