*Article* **A Physics-Informed Neural Network for the Prediction of Unmanned Surface Vehicle Dynamics**

**Peng-Fei Xu 1,2,\*, Chen-Bo Han 2, Hong-Xia Cheng 2, Chen Cheng <sup>2</sup> and Tong Ge <sup>1</sup>**


**Abstract:** A three-degrees-of-freedom model, including surge, sway and yaw motion, with differential thrusters is proposed to describe unmanned surface vehicle (USV) dynamics in this study. The experiment is carried out in the Qing Huai River and the data obtained from different zigzag trajectories are filtered by a Gaussian filtering method. A physics-informed neural network (PINN) is proposed to identify the dynamic models of the USV. PINNs combine the advantages of data-driven machine learning and physical models. They can also embed the speed and steering models into the loss function, which can significantly retain all types of information. Compared with traditional neural networks, the results show that the PINN has better generalization ability in predicting the surge and sway velocities and rotation speed with only limited training data.

**Keywords:** unmanned surface vehicle (USV); system identification; traditional neural network; physics-informed neural network; zigzag test

#### **1. Introduction**

In recent years, the unmanned surface vehicle (USV) has attracted considerable attention. The most important advantages of USVs are that they can be employed in extremely dangerous environments compared with traditional manned vehicles. In addition, USVs play a significant role in both commercial and military fields, such as resource exploration [1], shipping [2], mine countermeasures [3] and reconnaissance [4]. To guarantee that USVs can operate with good performance in these fields, the utilization of robust and effective maneuvering controllers is particularly important.

Numerous studies have focused on the control of USVs. System identification is the most popular method for handling indescribable systems from the given input/output data. Nagumo and Noda (1967) utilized continuous least square estimation based on an error-correction training procedure for system identification [5]. Holzhuter (1989) adopted recursive least square estimation in the identification of ship dynamics [6]. Kallstrom and Astrom (1981) demonstrated recursive maximum likelihood estimation used in the ship steering motion and showed a good prediction [7]. Yoon and Rhee (2003) proposed the extended Kalman filter technique and the modified Bryson–Frazier formulation smoother to predict motion variables, hydrodynamic force, vehicle speed and current direction [8]. Shin et al. (2017) utilized particle swarm optimization (PSO) with an adaptive control algorithm to predict the trajectory of USVs [9]. In addition, Selvam (2005) presented a frequency domain identification system for linear steering equations for ship maneuvering in calm seas [10].

Owing to the wind, current and other random disturbances, the modelling of ship dynamics is a strongly nonlinear problem. Khalid et al. (2020) proposed a non-singular adaptive integral-type finite time tracking control (FTSMC) for nonlinear systems with

**Citation:** Xu, P.-F.; Han, C.-B.; Cheng, H.-X.; Cheng, C.; Ge, T. A Physics-Informed Neural Network for the Prediction of Unmanned Surface Vehicle Dynamics. *J. Mar. Sci. Eng.* **2022**, *10*, 148. https://doi.org/ 10.3390/jmse10020148

Academic Editors: Margarita Sotnikova and Evgeny Veremey

Received: 5 December 2021 Accepted: 10 January 2022 Published: 24 January 2022

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

external disturbances [11]. The obtained results showed that the FTSM control technique guarantees that when the switching surface is reached, tracking errors converge to zero at a fast convergence rate. Vu et al. (2020) utilized the robust station-keeping (SK) control algorithm based on a sliding mode control (SMC) theory, designed to guarantee stability and better performance of a hovering over-actuated autonomous underwater vehicle (HAUV) despite the existence of model uncertainties and ocean current disturbance in the horizontal plane (HP) [12]. Thanh et al. (2020) presented a lumped perturbation observerbased robust control method using an extended multiple sliding surface for a system with matched and unmatched uncertainties [13]. An artificial neural network (ANN) that is capable of solving this nonlinear problem has been presented in recent years. Rajesh and Bhattacharyya (2008) proposed an ANN method to deal with the system identification of a large tanker. The Levenberg–Marquardt algorithm was utilized to train the net, and different numbers of hidden neurons were compared to select the best choice for the construction of the ANN [14]. Oskin et al. (2013) presented a recurrent neural network to identify both the linear and nonlinear behavior of ship dynamics [15]. Pan et al. (2013) utilized an efficient neural network approach to track the motion of autonomous surface vehicles with unknown ship dynamics [16]. However, traditional neural networks have some drawbacks and can be considered as "black box" models that cannot interpret the inherent laws and are not able to guarantee the generalization ability. In addition, a large number of training data are also required to obtain the optimized neural network.

