# GNSS Spoofing Identification and Smoothing Localization Method for GNSS/Visual SLAM System
## 3 Time-Localization Verification and Smoothing Localization Method
### Smoothing Localization Method
If the GNSS data frame does not meet the verification conditions, it is directly discarded. Only GNSS data frames that meet the verification conditions will enter the process of external parameter optimization and update. So, check the time and localization verification flag \(\mathbf{C}_{i}^{\text{T}}\) and \(\mathbf{C}_{i}^{\text{L}}\). If \(\mathbf{C}_{i}^{\text{T}}=0\), it means that the current GNSS frame has passed the time verification and can enter the localization verification. If \(\mathbf{C}_{i}^{\text{L}}=0\), it means that the current GNSS frame has also passed the localization verification. Thus, the visual SLAM data frame and the GNSS data frame of the current time \(i\) can perform smoothing localization method. The smoothing localization strategy \(\mathbf{S}_{1}\) is still adopted at this time \(i\) in order to optimize the cumulative error of visual SLAM system. Otherwise, if \(\mathbf{C}_{i}^{\text{L}}=1\), the smoothing localization strategy \(\mathbf{S}_{2}\) is adopted: do not update the external parameters \((\mathbf{R}^{\text{GV}},\mathbf{t}^{\text{GV}})\) of the camera. The camera pose obtained at the previous update time \((\mathbf{R}_{i-1}^{\text{GV}},\mathbf{t}_{i-1}^{\text{GV}})\), and the rotation and translation matrix \((\mathbf{R}_{i-1,i},\mathbf{t}_{i-1,i})\) of the camera between the frame \(f_{i-1}\) and frame \(f_{i}\) are used to calculate the GNSS/Visual SLAM coupled localization result. That is  
\[\mathbf{\chi}_{i}^{\text{GV}}=\left\{ \begin{array}{c}\left[\begin{array}{cc} \mathbf{R}_{i}^{\text{GV}}&\mathbf{t}_{i}^{\text{GV}}\\ 0&1\\ \end{array}\right]\mathbf{\chi}_{i}^{\text{V}}\quad\forall\mathbf{C}_{i}^{\text{P}} \,\ \forall\mathbf{C}_{i}^{\text{T}}\ (i<h)\ \ \ \text{or}\ \ \ \mathbf{C}_{i}^{\text{P}}=0\,\ \mathbf{C}_{i}^{\text{T}}=0\ (i\geq h)\ \ (\mathbf{S}_{1})\\ \left[\begin{array}{cc}\mathbf{R}_{i-1,i}&\mathbf{t}_{i-1,i}\\ 0&1\\ \end{array}\right]\left[\begin{array}{cc}\mathbf{R}_{i-1}^{\text{GV}}&\mathbf{t}_{i- 1}^{\text{GV}}\\ 0&1\\ \end{array}\right]\mathbf{\chi}_{i}^{\text{V}}\ \ \ \text{others}\ \ (\mathbf{S}_{2}) \end{array} \right. \tag{32}\]  
It can be seen from Equation (32) that the acquisition of \(\mathbf{\chi}_{i}^{\text{GV}}\) is related to \((\mathbf{R}^{\text{GV}},\mathbf{t}^{\text{GV}})\) and \((\mathbf{R}_{i-1,i},\mathbf{t}_{i-1,i})\). In order to optimize the error of \(\mathbf{\chi}_{i}^{\text{GV}}\), we divide the constrained optimization term into two parts, that is  
\[\min f(\mathbf{T}^{\text{GV}},\mathbf{T}_{i-1,i})=\min\ (\sum\limits_{i=1}^{n}\left\|\mathbf{ \chi}_{i}^{\text{G}}-\mathbf{T}^{\text{GV}}\mathbf{\chi}_{i}^{\text{V}}\right\|_{i\in \mathbf{S}_{1}}^{2}+\sum\limits_{i=1}^{n}\left\|\mathbf{\chi}_{i}^{\text{V}}-\mathbf{T}_{i -1,i}\mathbf{\chi}_{i-1}^{\text{V}}\right\|^{2}) \tag{33}\]where \(\mathbf{T}^{\rm{GV}}\) is the homogeneous transformation matrix of \((\mathbf{R}^{\rm{GV}},\mathbf{t}^{\rm{GV}})\) and \(\mathbf{T}_{i-1,i}\) is the homogeneous transformation matrix of \((\mathbf{R}_{i-1,i},\mathbf{t}_{i-1,i})\). The first part of the optimization \(\sum\limits_{i=1}^{n}\left\|\mathbf{\chi}_{i}^{\rm{G}}-\mathbf{T}^{\rm{GV}}\mathbf{\chi}_{i }^{\rm{V}}\right\|_{i\in\mathbf{S}_{1}}^{2}\) is only for the GNSS data frame and visual SLAM data frame using the smoothing localization strategy \(\mathbf{S}_{1}\). This part optimizes the reprojection error between the coordinates \(\mathbf{\chi}_{i}^{\rm{GV}}\) of the mobile terminal and the coordinates \(\mathbf{\chi}_{i}^{\rm{G}}\) of the GNSS measurement results. The second part of the optimization \(\sum\limits_{i=1}^{n}\left\|\mathbf{\chi}_{i}^{\rm{V}}-\mathbf{T}_{i-1,i}\mathbf{\chi}_{i -1}^{\rm{V}}\right\|^{2}\) is for all visual SLAM data frames, and this part optimizes the reprojection error of the two frames between the camera frames through the transformation of the rotation and translation matrix \(\mathbf{T}_{i-1,i}\).