# Adaptive Trajectory Tracking Control for
## 3 Trajectory Tracking Control Design  
The sliding mode control (SMC) algorithm is first proposed by [PERSON] in the early 1950s [33], and its advantages are that the algorithm is simple, less computational and has a strong robustness. With the efforts of scientific research all over the world, SMC is gradually applied to the control of robots [34], aircrafts [35], ships [36] and so on. In this section, surge control law and yaw control law are proposed based on a first-order sliding mode and a second-order sliding mode, respectively. First, define the trajectory tracking error variables:  
\[\left\{ \begin{array}{rcl}x_{e}&=&x-x_{d}\\ y_{e}&=&y-y_{d}\end{array} \right. \tag{4}\]  
Taking the time derivative of (4) along (1) produces  
\[\left[ \begin{array}{rcl}\dot{x}_{e}\\ \dot{y}_{e}\end{array} \right]~{}=~{}\left[ \begin{array}{rcl}\cos\psi&-\sin \psi\\ \sin\psi&\cos\psi\end{array} \right]\left[ \begin{array}{rcl}u\\ v\end{array} \right]-\left[ \begin{array}{rcl}\dot{x}_{d}\\ \dot{y}_{d}\end{array} \right] \tag{5}\]  
Then, define the velocity tracking error variables:  
\[\left\{ \begin{array}{rcl}u_{e}&=&u-u_{d}\\ v_{e}&=&v-v_{d}\end{array} \right. \tag{6}\]  
where \((u_{d},v_{d})\) are the desired surge velocity and sway velocity. **Assumption 2**. : _The tracked trajectory is required to be smooth enough. \(\dot{u}_{d}\), \(\dot{v}_{d}\), \(\dot{x}_{d}\), \(\ddot{x}_{d}\), \(\dot{y}_{d}\) and \(\ddot{y}_{d}\) are all bounded._  
Consider the following reference trajectory  
\[\left\{ \begin{array}{rcl}x_{d}&=&m(t)+D_{1}\\ y_{d}&=&n(t)+D_{2}\end{array} \right. \tag{7}\]  
where \(m(t)\) and \(n(t)\) are continuous time-varying functions, and \(D_{1}\) and \(D_{2}\) are two constants. Meanwhile, according to [37], the desired surge velocity and sway velocity are related to \((x_{d},y_{d})\), and they can be represented as  
\[\left\{ \begin{array}{rcl}u_{d}&=&\cos\dot{\psi}\dot{x}_{d}+\sin\psi\dot{y}_{ d}\\ v_{d}&=&-\sin\psi\dot{x}_{d}+\cos\psi\dot{y}_{d}\end{array} \right. \tag{8}\]  
In this paper, the method to track the reference trajectory is to design the control law to make the \((u_{e},v_{e})\) converge, and then the convergence of \((x_{e},y_{e})\) is achieved. Therefore, we assume that \((u_{d},v_{d})\) is related to \((x_{d},y_{d})\) and \((x_{e},y_{e})\), which can be represented as  
\[\left\{ \begin{array}{rcl}u_{d}&=&\cos\psi\dot{x}_{d}+\sin\psi\dot{y}_{d}-k \cos\psi x_{e}-k\sin\psi y_{e}\\ v_{d}&=&-\sin\psi\dot{x}_{d}+\cos\psi\dot{y}_{d}+k\sin\psi x_{e}-k\cos\psi y_ {e}\end{array} \right. \tag{9}\]  
where \(k\) is a positive parameter. By simplifying (1), we can get that  
\[\left\{ \begin{array}{rcl}u&=&\cos\psi\dot{x}+\sin\psi\dot{y}\\ v&=&-\sin\psi\dot{x}+\cos\psi\dot{y}\end{array} \right. \tag{10}\]  
Based on (9) and (10), (6) can be re-expressed as  
\[\left[ \begin{array}{rcl}u_{e}\\ v_{e}\end{array} \right]&=&\left[ \begin{array}{rcl}\cos\psi&\sin\psi\\ -\sin\psi&\cos\psi\end{array} \right]\left[ \begin{array}{rcl}\dot{x}_{e}+kx _{e}\\ \dot{y}_{e}+ky_{e}\end{array} \right] \tag{11}\]  
At the same time, the derivative of \(u_{d}\) and \(v_{d}\) can be represented as  
\[\left\{ \begin{array}{rcl}\dot{u}_{d}&=&\cos\psi\dot{x}_{d}+\sin\psi\dot{y}_ {d}+v_{d}r-k\cos\psi\dot{x}_{e}-k\sin\psi\dot{y}_{e}\\ \dot{v}_{d}&=&-\sin\psi\dot{x}_{d}+\cos\psi\dot{y}_{d}-u_{d}r+k\sin\psi\dot{x} _{e}-k\cos\psi\dot{y}_{e}\end{array} \right. \tag{12}\]  
Taking the time derivative of (11) along (2) and (12) produces  
\[\left[ \begin{array}{rcl}\dot{u}_{e}\\ \dot{v}_{e}\end{array} \right]&=&\left[ \begin{array}{rcl}rv_{e}\\ -ru_{e}\end{array} \right]+\left[ \begin{array}{rcl}\cos\psi&\sin\psi\\ -\sin\psi&\cos\psi\end{array} \right]\left[ \begin{array}{rcl}\dot{x}_{e}+k \dot{x}_{e}\\ \dot{y}_{e}+ky_{e}\end{array} \right] \tag{13}\]  
In the following subsection, surge control law \(\tau_{u}\) and yaw control law \(\tau_{r}\) will be designed to stabilise the velocity tracking errors \(u_{e}\) and \(v_{e}\), respectively.