In this study, a physics-informed neural network (PINN) is proposed to predict USV dynamics. Under the condition of a small amount of training data, the model can automatically meet the physical constraints and therefore has better generalization performance while ensuring accuracy and can predict the important physical parameters of the model. PINNs embed the dynamic models of an USV into the loss function rather than the pure data. Furthermore, this is the first time a PINN with a large optimal method (Xavier method, Adam method and Resnet block) has been used to identify USV models, which demonstrates that this method is better than traditional neural networks. The hydrodynamic coefficients can be calculated by limited training data directly. This boosts the application of artificial intelligent (AI) in marine research.

The structure of this study is as follows. Section 2 introduces the basic information of the studied USV and describes its dynamic models. In Section 3, the PINN and optimized method are introduced. The experiments of the USV are carried out and used in Section 4 as training and validation samples for system identifications of USV dynamic models and comparisons between the PINN and traditional neural networks. Section 5 concludes this study.

#### **2. USV Dynamics**

#### *2.1. Deepsea Warriors Uboat (DW-Uboat)*

The DW-uBoat (see Figure 1) produced by the Institute of Marine Vehicle and Underwater Technology of Hohai University, China, is designed as a streamline body due to anti-resistance. The boat has large storage to carry various instruments and equipment, as well as a large cover on the deck to disassemble and maintain the equipment. The vehicle is installed with two electric propellers that replace the traditional rudder and gimbaled thruster at the stern side of each hull. The steering motions are generated by the rpm differences in the two main thrusters. The length of the DW-uBoat is 1.80 m, the width is 0.70 m and the height is 0.48 m. The maximum speed of the vehicle is 2.5 knots. Moreover, there is no rudder or gimbaled thruster equipped in this vehicle, the steering motion can be generated by the operating RPM (revolution per minute) difference in the two main thrusters, the sway force action on the vehicle is also produced by the difference of the thrusters. Various sensors are equipped in the DW-uBoat as well. Two differential GPSs are installed in the bow and stern, respectively, combined with an electronic compass which can obtain the position, velocity and heading angle information. All of the above information and data are transformed into the computer during the experiments.

**Figure 1.** Profile of the DW-uBoat.

#### *2.2. Assumption*

In order to simply describe the motion of the USV, the three degrees of freedom (surge, sway and yaw) in the horizontal planar motion are considered. The notation proposed by Fossen (2002) was utilized and the description of the USV with its coordinate frame is shown in Figure 2, where *u*, *v* and *V* denote the surge, sway and total velocities of the USV in a body fixed frame, respectively, while *xi* and *yi* denote the north and east directions of the USV in the inertial frame, respectively. In addition, *ψ* and *β* denote the heading angle and course angle of the USV, respectively, while *X* represents the side slip angle. These simplifications can be concluded as follows:


**Figure 2.** Schematic description of differential thrust of the USV.

#### *2.3. Dynamic Models*

The equations of the kinematic model of the USV can be expressed as (Woo et al., 2018):

$$
\dot{\boldsymbol{\eta}} = \mathbf{R}(\boldsymbol{\eta}) \cdot \mathbf{v} \tag{1}
$$

$$\mathbf{v} = \begin{pmatrix} u, v, r \end{pmatrix}^T \tag{2}$$

$$
\mathfrak{n} = (\mathfrak{x}\_{i\prime} y\_{i\prime} \psi) \tag{3}
$$

$$\mathbf{R}(\boldsymbol{\eta}) = \begin{bmatrix} \cos(\boldsymbol{\psi}) & -\sin(\boldsymbol{\psi}) & 0\\ \sin(\boldsymbol{\psi}) & \cos(\boldsymbol{\psi}) & 0\\ 0 & 0 & 1 \end{bmatrix} \tag{4}$$

