*3.2. Kinematic Model*

The previous studies often ignored the influence of marine environments on the ship's motion state for the ease of modeling. In order to make the planned path fit the actual sailing situation, this paper establishes the kinematics model of ships considering the ocean current.

Figure 1 illustrates the kinematic model of a ship. *OeXeYe* denotes the world frame, which refers to the coordinate system with respect to the earth. The earth's gravity points to the positive direction of the z-axis. The x–y–z axes follow the right-hand rule. The origin of the world frame *Oe* is the geometrical center's initial position, the positive direction of the *OeXe* axis points to east, and the positive direction of *OeYe* points to north. *ObXbYb* denotes the local frame, which refers to the ship's body frame, *Ob* is used as the center of gravity of the ship, the positive direction of the *ObXb* axis points to the bow, and the positive direction of the *ObYb* axis points to the port side. *Ψ* denotes the yaw angle, *u* the surge velocity, *v* the sway velocity, and δ the rudder angle. According to Newton's second law, considering surge, sway, and yaw, the force at the center of gravity of the ship is

$$\begin{cases} X\_{\mathfrak{e}} = m\ddot{\mathfrak{x}} \\ Y\_{\mathfrak{e}} = m\ddot{\mathfrak{y}} \\ N\_{\mathfrak{r}} = I\_Z \ddot{\Psi} \end{cases} \tag{1}$$

$$I\_Z = \int\_V \left(\mathbf{x}^2 + \mathbf{y}^2\right) \rho\_{\text{m}} dV \tag{2}$$

where *Xe* denotes the force along the x-axis, *Ye* the force along the y-axis, *x*, *y* the position of the ship's center of gravity in the world frame, *m* the mass of the ship, *Nr* the force along the z-axis, .. *Ψ* the angular acceleration, and *IZ* the moment of inertia around the z-axis. As shown in Equation (2), it depends on the volume of the ship *V* and the mass density *ρm*. With the yaw *Ψ*, we express the transformation between the world frame and the local frame as

$$
\begin{bmatrix} X\_b \\ Y\_b \end{bmatrix} = \begin{bmatrix} \cos \Psi & -\sin \Psi \\ \sin \Psi & \cos \Psi \end{bmatrix} \begin{bmatrix} X\_\ell \\ Y\_\ell \end{bmatrix} \tag{3}
$$

Then, the forces on the surge and sway directions can be expressed as

$$\begin{cases} \mathbf{X}\_b = m \left( \dot{u} - vr \right) \\ \mathbf{Y}\_b = m \left( \dot{v} + ur \right) \end{cases} \tag{4}$$

where *<sup>r</sup>* denotes the yaw rate, and . *<sup>u</sup>* and . *v* denote the acceleration on the surge and sway directions, respectively. From Equations (3) and (4), we obtain the kinematic model as follows.

$$
\begin{bmatrix}
\dot{x} \\
\dot{y} \\
\dot{\Psi}
\end{bmatrix} = \begin{bmatrix}
\cos\Psi & -\sin\Psi & 0 \\
0 & 0 & 1
\end{bmatrix} \begin{bmatrix}
u \\ v \\ r
\end{bmatrix} \tag{5}
$$

$$
\begin{aligned}
\mathbf{Y}\_{b} \\
&\quad \mathbf{Y}\_{\text{(Sway)}} \\
&\quad \mathbf{Y}\_{\text{(Sway)}} \\
&\quad \mathbf{Y}\_{\text{(Sure)}}
\end{aligned}
$$

**Figure 1.** The kinematic model of a ship.

### *3.3. Dynamic Model*

<H

This paper uses the first-order K–T model to represent the hydrodynamic model of the ship, assuming that the port and starboard sides of the ship are symmetrical and the ship mass is uniformly distributed. The hydrodynamic equation can be expressed as:

$$
\dot{\mathbf{M}}\dot{\mathbf{v}} + \mathbf{C}\mathbf{v} + \mathbf{D}\mathbf{v} = \mathbf{\tau} \tag{6}
$$

where *v* = [*u*, *v*, *r*] *T*,

$$\mathbf{M} = \begin{bmatrix} m\_{11} & 0 & 0 \\ 0 & m\_{22} & 0 \\ 0 & 0 & m\_{33} \end{bmatrix} = \begin{bmatrix} m - X\_{\hat{u}} & 0 & 0 \\ 0 & m - Y\_{\hat{v}} & 0 \\ 0 & 0 & I\_z - N\_{\hat{r}} \end{bmatrix} \tag{7}$$

$$\mathbf{C} = \begin{bmatrix} 0 & 0 & -(m - Y\_{\dot{v}})v \\ 0 & 0 & (m - X\_{\dot{u}})u \\ (m - Y\_{\dot{v}})v & -(m - X\_{\dot{u}})u & 0 \end{bmatrix} \tag{8}$$

