**1. Introduction**

The ocean is an important strategic space for economic and social development. Due to the increasing exploitation and utilization of marine resources, autonomous underwater vehicles (AUVs) have been rapidly developed for use in the fields of pipeline inspection, seawater quality detection, marine geological exploration, submarine cable detection, and so on [1–3]. It is important to control the AUV to complete missions quickly and accurately [4–6]; however, complex underwater working environments increase the difficulty of controlling AUVs [7]. Therefore, as the premise to realize AUV missions, path tracking becomes an important problem to be solved.

There has been much research on AUV path tracking based on traditional design methods, including proportional integral differential (PID) control [8,9], sliding mode control [10,11], predictive control [12], and so on. PID is one of the most widely used algorithms for controller design; to guide an AUV to track an underwater cable, it forms a straight-line path-tracking control problem with magnetic sensing. Previous research presented a PID controller to track the desired guidance profiles in light of the linearizing feedback method [8]. The PID algorithm can give a line-of-sight guidance law with drift angle compensation to solve the problem of AUV tracking in a complex marine environment, and the PID algorithm can be used to guide AUVs to track the desired path [9]. However, PID is a linear control method, which is difficult to use in complex nonlinear systems related to AUVs in practice. To solve the under-actuated AUV horizontal path-tracking control problem, the authors of another study utilized a sliding mode control method

**Citation:** Tian, Q.; Wang, T.; Song, Y.; Wang, Y.; Liu, B. Autonomous Underwater Vehicle Path Tracking Based on the Optimal Fuzzy Controller with Multiple Performance Indexes. *J. Mar. Sci. Eng.* **2023**, *11*, 463. https://doi.org/ 10.3390/jmse11030463

Academic Editor: Sergei Chernyi

Received: 8 January 2023 Revised: 10 February 2023 Accepted: 13 February 2023 Published: 21 February 2023

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

<sup>1</sup> Qingdao Ship Science and Technology Co., Ltd., Harbin Engineering University, Qingdao 266000, China

with line-of-sight guidance and cross-track errors [10]; however, chattering was inevitable in the tracking control process. This necessitated a nonlinear second-order sliding mode controller for the purpose of improving the stability of the control system by eliminating the chattering motion [11]. In light of the backstepping algorithm, a model predictive control method was given for AUV path tracking [12]. In summary, the above traditional methods [8–12] are highly dependent on the models of AUV control systems, which are difficult to apply in engineering practice because of the difficulty of obtaining accurate models in complex underwater environments.

Compared with the traditional control methods of path tracking, intelligent algorithms have attracted more and more attention because their application of intelligent control is independent of an accurate kinetic model. Reinforcement learning refers to agent learning according to "trial and error", which interacts with the environment to obtain rewards to guide behavior for path tracking [13,14]. A line-of-sight method of guidance was proposed by reinforcement learning algorithms, which can also utilize long short-term memory neural networks to pre-train the reinforcement learning framework to speed up the learning process [13]. Considering the uncertainty of ocean currents and according to the data on ocean currents obtained by the observer, one study presented a novel reward function to improve the learning ability of a reinforcement learning architecture, and thus, deep reinforcement learning was developed for path tracking [14]. Fuzzy control is a method considering the theory of fuzzy mathematics, which has been used for AUV path tracking [15–17]. In fuzzy control, a nonlinear single-input fuzzy controller was used for path tracking, resulting in reductions in the computation complexity [15]. For an AUV with an unknown actuator saturation and environmental disturbance, the authors of one study presented a kinematic controller by the backstepping technique, whose law was designed in light of an indirect adaptive fuzzy logic control system [16]. To improve the performance of fuzzy controllers, the authors of another study proposed a fuzzy controller optimized by the genetic algorithm [17]. In summary, although there are many different intelligent control methods for AUV path tracking, they are focused on improving the tracking error; in practice, the path length and smoothness are also important for pathtracking performance. Therefore, a new method is needed to solve the AUV path-tracking problem with multiple good performance indexes.

It should be noted that the existing fuzzy theory and the related research have made some contributions regarding the collision avoidance problem in marine engineering. In one study, fuzzy theory was used to reason the degree of the collision risk, A\*search was used to make an avoidance action plan, and the action space searched by the ship was formed in the expert system using marine traffic rules [18]. In order to trigger the prompt alert of a potential collision, the authors of another study utilized evidential research theory to calculate the risk of collision according to the relevant navigation information [19]. Based on the need to prevent collisions according to sea rules, the authors of another study proposed a collision risk inference system using fuzzy rules to enable autonomous surface ships to avoid collisions [20]. Furthermore, on the basis of [20], the authors of another study proposed a local route planning method to avoid collisions with maritime autonomous surface ships [21]. Although the above works can provide some reference to fuzzy theory [18–21], they are difficult to directly use in AUV path tracking.

Path tracking is very important to perform missions in complex underwater environments. To solve the path-tracking problem for AUVs according to the established kinematic and dynamic models, a fuzzy controller is presented to realize path tracking. We select the path length, smoothness and cross-track position error as the performance indexes for the fuzzy controller, which determines the AUV tracking path energy, traveling time and tracking accuracy. The fuzzy controller is optimized with the optimization of membership function by the particle swarm optimization (PSO) algorithm. The designed fuzzy controller makes a path-tracking system with strong robustness and anti-interference ability.

The rest of this paper is arranged as follows. Section 2 gives the problem description and definition for AUV path tracking; Section 3 presents mathematical models for AUV path tracking; Section 4 proposes a fuzzy control method based on the PSO algorithm for AUV path tracking; Section 5 gives the results and discussion for the proposed algorithm; Section 6 provides some conclusive remarks.