where **<sup>v</sup>** denotes the velocity vector, . η is the position vector and *R*(η) is the rotation matrix that maps vectors from a body fixed frame to an inertial frame.

The planar dynamic model of the surface vehicle can be described as follows:

$$M\dot{v} + \mathbb{C}(v)v + D(v)v = f \tag{5}$$

where *M* denotes the mass matrix, which includes body and added masses, *C* is the Coriolis and centripetal matrix, *D* is the matrix of the damping coefficients and *f* is the control force and moment. Since the propulsion system of the DW-uBoat is a differential thruster type, according to Sonnenburg et al. (2013), *f* can be described as follows:

$$f = \begin{bmatrix} \tau\_X \\ \tau\_Y \\ \tau\_N \end{bmatrix} = \begin{bmatrix} T\_{port} + T\_{stbd} \\ 0 \\ (T\_{port} - T\_{stbd})B/2 \end{bmatrix} \tag{6}$$

where *Tport* and *Tstbd* denote the thrust force of the port and starboard side thrusters, respectively, and *B* is the beam of the DW-uBoat.

Therefore, the three-degrees-of-freedom nonlinear dynamic motion equation can be shown as follows:

$$\dot{u} = \frac{X\_{\left[u\right]u}}{m - X\_{\dot{u}}} |u| u + \frac{X\_u}{m - X\_{\dot{u}}} u + \frac{1}{m - X\_{\dot{u}}} \tau\_X \tag{7}$$

. *<sup>v</sup>* = *Iz*−*N*. *r* <sup>∇</sup> ((−*Yv* <sup>−</sup> *<sup>Y</sup>*|*v*|*v*|*v*<sup>|</sup> <sup>−</sup> *<sup>Y</sup>*|*r*|*v*|*r*|)*<sup>v</sup>* + ((*<sup>m</sup>* <sup>−</sup> *<sup>X</sup>* . *<sup>u</sup>*)*u*<sup>0</sup> − *Yr* − *<sup>Y</sup>*|*v*|*r*|*v*|− *<sup>Y</sup>*|*r*|*r*|*r*|)*<sup>r</sup>* <sup>+</sup> *<sup>τ</sup>Y*) <sup>−</sup> *mxG*−*Y*. *r* <sup>∇</sup> ((−(*<sup>m</sup>* <sup>−</sup> *<sup>X</sup>* . *<sup>u</sup>*)*u*<sup>0</sup> − *Nv* − *<sup>N</sup>*|*v*|*v*|*v*| − *<sup>N</sup>*|*r*|*v*|*r*|)*<sup>v</sup>* + (−*Nr* − *<sup>N</sup>*|*v*|*r*|*v*| − *<sup>N</sup>*|*r*|*r*|*r*|)*<sup>r</sup>* + *<sup>τ</sup>N*) (8) . *<sup>r</sup>* = *<sup>N</sup>*. *<sup>v</sup>*−*mxG* <sup>∇</sup> ((−*Yv* <sup>−</sup> *<sup>Y</sup>*|*v*|*v*|*v*<sup>|</sup> <sup>−</sup> *<sup>Y</sup>*|*r*|*v*|*r*|)*<sup>v</sup>* + (*<sup>m</sup>* <sup>−</sup> *<sup>X</sup>* . *<sup>u</sup>*)*u*<sup>0</sup> − *Yr* − *<sup>Y</sup>*|*v*|*r*|*v*| <sup>−</sup> *<sup>Y</sup>*|*r*|*r*|*r*|)*<sup>r</sup>* <sup>+</sup> *<sup>τ</sup>Y*) + *<sup>m</sup>*−*Y*. *v* <sup>∇</sup> ((−(*<sup>m</sup>* <sup>−</sup> *<sup>X</sup>* . *<sup>u</sup>*)*u*<sup>0</sup> − *Nv* − *<sup>N</sup>*|*v*|*v*|*v*| − *<sup>N</sup>*|*r*|*v*|*r*|)*<sup>v</sup>* + (−*Nr* − *<sup>N</sup>*|*v*|*r*|*v*| − *<sup>N</sup>*|*r*|*r*|*r*|)*<sup>r</sup>* + *<sup>τ</sup>N*) (9)

