*Article* **Path-Following Control Method for Surface Ships Based on a New Guidance Algorithm**

**Zhanshuo Zhang 1, Yuhan Zhao 1, Guang Zhao 2, Hongbo Wang 1,\* and Yi Zhao 1,\***


**Abstract:** A new type of path-following method has been developed to steer marine surface vehicles along desired paths. Path-following is achieved by a new hyperbolic guidance law for straight-line paths and a backstepping control law for curved paths. An optimal controller has been improved for heading control, based on linear quadratic regulator (LQR) theory with nonlinear feedback control techniques. The control algorithm performance is validated by simulation and comparison against the requirements of International Standard IEC62065. Deviations are within the allowable range of the standard. In addition, the experimental results show that the proposed method has higher control accuracy.

**Keywords:** ship motion control; path-following; guidance algorithm; nonlinear feedback

**Citation:** Zhang, Z.; Zhao, Y.; Zhao, G.; Wang, H.; Zhao, Y. Path-Following Control Method for Surface Ships Based on a New Guidance Algorithm. *J. Mar. Sci. Eng.* **2021**, *9*, 166. https://doi.org/10.3390/jmse9020166

Academic Editor: Jakub Montewka Received: 27 December 2020 Accepted: 1 February 2021 Published: 6 February 2021

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

**Copyright:** © 2021 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/).

#### **1. Introduction**

Autopilot is the main equipment for ship motion control; it controls the ship's course without the participation of the helmsman [1]. On autopilot, the ship follows the target route automatically, which can effectively reduce ship operating costs [2]. This paper presents a new method for ship track control. The goal of the control system is to follow a preset route with good anti-interference ability [3]. Path-following control systems for marine vehicles are usually constructed as three independent blocks: guidance, navigation and control [4]. Guidance is the action or the system that continuously computes the reference position, velocity and acceleration of the vehicle to be used by the control system [5]. Navigation is the action or the system that directs the vehicle, by which the position, course and traveled distance is determined. The control system determines the necessary forces and moments to achieve a certain objective.

Line of sight (LOS) is the most commonly used guidance algorithm. This algorithm was first applied to track control of surface ships by Mcgookin and Fossen and has been widely studied [6–9]. The advantage of the LOS guidance algorithm is that it controls the ship's motion by imitating the behavior of the helmsman to eliminate track deviation from the planned route. However, there are some defects in the LOS guidance algorithm. When the distance between the next target waypoint on the target route and the current position of the ship is large, a large track deviation will be produced when the ship tracks the planned route through the guidance algorithm, in addition, the convergence speed of the algorithm is also very slow. In response to this problem, an integral LOS (ILOS) has been proposed and extensively analyzed. Fossen and Lekkas [10] proposed an ILOS based on adaptive control theory that can compensate for drift forces effectively.

Stability analysis is an important topic for navigation and control systems used in autonomous marine vehicles. Proportional-integral-derivative (PID) controllers or proportional derivative controllers are usually used in ship autopilot design [11,12]. In recent

years, improved PID control algorithms have emerged. For example, steering parameters for normal adaptable PID autopilots have been developed during the last decade [13,14]. Dlabac et al. [15] presented a particle swarm optimization (PSO)-based PID controller for ship course-keeping. Recently, nonlinear controllers for autopilot motion control of marine vessels have been reported. Oh and Sun [16] presented a model predictive control for path following of underactuated surface vessels. Guerrero et al. [17] employed an adaptive high- order sliding mode controller for trajectory tracking of autonomous underwater vehicles. Designs based on neural networks [18,19], pole placement technique (PPT) [20], fuzzy logic [21], extended state observer technique (ESO) [22] and some other methods are also used. Wang et al. [23] presented a heading control algorithm based on an H-infinite optimization algorithm to counteract the influence of waves and ensure that ships can turn steadily in rough seas. Sun et al. [24] proposed a feedback linearization optimal heading control algorithm to effectively control a ship's course. Veremey et al. [25] proposed a new approach for the compensative transformation of reference dynamic output controllers. Du et al. [26,27] used adaptive robust nonlinear control to adjust a ship's course and track. Xiang et al. [28] improved the fuzzy logic method and tested it on underwater ships and marine surface vehicles. Xu et al. [29] proposed a vector field guidance law to follow the ship's trajectory. Although most of these methods have good results, there is no standard to verify the control effect of their experiments and the ship model they use is no comprehensive consideration for each type of ship, which cannot effectively verify the results. Liu et al. [30] proposed a nonlinear robust control algorithm based on Backstepping method to control ship straight-path tracking. However, there is no curve path tracking method in this study. Zhao et al. [31] based on Serret-Frenet frame transformation develop a tracking error model and the backstepping controller compensates the nonlinearity of the container ship. Xu et al. [32] proposed an adaptive backstepping controller for pathfollowing control of an underactuated ship based on a nonlinear steering model, which can achieve the effect of path control. But the shortcoming in both two is, they present pretty few control scenarios of the researches to verify the reliability of the algorithm, moreover, the scene of track control is too simple.

This paper presents a new path-following control law. The main innovation of this paper is to propose hyperbolic guidance law and apply it to straight-line path-following control. This design improves the convergence of the straight-line path-following control. For curved path-following in the transition between two adjacent straight-line paths, this paper improved a reverse stepping method to calculate heading rate commands to make the system globally asymptotically stable. Compared with the previous research, the extended state observer (ESO) for the controller model is established to estimate and compensate the state in this paper, which can improve the anti-interference ability of the ship in the path following. In the presence of sea current interference, also gives a correction formula. In this paper, linear quadratic regulator (LQR) and nonlinear feedback control are combined to improve the traditional LQR heading controller to improve the control accuracy of heading and yaw rate of the ship. Finally, the track control effect of three different types of ships is verified in simulations and the control effect is evaluated according to International Standard IEC62065 [33].

Section 2 establishes a mathematical model, including ship motion simulation and control and identifies controller parameters. Section 3 describes the design of the heading controller. Section 4 introduces the new guidance algorithm. Section 5 presents analysis of simulation results. Finally, Section 6 contains the conclusions.

