# Indoor Carrier Phase Positioning Technology Based on OFDM System
## 3 Positioning Algorithm
### Extended Kalman Filter  
For an EKF design, one needs first to define the unknown EKF states. An EKF for carrier phase positioning may include the following EKF states:  
* UE position. EKF for positioning needs to include the states associated with the unknown UE position. The EKF may use the 2D (or 3D) UE position coordinates directly as the EKF states. For example, in the following discussion of the EKF design, we assume the EKF states include a 2D position. * UE velocity. With the consideration of UE mobility, the EKF states may also include the UE velocity. The number of states for UE velocity is generally the same as the number of states for UE position. * Integer ambiguities. The premise of using the carrier phase for location is to solve integer ambiguities. According to Equation (25), it is necessary to solve the DD integer ambiguities while solving the user position. Let the position of the UE at epoch \(k\) be \(\mathbf{s}(k)\). In the absence of other information, assume that the velocity of UE keeps constant, the position at the next epoch can be expressed as \(\mathbf{s}(k+1)=\mathbf{s}(k)+\mathbf{v}T\). Furthermore, in the case of no cycle slip, the ambiguities remain consistent in each epoch. Assume the system states include 2D position, 2D velocity, and the DD integer ambiguities are obtained from \(m\) cells, and the system can be represented as: \[\left\{ \begin{array}{l}x(k+1)=x(k)+v_{x}(k)T\\ v_{x}(k+1)=v_{x}(k)\\ y(k+1)=y(k)+v_{y}(k)T\\ v_{y}(k+1)=v_{y}(k)\\ N_{ru}^{ij}(k+1)=N_{ru}^{ij}(k)\end{array} \right.\] (26) Assume the \(j\)-th cell is selected as the reference cell. The EKF state vector \(\mathbf{x}\) can be expressed as follows: \[\mathbf{x}\triangleq[\mathbf{s},\mathbf{v},\mathbf{N}]^{T}\] \[=\left[x,y,v_{x},v_{y},N_{ru}^{1j},\ldots,N_{ru}^{(j-1)j},N_{ru}^{ (j+1)j},\ldots,N_{ru}^{mj}\right]^{T}\,\] (27) where \(\mathbf{s}=(x,y)\) models the UE position; \(\mathbf{v}=(v_{x},v_{y})\) is the UE velocity, and \(\mathbf{N}=[N_{ru}^{1j},\ldots,N_{ru}^{(j-1)j},N_{ru}^{(j+1)j},\ldots,N_{ru}^{ mj}]\) includes the DD integer ambiguities. Based on the selected EKF states, the state transition equation of the discrete EKF for carrier phase positioning can be written as: \[\mathbf{x}(k+1)=\mathbf{F}(k)\mathbf{x}(k)+\mathbf{W}_{\mathbf{x}}(k).\] (28) The one-step state transition matrix is as follows: \[\mathbf{F}=\left[ \begin{array}{ccc}\mathbf{I}(2\times 2)&\mathbf{F}_{12}& \mathbf{0}\\ \mathbf{0}&\mathbf{I}(2\times 2)&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\mathbf{I}(m-1\times m-1)\end{array} \right],\] (29) where \(F_{12}=\left[ \begin{array}{cc}\Delta T&0\\ 0&\Delta T\end{array} \right]\), \(E[\mathbf{W}_{\mathbf{x}}]=\mathbf{0}\), and \(\mathbf{Q}=E\big{[}\mathbf{W}_{\mathbf{x}}\mathbf{W}_{\mathbf{x}}^{\mathbf{T }}\big{]}=\text{diag}(\mathbf{Q}_{r};\mathbf{Q}_{v};\mathbf{0}(\mathbf{m}- \mathbf{1}\times\mathbf{m}-\mathbf{1}))\), \(\mathbf{Q}_{r}=\text{diag}\Big{\{}\sigma_{x}^{2},\sigma_{y}^{2}\Big{\}}\), \(\mathbf{Q}_{v}=\text{diag}\Big{\{}\sigma_{v_{x}}^{2},\sigma_{v_{y}}^{2}\Big{\}}\), \(\mathbf{I}\) represents an identity matrix, and \(\mathbf{0}\) represents a zero matrix. \(\Delta T\) is the time interval of the state transition of the Kalman filter. \(\sigma_{x}^{2},\sigma_{y}^{2}\) and \(\sigma_{v_{x}}^{2},\sigma_{v_{y}}^{2}\) represent the uncertainty in the prediction of the UE position and velocity. The measurement equations of the discrete EKF as: \[\mathbf{Z}(k+1)=\mathbf{h}(\mathbf{x}(k+1))+\mathbf{W}_{\mathbf{Z}}(k+1)\] (30) \[\mathbf{Z}(k+1)=\left[ \begin{array}{c}\mathbf{T}\\ \mathbf{\Theta}\end{array} \right]\mathbf{,T}(k+1)=\left[ \begin{array}{c} \hat{\mathbf{T}}_{r}^{1j}(k+1)\\ \vdots\\ \hat{\mathbf{T}}_{r}^{(j-1)j}(k+1)\\ \vdots\\ \hat{\mathbf{T}}_{r}^{mj}(k+1)\end{array} \right]\] (31)\[\mathbf{\Theta}(k+1)=\left[ \begin{array}{c}\Phi_{r}^{1j}(k+1)\\ \vdots\\ \Phi_{r}^{(j-1)j}(k+1)\\ \Phi_{r}^{(j+1)j}(k+1)\\ \vdots\\ \Phi_{r}^{mj}(k+1)\end{array} \right] \tag{32}\]  
\[\mathbf{W}_{z}(k+1)=\left[ \begin{array}{cc}\mathbf{W_{T}}(k+1)\\ \mathbf{W_{P}}(k+1)\end{array}