## 3 Controller Design
### Design of Virtual Velocities  
Usually, the aim of trajectory tracking control is to make the actual trajectory follow the reference trajectory by adjusting the controller according to the position error. In order to construct the Lyapunov function according to the position error equation and the design, a suitable control expression to satisfy the Lyapunov stability theory to achieve trajectory  
Figure 1: Earth-fixed \(O-X_{o}Y_{o}\) and body-fixed \(A-XY\) coordinate frames of a USV.  
tracking, the actual position, and the reference position are calculated to obtain the position error equation.  
\[\left[\begin{array}{c}x_{e}\\ y_{e}\end{array}\right]=\left[\begin{array}{c}x-x_{d}\\ y-y_{d}\end{array}\right] \tag{9}\]  
where \((x,y)\), \((x_{d},y_{d})\), \((x_{e},y_{e})\) are the USV time-varying actual trajectory coordinates, reference trajectory coordinates, and error trajectory coordinates, respectively.  
The derivation of the two sides of Equation (9) with respect to time \(t\) can be obtained.  
\[\left[\begin{array}{c}\dot{x}_{e}\\ \dot{y}_{e}\end{array}\right]=\left[\begin{array}{c}\dot{x}-\dot{x}_{d}\\ \dot{y}-\dot{y}_{d}\end{array}\right]=\mathbf{J}\left[\begin{array}{c}u\\ v\end{array}\right]-\left[\begin{array}{c}\dot{x}_{d}\\ \dot{y}_{d}\end{array}\right] \tag{10}\]  
where \(\mathbf{J}=\left[\begin{array}{cc}\cos(\psi)&-\sin(\psi)\\ \sin(\psi)&\cos(\psi)\end{array}\right]\).  
In order to devise the controller based on the dynamic equation, the virtual speed is defined as follows:  
\[\left[\begin{array}{c}u_{d}\\ v_{d}\end{array}\right]=\mathbf{J}^{\mathbf{T}}\left[\begin{array}{c}\dot{x }_{d}+b_{x}\text{tanh}(-\frac{a_{x}}{b_{x}}x_{e})\\ \dot{y}_{d}+b_{y}\text{tanh}(-\frac{a_{y}}{b_{y}}y_{e})\end{array}\right] \tag{11}\]  
where \(a_{x}\) and \(a_{y}\) are positive numbers, and \(b_{x}\), \(b_{y}\
eq 0\).  
The position error converges to \((0,0)\) when the actual velocity satisfies the defined virtual velocity. The velocity error is defined in the same way as the position error:  
\[\left[\begin{array}{c}e_{u}\\ e_{v}\end{array}\right]=\left[\begin{array}{c}u\\ v\end{array}\right]-\left[\begin{array}{c}u_{d}\\ v_{d}\end{array}\right] \tag{12}\]  
where \(\left[\begin{array}{c}u\\ v\end{array}\right]=\mathbf{J}^{\mathbf{T}}\left[\begin{array}{c}\dot{x}\\ \dot{y}\end{array}\right]\). Then the velocity errors can be calculated as:  
\[\left[\begin{array}{c}e_{u}\\ e_{v}\end{array}\right]=\mathbf{J}^{\mathbf{T}}\left[\begin{array}{c}\dot{x }_{e}-b_{x}\text{tanh}(-\frac{a_{x}}{b_{x}}x_{e})\\ \dot{y}_{e}-b_{y}\text{tanh}(-\frac{a_{y}}{b_{y}}y_{e})\end{array}\right] \tag{13}\]  
When the velocity error converges to \((0,0)\), the position error satisfies the following expression:  
\[\left\{\begin{array}{c}\dot{x}_{e}=b_{x}\text{tanh}(-\frac{a_{x}}{b_{x}}x_{ e})\\ \dot{y}_{e}=b_{y}\text{tanh}(-\frac{a_{y}}{b_{y}}y_{e})\end{array}\right. \tag{14}\]  
Therefore, the following Lyapunov function can be defined according to the position error.  
\[V_{1}=\frac{1}{2}x_{e}^{2}+\frac{1}{2}y_{e}^{2} \tag{15}\]  
The time derivative of \(V_{1}\) is  
\[\dot{V}_{1}=x_{e}\dot{x}_{e}+y_{e}\dot{y}_{e}=-x_{e}b_{x}\text{tanh}(\frac{a_ {x}}{b_{x}}x_{e})-y_{e}b_{y}\text{tanh}(\frac{a_{y}}{b_{y}}y_{e})\leq 0 \tag{16}\]  
It can be seen that Inequality (16) is semi-negative definite, and the position error converges asymptotically, which means that when the speed error converges to \((0,0)\), the position error also converges to \((0,0)\).