## 6 Closed-Loop Simulation
### Adaptability to Environment and Control System  
In order to guarantee convergence and computational efficiency, the DNN-LCvx algorithm does not consider the atmospheric drag. This section will verify the robustness of the proposed algorithm by adding an atmospheric drag term to the dynamics model. Moreover, the effect of the control system execution error on the simulation results is also considered. The thrust in the guidance period is assumed to be a constant value that cannot be continuously changed. The constant value is the interpolation average of the optimal thrust sequence in the guidance period. In the closed-loop simulation, the  
Figure 17: Impact of the discrete precision on elapsed time. increased disturbances will cause the actual state variables to diverge from the planned trajectory. Therefore, the guidance module needs to update the guidance law in real-time, as shown in Figure 18.  
The dynamic equations of the system are:  
\[\dot{r}=v\] \[\dot{v}=g+\frac{\kappa T}{m}-\frac{1}{2m}\rho C_{\mathrm{d}}S_{\mathrm{ ref}}\|v\|v \tag{21}\] \[\dot{m}=-\frac{\kappa\|T\|}{\mathrm{I}\mathrm{I}\mathrm{I}\mathrm{ I}\mathrm{I}\mathrm{I}\mathrm{I}\mathrm{I}}\]  
where \(\rho\) is the density of the atmosphere, and the value is 1.225 kg/m\({}^{3}\); C\({}_{\mathrm{d}}\) is the drag coefficient; \(S_{\mathrm{ref}}\) is the reference area of the rocket, and the value is 10.51 m\({}^{2}\). \(T\) is the control variables computed by DNN-LCvx, and \(\kappa\) is the ratio of the actual control variables to the expected control variables, which indicates the error of the control system. The remaining parameters are the same as (1), and the initial conditions of the simulation are shown in Table 2. The simulation results of the landing error of different C\({}_{\mathrm{d}}\) and \(\kappa\) can be obtained, as shown in Tables 6 and 7, where the guidance period is 200 ms and the discrete number is 30. \begin{table}
\begin{tabular}{c c c c c} \hline \hline \(C_{\mathrm{d}}\) & **0.5** & **1.0** & **1.5** & **2.0** \\ \hline position error (m) & 0.0480 & 0.0116 & 0.0133 & 0.0189 \\ velocity error (m/s) & 0.1701 & 0.0012 & 0.0027 & 0.0147 \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Statistics of landing error with \(\kappa\) = 1.0. Figure 18: Flow chart of the MPC-based closed-loop simulation. It can be seen from above results that when \(\kappa\) is fixed and \(C_{\rm d}\) is free, the rocket can achieve high-precision landing, and the landing accuracy is not highly correlated with the \(C_{\rm d}\). When \(C_{\rm d}\) is fixed and \(\kappa\) is free, the rocket can also achieve high-precision landing. However, the simulation also indicated that the landing error would increase significantly for \(\kappa<1\). For example, the landing speed error reached 1.7474 m/s if \(\kappa=0.95\). The following strategy can be used to solve the problem of low landing accuracy for \(\kappa<1\): In the trajectory planning stage, set \(T_{\rm max}\) slightly smaller than the nominal maximum thrust \(T_{n,\rm max}\) in advance. When the rocket's maximum thrust is smaller than \(T_{n,\rm max}\), there is still enough margin to guarantee \(\kappa\geq 1\). The thrust profile is plotted with \(C_{\rm d}=1.0\) and \(\kappa=1.02\), as shown in Figure 19.  
The red marks in the figure indicate the open-loop control sequence running the DNN-LCvx algorithm at the initial state. The black curve is the closed-loop simulation result without any disturbance, and it can be seen that the closed-loop simulation results are highly consistent with the open-loop results. The blue curve is the control sequence obtained by closed-loop simulation considering aerodynamic drag and thrust execution error. It can be seen that the second switch time of the thrust is delayed, and the total flight time of the rocket also increases accordingly. The position error of the landing is 0.0025 m, and the velocity error is 0.0201 m/s. The algorithm can achieve a high-precision landing.