#### **2. Mathematical Model of Ship Motion**

#### *2.1. Process Plant Model*

We describe the ship motion model in five basic compositions, with three degrees of freedom, shown in Figure 1. The model is derived from Newton's laws of motion using linear equations to relate hydrodynamic forces to the respective motions in the horizontal plane. The equations are as follows [4]:

$$\left[m\left[\dot{u} - \upsilon r - x\_{\mathcal{S}}r^2 - y\_{\mathcal{S}}\dot{r}\right] = X\_{\prime} \tag{1}$$

$$m\left[\dot{v} + \mu r - y\_{\mathcal{J}}r^2 + x\_{\mathcal{J}}\dot{r}\right] = \mathcal{Y}\_{\prime} \tag{2}$$

$$I\_z \dot{r} + m \left[ \mathbf{x}\_{\mathcal{S}} \left( \dot{v} + ur \right) - y\_{\mathcal{S}} \left( \dot{u} - vr \right) \right] = N\_\prime \tag{3}$$

where *X*, *Y* and *N* denote external forces and moment, while *xg*, *yg*, *zg* describe the location of the center of gravity. *u*,*v* and *r* denote surge velocity, sway velocity and yaw angular velocity, respectively, . *u*, . *<sup>v</sup>* and . *r* are their derivatives. *Iz* is the yaw moment of inertia, *m* is the total mass of ship. It is common to let the body frame coordinate origin coincide with the center of gravity; thus, the equations can be rewritten as:

$$m\left(\dot{u} - vr\right) = X\_\prime \tag{4}$$

$$m(\dot{v} + \mu r) = Y\_\prime \tag{5}$$

$$I\_z \dot{r} = N.\tag{6}$$

**Figure 1.** Ship motion mathematical model.

The hydrodynamic force *X* is linearized and is assumed to be proportional to the ship linear velocity, *u* in surge. Let *Ru* denote the linear coefficient of hydrodynamic resistance to forward motion and *Xthrust* denote the thrust provided by the propeller. Thus Equation (4) becomes:

$$m(\dot{u} - vr) = X\_{thrust} - R\_{\text{\textquotedblleft}tr} \,\text{u}.\tag{7}$$

Let *τ<sup>u</sup>* denote the time constant of the linear surge response model, *Ku* denote the coefficient of thrust, *u*max denote maximum forward speed, and *X*max denote maximum thrust:

$$\begin{aligned} \tau\_u &= m/R\_{u\prime} \\ \mu\_{\text{max}} &= X\_{\text{max}}/R\_{u\prime} \\ K\_u &= \mu\_{\text{max}}/\tau\_u. \end{aligned} \tag{8}$$

Substituting Equation (8) into Equation (7) yields:

$$
\dot{\mu} = K\_{\mu} X^{\prime} + vr - u/\tau\_{\mu}. \tag{9}
$$

In the same way, for sway response model let *τ<sup>v</sup>* = *m*/*Rv* denote the linear coefficient of hydrodynamic resistance to sway motion, then Equation (5) becomes:

$$
\dot{\upsilon} = -\iota r - \upsilon/\tau\_{\upsilon}.\tag{10}
$$

For the yaw response model, Equation (6) becomes:

$$I\_z \dot{r} = K\_r \left(\delta\_a K\_\mu X' \tau\_\mu / L + \mathcal{W} \right) + \gamma L R\_v (\upsilon - \gamma L r) - R\_r r\_\prime \tag{11}$$

where *Kr* is a constant of proportionality, *γ* is the yaw stability factor, *L* is the length of the ship, *δ<sup>a</sup>* is the real rudder deflection, *Rv* is the linear coefficient of hydrodynamic resistance to lateral motion, *Rr* is the linear coefficient of hydrodynamic resistance to yaw and *τ<sup>r</sup>* = *Iz*/*Rr* denotes the time constant of the yaw response model. Simplifying by relating the moment of inertia to the mass and length as a uniformly dense rod to its mass and length, then the moment of inertia can be obtained as *Iz* = *mL*2/12. *KrW* is the turning moment imparted by wave disturbance, *K r* is the normalized coefficient of rudder moment, which can be expressed as *K <sup>r</sup>* = *Krδ*max/*Iz*.

The wave interference model established in this paper consists of a series of square half wave waves. The duration *T* and height *H* of each half wave are random numbers related to the Bretschneider wave spectrum [34]. Finally, a square wave interference signal is generated by the wave model, in which the calculation methods of the duration *T* and the wave height *H* are as follows:

$$\begin{cases} \quad T = 0.5T\_0(\text{ss}) \times (1 + 0.5Rand\_b) \\\ H = H\_0(\text{ss}) \times (1 + H\_r \times Rand\_b) \times A\_a \end{cases} \tag{12}$$

where *Randb* denotes a random number among [−1, 1]. A value of 0.5 for *Hr* is recommended, while *Aa* has alternating sign (i.e., ±1) to describe wave direction, *ss* means the sea state level, *T*0(*ss*) and *H*0(*ss*) are the natural period and significant wave height under sea state *ss*, respectively. The range of values is shown in Table 1.


**Table 1.** The value of natural period and meaningful wave height under different sea conditions.

Referring to the modeling method of wave interference in IEC62065, this paper ignores the influence of wave interference on ship surge motion and sway motion, only adds the wave interference torque of ship's yaw motion to the mathematical model of ship's motion. Rewrite ship yaw Equation (11) as:

$$\dot{r} = K\_{r}^{\prime} \frac{K\_{\rm u} X^{\prime} \tau\_{\rm u}}{L} \cdot \delta\_{\rm u}^{\prime} + \frac{12 \gamma (\upsilon - \gamma L r) \tau\_{r}}{L \tau\_{\upsilon}} - \frac{r}{\tau\_{r}} + 0.01 K\_{r}^{\prime} S\_{f} H\_{\prime} \tag{13}$$

where *δ<sup>a</sup>* is the normalized rudder position obtained by *δ <sup>a</sup>* = *δa*/*δa*max, *Sf* is a Scaling Factor. A value of 20 for the Scaling Factor is recommended.

#### *2.2. Control Plant Model*

We simplify the process plant model described in the previous section to design the autopilot control algorithm. The simplified model contains only the main physical properties of the process. Notomo [35] proposed a linearized model for ship steering equations, which is given by a simple transfer function between *r* and *δ*.

$$\frac{r}{\delta}(\mathbf{s}) = \frac{\mathbf{K}}{(\mathbf{1} + \mathbf{T}\mathbf{s})'} \tag{14}$$

where *T* and *K* are the time constant and gain constant, respectively. Neglecting the roll and pitch modes (*φ* = *θ* = 0), such that:

.

$$
\psi = r \tag{15}
$$

finally yields:

$$\frac{\psi}{\delta}(\mathbf{s}) = \frac{\mathbf{K}}{\mathbf{s}(1+T\mathbf{s})},\tag{16}$$

where *ψ* is the heading angle.

The time domain form of Equation (16) is:

$$T\ddot{\psi} + \dot{\psi} = \mathcal{K}\delta.\tag{17}$$

Notomo's first order model is usually written as:

$$T\dot{r} + r = K\delta.\tag{18}$$

When the straight motion of the ship is unstable or critical stable, nonlinear maneuvering models should be used. A nonlinear term can be added in Equation (18); thus, Notomo's nonlinear first order model can be obtained as:

$$
\dot{T}\dot{r} + r = K(\delta + \mathcal{K}\_v v). \tag{19}
$$

This is the commonly used control plant model for the design of the steering autopilot, in which *Kv* is the coefficient of the nonlinear term.

#### *2.3. Controller Parameter Identification*

In the above-mentioned control model, some parameters cannot be obtained directly but need to be obtained by system parameter identification. In control applications, the controller performance is bound to the assumptions and approximations of the model. To obtain the corresponding controller parameters more accurately, we apply the forgetting factor least square algorithm to Notomo's nonlinear first order model to identify the ship motion model.

The Recursive Least Square (RLS) algorithm with exponential forgetting is given as follows [36]:

$$
\hat{\theta}(k) = \hat{\theta}(k-1) + Q(k) \left[ y(k) - \Phi^T(k) \hat{\theta}(k-1) \right], \tag{20}
$$

$$Q(k) = P(k-1)\Phi(k)\left[\lambda I + \Phi^T(k)P(k-1)\Phi(k)\right]^{-1},\tag{21}$$

$$P(k) = \frac{1}{\lambda} \left[ I - \mathcal{Q}(k) \Phi^T(k) \right] P(k-1), \tag{22}$$

where the forgetting factor value of *λ* is 0.98 < *λ* < 0.995, Φ(*k*) is the data vector and ˆ *θ*(*k*) is the estimated value of the parameter vector. *Q*(*k*) and *P*(*k*) are the intermediate variable help us get ˆ *θ*(*k*) we want.

Next, referring to the ship motion simulation model, substituting control Equation (19) into ship motion Equation (13), the values of *T*, *K* and *Kv* are obtained as follows:

$$\begin{cases} \quad T = \frac{\frac{\tau\_v \tau\_r}{\tau\_v + 12\tau\_r \gamma^2}}{\frac{T K\_r \prime u\_{\text{max}} X'}{L \mathcal{L}\_{\text{max}}}}, \\\quad K\_v = \frac{12\gamma T}{K L \tau\_v}. \end{cases} \tag{2.3}$$

To facilitate the identification calculation, Equations (11) and (13) are rewritten in the following form:

$$\begin{cases} \ Y\_0 = \theta\_0 X\_0 + \theta\_1 X\_1\\ \ Y\_1 = \theta\_2 X\_2 \end{cases} \tag{24}$$

where

$$\begin{cases} \ Y\_0 = \dot{r} - \frac{12\gamma}{L\tau\_v} \upsilon\_{\mathcal{U}} + \frac{12\gamma^2}{\tau\_v} r \\\ Y\_1 = \dot{\upsilon}\_{\mathcal{K}} + \iota\_{\mathcal{K}} r \end{cases} , \tag{25}$$

$$\begin{cases} X\_0 = \frac{U}{L} \delta'\_{\, \, a} \\ \quad X\_1 = r \\ \quad X\_2 = v\_w \end{cases} \tag{26}$$

$$\begin{cases} \begin{array}{c} \theta\_0 = \frac{KL}{T\Pi} \\ \theta\_1 = -\frac{1}{T} + \frac{12\gamma^2}{\tau\_v} \\ \theta\_2 = -\frac{1}{\tau\_v} \end{array} . \end{cases} \tag{27}$$

According to the recursive formula of the forgetting factor least squares identification algorithm in Equations (20)–(22), the corresponding identification results *θ*0, *θ*<sup>1</sup> and *θ*<sup>2</sup> can be obtained. Through *θ*0, *θ*<sup>1</sup> and *θ*2, the three controller parameters *T*ˆ, *K*ˆ and *K*ˆ *<sup>v</sup>* of the nonlinear first-order Notomo model can be solved:

$$\begin{cases} \begin{array}{l} \Upsilon = \frac{1}{-\delta\_1 + \frac{12\gamma^2}{\pi\_v}},\\ \hat{\mathcal{K}} = \frac{\frac{\partial\_0}{\partial\_r} \hat{T} \hat{U}}{L},\\ \hat{\mathcal{K}}\_v = \frac{12\gamma^2}{L\mathcal{K}\tau\_v}. \end{array} \end{cases} \tag{28}$$

#### **3. Optimal Heading Controller**

This section describes the design of the optimal heading controller. The main goal is to calculate the controller parameters in terms of the Notomo constants obtained by the identification algorithm in the previous section and introduce them in the LQR controller law. Then, nonlinear feedback is added to improve LQR controller to achieve nonlinear control and better control accuracy. In addition, to filter out the influence of sea wave interference on the acquisition of ship heading signal, an extended state observer (ESO) is added to this design to obtain the estimated value of the low-frequency heading signal. Thus, the controller can obtain accurate and fast course control.

#### *3.1. LQR Controller*

Assume that the heading signal *ψ* can be obtained by a compass and the yaw rate *r* can be obtained by a rate gyro or by a state observer. Notomo's first order model in Equation (18) can be written as the state space form:

$$
\dot{X} = AX + Bu\_{c\prime} \tag{29}
$$

where *X* = (*r*, *ψ*, *δ*) *<sup>T</sup>* is the state vector and *uc* is the controller input, which denotes the desired rudder rate. *A* and *B* are the coefficient matrixes with:

$$A = \begin{pmatrix} -1/T & 0 & K/T \\ 1 & 0 & 0 \\ 0 & 0 & 0 \end{pmatrix},\tag{30}$$

$$B = \begin{pmatrix} 0 & 0 & 1 \end{pmatrix}^T,\tag{31}$$

*Xd* = (*rd*, *ψd*, *δ*) *<sup>T</sup>* denotes the objective state vector. The goal of the controller design is to converge the state *X* to the objective *Xd*:

$$\lim\_{t \to \infty} X = X\_{d\prime} \tag{32}$$

*X*1 denotes the error vector:

$$
\widetilde{X} = X - X\_d = \begin{pmatrix} \widetilde{r} \,\widetilde{\psi} \,\delta \end{pmatrix}^T,\tag{33}
$$

where <sup>1</sup>*<sup>r</sup>* <sup>=</sup> *<sup>r</sup>* <sup>−</sup> *rd*, *<sup>ψ</sup>*<sup>1</sup> <sup>=</sup> *<sup>ψ</sup>* <sup>−</sup> *<sup>ψ</sup>d*. The control performance specification can be measured in terms of:

$$J = \int\_0^\infty \left( \tilde{X}^T Q X + \mu\_c^{-T} R \mu\_c \right) dt\_\prime \tag{34}$$

where *Q* is a 3-dimensional diagonal matrix, in which diagonal elements are the weighting factors. *R* is the weighting factor of the input. The LQR problem is to find the optimal control *uc*(*t*) such that *J* in Equation (34) is minimized,

$$\mu\_{\varepsilon} = -R^{-1}B^{T}P\hat{X}\_{\prime} \tag{35}$$

where *P* is the positive defined solution of the Riccati Equation [37]:

$$A^T P + PA - PBR^{-1}B^T P + Q = 0\tag{36}$$

Let

$$\left( (k\_1, k\_2, k\_3)^T = -R^{-1} B^T P \right) \tag{37}$$

where *k*1, *k*<sup>2</sup> and *k*<sup>3</sup> are the controller gains obtained by the LQR law. Thus, the representation of the controller can be written as:

$$\delta\_{LQR} = \int\_0^t \left( k\_1 \widetilde{r} + k\_2 \widetilde{\Psi} + k\_3 \delta \right) d\tau. \tag{38}$$

#### *3.2. Feedback Nonlinearization Compensation*

In the controller design here, a nonlinear feedback term is added in the control law for compensating the nonlinear maneuvering of the ship. Notomo's nonlinear first order model can be rewritten as:

$$T\dot{r} + r = K(\delta + K\_v v). \tag{39}$$

Comparing with the linear controller law obtained in the previous section, the following equation can be obtained:

$$
\delta\_{LQR} = \delta\_{com} + \mathcal{K}\_{\mathcal{V}} \upsilon\_{\prime} \tag{40}
$$

where *δcom* is the command rudder angle, *Kvv* can be treated as the feedback term, such that:

$$
\delta\_{\rm com} = \delta\_{\rm LQR} - \delta\_{\rm FLJ} \tag{41}
$$

with *δFL* = *Kvv* and the value of *Kv* is obtained from the identification algorithm in the previous section.

#### *3.3. Extended State Observer*

Both surface ships and underwater vehicles need state observers to process signal data from sensors and navigation equipment. The observer in this paper is designed in terms of the nonlinear ship model and the wave disturbance model. The nonlinear ship model and the wave disturbance model are as follows:

$$\begin{cases} \begin{aligned} \dot{T}\dot{r} + r &= \mathcal{K}(\delta - \delta\_{\text{ll}} + \mathcal{K}\_{\text{U}} \upsilon) + \omega\_{\text{V}} \\ \ddot{\Psi}\_{\omega} + 2\xi\omega\_{0}\dot{\Psi}\_{\omega} + \omega\_{0}^{2}\psi\_{\omega} &= \omega\_{\omega} \end{aligned} \tag{42}$$

where *δ<sup>n</sup>* is the rudder offset, *ω<sup>r</sup>* and *ωω* are the zero-mean Gaussian measurement white noise; *ψω* represents the first-order wave-induced motion, and *ς* is the relative damping ratio, conventionally assigned a value of 0.075. *ω*<sup>0</sup> is the wave frequency.

Based on Equation (42), the state space equation of the extended state observer is:

$$
\dot{\hat{X}} = A\hat{X} + B\Gamma + G(Y - C\hat{X}),
\tag{43}
$$

where *X*ˆ denotes the estimation of the state, *X*ˆ = ˆ *δn*,*r*ˆ, *ψ*, ˆ *ξω*, *ψ*ˆ*<sup>ω</sup> <sup>T</sup>* and . ˆ *ξω* = *ψ*ˆ*ω*. Γ is the input of the model and Γ = *δ* + *Kvv*; *G* is the gain matrix; ˆ *δ<sup>n</sup>* is the estimation of the rudder offset; *Y* is the heading signal obtained by the compass with *Y* = *ψ* + *ψω*.*A*, *B* and *C* are the coefficient matrixes with:

*A* =

$$
\begin{pmatrix}
0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & -\omega\_0^2 & -2\zeta\omega\_0 \\
\end{pmatrix},\tag{44}
$$

$$
B = \begin{pmatrix} 0 \\ \frac{K}{T} \\ 0 \\ 0 \\ 0 \end{pmatrix},\tag{45}
$$

$$
C = \begin{pmatrix} 0 \\ 0 \\ 1 \\ 0 \\ 1 \end{pmatrix}.\tag{46}
$$

The error of the state vector can be denoted as *<sup>E</sup>* <sup>=</sup> *<sup>X</sup>*<sup>ˆ</sup> <sup>−</sup> *<sup>X</sup>*, of which the differential equation is: .

$$
\dot{E} = (A - G\mathbb{C})E.\tag{47}
$$

To keep the asymptotic stability of the error vector, the solution of Equation (47) should be *E*(*t*) = *E*0*e*−*kt*, where *E*<sup>0</sup> is the initial error value and *k* is a scale factor. Thus, all of the eigenvalues of the matrix (*A* − *GC*) have negative real parts. The gain matrix *G* can be found by pole placement in terms of the eigenvalues. In this case, the eigenvector of the matrix (*A* − *GC*) is chosen as: *P* = (*P*0, *P*1, *P*2, *P*3, *P*4) = (1.5/*T*, 1.5/*T*, 1.5/*T*, 15*ςω*0, 15*ςω*0) and the gain matrix can be obtained by using the MATLAB function.

#### **4. Guidance Law**

Systems for guidance consist of a waypoint generator with human interface. A new hyperbolic guidance method for straight-line path-following control is presented in this paper. A Lyapunov function analysis [38] is used to prove the stability of this method. For curve guidance, based on the Lyapunov stability function, this paper presents a reverse stepping method to calculate heading rate command and make the system globally asymptotically stable, with a correction formula for current interference.

#### *4.1. Error Coordinates*

Consider a straight-line path implicitly defined by two waypoints *pk* = (*xk*, *yk*) *<sup>T</sup>* <sup>∈</sup> *<sup>R</sup>*<sup>2</sup> and *pk*<sup>+</sup><sup>1</sup> = (*xk*+1, *yk*<sup>+</sup>1) *<sup>T</sup>* <sup>∈</sup> *<sup>R</sup>*2, respectively. Also, consider the position of the ship denoted by the point *pt* = (*xt*, *yt*) *<sup>T</sup>* <sup>∈</sup> *<sup>R</sup>*2. Then the direction of the path can be defined as:

$$\mathfrak{a}\_{k} := \mathfrak{a}\text{tan}2(\mathfrak{x}\_{k+1} - \mathfrak{x}\_{k'}\mathcal{Y}\_{k+1} - \mathfrak{y}\_{k}).\tag{48}$$

Fossen [4] gives the formula to calculate the cross-track error:

$$\vec{P}(t) = -[\mathbf{x}\_t - \mathbf{x}\_k]\cos(\mathfrak{a}\_k) + [\underline{y}\_t - \underline{y}\_k]\sin(\mathfrak{a}\_k). \tag{49}$$

The calculation of the cross-track error in the transition curved path between two adjacent straight-line paths is complicated. Figure 2 shows two adjacent straight-line paths described by the waypoints *pk*,*pk*<sup>+</sup><sup>1</sup> and *pk*+2. *Rk*<sup>+</sup><sup>1</sup> is the radius of the transition curve and the cross-track error of the transition curved path can be obtained by:

**Figure 2.** The transition curved path.

First, determine the direction of the curved path (clockwise or counterclockwise). Based on Equation (48), the direction *α<sup>k</sup>* of the straight-line path *pk pk*<sup>+</sup><sup>1</sup> and the direction *αk*+<sup>1</sup> of the straight-line path *pk*<sup>+</sup><sup>1</sup> *pk*<sup>+</sup><sup>2</sup> can be calculated. Then the direction of the curved path is:

$$F\_{k+1} = \text{sign}(\sin(a\_{k+1} - a\_k));\tag{50}$$

here, *Fk*<sup>+</sup><sup>1</sup> denotes the direction of the curved path, a positive sign means clockwise and a negative sign means counterclockwise.

Second, determine the center point of the curved path. The angle between the two adjacent straight-line paths can be obtained in terms of the direction *αk*, *αk*+<sup>1</sup> and *Fk*+1.

$$
\gamma\_{k+1} = \pi - F\_{k+1}(\mathfrak{a}\_{k+1} - \mathfrak{a}\_k). \tag{51}
$$

Then the distance between the center point and the waypoint *pk*<sup>+</sup><sup>1</sup> can be determined in terms of the angle *γk*+<sup>1</sup> and the radius *Rk*+1.

$$D\_{k+1} = R\_{k+1} / \sin\left(\frac{\gamma\_{k+1}}{2}\right). \tag{52}$$

The angle between the vector from the center point *Ok*<sup>+</sup><sup>1</sup> to the waypoint *pk*<sup>+</sup><sup>1</sup> and North can be obtained in terms of the angle *γk*<sup>+</sup>1, the direction *Fk*<sup>+</sup><sup>1</sup> and *αk*.

$$
\mathfrak{a}\_{\mathcal{O}\_{k+1}} = \mathfrak{a}\_k - F\_{k+1} \gamma\_{k+1}.\tag{53}
$$

Based on the waypoint *pk*+1, the direction *αOk*+<sup>1</sup> and the distance *Dk*<sup>+</sup><sup>1</sup> from the center point *Ok*<sup>+</sup><sup>1</sup> to the waypoint *pk*+1, the coordinate *POk*<sup>+</sup><sup>1</sup> = *xOk*<sup>+</sup><sup>1</sup> , *yOk*<sup>+</sup><sup>1</sup> of the center point *Ok*<sup>+</sup><sup>1</sup> can be determined:

$$\mathcal{p}\_{O\_{k+1}} = \mathcal{p}\_{k+1} - R\_{k+1} \binom{\sin \mathfrak{a}\_{O\_{k+1}}}{\cos \mathfrak{a}\_{O\_{k+1}}} \,. \tag{54}$$

Finally, the cross-track error can be calculated by:

$$\vec{P}(t) = F\_{k+1} \| \boldsymbol{p}\_t - \boldsymbol{p}\_{O\_{k+1}} \| \, -\boldsymbol{R}\_{k+1}.\tag{55}$$

The course angle command is the direction of the vector tangential to the point on the path that is closest to the vehicle. The course angle command can be calculated by:

$$\dot{\chi}(t) = \chi(t) - atan2\left(\mathbf{x}(t) - \mathbf{x}\_{O\_{k+1}}, y(t) - y\_{O\_{k+1}}\right) + \frac{\pi}{2}F\_{k+1}\tag{56}$$

here, *χ*(*t*) is the current course.

#### *4.2. Straight-Line Path Guidance*

The main goal of straight-line path-following control is to eliminate cross-track and heading errors. Hyperbolic guidance will achieve a more rapid convergence of pathfollowing maneuvering because of its smoothing and transition properties. Thus, a hyperbolic guidance methodology is adopted with a hyperbolic tangent function. As shown in Figure 3, the curve OC denotes a hyperbola, of which the asymptote is the straight-line path. The hyperbola equation is:

$$y = R\_c \frac{e^{k\_c x} - e^{-k\_c x}}{e^{k\_c x} + e^{-k\_c x}},\tag{57}$$

where *Rc* denotes the distance between the origin *O* and the straight-line and *P*1(*t*) is the distance from the ship to the planned route at time *t* with *Rc* > *P*1(*t*).

**Figure 3.** The hyperbolic guidance law.

Then, the position of the ship *pt* can be denoted by *x*0, *Rc* − *P*1(*t*) and the angle *ζ* shown in Figure 3 can be calculated by:

$$\mathcal{Z}(t) = \text{sign}\left(\widetilde{P}(t)\right) \arctan\left[k\_c \left(2\left|\widetilde{P}(t)\right| - \frac{\widetilde{P}(t)^2}{R\_c}\right)\right],\tag{58}$$

where *kc* is a constant coefficient with *kc* > 0, denoting the rate of approach to the straightline path.

Then the course command can be obtained by:

$$\chi\_c = a\_k + \zeta(t) = a\_k + \text{sign}\left(\check{P}(t)\right)\text{arctan}\left[k\_c\left(2\left|\check{P}(t)\right| - \frac{\check{P}(t)^2}{R\_c}\right)\right],\tag{59}$$

where *χ<sup>c</sup>* is the command course and *α<sup>k</sup>* is initial heading angle.

#### *4.3. Curved Path Guidance*

For curved path following, a kinematic controller generates the desired states for motion control. The control method can be designed using a dynamic model of the ship by specifying a reference frame that moves along the path. A Serret-Frenet reference frame [39] is usually chosen. Figure 4 shows an inertia reference frame {*i*} = (*xi*, *yi*, *zi*), a body-fixed reference frame {*s*} = (*xs*, *ys*, *zs*) and a Serret-Frenet frame {*m*} = (*xm*, *ym*, *zm*). The origin *Om* of {*m*} is attached to the point on the path that is closest to the vehicle. R denotes the radius of the curved path.

**Figure 4.** Path-following: reference frame.

The notation *H<sup>c</sup> <sup>a</sup>*/*<sup>b</sup>* is adopted in this paper, where {*a*}, {*b*} and {*c*} denote the three different frames and *H* denotes the coordinate of {*a*} in frame {*b*} relative to {*c*}. Such that:

$$r\_{\mathbf{m}/i}^i + r\_{\mathbf{s}/m}^i = r\_{\mathbf{s}/i\prime}^i \tag{60}$$

where *r* denotes the distance vector.

Time differentiation of Equation (60) yields:

$$
\upsilon\_{m/i}^i + \frac{d}{dt}\upsilon\_{s/m}^i = \upsilon\_{s/i\prime}^i \tag{61}
$$

where *v* denotes the speed vector. And *<sup>d</sup> dtri <sup>s</sup>*/*<sup>m</sup>* can be obtained by:

$$\frac{d}{dt}r\_{\text{s}/m}^i = R\_m^i \omega\_{m/i}^i \times r\_{\text{s}/m}^m + R\_m^i \upsilon\_{\text{s}/m}^m \tag{62}$$

where *R<sup>i</sup> <sup>m</sup>* denotes the transformation matrix from {*m*} to {*i*} and *<sup>ω</sup><sup>i</sup> <sup>m</sup>*/*<sup>i</sup>* <sup>=</sup> 0, 0, <sup>−</sup> . *α T* denotes the rotation vector between the {*m*} and {*i*} frames.

Substituting Equation (62) into Equation (61) and multiplying by *R<sup>i</sup> <sup>m</sup>* on both sides of the equation, yields:

$$
\boldsymbol{v}\_{m/i}^{m} + \boldsymbol{\omega}\_{m/i}^{l} \times \boldsymbol{r}\_{s/m}^{m} + \boldsymbol{v}\_{s/m}^{m} = \boldsymbol{R}\_{s}^{m} \boldsymbol{v}\_{s/i}^{s}.\tag{63}
$$

Then the kinematic equations can be obtained:

$$\begin{cases} \dot{\vec{P}} = -\omega \sin \tilde{\chi} \\ \dot{\vec{\alpha}} = \frac{\mu \cos \tilde{\chi}}{R + FP} \end{cases} \tag{64}$$

where *<sup>P</sup>*<sup>1</sup> is the position deviation, *<sup>χ</sup>*<sup>1</sup> is the course deviation, *<sup>α</sup>* is the planned course and *F* indicates the direction of the transition curve. *F* = 1 means turning clockwise, *F* = −1 means turning counterclockwise.

Thus, goal of the curved path-following controller is to calculate the yaw rate commands, forcing the ship to approach the curved path. This paper presents a reverse stepping calculation method based on the Lyapunov function to obtain the yaw rate commands.

First, calculate the course commands. Consider the Lyapunov function candidate as follows:

$$V\_1 = \frac{1}{2}\widehat{P}^2.\tag{65}$$

Time differentiation of Equation (65) yields:

$$
\dot{V}\_1 = -\widetilde{P}\mu\sin(\chi-\kappa).\tag{66}
$$

To satisfy global asymptotic stability (GAS), it is necessary to guarantee that *V*<sup>1</sup> < 0 as *<sup>P</sup>*<sup>1</sup> <sup>=</sup> 0 and . *V*<sup>1</sup> = 0 as *P*1 = 0. Thus, the following equation is adopted:

$$
\dot{V}\_1 = -k\_1 \hat{P}^2 \le 0,\tag{67}
$$

where *k*<sup>1</sup> is the scaling factor, with *k*<sup>1</sup> > 0.

Based on Equation (65) and Equation (66), the course commands can be calculated by:

$$\chi\_{\varepsilon} = \alpha + \arcsin\left(\frac{k\_1 \bar{P}}{\mu}\right). \tag{68}$$

Equation (68) suggests that the course command *χ<sup>c</sup>* will approach the path direction *α* to eliminate the course error *<sup>χ</sup>*1, as the cross-track error is decreasing. However, the path direction *α* is varying with ship motion during the curved path-following control. Thus, it is necessary to calculate the yaw rate commands. Consider the Lyapunov function candidate:

$$V\_2 = \frac{1}{2}\tilde{\chi}^2,\tag{69}$$

with *<sup>χ</sup>*<sup>1</sup> <sup>=</sup> *<sup>χ</sup>* <sup>−</sup> *<sup>χ</sup>c*. Time differentiation of Equation (69) yields:

$$\dot{V}\_2 = (\chi - \chi\_c) \left( \dot{\chi} - \dot{\alpha} - \frac{\dot{\tilde{P}}}{\sqrt{\left(u/k\_1\right)^2 - \tilde{P}^2}} \right). \tag{70}$$

To satisfy GAS, it is necessary to guarantee that . *<sup>V</sup>*<sup>2</sup> <sup>&</sup>lt; 0 as *<sup>χ</sup>* <sup>=</sup> *<sup>χ</sup><sup>c</sup>* and . *V*<sup>2</sup> = 0 as *χ* = *χc*. Thus, the following equation is adopted:

$$
\dot{V}\_2 = -k\_2 \hat{\chi}^2,\tag{71}
$$

where *k*<sup>2</sup> is the scaling factor, with *k*<sup>2</sup> > 0.

Based on Equations (64), (68), (70) and (71), the course commands can be calculated by:

$$\dot{\chi}\_c = \frac{u \cos \tilde{\chi}}{R + F\tilde{P}} - \frac{-u \sin \tilde{\chi}}{\sqrt{\left(u/k\_1\right)^2 - \tilde{P}^2}} - k\_2 \tilde{\chi}\_\prime \tag{72}$$

where . *χ<sup>c</sup>* is the derivative of *χc*, indicating the command track angular rate. We neglect the varying of the drift angle *β*, thus the varying rate course command can be treated as the yaw rate command, approximately. However, this does not fit in the presence of wave disturbance. In the presence of sea current interference, the yaw rate commands need to be adjusted as:

$$
\sigma\_c = \dot{\chi}\_c \frac{u\_\%}{u\_\% - u\_f \cos(\varphi\_\% - \varphi\_f)} \,\prime \tag{73}
$$

where *rc* denotes the yaw rate command, *ug* denotes the ship speed over the ground, with direction *ϕ<sup>g</sup>* and *uf* is the current speed through water, with direction *ϕ<sup>f</sup>* .

Figure 5 is the three-layer control structure of ship track control proposed in this paper. The track control module calculates the current planned navigation section of the ship according to the current ship position information and environmental interference information and calculates the track deviation and heading deviation, then modifies the planned heading angle according to the deviation information, calculates the command heading angle and sends it to the heading control module. According to the current compass signal, rudder angle signal and yaw speed signal, the course control module calculates the course deviation after comparing with the command heading and calculates the command rudder angle through the course control algorithm.

**Figure 5.** Basic composition of track control system.

Finally, the rudder angle control layer drives the rudder to make the actual rudder angle consistent with the command rudder angle, so as to realize the track control of the ship.

Figure 6 shows the path-following control overall flow chart:

**Figure 6.** Path-following control flow chart.

#### **5. Simulation Results**

International Standard IEC62065 is used to test the performance of the path-following control algorithm presented in this paper. Based on the standard, three classes of ship are adopted: class A fast ferry, class B container and class C tanker. See Table 2 for details.

**Table 2.** Parameters for three ships.


The heading controller parameters are given in Table 3:

**Table 3.** Heading controller parameters.


The ships' initial states for the three test scenarios are as follows:

Ship A:(u0, v0, r0, ψ0) = (15.4 m/s, 0 m/s, 0 rad/s, 0 deg);

Ship B:(u0, v0, r0, ψ0) = (12.9 m/s, 0 m/s, 0 rad/s, 0 deg);

Ship C:(u0, v0, r0, ψ0) = (5.1 m/s, 0 m/s, 0 rad/s, 65 deg);

In control applications, it is important to validate the controller experimentally, this paper takes ship class B as the simulation object and the ship parameters are shown in Table 2. The step steering signal is selected as the input signal and the rotation experiment is used as the experimental method of controller parameter identification. The trajectory is shown in Figure 7 and the simulation data is shown in Table 4.

**Table 4.** Simulation data of class B ship rotation experiment.


It can be seen from the experimental results that the control model established in this paper meets the ship's turning characteristics and the established model is reliable.

Secondly, the course control algorithms of the three types of ships in Table 2 are verified. For ship class A, the initial speed of the ship is 15.4m/s, the command thrust is 0.67, under sea state 3 and the command heading angle is 30 degrees. As for ship class B,

the initial speed is 12.9 m/s, the command thrust is 0.8, under sea state 3 and the command heading angle is 30 degrees. For ship class C, the initial speed of the ship is 5.1m/s, the command thrust is 1, under sea state 3 and the command heading angle is 30 degrees. Figures 8–10 shows that the improved LQR control algorithm in this paper is compared with the traditional LQR algorithm and the simulation experimental chart of course control is obtained. The simulation data is shown in Table 5.

**Figure 7.** Testing results for ship class B in rotation experiment.

**Figure 8.** Comparative experiment of course control for ship class A: (**a**) The course angle changes with time; (**b**) The actual rudder angle changes with time.

**Figure 9.** Comparative experiment of course control for ship class B: (**a**) The course angle changes with time; (**b**) The actual rudder angle changes with time.

**Figure 10.** Comparative experiment of course control for ship class C: (**a**) The course angle changes with time; (**b**) The actual rudder angle changes with time.


**Table 5.** The results of the heading control test.

Based on the above experimental results, the following conclusions can be drawn: the improved algorithm combining LQR with feedback nonlinearization control can achieve the function of ship course control, the overshoot, control accuracy and corresponding time are better than the traditional LQR control method. In addition, by adding a state observer can ensure that the ship can sail according to the expected instructions under sea state 3 without frequent steering.

There are three test scenarios used to evaluate performance of the path-following controller. Details of the scenarios are given in Tables 6–8.


**Table 6.** The parameters of the track for ship class A.

**Table 7.** Parameters of the track for ship class B.


**Table 8.** Parameters of the track for ship class C.


Results of testing the three classes of ship are shown in Figures 11–13. WPTs in the figure are waypoints.

**Figure 11.** Testing results for ship class A: (**a**) Ship trajectory; (**b**) Observation index: rudder angle, track deviation and heading deviation.

**Figure 12.** Testing results for ship class B: (**a**) Ship trajectory; (**b**) Observation index: rudder angle, track deviation and heading deviation.

**Figure 13.** Testing results for ship class C: (**a**) Ship trajectory; (**b**) Observation index: rudder angle, track deviation and heading deviation.

From Figure 11, we can see that ship class A has a maximum cross-track error of 24.8 m and the maximum course error 11.3◦, which satisfies the requirements set by IEC62065 of setting the course deviation limit to 25◦ and the cross-track deviation to 100 m. The experimental results show that this algorithm has the advantage of less steering time.

Results for ship class B are shown in Figure 12, with a maximum cross-track error of 22 m and maximum course error of 1.6◦, which satisfies the requirements of setting the course deviation limit to 15◦ and the cross-track deviation to 60 m.

Results for ship class C are shown in Figure 13, where the experimental environment is under rough sea state 5, with maximum cross-track error of 27.24 m and maximum

course error of 3.9◦, which satisfies the requirements of setting the course deviation limit to 15◦ and the cross-track deviation to 100 m.

Tests of ship class B in the presence of wave disturbance and a simulated current of 5 kn are also performed. The results are shown in Figure 14.

**Figure 14.** Testing results for ship class B in the presence of disturbance: rudder angle, track deviation and heading deviation.

As shown in Figure 14, in the presence of sea state 3 and a simulated current of 5 kn, 30◦N and the other requirements for test are the same as those for ship class B listed earlier, the results for ship class B satisfy the IEC62065 requirements with maximum cross-track error of 30.1 m and maximum course error of 3.96◦. The experimental result shows that the proposed algorithm has demonstrated good robustness.

To further verify the control effect of the proposed algorithm, additional comparative experiments have been done. For ship class B, the traditional and adaptive PID control algorithms were used for track control, as shown in Figure 15. The experimental results are also compared with traditional LQR controller and the improved LQR control algorithm with nonlinear feedback term proposed in this paper and the track deviations are shown in Figure 16. Specific data are in Table 9. It can be seen from the experimental results that the traditional LQR control method has better tracking effect in the tracking task of direct sail or low speed tracking simple curve. However, it is difficult to guarantee the tracking accuracy in tracking complex task path. The maximum deviation under traditional PID controller, adaptive PID controller, traditional LQR controller and improved LQR controller are as follows: 176.9 m, 48.51 m, 23.32m and 22 m. In terms of stability, the traditional LQR controller performs poorly. And for the improved LQR controller, the deviation is around 0 for more than 3000 s. The performance of the control method proposed in this paper is significantly better than that of the other three control methods.

**Figure 15.** Navigation route for ship class B under different control methods: (**a**) traditional proportional-integral-derivative (PID) control law; (**b**) adaptive PID control law.

**Figure 16.** Testing results for ship class B under different control methods.

**Table 9.** Experimental result for comparison of different control algorithms.


#### **6. Conclusions**

A new practical guidance and control algorithm for marine vehicles is introduced in this paper. The main innovation is the hyperbolic guidance law used in straight-line path-following control. For curved path-following in the transition between two adjacent straight-line paths, this paper improves the reverse stepping method for the controller to calculate heading rate command to make the system globally asymptotically stable, with a correction formula for sea current interference. Traditional LQR and feedback nonlinear control are combined to improve the accuracy of course control. Different types of ships are verified in this paper, simulation results based on the International Standard IEC62065 are included to demonstrate system performance. The algorithms satisfy the IEC62065 testing requirements. Three additional experiments verified that the control method has good robustness and good control effect.

**Author Contributions:** Conceptualization, Z.Z. and H.W.; methodology, Z.Z.; software, Z.Z.; validation, Z.Z., H.W., Y.Z. (Yuhan Zhao) and G.Z.; formal analysis, Z.Z.; investigation, Z.Z.; resources, Z.Z.; data curation, Y.Z. (Yuhan Zhao) and G.Z.; writing—original draft preparation, Z.Z.; writing—review and editing, Z.Z.; visualization, Z.Z.; supervision, H.W. and Y.Z. (Yi Zhao); project administration, H.W. and Y.Z. (Yi Zhao); funding acquisition, H.W. All authors have read and agreed to the published version of the manuscript.

**Funding:** This study was funded by the Russian Foundation for Basic Research (RFBR) (No. 20-07-00531).

**Institutional Review Board Statement:** "Not applicable" for studies not involving humans or animals.

**Informed Consent Statement:** "Not applicable" for studies not involving humans.

**Data Availability Statement:** Data sharing not applicable. No new data were created or analyzed in this study. Data sharing is not applicable to this article.

**Acknowledgments:** The authors are grateful to the anonymous reviewers for their valuable comments and suggestions that helped improve the quality of this manuscript.

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

#### **References**