where *X*(·), *Y*(·) and *N*(·) denote the constant hydrodynamic coefficients, which are the partial derivatives of the surge, sway force and yaw moments, respectively. The detailed hydrodynamic coefficients can be viewed as follow:

$$\begin{cases} \begin{bmatrix} X\_{|u|v\prime}, X\_{u\prime}, X\_{\hat{u}} \end{bmatrix} \\\\ \begin{bmatrix} \mathbf{Y}\_{\hat{v}\prime} \mathbf{Y}\_{\hat{r}\prime} \mathbf{Y}\_{|v|v\prime} \mathbf{Y}\_{\hat{v}\prime} \mathbf{Y}\_{|r|v\prime} \mathbf{Y}\_{r\prime} \mathbf{Y}\_{|v|r\prime} \mathbf{Y}\_{|r|r} \end{bmatrix} \\\\ \begin{bmatrix} \mathbf{N}\_{\hat{v}\prime} \mathbf{N}\_{\hat{r}\prime} \mathbf{N}\_{\hat{v}\prime} \mathbf{N}\_{\hat{v}\prime} \mathbf{N}\_{\hat{r}\prime} \mathbf{N}\_{\hat{r}\prime} \mathbf{N}\_{\hat{v}\prime} \mathbf{N}\_{\hat{r}\prime} \mathbf{N}\_{\hat{r}\prime} \end{bmatrix} \end{cases} \tag{10}$$

#### **3. PINNs**

#### *3.1. ANNs*

ANNs have been a research hotspot in the field of AI since the 1980s. They abstract the neural network of the human brain from the perspective of information processing to establish simple models and forms of different networks according to different connection modes. Mathematically, ANNs can be described as direct graphs composed of a group of vertices representing neurons and a group of edges representing links. There are many variants of neural networks, such as feedforward, conventional and recurrent neural networks, that perform various increasingly complex tasks. In this study, the feedforward neural network, which is also referred to as a multilayer perceptron, is adopted to solve the problem.

The simplest structure of a multilayer perceptron contains a single input layer, single hidden layer and single output layer and can be viewed in Figure 3. In this case, the operating principle of the single cell body can be described in Figure 4 and the output in the hidden layer is calculated as follows:

$$y\_j = f\_j \left( b\_j + \sum\_{i=1}^d w\_{i,j} x\_i \right) \tag{11}$$

where *wi*,*<sup>j</sup>* denotes the weights from the input layer to the hidden layer, *bj* represents the threshold values and *fi* is the nonlinear activation function. The activation function can endow the neurons with the ability to solve nonlinear problems, which means that the neural network decodes any nonlinear function arbitrarily. The commonly adopted activation functions include sigmoid, Tanh, ReLU and Leaky ReLU functions, as demonstrated in Figure 5.

**Figure 3.** Structure of the deep neural network.

**Figure 4.** Operating principle of the single cell body.

**Figure 5.** Commonly used activation functions.

In addition, it is also possible to incorporate additional hidden layers between the input and output layers. Therefore, the output in another hidden layer can be expressed as follows:

$$y\_k = f\_k \left[ b\_k^{(2)} + \sum\_{i=1}^{m\_2} w\_{j,k}^{(2)} \cdot f\_{\bar{\jmath}}(b\_{\bar{\jmath}}^{(1)} + \sum\_{i=1}^{m\_1} w\_{i,\bar{\jmath}}^{(1)} x\_{\bar{\jmath}}) \right] \tag{12}$$

An extension of this process as a simple application of the chain rule can be described as follows:

$$y(\mathbf{x}) = f\_d(\cdot \cdot \cdot f\_2(f\_1(\mathbf{x}))) \tag{13}$$

"Deep" neural networks mean that the structure of the neural network includes many hidden layers between the input and output layers. The advantages of increasing the amount of hidden layers can reduce the computing cost in some practices and can solve more complex nonlinear problems with less data. However, Hagan et al. (1994) proposed that the performance of a neural network is weakened with increasing hidden layers [17]. He et al. (2016) also put forward that the process from input to output is almost irreversible (information loss) due to the existence of the nonlinear activation function [18]. It is difficult to obtain the original input from the output. Therefore, it is significant that the neural network needs to benefit from the identity mapping. The residual neural network is proposed to ensure that the internal structure of the model has an identity mapping capability in order to ensure that network will not degenerate in the stacking of additional hidden layers.

