## 7 The Simulation
### The Nominal State Simulation  
Before testing the algorithms presented in this paper in real flight, more realistic procedures should be implemented to evaluate the performance levels of the algorithms. A hardware-in-the-loop (HIL) simulation was therefore carried out to test and verify in real time the algorithms deployed in the autopilot. The complete HIL architecture is depicted in Figure 21. The architecture comprised two main components, namely, the real-time simulator and the autopilot. The simulator communicated with the autopilot through the full duplex serial link at 400 Hz to receive control instructions, ran the 6-DOF model to calculate the vehicle status (e.g., position, attitude, velocity, etc.), and transmitted sensor data (e.g., inertial measurement unit, GPS, geomagnetism, etc.) to the autopilot. Based on the RC receiver inputs and the sensor information provided by the simulator, the autopilot ran the control program to control the servos and sent back control instructions to the simulator to form a closed loop. In addition, the ground station monitored the flight status in real time. The flight control system was implemented with an approach combining of MATLAB/Simulink and the embedded coder technology to generate the C code for direct deployment. For hardware configuration, the HIL simulation was conducted on the autopilot with a CPU of STM32F765 VGT6 216 MHz and the simulator with a CPU of ARM Cortex-A53 1.2 GHz. Furthermore, the controllers ran at 400 Hz with the guidance at 20 Hz.  
First, the nominal state HIL simulation was executed to provide a benchmark and to verify the feasibility of the proposed STOV and SRVL strategy. The takeoff point of the aircraft was set as the origin and it flew along the reference route. The initial mass of the aircraft was 13 kg, and the servo bandwidth was 20 rad/s.  
The trajectory simulation results are depicted in Figure 22, with the time history of the flight states depicted in Figure 23.  
Figure 21: Hardware-in-the-loop configuration.  
Figure 22 reveals that the designed control system can provide an excellent trajectory tracking performance in a nominal state and ensure a precise landing at the default landing point. The results depicted in Figure 23 reflect that the aircraft has touched down and enters the ground deceleration stage, which is identical to a normal landing. The touchdown groundspeed was 14 m/s, satisfying the control targets. According to Figure 23, in the whole process simulation, the altitude command tracking deviation of the aircraft was basically kept at about 1 m after stable flight, there was slight vibration near the command, the speed command tracking was accurate, and there was basically no deviation during the flight. The speed command tracking deviation of the aircraft was 14 m/s, and the speed command tracking deviation of the aircraft was 14 m/s. The speed command tracking deviation of the aircraft was  
cruise flight. The deviation of the attitude command tracking was mainly at the end of the takeoff and taxiing section. At this time, the speed of the aircraft reached the ground speed and started to climb. Therefore, the response of the pitch angle had a certain overshoot. After that, the deviation of the pitch angle command tracking in the cruise section was small. There was no deviation in the whole process of rolling angle command tracking.  
The nominal state simulation proves that the aircraft's strategy allows it to short land with the forest flight states and track the control commands.