# GNSS Spoofing Identification and Smoothing Localization Method for GNSS/Visual SLAM System
## 3 Time-Localization Verification and Smoothing Localization Method
### Time Verification  
Time verification is primarily used to identify whether the GNSS data frames and visual SLAM data frames are synchronized in time. For the original data of the vision system and the GNSS system, there is a certain time deviation between the two data streams, so, time synchronization is required. The ideal method for clock synchronization between different systems is hardware trigger synchronization, but this method requires a high degree of hardware integration, which is difficult to achieve. Therefore, the more common method in engineering is soft synchronization. That is, when data is obtained by the terminal, the system software time stamp is added to the data frame, and time synchronization is performed according to the software time stamp.  
In addition, when sensor trigger delay, transmission delay or GNSS spoofing occurs, it may cause a small time misalignment between GNSS and visual SLAM system. So, in time verification process, it is first required to obtain the frame rate of GNSS and visual SLAM data acquisition, and use the sensor with the high frame rate as the reference sensor to perform time verification on the other sensor. In general, although the GNSS system can provide absolute position, its update rate is low, while the visual update rate is high. That is, between two GNSS data frames, there will be many visual frames generated. If the GNSS frame is used as the reference, only the visual frame synchronized with the GNSS will be retained, and other visual data frames will be discarded. In order to be able to retain more frames, we choose the faster sensor (Visual SLAM) as the reference source.  
The time deviation \(\delta t_{i}\) between GNSS and visual SLAM system at time \(i\) is  
\[\delta t_{i}=t_{i}^{V}-t_{j}^{G} \tag{7}\]  
where \(t_{i}^{V}\) is the timestamp of the visual SLAM system and \(t_{j}^{G}\) is the timestamp of the GNSS system.  
Let \(\delta_{\text{T}}\) be the time verification threshold of visual SLAM and GNSS data frames (which need to be adjusted according to the actual frame rate of the sensors, for example, 0.01s). In the time verification process, the visual SLAM data frame is set as the main frame, and the GNSS data frame in the buffer is verified according to Equation (15). If \(|\delta t_{i}|\leq\delta_{\text{T}}\), the time deviation between GNSS and visual SLAM system is within the time verification threshold \(\delta_{\text{T}}\), and the time verification is judged to be normal, and the time domain verification flag is set to \(C_{i}^{\text{T}}\)\(=0\); if \(|\delta t_{i}|>\delta_{\text{T}}\), the time deviation between GNSS and visual SLAM system exceeds the threshold range, it is judged that the time domain verification is abnormal, and the time domain verification flag is set to \(C_{i}^{\text{T}}\)\(=1\), that is  
\[C_{i}^{\text{T}}=\left\{\begin{array}{ll}0&\delta t_{i}-\delta_{\text{T}}\leq 0 \\ 1&\delta t_{i}-\delta_{\text{T}}>0\end{array}\right. \tag{8}\]  
Localization verification will be processed only after the GNSS frames and the visual SLAM frame are synchronized. If \(\delta_{\text{T}}\) is too large, there are many GNSS frames that meet the threshold, and GNSS data frames that are misaligned with the visual SLAM data frames may be input into the back-end processing, resulting in large spatial errors between the GNSS and visual SLAM data frames, and if \(\delta_{\text{T}}\) is too small, there are fewer GNSS frames that meet the threshold requirement, which will cause normal GNSS data frames to be discarded, and the system will increase the accumulated error due to the lack of GNSS frame calibration. Therefore, the selection of the time verification threshold is very important, and we will conduct simulation analysis in Section 4. The time verification is shown in Figure 2.  
After time verification, the GNSS data frame and the visual SLAM data frame are synchronized in time. Next, the visual SLAM data frame and the verified GNSS data frame are input into the localization verification process.