#### *3.2. PINN Method*

Raissi et al. (2017) first proposed the PINN to solve the data-driven solution and discovery of partial differential equations [19]. A PINN is a neural network that is trained to solve supervised learning tasks while respecting any given law of physics described by general nonlinear partial differential equations.

We assume a simple form of the parametrized and nonlinear partial differential equation, as follows:

$$
\mu\_t + N(u; \lambda) = 0, \quad \text{x} \in \Omega, \quad t \in [0, T] \tag{14}
$$

where *u*(*t*, *x*) denotes the latent solution of the partial differential equation and *N*(*u*; *λ*) is a nonlinear operator parametrized by *λ*. Equation (13) represents a wide range of problems in mathematical physics, including conservation laws, diffusion processes, advectiondiffusion-reaction systems and kinetic equations.

The physical problem can then be cast into the form of Equation (14) and its solution can be calculated by minimizing the loss function of a neural network. The target of the loss function is the mean squared error loss, as expressed in Equation (15), which contains two parts. The loss *MSEu* denotes the loss function of the initial and boundary conditions, while *MSEf* enforces the structure imposed by a target partial differential equation at a finite set of collocation points.

$$f \equiv u\_t + \mathcal{N}(u; \lambda) \tag{15}$$

$$MSE = MSE\_{\mathcal{U}} + MSE\_f \tag{16}$$

$$MSE\_{\boldsymbol{u}} = \frac{1}{N\_{\boldsymbol{u}}} \sum\_{i=1}^{N\_{\boldsymbol{u}}} \left| u \left( t\_{\boldsymbol{u}\prime}^{i} \boldsymbol{x}\_{\boldsymbol{u}}^{i} \right) - \boldsymbol{u}^{i} \right|^{2} \tag{17}$$

