# Indoor Carrier Phase Positioning Technology Based on OFDM System
## 3 Positioning Algorithm
### TOA and Carrier Phase Measurements  
According to Equations (10) and (19), further considering the non-ideal factors such as clock error and NLOS error, the TOA measurements and carrier phase between the \(i\)-th BS and user equipment (UE) \(r\) at a specific epoch can be written as:  
\[ \begin{split} T_{r}^{i}&=(d_{r}^{i}+m_{r}^{i}+w_{r, T}^{i})/c+\delta t^{i}-\delta t_{r}\\ \phi_{r}^{i}&=\frac{\frac{d_{r}^{i}+c(\delta t^{i}- \delta t_{r})+m_{r}^{i}}{\lambda}-N_{r}^{i}+w_{r,P}^{i}}{\ \ },\end{split}  \tag{20}\]  
* \(\delta t^{i}\) (unknown) is the clock error of the transmitter \(i\) (unit: s). * \(\delta t_{r}\) (unknown) is the clock error of the receiver \(r\) (unit: s). * \(m_{r}^{i}\) (unknown) represents the channel bias introduced by NLOS reflections (unit: m). The SD of the TOA and carrier phase measurements from the receiver \(r\) by measuring the signals from two transmitters \(i\) and \(j\) can be expressed as:  
\[ \begin{split} T_{r}^{ij}&=(d_{r}^{ij}+m_{r}^{ij}+w_ {r,T}^{ij})/c+\delta t^{ij}\\ \phi_{r}^{ij}&=\frac{d_{r}^{ii}+c\delta t^{ij}+m_{r} ^{ii}}{\lambda}-N_{r}^{ij}+w_{r,P}^{ij}\end{split} \, \tag{21}\]where the double superscript \"\(ij\)\" indicates the differential operation between transmitters \(i\) and \(j\), i.e., \(s_{r}^{ij}=s_{r}^{i}-s_{r}^{j};s\in\{T,\phi,d,\delta t,N,m,w\}\). According to Equations (10) and (19), the measurement noise \(w_{r,T}^{ij}\) and \(w_{r,p}^{ij}\) are still independent Gaussian noise with following distributions, i.e.,  
\[E\Big{[}w_{r,T}^{ij},w_{r,T}^{kj}\Big{]}=\left\{ \begin{array}{ll}\sigma_{r,i }^{2}+\sigma_{r,j}^{2};&i=k\\ \sigma_{r,j}^{2};&i\
eq k\end{array} \right.. \tag{22}\]  
The SD operation of Equation (21) removes the measurement errors common to the receiver, e.g., the receiver clock offset \(\delta t_{r}\). Furthermore, the double-difference (DD) TOA and carrier phase measurements from two transmitters \(i\) and \(j\), and two receivers \(r\) and \(u\) can be expressed as:  
\[ \begin{array}{l}T_{ru}^{ij}=\left(d_{ru}^{ij}+m_{ru}^{ij}+w_{ru,T}^{ij}\right) /c\\ \phi_{ru}^{ij}=\frac{d_{ru}^{ij}+m_{ru}^{ij}}{\lambda}-N_{ru}^{ij}+w_{ru,p}^{ ij}\end{array} , \tag{23}\]  
where the double superscript \"\(ij\)\" indicates the differential operation between transmitters \(i\) and \(j\), and double subscript \"\(ru\)\" indicates the differential operation between receivers \(r\) and \(u\), \(s_{ru}^{ij}=s_{r}^{ij}-s_{u}^{ij}=\left(s_{r}^{i}-s_{r}^{j}\right)-\left(s_{u} ^{i}-s_{u}^{j}\right);s\in\{T,\phi,d,\delta t,N,m,w\}\). DD measurement noise \(w_{ru,T}^{ij}\) and \(w_{ru,p}^{ij}\) are no longer independent Gaussian noise. Assume the transmitter \(j\) is selected as the reference, we have:  
\[E\Big{[}w_{ru,T}^{ij},w_{ru,T}^{kj}\Big{]}=\left\{ \begin{array}{c}\sigma_{r, j}^{2}+\sigma_{u,j}^{2};i\
eq k\\ \sigma_{r,i}^{2}+\sigma_{u,i}^{2}+\sigma_{r,j}^{2}+\sigma_{u,i}^{2};i=k\end{array} \right.. \tag{24}\]  
DD operation removes the measurement biases related to the transmitters and the receivers, such as the transmitter clock offsets and receivers clock offsets. We introduce the concept of reference device, where it is assumed that \(u\) is the reference device and that the location of terminal \(u\) is known. It can be seen by Equation (23) that the introduction of the reference device helps to eliminate the clock error. We can construct the SD measurements from the DD measurements, which are not impacted by the receiver and the transmitter clock biases. Given that \(d_{u}^{ij}\) can be obtained from the known locations of the reference device \(u\) and the BSs, we can construct the SD measurements \(\hat{T}_{r}^{ij}\) and \(\Phi_{r}^{ij}\):  
\[ \begin{array}{l}\hat{T}_{r}^{ij}\triangleq cT_{ru}^{ij}+d_{u}^{ij}=d_{r}^{ ij}+m_{ru}^{ij}+w_{ru,T}^{ij}\\ \Phi_{r}^{ij}\triangleq\phi_{ru}^{ij}+\frac{d_{r}^{ij}}{\lambda}=\frac{d_{r}^{ ij}+m_{ru}^{ij}}{\lambda}-N_{ru}^{ij}+w_{ru,p}^{ij}\end{array} , \tag{25}\]  
Equation (25) shows the \(\hat{T}_{r}^{ij}\) and \(\Phi_{r}^{ij}\) are not impacted by the receiver and the transmitter clock biases.