# RTK with the Assistance of an IMU-Based Pedestrian Navigation Algorithm for Smartphones
## 2 Materials and Methods
### Implementation of RTK
#### 2.1.2 Theory of RTK  
RTK is a differential positioning methodology that utilizes the double-differencing pseudorange and carrier phase. We present the principle of triple-frequency RTK for the sake of generality. We can use single-frequency RTK or dual-frequency RTK in practical applications. We define state vector \(\mathbf{x}\) and measurement vector \(\mathbf{y}\) as follows:\[\mathbf{x}=\left({\mathbf{r_{r}}}^{T},{\mathbf{v_{r}}}^{T},{\mathbf{B_{1}}}^{T},{\mathbf{B_{2}}}^{T},{ \mathbf{B_{5}}}^{T}\right)^{T} \tag{10}\]  
\[\mathbf{y}=\left({\mathbf{\Phi_{1}}}^{T},{\mathbf{\Phi_{2}}}^{T},{\mathbf{\Phi_{5}}}^{T},{\mathbf{P_{ 1}}}^{T},{\mathbf{P_{2}}}^{T},{\mathbf{P_{5}}}^{T}\right)^{T} \tag{11}\]  
where \(\mathbf{r_{r}}\) and \(\mathbf{v_{r}}\) are the position and velocity of the rover, respectively; \(\mathbf{B_{i}}\) is the \(L_{i}\) single-differencing carrier-phase biases. \(\mathbf{\Phi_{i}}\) and \(\mathbf{P_{i}}\) are the double-differencing phase-range and pseudorange measurements on the \(L_{i}\) band, respectively. When it comes to the predicting procedure, we can define \(F_{k-1}^{k}\) as Equation (12), considering basic kinematics theory and the consistency of the carrier biases if there is no loss of lock:  
\[F_{k-1}^{k}= \begin{bmatrix}\mathbf{I_{3\times 3}}&\mathbf{I_{3\times 3}}\Delta t&\mathbf{O_{ 3\times(3m-3)}}\\ \mathbf{O_{3\times 3}}&\mathbf{I_{3\times 3}}&\mathbf{O_{3\times(3m-3)}}\\ \mathbf{O_{(3m-3)\times 3}}&\mathbf{O_{(3m-3)\times 3}}&\mathbf{I_{(3m-3)\times(3m-3)}} \end{bmatrix}  \tag{12}\]  
When it comes to the updating procedure, we can define the measurement function \(\mathbf{h(x)}\) as Equation (13), assuming there are \(m\) satellites in view:  
\[\mathbf{h(x)}=\left({\mathbf{h_{\Phi,1}}}^{T},{\mathbf{h_{\Phi,2}}}^{T},{\mathbf{h_{\Phi,5}}}^ {T},{\mathbf{h_{p,1}}}^{T},{\mathbf{h_{p,2}}}^{T},{\mathbf{h_{p,5}}}^{T}\right)^{T} \tag{13}\]  
where:  
\[\mathbf{h_{\Phi,i}}= \begin{bmatrix}\rho_{rb}^{12}+\lambda_{i}(B_{rb}^{1}-B_{rb}^{ 2})\\ \rho_{rb}^{13}+\lambda_{i}(B_{rb}^{1}-B_{rb}^{3})\\ \vdots\\ \rho_{rb}^{1m}+\lambda_{i}(B_{rb}^{1}-B_{rb}^{m})\end{bmatrix}  \tag{14}\]  
\[\mathbf{h_{p,i}}= \begin{bmatrix}\rho_{rb}^{12}\\ \rho_{rb}^{13}\\ \vdots\\ \rho_{rb}^{1m}\end{bmatrix}  \tag{15}\]  
In the two equations, \(\lambda_{i}\) is the wavelength of the \(L_{i}\) bands. \(\rho_{rb}^{1k}\) is the double-differencing pseudorange of the 1 st satellite and the \(k\)th satellite. We define \(\mathbf{D}\) as the single-differencing matrix:  
\[\mathbf{D}= \begin{bmatrix}1&-1&0&\dots&0\\ 1&0&-1&\dots&0\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ 1&0&0&\dots&-1\end{bmatrix}  \tag{16}\]  
We utilize \(e_{r}^{k}\) to stand for the LOS vector from the receiver antenna to the \(k\)th satellite in ECEF. We can define \(\mathbf{E}\) as:  
\[\mathbf{E}= \begin{bmatrix}e_{r}^{1}\\ \mathbf{e_{r}}^{2}\\ \vdots\\ e_{r}^{m}\end{bmatrix}  \tag{17}\]  
Finally, we can write \(\mathbf{H}_{k}\) as:  
\[ \begin{split}\prescript{A}{B}{\mathbf{\hat{q}}^{*}}=& \prescript{B}{A}{\mathbf{\hat{q}}}=\begin{bmatrix}q_{0}\\ -q_{1}\\ -q_{2}\\ -q_{3}\end{bmatrix}\end{split}  \tag{21}\]  
We can define \(\prescript{S}{\mathbf{\omega}}\) as a quaternion that is formed with the components of the \(\omega_{nb}^{b}\), assuming \(\omega_{nb}^{b}\) is the angular rate:  
\[\omega_{nb}^{b}= \begin{bmatrix}\omega_{x}\\ \omega_{y}\\ \omega_{z}\end{bmatrix}  \tag{22}\]  
\[\prescript{S}{\mathbf{\omega}}= \begin{bmatrix}0\\ \omega_{x}\\ \omega_{y}\\ \omega_{z}\end{bmatrix}