$$MSE\_f = \frac{1}{N\_f} \sum\_{i=1}^{N\_f} \left| f \left( t\_{f'}^i x\_f^i \right) \right|^2 \tag{18}$$

where *t i <sup>u</sup>*, *x<sup>i</sup> <sup>u</sup>*, *u<sup>i</sup> Nu <sup>i</sup>*=<sup>1</sup> denotes the initial and boundary training data on solution of the equation and *t i <sup>f</sup>* , *<sup>x</sup><sup>i</sup> f Nf i*=1 are the collocation points for *f*(*t*, *x*).

#### *3.3. PINN for Solving Dynamic Models of the USV*

The process of PINN solving the dynamic models of the USV can be viewed in Figure 6. The time *t* is selected as input, the velocities *u, v* and *r* are deemed as outputs and the layers and neurons in each layer between input and output, which constitute the fully connected-NN structure. The dynamic models of USV should be transformed as Equation (14). For illustration purposes only, the structure of a network with three hidden layers and five neurons per hidden layer is demonstrated in Figure 6. Actually, the structure of the network includes 6 layers with 8 neurons in each layer. The dynamic models are then embedded into the loss function. The automatic differentiation technique is adopted to compute the physical-based loss function and the velocity *u* on the training data is calculated by minimizing the loss function. In addition, *I* in the green box denotes the identity operator, while the *∂<sup>t</sup>* is the differential operator, which can be explained as an activation operator. The speed and steering models are embedded into the loss function and all the hydrodynamic coefficients are determined [20]. In order to reduce the error of the loss function, the Adam optimizer is utilized to optimize the target function. The Adam optimizer can constantly adjust the learning rates with the situation changes in the learning process. The 'Xavier' method is designed to decide the initial weights and biases which can ensure faster convergence of the neural network. A residual neural network is added in the FCNN to avoid gradient explosion and/or gradient disappearance.

**Figure 6.** Structure of the PINN for solving dynamic models of the USV.

#### **4. Results**

#### *4.1. Data Preprocessing*

The experiment was operated in the Qing Huai River in Nanjing, as shown in Figure 7, with constant wind and current always present at this location. It is noted that the wind and current is not strong and has a low influence on the performance of the USV. The DW-uBoat voyages in the Qing Huai River can be seen in Figure 8. Two straight lines with varying rpm of differential thrusters are used to estimate the speed model and two different zigzag trajectories are designed for training and testing the steering model. The data collected by the receiver per 0.25 s and the 1000 s' data is adopted to train the dynamic model of the USV. Furthermore, the normalization technique is used to guarantee the accurate forecast results due to the large range among each dimension of input data. The min-max normalization is selected and can be expressed as:

$$\mathbf{x}' = \frac{\mathbf{x} - \mathbf{x}\_{\text{max}}}{\mathbf{x}\_{\text{max}} - \mathbf{x}\_{\text{min}}} \tag{19}$$

**Figure 7.** Qing Huai River in Google Maps.

**Figure 8.** DW-uBoat voyage on the Qing Huai River.

#### *4.2. Identified Results*

In this section, the number of training data is 4000 and the number of testing data is 4000. The results can be viewed in Figure 9. The training and testing data are obtained by different straight-line and zigzag trajectories. The first picture represents the predicted and true results of the straight-line motions while the last two pictures represent the predicted and true results of the zigzag trajectories. Left of the red line is the training set and right of the red line is the testing set. The blue lines represent the experiment results and yellow dotted lines represent the results predicted by the PINN. It is obvious that the PINN has a strong ability for reconstructing the dynamics of the USV, since the mean square errors of the surge and sway velocities and rotation speed are small. In addition, the PINN also has a good generalization ability in the testing set, meaning that it can accurately predict the unknown trajectory. It is noteworthy that the number of training data is not large, which means we can obtain the dynamic model of the USV using a small dataset and high convergence speed.

**Figure 9.** Observed and predicted surge, sway and rotation velocities in training and test sets.

#### *4.3. PINN Versus Traditional Neural Network*

In this section, the PINN method is compared with a tradition neural network. We select the same structure of the neural network (fully-connected with four layers and ten neurons in each layer) and training data. The mean square errors are utilized to test the performance of the PINN and traditional neural network. Table 1 shows the identification results of the hydrodynamic coefficients. A comparison between the PINN and traditional neural network in the testing set under different numbers of samples is given in Table 2. It is obvious that the PINN has a better generalization ability for predicting the dynamic models of the USV. The PINN method is lower than the traditional neural network method in order of magnitude. The PINN can also predict the dynamic models under low numbers of training samples and a simple neural structure.




**Table 2.** Comparison between MSE of PINN and traditional NN in the testing set under different numbers of training samples.

#### **5. Conclusions**

In this study, the PINN method was first proposed to identify the dynamic models of a USV. Zigzag and straight-line tests were carried out in the Qing Huai river to obtain the data. The physics-driven deep learning method, instead of the data-driven deep learning method, was utilized to obtain the USV dynamics. The speed model and steering model of the USV were embedded into the loss function which can guarantee the loss function, including the physical information. The results show that the PINN has a better generalization ability in predicting the sway and surge velocities and rotation speed under a small number of training samples and the simple structured neural network compared with the traditional neural network. There is a reasonable prospect that the PINN method can replace traditional deep learning for the identification of the dynamic models of unmanned surface vehicles. In the future, the model of the USV with wind, waves and other disturbances will be embedded into the PINN and identified.

**Author Contributions:** Conceptualization, C.C.; methodology, P.-F.X.; validation, C.-B.H.; formal analysis, C.C.; data curation, C.-B.H.; writing—original draft preparation, C.C.; writing—review and editing, H.-X.C.; supervision, P.-F.X.; project administration, T.G.; funding acquisition, T.G. All authors have read and agreed to the published version of the manuscript.

**Funding:** National Natural Science Foundation of China (52071131), the Marine Science and Technology Innovation Project of Jiangsu Province (HY2018-15), the National Key Research and Development Program of China (2018YFF0215005), and the China Postdoctoral Science Foundation (2018M640390).

**Data Availability Statement:** Not applicable.

**Acknowledgments:** Thanks to Yalin Shen, Yanxu Ding for their preliminary preparations for this article.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **References**

