## 3 Gaussian-Process-Based MPC
### Gaussian Process for Uncertainty Modeling  
In the pursuit of precision and the optimal AUV control performance, the significance of a carefully formulated cost function cannot be overstated. This function acts as the guiding beacon, enabling the AUV to meticulously follow its desired trajectory, thereby showcasing the effectiveness of our control strategies. However, the complexity of AUV motion, combined with the uncertainties prevalent in the underwater environment, often poses challenges in obtaining precise parameter values. As we strive for the high-precision control of AUVs in three-dimensional spaces, it becomes imperative to effectively grapple with these uncertainties. One promising approach to address this challenge is the utilization of Gaussian process regression, a powerful tool for modeling uncertainties. Gaussian process regression provides a practical solution to navigate the intricacies of the AUV's motion model. It does so by introducing the concept of uncertainty into predictions and facilitating the derivation of probability distributions when fitting nonlinear data. This innovative approach liberates us from the constraints of fixed model parameters, enabling us to embrace the inherent uncertainties within our models. This adaptive capability empowers us to make well-informed decisions even when dealing with changing conditions and inaccurate model parameters, ultimately enhancing the AUV's performance in trajectory tracking and obstacle avoidance tasks. The upcoming section will offer a comprehensive exploration of the practical application of this powerful technique in enhancing AUV control. We will delve into how Gaussian process regression can be leveraged to model uncertainties, estimate probability distributions, and ultimately enhance the AUV's performance in trajectory tracking and obstacle avoidance tasks. This methodology not only reinforces the robustness of AUV control but also opens the door to greater adaptability in dynamic underwater environments. Gaussian processes, an extension of the multivariate Gaussian distribution, are a key concept in probability theory and mathematical statistics. It is essential to note that a finite dimensional subset of a Gaussian process adheres to a multivariate Gaussian distribution. A Gaussian process is uniquely characterized by a mean function and a covariance function, where the covariance function is often referred to as the kernel function. The mean function sets the overall position of the sample, while the covariance function, or kernel function, encodes the distance relationships between distinct input points. In this simulation, the squared exponential covariance function will be employed for calculations. As such, for \(n\)-dimensional data points \(\mathbf{x}\) and \(\mathbf{x}^{\prime}\), the exponents for the squared exponential covariance between these points can be expressed as follows:  
\[k_{\text{SE}}\big{(}\mathbf{x},\mathbf{x}^{\prime}\big{)}=\sigma^{2}\text{exp}\bigg{(} -\frac{1}{2}\big{(}\mathbf{x}-\mathbf{x}^{\prime}\big{)}^{\text{T}}\mathbf{m}^{-1}\big{(} \mathbf{x}-\mathbf{x}^{\prime}\big{)}\bigg{)} \tag{47}\]  
where \(\sigma\) and \(\mathbf{m}\) represent the hyper-parameters, and \(\mathbf{m}\) can be expressed as a diagonal matrix \(\mathbf{m}=\text{diag}\big{(}\mathbb{1}_{1}^{2},\ldots,\mathbb{1}_{n}^{2}\big{)}\), with \(\mathbb{1}_{1}^{2},\ldots,\mathbb{1}_{n}^{2}\) being the length scales for each dimension. During the simulation process, the mean function and kernel function can be obtained by collecting samples from the AUV's state space for offline learning. Let \(\mathbf{Y}=[\mathbf{y}_{1},\ldots,\mathbf{y}_{m}]^{\text{T}}\) and \(\mathbf{X}=[\mathbf{x}_{1},\ldots,\mathbf{x}_{m}]^{\text{T}}\) represent the dependent and independent variables of the collected data, respectively.