# Stream: Spatial Trajectory Enhanced Attention Mechanism for Abnormal UAV Trajectory Detection
## 3 System Design
### Data Visualization
This reduces the volatility of the location data, thereby obtaining a more accurate trajectory. This  
Figure 2: Two-way ranging with time-of-flight calculation diagram. process of data smoothing is based on a mathematical model of the Kalman filter, which describes the dynamic behavior of the system and takes into account measurement noise and process noise. Kalman filters are defined as follows:  
\[ \begin{array}{rcl}\hat{x}_{k|k-1}&=&Ax_{k-1|k-1}+Bu_{k},\\ P_{k|k-1}&=&AP_{k-1|k-1}A^{T}+\mathcal{Q},\\ K_{k}&=&P_{k|k-1}H^{T}(HR_{k|k-1}H^{T}+R)^{-1},\\ \hat{x}_{k|k}&=&\hat{x}_{k|k-1}+K_{k}(z_{k}-H\hat{x}_{k|k-1}),\\ P_{k|k}&=&(I-K_{k}H)P_{k|k-1}.\end{array}  \tag{5}\]  
In the first equation, \(\hat{x}_{k|k-1}\) represents the predicted state vector at time \(k\) based on information available up to time \(k-1\). Matrix \(A\) is the state transition model that is applied to the previous state \(\hat{x}_{k-1|k-1}\), while \(B\) is the control input model that operates on the control vector \(u_{k}\). The second equation predicts the covariance of the predicted state, where \(P_{k|k-1}\) is the estimate of the covariance of the state vector at time \(k\). Matrix \(Q\) is the process noise covariance matrix, reflecting the uncertainty in the model. The third equation calculates Kalman gain \(K_{k}\), which weighs the importance of the measurements versus the current state estimate. Here, \(H\) is the observation model that maps the true state space into the observed space. \(R\) is the measurement noise covariance matrix, quantifying the uncertainty in sensor measurements. Through the next equation, the state estimate is updated by incorporating the new measurement \(z_{k}\). The term \(z_{k}-H\hat{x}_{k|k-1}\) represents the measurement residual, or the difference between the actual measurement and what the model predicted. Finally, the estimate of the covariance of the state vector is updated through the last equation. This step reflects the reduction in uncertainty as a result of the measurement update. In our application, matrices \(Q\) and \(R\) are empirically set to 0.0001 and 0.1, respectively. These values are chosen to balance the model's sensitivity to the process noise and measurement noise. Through the iterative application of these equations, the Kalman filter provides refined estimates of the system state \(x_{k}\), continually updating the state and measurement covariance matrices \(P_{k}\) and \(P_{k-1}\). This results in a more accurate and less volatile trajectory estimation for the UAVs, even in the presence of noisy and uncertain measurements. It converts the location data that have been applied to the Kalman filter into an image, making it possible to effectively check the trajectory of the UAV. This process corresponds to each location dataset as a pixel value between 0 and 255 to generate an image having a size of \(159\times 158\) pixels. By going through this process, it is possible to effectively check the UAV's trajectory, which was difficult to confirm with numerical data, and make the CNN model's learning process more efficient and accurate, contributing to the improvement in UAV trajectory classification performance.