$$D = \begin{bmatrix} d\_{11} & 0 & 0 \\ 0 & d\_{22} & 0 \\ 0 & 0 & d\_{33} \end{bmatrix} = \begin{bmatrix} -X\_{\nu} & 0 & 0 \\ 0 & -Y\_{\nu} & 0 \\ 0 & 0 & -N\_{\mathcal{I}} \end{bmatrix} \tag{9}$$

$$
\boldsymbol{\pi} = \boldsymbol{\pi}\_{\mathrm{E}} + \boldsymbol{\pi}\_{\mathrm{I}} \tag{10}
$$

where *M* denotes the inertial mass matrix, *C* the Coriolis centripetal force matrix, and *D* the drag coefficient matrix. *Xu* and *Yv* denote the derivatives for the hydrodynamic, *X* . *<sup>u</sup>* = *<sup>∂</sup><sup>X</sup> ∂* . *u* , *Y*. *<sup>v</sup>* = *<sup>∂</sup><sup>Y</sup> ∂* . *<sup>v</sup>* , and *N*. *<sup>r</sup>* = *<sup>∂</sup><sup>N</sup> ∂* . *<sup>r</sup>* . *τ<sup>E</sup>* denotes the force imposed by the environment and *τ<sup>r</sup>* denotes the thrust of the propeller.

#### *3.4. Ocean Circulation Model*

Affected by the environment such as sea wind and ocean currents, a ship easily deviates from its course or even capsizes during sailing, resulting in property damage and even casualties. Therefore, we consider the influence of ocean currents on the ship's motion state when planning its path.

Ocean currents are formed when seawater flows in a certain direction at a regular, relatively steady speed. It is a large-scale, aperiodic form of seawater movement. According to the characteristics of its location and time, ocean currents can be divided into uniform currents, non-uniform currents, steady currents, and unsteady currents. In offshore or seabed areas with irregular topography, the model of ocean currents is more complicated. To simplify the modeling, we assume that ocean currents are constant and uniform. Let *Vc* denote the ocean current speed and *Ψ<sup>c</sup>* the direction of the current. Then, the velocity of the ocean currents can be expressed as

$$\mathbf{w\_c} = \begin{bmatrix} V\_c \cos \Psi\_c & V\_c \sin \Psi\_c \end{bmatrix}^T \tag{11}$$

Affected by ocean currents, the actual velocity of the ship is different from its velocity in still water. At this time *vr* = *v* − *vc*, where *vr* is the velocity of the ship relative to the ocean current.

#### *3.5. Optimization Objectives*

When a ship sails along a trajectory, the collision-free cost function is

$$f\_{\mathcal{E}} = -\sum\_{i=0}^{n} Dis(Obstacle(p\_i))\tag{12}$$

where *Dis*(*Obstacle*(*pi*)) denotes the minimum distance from a waypoint *pi* to the obstacles, which can be obtained by the Euclidean signed distance field (ESDF) [36]. The distance will be negative if a waypoint is within an obstacle.

The smoothness is determined by the sum of snaps along the trajectory. The smoothness cost can be defined as

$$f\_s = \int\_0^T \left(p^{(4)}(t)\right)^2 dt\tag{13}$$

where *p*(4)(*t*) denotes the fourth-order derivative, i.e., jerk, at time *t*.

The fuel consumption depends on the sailing speed. We use the exponential distribution model proposed in [37] as follows to describe the relationship between fuel consumption and speed.

$$FCPH = 0.128e^{0.243V} \tag{14}$$

where *<sup>V</sup>* <sup>=</sup> <sup>√</sup>*v*<sup>2</sup> <sup>+</sup> *<sup>u</sup>*2. Thus, we define the cost function of fuel consumption as

$$f\_o = \sum\_{i=1}^{n-1} t\_i \cdot FCPH\_i \tag{15}$$

where *ti* denotes the time duration between waypoint *pi* and *pi*+<sup>1</sup> and *FCPHi* the fuel consumption per hour between waypoint *pi* and *pi*+1.

Combining the collision-free cost, the smoothness cost, and the fuel consumption cost, we obtain the overall optimization objective function

$$F = \min\{f\_c + f\_s + f\_o\}\tag{16}$$

subject to

$$\left|\mathfrak{u}\right| \stackrel{\prec}{\leq} \mathfrak{u}\_{\max} \tag{17}$$

$$|v| \le v\_{\max} \tag{18}$$

$$|r| \le r\_{\text{max}} \tag{19}$$

where *umax*, *vmax*, and *rmax* are the maximum surge velocity, the maximum sway velocity, and the maximum yaw rate, respectively.