#### **2. Problem Description and Definition for AUV Path Tracking**

The goal of AUV path tracking is to follow the desired path with the performance indexes. In the tracking process, once the coordinates of the current and target locations are given, the desired attitude angles can be obtained with the desired AUV velocity, the essence is to eliminate the error between the practical and desired angles. In order to solve the AUV path-tracking problem, we select the path length, smoothness and cross-track position error as the path-tracking performance indexes. The reason is that the indexes determine the path tracking energy consumption, travelling time, etc. [22]. The fuzzy control can solve the control problem of nonlinear system with strong robustness effectively; therefore, the fuzzy controller is presented for path tracking in this paper. Figure 1 gives the technology roadmap for AUV path tracking. The optimization performances for the fuzzy controller are formed according to the established kinematic and dynamic models, the deviations and their derivatives are taken as input parameters. We present the PSO algorithm to optimize the membership function to realize optimal path tracking. The AUV tracks with the desired path based on the optimized fuzzy controller.

**Figure 1.** The technology roadmap for AUV path tracking.

We select the cross-track position and heading angle errors as the important factors to illustrate the path-tracking effect [10]. Figure 2 shows the definitions of the AUV's cross-track position and heading angle errors, where *Ppr* = *Pdx*(*i* − 1), *Pdy*(*i* − 1), *Pcu* = *Pdx*(*i*), *Pdy*(*i*) and *Pne* = *Pdx*(*i* + 1), *Pdy*(*i* + 1) are the adjacent discrete points of the desired path. *Pce* = (*Px*(*t*), *Py*(*t*)) is the AUV's center.

**Figure 2.** Cross-track position and heading angle errors for the AUV.

The cross-track position error *e*(*t*) is the vertical distance from the AUV's center to the adjacent segment of the desired path. In light of the points *Ppr*, *Pcu* and *Pce*, the cross-track position error can be obtained as follows:

$$\begin{aligned} \dot{e}(t) &= d(t) \times \sin(\delta(t)) \end{aligned} \tag{1}$$

where *d*(*t*) is the distance from the AUV's center to the target point.

