# Acquisition and Processing of UAV Fault Data Based on Time Line Modeling Method
## 3 The Design of Simulation Environments and Simulation Tasks
### Construction of UAV Simulation Flight  
In this section, the construction of the UAV flight is introduced. This paper identifies four simple flight paths. The four flight trajectories are shown in Figure 3. A linear interpolation method is used to insert more waypoints between two waypoints. The interpolation algorithm is shown in Algorithm 1. ```
Input: raw latitude and longitude points; Output: longitude and latitude points after linear interpolation; for i in len(raw data points): Calculate the straight line (\(LineLon_{i}\)) passing through two waypoints; for j in range(PointNum): X_New= Equidistant points at highest and lowest latitudes; Y_New=Bring X_New into the equation of \(LineLon_{i}\); Save X_New, Y_New to txt file; End. ```  
**Algorithm 1**Linear interpolation algorithm between two waypoints points  
\[LineLon_{i}=k*LineLat_{i}+b \tag{1}\]  
Among them, \(k\) refers to the slope of two points \((Lat_{i},Lon_{i})\), \((Lat_{i+1},Lon_{i+1})\). \(b\) is the coefficient. \(Lat_{i}\), \(Lon_{i}\) refers to the currently processed longitude and latitude, and \(LineLon_{i}\), \(LineLat_{i}\) refer to the newly generated longitude and latitude. For example, the straight line passing through points \(A(-35.3632621,149.1652374)\) and \(B(-35.36328381,149.16306103)\) is \(LineLon_{i}=100.24735145735254*LineLat_{i}+3694.23860180339\). The matrix of Equation (2) shows the coordinate points generated by the interpolation algorithm. \[ \begin{bmatrix}LineLat_{i}&LineLon_{i}\\ \end{bmatrix} = \begin{bmatrix}-35.3632621&149.16523739\\ -35.36326365&149.16508193\\ -35.3632652&149.16492648\\ \vdots&\vdots\\ -35.36328226&-35.36328381\\ -35.36328381&149.16306102\\ \end{bmatrix}  \tag{2}\]  
In order to simulate the altitude change of the UAV, this paper generates altitude in a random range and uses the Savitzky-Golay filter algorithm [19] to smooth them. Thecomparison effect before and after smoothing is shown in Figure 4; the blue line refers to the randomly generated height within the range of 15 to 25 m. It can be seen that its change range is huge. The red line refers to the altitude after smoothing. It can be seen from the figure that the altitude change of the UAV smoothed by the algorithm is more gentle, which can simulate the height change of the actual UAV. This article uses a 3-dimensional scatter diagram to display the changes in the waypoints before and after using the linear interpolation algorithm and Savitzky-Golay filter algorithm. As shown in Figure 5, the blue line is the change of longitude, latitude, and altitude, and the orange line is the change of longitude and latitude. Figure 5a shows that there are only six waypoints before the waypoint is inserted, and the altitude changes drastically, which cannot genuinely simulate the actual flight trajectory of the UAV. As shown in Figure 5b, after using the interpolation algorithm and the Savitzky-Golay algorithm, there are 90 waypoints in the figure, and the change of al  
Figure 4: Altitude comparison of waypoints before and after using the Savitzky-Golay algorithm. Figure 3: UAV 2D flight trajectory map. This paper uses Dronekit to control the UAV for four autonomous flights. The simulations of GPS failure, Accelerometer failure, Engine failure, and Remote-Control System failure were performed simultaneously. The flight path of the UAV under QGroundControl is shown in Figure 6. Each point in the figure means: GPS failure occurs from point A to B, and GPS returns to normal from point B to C; the accelerometer failure occurs from point C to D, and the accelerometer returns to normal from point D to E; the engine failure occurred from point E to F, and the engine returned to normal from point F to G; from point G to H, a Remote-Control System failure occurred. For example, in Figure 6a, a GPS failure occurs from point A (\(-35.3615\), \(149.1625\), \(21.9135\)) to point B (\(-35.3610\), \(149.1644\), \(21.2618\)). Accelerometer failure occurred from point C (\(-35.3611\), \(149.1650\), \(19.9449\)) to D (\(-35.3617\), \(149.1655\), \(18.7668\)).