# Calibration of Magnetometers with GNSS Receivers and Magnetometer-Aided GNSS Ambiguity Fixing
## 3 Calibration of Magnetic Flux Sensors
### Attitude Determination with Three GNSS Receivers
#### 3.2.3 Integer Ambiguity Fixing Using Prior Information on Baseline Coordinates
It minimizes the cost function  
\[C(\varphi,\theta,\psi)=\sum_{r=2}^{3}\|\vec{b}_{1r}^{\mathrm{n}}-R_{\mathrm{b} }^{\mathrm{n}}(\varphi,\theta,\psi)\vec{b}_{1r}^{\mathrm{b}}\|^{2}. \tag{19}\]Once the rotation matrix is found, the attitude angles can obtained from Equation (4):  
\[\hat{\varphi} = \mathrm{atan}\left((R_{n}^{\mathrm{b}})_{1,2}/(R_{n}^{\mathrm{b}})_{1,1}\right),\] \[\hat{\theta} = \mathrm{asin}\left((-R_{n}^{\mathrm{b}})_{1,3}\right),\] \[\hat{\psi} = \mathrm{atan}\left((R_{n}^{\mathrm{b}})_{2,3}/(R_{n}^{\mathrm{b}} )_{3,3}\right). \tag{20}\]  
We constrain the sequential tree search of inequality  
\[\hat{N}_{1r}^{kl}-\sigma_{\hat{N}_{1r}^{kl}}\cdot\gamma^{kl}\leq N_{1r}^{kl} \leq\hat{N}_{1r}^{kl}+\sigma_{\hat{N}_{1r}^{kl}}\cdot\gamma^{kl}\quad\forall\,k, \tag{21}\]  
by integrating prior information on the baseline lengths and coordinates (provided in body-fixed frame), i.e., we consider only these integer candidates \(N_{1r}^{kl}\), where the respective baseline estimate shows consistent baseline length and attitude information. This leads to the following additional requirements:  
\[\frac{\left(\|\tilde{b}_{1r}^{\mathrm{n}}(N_{1r}^{1l}\ldots,N_{1r}^{kl})\|-\| \tilde{b}_{1r}^{\mathrm{b}}\|\right)^{2}}{\sigma_{1_{1r}^{\mathrm{I}}}^{2}+ \sigma_{1_{2r}^{\mathrm{I}}}^{2}}\stackrel{{!}}{{\leq}}\gamma_{1 _{1r}}^{2}\quad\forall\,r\quad\wedge, \tag{22}\]  
\[\min_{\varphi,\theta,\varphi}\left(\sum_{r=2}^{3}\|\tilde{b}_{1r}^{\mathrm{n} }\left(N_{1r}^{1l}\ldots,N_{1r}^{kl}\right)-R_{\mathrm{b}}^{\mathrm{n}}( \varphi,\theta,\varphi)\tilde{b}_{1r}^{\mathrm{b}}\|\right^{2}\right)\stackrel{{! }}{{\leq}}\gamma_{\varphi,\theta,\varphi}^{2}, \tag{23}\]  
with the following notations:  
\[ \begin{array}{ll}\tilde{b}_{1r}^{\mathrm{n}}(N_{1r}^{1l}\ldots N_{1r}^{kl})& \text{baseline estimate for partially fixed integer ambiguities,}\\ \sigma_{1_{r}^{\mathrm{I}}}^{2}&\text{variance of length of baseline estimate assuming correct partial ambiguity fixing,}\\ \sigma_{1_{r}^{\mathrm{I}}}^{2}&\text{variance of prior information on baseline length,}\\ \gamma_{1}^{2}&\text{upper bound on the squared normalized baseline length error,}\\ \gamma_{\varphi,\theta,\varphi}^{2}&\text{upper bound on the sum of squared baseline residuals.}\end{array} \]  
We derive the baseline estimate for partially fixed ambiguities: the double difference ambiguities are split into _float_ ambiguities \(N_{1r}^{1}\) and _fixed_ ambiguities \(N_{1r}^{2}\). As float and fixed double difference ambiguities in \(N_{1r}\) are not sorted, the mapping of \(N_{1r}^{1}\) and \(N_{1r}^{2}\) to \(N_{1r}\) is given by  
\[\lambda N_{1r} = A_{1r}^{1}(\lambda)N_{1r}^{1}+A_{1r}^{2}(\lambda)N_{1r}^{2}, \tag{24}\]  
where \(A_{1r}^{1}\) and \(A_{1r}^{2}\) describe the mapping of float/integer ambiguity vectors \(N_{1r}^{1}\) and \(N_{1r}^{2}\) to \(N_{1r}\). The ambiguity decomposition is included in the measurement model of Equation (10) being rewritten as  
\[z_{n}=\underbrace{\left( \begin{array}{cc}H&0\\ 0&H\\ H&0\\ 0&H\end{array} \right)}_{\bar{H}}\left( \begin{array}{c}\tilde{b}_{12}^{ \mathrm{n}}(t_{n})\\ \tilde{b}_{13}^{\mathrm{n}}(t_{n})\end{array} \right)+\underbrace{\left( \begin{array}{cc}A_{12}^{1}(\lambda)&0\\ 0&A_{13}^{1}(\lambda)\\ 0&0\\ 0&0\end{array} \right)}_{\bar{A}^{1}}\left( \begin{array}{c}N_{12}^{1}\\ N_{13}^{1}\end{array} \right)+\underbrace{\left( \begin{array}{cc}A_{12}^{2}( \lambda)&0\\ 0&A_{13}^{2}(\lambda)\\ 0&0\\ 0&0\end{array} \right)}_{\bar{A}^{2}}\left( \begin{array}{c}N_{12}^{2}\\ N_{13}^{2}\end{array} \right). \tag{25}\]  
The fixed ambiguities \(\hat{N}_{1r}^{2}\), \(r\in\{2,3\}\) are subtracted from the measurements. Subsequently, a projection on the space orthogonal to \(\bar{A}^{1}\) is applied to eliminate all non-baseline terms, i.e.,  
\[P_{\bar{A}^{1}}^{\perp}\left(z_{n}-\bar{A}^{2}\left( \begin{array}{c}\hat{N}_ {12}^{2}\\ \hat{N}_{13}^{2}\end{array} \right)\right)=P_{\bar{A}^{1}}^{\perp}\left(\bar{H} \left( \begin{array}{c}\tilde{b}_{12}^{\mathrm{n}}(t_{n})\\ \tilde{b}_{13}^{\mathrm{n}}(t_{n})\end{array}