$$d(t) = \sqrt{{(P\_y(t) - P\_{dy}(i))}^2 + {(P\_x(t) - P\_{dx}(i))}^2 \tag{2}$$

The cross-track heading angle error *<sup>δ</sup>*(*t*) is an angle between the <sup>→</sup> *PcePcu* and <sup>→</sup> *PprPcu* vectors, which can be given as follows:

$$\delta(t) = \arctan\left(P\_{dy}(i) - P\_{\mathcal{Y}}(t)\right) / \left(P\_{dx}(i) - P\_{x}(t)\right) - \arctan\left(P\_{dy}(i) - P\_{dy}(i-1)\right) / \left(P\_{dx}(i) - P\_{dx}(i-1)\right) \tag{3}$$

In this paper, the smaller the cross-track position and heading angle errors, the better the tracking effect.

In Figure 2, the straight line *PcePpe* is perpendicular to *PprPcu*, *Ppe* is the corresponding crossing point. Whether the AUV drives into the next segment path can be evaluated by the following decision factor *fd*(*t*):

$$L = d(t)\cos(\delta(t))\tag{4}$$

$$f\_d(t) = \begin{cases} 1 & \quad \quad (L \le 0 \text{ or } \ d(t) \le r) \\ 0 & \quad \quad (L > 0 \text{ and } \ d(t) > r) \end{cases} \tag{5}$$

where *L* denotes the length of straight line *PpePcu*. *r* and *Pcu* are the circle radius and center, respectively. If *L* ≤ 0 or *d*(*t*) ≤ *r*, then *fs*(*t*) = 1, that is, the AUV executes path tracking in the next segment. If *L* > 0 and *d*(*t*) > *r*, then *fs*(*t*) = 0, and the AUV executes path tracking in the current segment.

#### **3. Mathematical Models for AUVs**

#### *3.1. AUV Kinematic Model*

Figure 3 shows the platform of our self-made "Ocean Star" AUV, six thrusters provide forces to control the AUV. The detailed AUV's mechanical structure and size can be found in the Section 5. We give the earth ({*O* − *X*,*Y*, *Z*}) and body-fixed frames ({*O*<sup>1</sup> − *X*1,*Y*1, *Z*1}) to express the AUV kinematic model, the AUV kinematic model can be written as follows [23–27]:

$$
\dot{\eta} = \begin{bmatrix} J\_1 & \mathbf{0}\_{3 \times 3} \\ \mathbf{0}\_{3 \times 3} & J\_2 \end{bmatrix} \mathbf{v} \tag{6}
$$

$$
\begin{bmatrix} \dot{\mathbf{x}} & \dot{\mathbf{y}} & \dot{\mathbf{z}} & \dot{\boldsymbol{\Phi}} & \dot{\boldsymbol{\Phi}} & \dot{\boldsymbol{\Phi}} \end{bmatrix}^T = \begin{bmatrix} J\_1 & \mathbf{0}\_{3 \times 3} \\ \mathbf{0}\_{3 \times 3} & J\_2 \end{bmatrix} \begin{bmatrix} u & v & w & p & q & r \end{bmatrix}^T \tag{7}
$$

where *η* = ' *xyz φθψ*(*<sup>T</sup>* , *x*, *y*, *z* represent the AUV's location in the Earthframe, *φ*, *θ*, *ψ* are AUV's roll, pitch and yaw angles in the Earth-frame frame; *υ* = ' *uvwpqr*( , *u*, *v*, *w* are the surge, sway and heave in the body-fixed frame, *p*, *q*, *r* are the roll, pitch and yaw rates in the body-fixed frame; *J*<sup>1</sup> and *J*<sup>2</sup> denote the coordinate transformation matrixes, whose mathematical expressions can be presented as follows:

$$J\_1 = \begin{bmatrix} \cos\theta\cos\psi & \sin\theta\sin\phi\cos\psi - \cos\phi\sin\psi & \sin\theta\sin\psi + \sin\theta\cos\phi\cos\psi\\ \cos\theta\sin\psi & \sin\theta\sin\phi\sin\psi + \cos\phi\cos\psi & \sin\theta\cos\phi\sin\psi - \sin\phi\cos\psi\\ -\sin\theta & \sin\phi\cos\theta & \cos\phi\cos\theta \end{bmatrix} \tag{8}$$

$$J\_2 = \begin{bmatrix} 1 & \sin\phi\tan\theta & \cos\phi\tan\theta \\ 0 & \cos\phi & -\sin\phi \\ 0 & \sin\phi/\cos\theta & \cos\phi/\cos\theta \end{bmatrix} \tag{9}$$

**Figure 3.** Two coordinate systems for the AUV.

#### *3.2. AUV Dynamic Model*

The dynamic equation of the AUV's motion can be given as follows [11,25,28]:

$$
\dot{\mathcal{M}}\dot{\boldsymbol{\nu}} + \mathcal{C}(\boldsymbol{\nu})\boldsymbol{V} + \mathcal{D}(\boldsymbol{\nu})\boldsymbol{\nu} + \mathcal{g}(\boldsymbol{\eta}) = \boldsymbol{\pi} \tag{10}
$$

where *<sup>M</sup>* ∈ *<sup>R</sup>*6×<sup>6</sup> is the inertial matrix, which includes the added mass; *<sup>D</sup>* ∈ *<sup>R</sup>*6×<sup>6</sup> is the damping matrix; *<sup>g</sup>* ∈ *<sup>R</sup>*6×<sup>6</sup> is the gravitational terms matrix; *<sup>C</sup>* ∈ *<sup>R</sup>*6×<sup>6</sup> is the matrix of Coriolis and centripetal terms; *υ* is the position and orientation vector; *τ* is the control forces vector. The AUV's gravitational and buoyancy centers are located at one point. The translational and rotational motions can be described with six equations, which denote surge, sway, heave, roll, pitch, and yaw, respectively as follows:

$$\begin{aligned} m \left( \dot{u} - \upsilon r + wq - \mathbf{x}\_{\mathcal{S}} \left( q^2 + r^2 \right) + z\_{\mathcal{S}} (pr + q) \right) \\ = X\_{HS} + X\_u |u| + X\_{\dot{u}} u + X\_{u\eta} wq + X\_{\eta\eta} qq + X\_{\upsilon r} \upsilon r + X\_{rr} rr + X\_{prop} \end{aligned} \tag{11}$$

$$\begin{aligned} m\left(\dot{v} - wp + ur - z\_3\left(qr - \dot{p}\right) + x\_\xi \left(pq + \dot{r}\right)\right) \\ = Y\_{HS} + Y\_{\psi|v|}v|v| + Y\_{r|r|}r|r| + Y\_{\dot{v}}\dot{v} + Y\_{\dot{r}}\dot{r} + Y\_{ur}ur + Y\_{\dot{v}p}wp + Y\_{pq}pq + Y\_{\dot{u}v}uv + Y\_{\dot{u}u\delta\_p}u^2\delta\_r \end{aligned} \tag{12}$$

$$\begin{aligned} m\left(\dot{w} - u\eta + v\rho - z\_3(q^2 + p^2) + x\_3(rp + \dot{q})\right) \\ = Z\_{HS} + Z\_{w|w|}w|w| + Z\_{\dot{q}|\dot{q}|}q|\dot{q}| + Z\_{\dot{u}}\dot{w} + Z\_{\dot{q}}\dot{q} + Z\_{u\dot{q}}u\eta + Z\_{vp}v\rho + Z\_{pv}pv + Z\_{uu}uw + Z\_{uu\delta\_t}u^2\delta\_{\ast} \end{aligned} \tag{13}$$

$$\begin{array}{l} \left| I\_{xx} \dot{p} + \left( I\_{xx} - I\_{yy} \right) qr + m \right| - z\_{\mathcal{R}} \left( \dot{v} - wp + \mu r \right) \right| \\\ = \mathcal{K}\_{HS} + \mathcal{K}\_{p \left| p \right|} p \left| p \right| + k\_{p \left| p \right|} p \left| p \right| + k\_{\dot{p}} \dot{p} + k\_{prop} \end{array} \tag{14}$$

$$\begin{aligned} \left| \begin{array}{c} I\_{yy} \dot{q} + (I\_{xx} - I\_{zz}) pr + m \Big| z\_3 (\dot{u} - vr + uq) - x\_3 (\dot{w} - uq + vp) \Big| = \\ \left| M\_{HS} + M\_{w|w|} q|q \right| + M\_{\dot{q}|q|} q|q| + M\_{\dot{w}} \dot{w} + M\_{\dot{q}} \dot{q} + M\_{\dot{q}l} uq + M\_{\dot{q}l} vp + M\_{rp} rp + M\_{uu} uw + M\_{uu\delta\_i} u^2 \delta\_{\delta} \end{array} \right| \tag{15}$$

$$\begin{aligned} \left| I\_{xx}\dot{r} + \left( I\_{yy} - I\_{xx} \right) q\rho + m \right| \mathbf{x}\_{\mathfrak{g}} (\dot{v} - w\rho + ur) \right| &= \\ \left| N\_{HS} + N\_{\dot{v}|\boldsymbol{v}|} v|v| + N\_{\dot{r}|\boldsymbol{r}|} r|\boldsymbol{r}| + N\_{\dot{v}}\dot{v} + N\_{\dot{r}}\dot{r} + N\_{ur}ur + N\_{\dot{v}p}wp + N\_{\mathbb{H}p}pq + N\_{uv}uv + N\_{uu\delta\_{r}}u^{2}\delta\_{r} \right| \end{aligned} \tag{16}$$

where *m* is the AUV's mass; *xg* and *zg* are the location parameters of the AUV's gravitational centers; *Ixx*, *Iyy*, *Izz* are the AUV's inertia mass moments; *Xu*, *Yv*, *Zq*, *Nr*, *Nv* and *Mq* are the speed coefficients; *Xu*|*u*|, *Yv*|*v*|, *Zq*|*q*|, *Mw*|*w*|, *M*|*w*|*q*, *Nr*|*r*|, *Mq*|*q*<sup>|</sup> are the second-order speed coefficients; *Xwq* and *Xqq* are the second-order speed coefficients; *δ<sup>s</sup>* and *δ<sup>r</sup>* are the vertical angle and horizontal fins, respectively; *Xprop* is the propeller thrust; and *kprop* is the propeller torque.

It should be noted that one can select several equations from Equations (11) to (16) for path-tracking design according to the actual engineering.

#### **4. AUV Path Tracking with the Fuzzy Controller**

#### *4.1. The Design of the Fuzzy Controller*

Fuzzy control is a human-like intelligent control method embodying the human control experience and strategy [29]. Fuzzy control does not depend on the precise models of the nonlinear control system, which can be used in the control process with strong robustness and good anti-interference performance [30–32]. A fuzzy controller contains four basic elements: fuzzification, knowledge base, fuzzy inference and defuzzification.

In this paper, we select triangle membership function for fuzzification, the reasons are given as follows: (1) Consisting of simple straight-line segments, triangular membership function is very easy to apply in fuzzy control; (2) Triangular membership function can obtain good performance for AUV control [30]. The methodologies to use for membership function optimization are given as follows: the membership function is assumed as an isosceles triangle, the function includes three parameters; the first and third parameters are optimized by the PSO algorithm, the middle is obtained as the average of the first and third values. Input parameters *<sup>e</sup>*(*t*) and . *e*(*t*) are transformed into fuzzy information based on the given triangle membership function. Based on the results of different fuzzy control rules with a trial-and-error method, Table 1 can be obtained with the fuzzy control rules for AUV path tracking. Combined with the input parameters, the output parameters attitude angles are obtained according to the fuzzy control rules, which are changed with *<sup>e</sup>*(*t*) and . *e*(*t*). The center of gravity method has smooth output inference control, whose output changes in response to small changes in the input value. Therefore, we select the center of gravity method for defuzzification in this paper.

**Table 1.** Fuzzy control rules for the AUV.


**Remark 1.** *NB denotes negative big, NM denotes negative middle, NS denotes negative small, ZO denotes zero, PS denotes positive small, PM denotes positive middle, PB denotes positive big.*

In the control process for AUV path tracking, once the coordinates of the current and target locations are given, the desired attitude angles can be obtained at the desired AUV velocity [17]. Therefore, we select not only the cross-track position and attitude angle errors but also their derivatives as the input parameters. Figures 4 and 5 show the membership functions of cross-track position errors and corresponding derivatives, respectively, which are like the ones for cross-track attitude angle errors and their derivatives. Input and output variables need to be divided into different fuzzy sets. The more numbers of the fuzzy sets, the more detailed and flexible for the constituted fuzzy control rules, this may increase the programming complexity and computing time. Conversely, the less numbers of the fuzzy sets, the less simple the fuzzy control rules, this may lead to difficulties for the controller to achieve the expected effect. We divide input and output variables into seven fuzzy sets based on the experiment, which are good enough to balance the calculation time and control accuracy. The fuzzy states of cross-track position errors and their derivatives are

given as follows: (1) Cross-track position error (*e*(*t*)) is divided into seven fuzzy states as follows, *NB* ∈ [*α*<sup>1</sup> , *<sup>α</sup>*<sup>1</sup> ], *NM* ∈ [*α*<sup>1</sup> , *<sup>α</sup>*<sup>1</sup> ], *NS* ∈ [*α*<sup>1</sup> , *<sup>α</sup>*<sup>1</sup> ], *ZO* ∈ [*α*<sup>1</sup> , *<sup>α</sup>*<sup>1</sup> ], *PS* ∈ [*α*<sup>1</sup> , *<sup>α</sup>*<sup>1</sup> ], *PM* ∈ [*α*<sup>1</sup> , *<sup>α</sup>*<sup>1</sup> ], *PB* ∈ [*α*<sup>1</sup> , *<sup>α</sup>*<sup>1</sup> ]; (2) Cross-track position error derivative is divided into seven fuzzy states as follows: *NB* ∈ [*α*<sup>2</sup> , *<sup>α</sup>*<sup>2</sup> ], *NM* ∈ [*α*<sup>2</sup> , *<sup>α</sup>*<sup>2</sup> ], *NS* ∈ [*α*<sup>2</sup> , *<sup>α</sup>*<sup>2</sup> ], *ZO* ∈ [*α*<sup>2</sup> , *<sup>α</sup>*<sup>2</sup> ], *PS* ∈ [*α*<sup>2</sup> , *<sup>α</sup>*<sup>2</sup> ], *PM* ∈ [*α*<sup>2</sup> , *<sup>α</sup>*<sup>2</sup> ], *PB* ∈ [*α*<sup>2</sup> , *<sup>α</sup>*<sup>2</sup> ]. Similar to Figures 4 and 5, the fuzzy states of the attitude angles and their derivatives can be given as follows: (1) Cross-track attitude angle error is divided into seven fuzzy states as follows: *NB* ∈ [*α*<sup>3</sup> , *<sup>α</sup>*<sup>3</sup> ], *NM* ∈ [*α*<sup>3</sup> , *<sup>α</sup>*<sup>3</sup> ], *NS* ∈ [*α*<sup>3</sup> , *<sup>α</sup>*<sup>3</sup> ], *ZO* ∈ [*α*<sup>3</sup> , *<sup>α</sup>*<sup>3</sup> ], *PS* ∈ [*α*<sup>3</sup> , *<sup>α</sup>*<sup>3</sup> ], *PM* ∈ [*α*<sup>3</sup> , *<sup>α</sup>*<sup>3</sup> ], *PB* ∈ [*α*<sup>3</sup> , *<sup>α</sup>*<sup>3</sup> ]; (2) Cross-track attitude angle error derivative is divided into seven fuzzy states as follows: *NB* ∈ [*α*<sup>4</sup> , *<sup>α</sup>*<sup>4</sup> ], *NM* ∈ [*α*<sup>4</sup> , *<sup>α</sup>*<sup>4</sup> ], *NS* ∈ [*α*<sup>4</sup> , *<sup>α</sup>*<sup>4</sup> ], *ZO* ∈ [*α*<sup>4</sup> , *<sup>α</sup>*<sup>4</sup> ], *PS* ∈ [*α*<sup>4</sup> , *<sup>α</sup>*<sup>4</sup> ], *PM* ∈ [*α*<sup>4</sup> , *<sup>α</sup>*<sup>4</sup> ], *PB* ∈ [*α*<sup>4</sup> , *<sup>α</sup>*<sup>4</sup> ].

**Figure 4.** Membership function of the cross-track position error.

**Figure 5.** Membership function of the corresponding derivative.

**Remark 2.** *Cross-track attitude angle errors include the cross-track roll, pitch, and yaw (heading) angle errors in the three-dimensional environment, cross-track attitude angle error is the heading angle error if just considering path tracking in the XOY plane, the definition is given in Section 2*.

#### *4.2. The Optimization for the Fuzzy Controller*

In this paper, fuzzy control converts a linguistic control strategy into an automatic controller capable of managing the AUV path-tracking system. The membership function greatly affects the performance of the fuzzy controller, whose parameters are usually obtained by the cut-and-trial method with many experiments. This takes a lot of time and increases the difficulty to obtain the optimal value. Therefore, an algorithm needs to optimize the controller to ensure the control performance.

PSO is a popular and efficient method to solve many different kinds of engineering optimization problems [33,34]. The PSO algorithm has been proven to be simple for formulation, easy for programming and has good convergence [35–38], this conclusion is verified for fuzzy controller optimization of AUV path tracking. The PSO algorithm simulates the foraging behavior of a flock of flying birds, the result is achieved through cooperation and competition between individuals in the flock. In the PSO algorithm, flying "birds" are simulated by particles without weight or volume, each potential solution is represented by one particle in the search space, and its "flight state" is denoted with both the velocity and position of the particle. The global optimal search is realized by the particles, which continuously learns from the group and neighborhood optimal solutions. The new particle position and velocity can be obtained as follows [39,40]:

$$\upsilon\_{\mathcal{P}}(k+1) = w\_{\mathcal{P}}\upsilon\_{\mathcal{P}}(k) + c\_1 r\_1 (B\_{\mathcal{P}} - \mathfrak{x}\_{\mathcal{P}}(k)) + c\_2 r\_2 (B\_{\mathcal{S}} - \mathfrak{x}\_{\mathcal{P}}(k)) \tag{17}$$

$$
\pi\_p(k+1) = \pi\_p(k) + v\_p(k+1)\tag{18}
$$

$$w\_p(k) = w\_{\max} - \frac{w\_{\max} - w\_{\min}}{N\_{\max}} N\_{iter}(k) \tag{19}$$

where *vp*(*k*) is the current velocity of one particle; *vp*(*k* + 1) is the new velocity of one particle; *k* is the *k*-th iteration; *wp* is the inertia weight; *c*<sup>1</sup> is the social acceleration for the local best position; *c*<sup>2</sup> is the cognitive acceleration for the global best position; *r*<sup>1</sup> and *r*<sup>2</sup> are random numbers between 0 and 1; *Bp* and *Bg* are the best solutions found by a particle and in a population, respectively; *xp*(*k*) is the current position; *xp*(*k* + 1) is the new position; *Nmax* is the maximum number of iterations; *Niter*(*k*) is the current number of iteration; and *wmax* and *wmin* are the initial and final inertia weight, respectively.

In this paper, the following function is given to optimize the fuzzy controller to improve the path-tracking performance.

$$F\_{TM} = f\_L + f\_S + f\_E \tag{20}$$

where *FTM* is the optimization performance index including *fL*, *fS* and *fE*; *fL* is the length of the tracking path; *fS* is the smoothness of the tracking path; and *fE* is the average crosstrack position error. To solve the multiple objective functions for path tracking, a weight coefficient method is presented to transform Equation (20) as follows:

$$F\_{TM} = \mathfrak{a}\lfloor f\_L \rfloor + \beta \lfloor f\_S \rfloor + \gamma \lfloor f\_E \rfloor \tag{21}$$

where *α*, *β*, *γ* are the weight coefficients; and *fL*, *fS*, *fE* are the normalized values of *fL*, *fS*, *fE* respectively.

#### (1) Tracking path length

The start and target points are (*x*0, *y*0, *z*0) and (*xT*, *yT*, *zT*) for the path, respectively, and *T* is the total number of the segments of the tracking path. The path can be expressed as follows: *A* = [(*x*0, *y*0, *z*0), ··· ,(*xt*, *yt*, *zt*), ··· ,(*xT*, *yT*, *zT*)].

The total length of the tracking path can be obtained as follows [22,41]:

$$f\_L = \sum\_{t=0}^{T} d(q\_{t\prime}q\_{t+1})\tag{22}$$

where *qt* = (*xt*, *yt*, *zt*) is one point of the tracking path at *t*, and *t* is the corresponding serial segment number. *d*(*qt*, *qt*+1) is the length from the adjacent point *qt* to *qt*+1, which can be calculated as follows:

$$d(q\_t, q\_{t+1}) = \sqrt{\left(\mathbf{x}\_{t+1} - \mathbf{x}\_t\right)^2 + \left(y\_{t+1} - y\_t\right)^2 + \left(z\_{t+1} - z\_t\right)^2} \tag{23}$$

#### (2) Tracking path smoothness

A virtual triangle is used to describe the path smoothness, which is composed of three adjacent points *qt*−1, *qt*, and *qt*+1. The cosine function is given to obtain the intersection angle for the AUV tracking path as follows.

$$\cos \kappa\_s = \frac{\overline{b}^2 + \overline{c}^2 - \overline{a}^2}{2\overline{b}\overline{c}} \tag{24}$$

$$f\_{\mathbb{S}}(A) = \sum\_{r=1}^{\mathbb{R}} \frac{1}{a\_{\mathbb{s}}} \, \Big|\, \qquad \qquad \qquad \mathfrak{a}\_{\text{min}} < \mathfrak{a}\_{\mathbb{s}} < \mathfrak{a}\_{\text{max}} \tag{25}$$

where *<sup>α</sup><sup>s</sup>* is the intersection angle with the corner vertex of *qt* (rad). <sup>1</sup>*a*, <sup>1</sup>*b*, and *<sup>c</sup>*<sup>1</sup> are the lengths of triangle sides with the angles of *αs*, *γs*, and *βs*, respectively. *β<sup>s</sup>* is the intersection angle with the corner vertex of *qt*−<sup>1</sup> (rad); and *γ<sup>s</sup>* is the intersection angle with the corner vertex of *qt*+<sup>1</sup> (rad). *fS*(*A*) is the AUV tracking path smoothness, the smaller *fS*(*A*), the better the path smoothness. *r* = 1, 2, 3 ··· *R*, *R* is the serial number of the corner for each turning point.

#### (3) Cross-track position error

The average of the total absolute of the cross-track position errors is given as a performance index, which is referred to simply as the average cross-track position error in this paper, calculated as follows:

$$f\_E = \frac{1}{T} \sum\_{t=0}^{T} |e\_t| \tag{26}$$

where *fE* is the average of the total |*et*|; *et* is one cross-track position error; and |*et*| denotes the absolute value of *et*.

Figure 6 shows the flowchart of the path tracking in light of the fuzzy controller with the PSO algorithm, algorithm 1 presents the path-tracking steps in detail.

#### **Algorithm 1: The path-tracking algorithm**

1: Establishing the AUV kinematic model (Equation (7)) and the dynamic model (Equation (10)), obtaining the optimization function (Equation (21)) for the fuzzy controller for path tracking; 2: Defining the rules for the fuzzy controller, setting the basic initial parameters of the triangle membership function;

3: Initializing the parameters including *c*1, *c*2, and so on;

4: Setting the AUV start point as *q*0, *t* = 0;

5. Obtaining the target point of the desired path (*qt*);

6: Calculating the errors and these derivatives of the input parameters of the fuzzy controller, executing fuzzification optimization;

7: Realizing the fuzzy inference based on the membership functions, executing the defuzzification operation;

8: Calculating the fitness functions of each particle based on Equation (21), obtaining the optimization particle position;

9: Updating the current velocity of each particle based on Equations (17)–(19);

10: If *Niter* is smaller than *Nmax*, go to the next step, else if, obtain the parameters of membership functions, setting *Niter* = *Niter* + 1, go to step 7;

11: Obtaining the tracking point *qt* based on the AUV kinematic and dynamic models, if *t* is smaller than *T*, setting *t* = *t* + 1, go to step 4, else if, go to the next step; 12: Obtain the optimal tracking path.

**Figure 6.** Flowchart for path tracking with the fuzzy controller.

#### **5. Results and Discussion**

In this section, a self-made "Ocean Star" AUV is used to illustrate the effectiveness of the proposed algorithm. Figure 7 gives the "Ocean Star" AUV and its configuration, the length is 400 mm, the width is 295 mm, and the high is 255 mm. Six thrusters are given to provide forces to control the AUV, Figure 7b shows the corresponding configuration.

**Figure 7.** The mechanical structure and physical drawing.

Different scenarios are given including straight line, sine, half-moon shape, Archimedean spiral, and practical paths tracking. For the PSO algorithm, the initial value of the inertia weight *wp* = 0.8, the social and cognitive accelerations are *c*<sup>1</sup> = 0.5 and *c*<sup>2</sup> = 0.2, respectively. In general, the fewer particles, the more iterations are required to obtain good optimization results. For example, the algorithm needs more than 100 iterations with 15 particles and 160 iterations with 10 particles to guarantee the optimization results. In this paper, the number of particles and the maximum number of iterations are good enough for the proposed algorithm with the settings as follows: the number of the particles is 20 for the group, the maximum number of iterations is 50. We set the weight coefficients as *α* = 0.3, *β* = 0.1, and *γ* = 0.6 for the optimization objective functions.

A desired straight line is given as follows: *x*(*t*1) = *t*<sup>1</sup> + 10, *y*(*t*1) = 2*t*<sup>1</sup> + 10, where *t*<sup>1</sup> ∈ [0, 60] (as shown in Figure 8). The straight line is discretized by the sequential discrete points [(10, 10, 0),(11.7, 13.3, 0), ··· ,(70, 130, 0)], and the corresponding start point is (10, 10, 0) [m]. The initial position, Euler angle, and velocity are set to (*x*, *y*, *z*)=(0, 0, 0) [m], (*ϕ*, *θ*, *φ*)=(0 ◦ , 0◦ , 0◦ ), (*u*, *v*, *w*)=(0, 0, 0) [kn], respectively. The desired velocity is set to (*u*, *v*, *w*)=(0.18, 0, 0) [kn]. Figure 8 shows the desired and tracking path curves, we can see that the tracking path coincides well with the desired path. The tracking path length is 141.46 m, smoothness is 982.4, and average cross-track position error is 0.078 m. Figure 9 shows the cross-track position error, Figure 10 shows the heading angle error. The cross-track position and heading angle errors become smaller and smaller over time. The cross-track position error is limited in the range of [−0.084 m, 0.037m], and the standard deviation is 0.007 m for path cross-track position errors calculated from the start to the target tracking points. The cross-track heading angle error is limited in the range of [−0.008 rad , 0.19 rad], and the standard deviation is 0.0045 rad for the cross-track heading angle errors calculated from the start to the target tacking points. The proposed fuzzy controller with the PSO algorithm can deal with straight line path tracking practically and effectively.

**Figure 8.** Path tracking results for the straight line.

**Figure 9.** Cross-track position error for the straight line.

**Figure 10.** Cross-track heading angle error for the straight line.

The desired sine curve path is given as follows: *x*(*t*2) = *t*2, *y*(*t*2) = 5 sin(*t*2*π*/40), where *t*<sup>2</sup> ∈ [0, 240], Figure 11 shows the corresponding curve. The sine curve is discretized by the sequential discrete points [(0, 0, 0),(2, 0.78, 0), ··· ,(240, 0, 0)], and the corresponding start point is (0, 0, 0) [m]. The initial position, Euler angle, and velocity are set to (*x*, *y*, *z*) = (−10, −1, 0) [m], (*ϕ*, *θ*, *φ*)=(0 ◦ , 0◦ , 0◦ ), and (*u*, *v*, *w*)=(0, 0, 0) [kn], respectively. The desired velocity is set to (*u*, *v*, *w*)=(0.18, 0, 0) [kn]. Figure 11 shows the tracking path by the proposed algorithm, the tracking path length is 259.52 m, smoothness is 1802.2, and average cross-track position error is 0.18 m. Figure 12 shows the cross-track position error, Figure 13 shows the cross-track heading angle error. The cross-track position error is limited in the range of [−0.79 m, 0.66 m], and the standard deviation is 0.25 m for the path-tracking position. The cross-track heading angle error is limited in the range of [−0.31 rad, 0.22 rad], and the standard deviation is 0.08 rad for the cross-track heading angle error. Although larger values are at the peaks and valleys of the cross-track position and heading angle errors, the tracking path still coincides well with the desired curve. The proposed fuzzy controller with the PSO algorithm can deal with sine curve path tracking practically and effectively.

**Figure 11.** Path-tracking results for the sine curve.

**Figure 12.** Cross-track position error for the sine curve.

**Figure 13.** Cross-track heading angle error for the sine curve.

The desired half-moon shape path is given as follows: *x*(*t*3) = 50 cos(*t*3), *y*(*t*3) = 50 sin(*t*3), where *t*<sup>3</sup> ∈ [−*π*/2, *π*/2]. *x*(*t*4) = 100 cos(*t*4) +100 cos(5*π*/6), *y*(*t*4) = 100 sin(*t*4), where *t*<sup>4</sup> ∈ [*π*/6, −*π*/6]. Figure 14 shows the half-moon shape path, which is discretized by the sequential discrete points [(0, −50, 0),(0.7854, −49.9938, 0), ··· ,(0, −50, 0)]. The start and target points are all at (0, −50, 0) [m] for the desired path, the AUV moves along the half-moon shape in an anti-clockwise direction. The initial position, Euler angle, and velocity are set to (*x*, *y*, *z*)=(−10, −60, 0) [m], (*ϕ*, *θ*, *φ*)=(0 ◦ , 0◦ , 0◦ ), and (*u*, *v*, *w*)=(0, 0, 0) [kn], respectively. The desired velocity is set to (*u*, *v*, *w*)=(0.18, 0, 0) [kn]. Figure 14 shows the tracking path by the proposed algorithm, the red curve coincides well with the desired path. The tracking path length is 278.38 m, smoothness is 1931.5, and average cross-track position error is 0.17 m. Figures 15 and 16 show the cross-track position and heading angle errors, respectively. The standard deviation is 0.38 m for the path cross-track position calculated from the start to the target tracking points. The standard deviation is 0.11 rad for the cross-track heading angle error calculated from the start to the target tracking point. The proposed fuzzy controller algorithm can deal with the half-moon shape path tracking practically and effectively.

**Figure 14.** Tracking results for the half-moon shape.

**Figure 15.** Cross-track position error for the half-moon shape.

**Figure 16.** Cross-track heading angle error for the half-moon shape path.

Some comparison results are given to make an in-depth analysis of the path-tracking simulation results. A desired Archimedean spiral path is given as follows: *x*(*t*5)=(5*t*<sup>5</sup> cos(*t*5)), *y*(*t*5) = 40 + (5*t*<sup>5</sup> sin(*t*5)), where *t*<sup>5</sup> ∈ [1.5*π* : 4.1*π*]. Figure 17a shows the Archimedean path, which is discretized by the sequential discrete points [(0, 16.44, 0) [m], (2.26, 16.0, 0) [m], ··· ,(61.25, 59.9, 0) [m]], the corresponding start point is (0, 16.44, 0) [m]. It should be noted that Figure 17b is a partial enlargement of Figure 17a. The initial position, Euler angle, and velocity are set to (*x*, *y*, *z*) = (−3, 16, 0) [m],(*ϕ*, *θ*,*φ*)=(0 ◦ , 0◦ , 0◦ ), and (*u*,*v*,*w*)=(0, 0, 0) [kn], respectively. The desired velocity is set to (*u*,*v*,*w*)=(0.34, 0, 0) [kn]. Figures 18 and 19 show the comparison tracking results between the proposed algorithm, fuzzy control method (using only fuzzy logic), and the traditional method (PID algorithm). Table 2 gives the corresponding comparison with some performance indexes. The tracking path length is 360.9 m, smoothness is 1353, and average cross-track position error is 0.05 m by the proposed algorithm. The tracking path length is 361.2 m, smoothness is 1355, and average cross-track position error is 0.06 m by the fuzzy control method. The tracking path length is 361.8 m, smoothness is 1357, and average cross-track position error is 0.09 m by the traditional method. Figure 18 shows the cross-track position error for the Archimedean spiral. The fluctuating range of the error curve by the proposed algorithm is smaller than the fuzzy control and traditional methods. The standard deviations of the cross-track position errors are 0.065 m, 0.078 m, and 0.113 m by the proposed, fuzzy control, and traditional methods, respectively. The proposed algorithm obtains better tracking results compared with the fuzzy control and traditional methods.

**Figure 17.** (**a**). Path-tracking results for Archimedean spiral. (**b**) Partial enlargement for the tracking path.

**Figure 18.** Cross-track position error for the Archimedean spiral.

**Figure 19.** Cross-track heading angle error for the Archimedean spiral.



Figures 20 and 21 show a desired path in the real environment of our university. The length and width are obtained for a man-made river with an irregular polygon shape based on a diastimeter. The desired path is the line with a distance of 1 m from the riverbank to the AUV's center. As shown in Figure 21, we establish the coordinate system (*XOY*), and select a point of the bottom left corner of the river as the origin. The AUV start and target positions are at the same point (*x*, *y*, *z*)=(44.7, 1, 0) [m], and the AUV moves along the path in a clockwise direction. The initial Euler angle is (*ϕ*, *θ*, *φ*)=(180◦ , 0◦ , 0◦ ), the initial velocity is (*u*, *v*, *w*)=(0, 0, 0) [kn], and the desired velocity is (*u*, *v*, *w*)=(0.18, 0, 0) [kn]. Figure 21 shows the tracking results, the tracking path length is 99.14 m, smoothness is 633.59, and average cross-track position error is 0.05 m. Figure 22 shows the cross-track position error, and the standard deviation is 0.1 m of the cross-track position errors. Figure 23 shows the cross-track heading angle error, and the standard deviation is 0.04 of the cross-track

heading angle errors. Results show that the AUV can follow the path effectively by the proposed algorithm.

**Figure 20.** The desired path in a real man-made river.

**Figure 21.** The path tracking in the real man-made river.

**Figure 22.** Cross-track position error for the AUV.

**Figure 23.** Cross-track heading angle error for the AUV.

#### **6. Conclusions**

AUV path tracking is important to realize for AUV application in numerous missions for the exploration of marine resources. In this paper, a fuzzy controller was designed with multiple performance optimizations to complete path tracking. Based on the established AUV kinematic and dynamic models, we selected the path length, smoothness and crosstrack position error as the objective functions of the optimization problem for the fuzzy controller. The PSO algorithm was used to optimize the membership function. We gave the straight line, sine curve, half-moon shape, Archimedean spiral, and practical paths to test the fuzzy controller's performance for path tracking. The test results showed that the AUV effectively tracked the desired path using the proposed algorithm. Compared to the traditional algorithm, the designed controller made the path-tracking system perform well with better tracking accuracy, better smoothness and a shorter length using the proposed algorithm.

In the near future, we are interested in improving the path-tracking performance by incorporating salient features such as sliding mode control, deep reinforcement learning, and so on. Collaborative work on multiple AUVs is an important way to efficiently accomplish these missions, of which the key factor is how to accurately track multiple paths. Therefore, providing a method for multiple AUV path tracking is also our next work.

**Author Contributions:** Conceptualization, Q.T. and T.W.; methodology, Q.T.; software, T.W.; validation, Q.T., Y.W., Y.S. and B.L.; formal analysis, Q.T.; investigation, Q.T. and T.W.; resources, Y.W.; data curation, Y.S.; writing—original draft preparation, Q.T.; writing—review and editing, Y.W.; visualization, Y.S.; supervision, B.L.; project administration, B.L.; funding acquisition, Y.W. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the China Post-doctoral Science Foundation (2022M710934), Post-doctoral Applied Research Project of Qingdao City, and the Project of Shandong Province Higher Educational Young Innovative Talent Introduction and Cultivation Team (Intelligent Transportation Team of Offshore Products).

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

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