## 4 Numerical Simulations and Analysis
### Avoidance of Static Obstacles on the Horizontal Plane  
To validate the Gaussian-process-based MPC's ability to handle external constraints, a series of obstacle avoidance experiments for the AUV were meticulously designed and simulated. In this comprehensive assessment of the control method's performance, obstacles were strategically positioned within the positional space. It is important to note that, during the simulation, the AUV dynamically selects obstacles for state observation based on predefined obstacle selection rules, while disregarding others. This approach optimizes the AUV's interactions with obstacles, enabling an in-depth study of its obstacle avoidance capabilities. The simulation encompasses gradual modifications to the size and position of the obstacles to comprehensively test the AUV's ability to navigate around them. The selected shape for the obstacles is the conventional elliptical form, and their specific parameters are presented in Table 2. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Obstacles** & **Coordinate Parameters/(\(x\), \(y\))** & **Scale Parameter/(l, h)** \\ \hline Obs. 1 & (17.0, 16.0) & (0.5, 1.0) \\ Obs. 2 & (14.0, 12.0) & (0.5, 1.0) \\ Obs. 3 & (39.0, 35.5) & (1.0, 2.0) \\ Obs. 4 & (14.0, 12.0) & (1.0, 2.0) \\ Obs. 5 & (25.0, 25.0) & (1.0, 2.0) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Coordinate and scale parameters of obstacles on the horizontal plane. Figure 5: The results of sinusoidal trajectory tracking. Figure 6: The tracking results and errors with time during simulation for tracking sinusoidal trajectory. The first column of Table 2 denotes the obstacle number, the second column provides the Cartesian coordinates of each obstacle, and the third column specifies the size of each obstacle. The expected state for obstacle avoidance is denoted as \(\boldsymbol{y}_{ref}=[49,40,0]^{\text{T}}\). The initial state and input values of the AUV are set as \(\boldsymbol{x}_{0}=[1.5,0,0,0,0,0]^{\text{T}}\) and \(\boldsymbol{u}_{0}=[0,0]^{\text{T}}\), respectively. Additionally, the obstacle selection parameters are set as \(angle=\pi/2\) and \(dir=3\) m. The simulation is conducted with a sampling period \(T=0.1\) s and the prediction step \(p=15\). In the simulation experiments, specific constraints were imposed on the input \(\boldsymbol{u}=\left[T_{prop},\delta\right]^{\text{T}}\) and state space \(\boldsymbol{x}=[u,v,r,x,y,\psi]^{\text{T}}\) of the AUV to ensure safe and controlled motion. The constraints were rigorously defined as follows:  
\[\boldsymbol{u}_{min} =\left[0,-\frac{30\pi}{180}\right]^{\text{T}} \tag{59a}\] \[\boldsymbol{u}_{max} =\left[4.4,\frac{30\pi}{180}\right]^{\text{T}}\] (59b) \[\boldsymbol{x}_{min} =\left[0,-0.9,-\frac{25\pi}{180},-INF,-INF,-INF\right]^{\text{T}}\] \[\boldsymbol{x}_{max} =\left[2,0.9,\frac{25\pi}{180},INF,INF,INF\right]^{\text{T}}\]  
The weight matrices of the _Loss_ function are defined as follows:  
\[ \begin{split}\boldsymbol{Q}=\boldsymbol{diag}& \big{(}\boldsymbol{10}^{-6},\boldsymbol{10}^{-6},\boldsymbol{10}, \boldsymbol{10},\boldsymbol{10}^{-1}\big{)}\\ & R=\text{diag}\big{(}10^{-3},10^{-3}\big{)}\\ & S=\text{diag}\big{(}10^{-6},10^{-6}\big{)}\end{split}  \tag{60}\]  
Figure 7 provides a comprehensive illustration of the simulation results, showcasing the remarkable obstacle avoidance capabilities of the AUV. The figure is thoughtfully divided into several subgraphs, with each offering unique insights into the AUV's motion trajectories as it adeptly navigates around various obstacles. Figure 7a depicts the motion trajectory of the AUV while avoiding Obs. 1. This subgraph highlights the AUV's ability to navigate around a single obstacle. Figure 7b illustrates the AUV's trajectory while avoiding Obs. 2 and Obs. 3 simultaneously. The positioning of Obs. 2 at the intersection of two curves from Figure 7a allows for a rigorous evaluation of the AUV's obstacle avoidance capabilities when encountering multiple obstacles. Figure 7c,d present the trajectories of the AUV while avoiding Obs. 3, Obs. 4, and Obs. 5.