## 3 LOS Guidance Algorithms
### Problem Formulation  
From Figure 2, \((x,y)\) stands for the coordinates of USV in the Earth-fixed inertial frame. In this article, we consider the path-following task at the kinematic level and assume that the speed can be manually or automatically controlled. The resultant speed of the USV is the vector sum of \(u\) and \(v\)\(U=\sqrt{u^{2}+v^{2}}\) and \(U_{\rm min}\leq U\leq U_{\rm max}\), \(U_{\rm min}>0\). Consider a geometric path \((x_{p}(\theta),y_{p}(\theta))\) as the reference path, where \(\theta\) is an independent variable. The along-track error and the cross-track error are computed as the orthogonal distance to the path-tangential reference frame defined by the point \((x_{p}(\theta),y_{p}(\theta))\). Hence:  
\[\left[\begin{array}{c}x_{e}\\ y_{e}\end{array}\right]=R^{T}(\gamma_{p})\left[\begin{array}{c}x-x_{p}( \theta)\\ y-y_{p}(\theta)\end{array}\right] \tag{11}\]  
\[R(\gamma_{p})=\left[\begin{array}{cc}\cos(\gamma_{p})&-\sin(\gamma_{p})\\ \sin(\gamma_{p})&\cos(\gamma_{p})\end{array}\right] \tag{12}\]  
where \(R(\gamma_{p})\in SO(2)\) is the rotation matrix in yaw.  
\[\gamma_{p}(\theta)=arc\tan(y_{p}^{\prime}(\theta),x_{p}^{\prime}(\theta)) \tag{13}\]  
where \(x_{p}^{\prime}(\theta)=\partial x_{p}/\partial_{\theta}\) and \(y_{p}^{\prime}(\theta)=\partial y_{p}/\partial_{\theta}\). Note that for a straight line, \(\gamma_{p}=arc\tan(y_{j+1}-y_{j},x_{j+1}-x_{j})\) is a constant between the waypoints. The equations of the along- and the cross-track errors for a given vehicle position \((x,y)\) become:  
\[\left\{\begin{array}{c}x_{e}=(x-x_{p}(\theta))\cos(\gamma_{p})+(y-y_{p}( \theta))\sin(\gamma_{p})\\ y_{e}=-(x-x_{p}(\theta))\sin(\gamma_{p})+(y-y_{p}(\theta))\cos(\gamma_{p})\end{array}\right. \tag{14}\]  
where \(x_{e}\) represents the along-tracking error and \(y_{e}\) is the cross-tracking error. Differentiating \(x_{e}\) and \(y_{e}\) along (14) gives:  
\[\dot{x}_{e}=U\cos(\psi-\gamma_{p}+\beta)+\dot{\gamma}_{p}y_{e}-U_{p} \tag{15}\]  
where \(\beta=arc\tan(v,u)\) denotes the sideslip angle and \(U_{p}\) is the virtual reference speed to stabilize \(x_{e}\).  
\[\dot{y}_{e}= -(\dot{x}-\dot{x}_{p}(\theta))\sin(\gamma_{p})-(x-x_{p}(\theta)) \cos(\gamma_{p})\dot{\gamma}_{p}\] \[+(\dot{y}-\dot{y}_{p}(\theta))\cos(\gamma_{p})-(y-y_{p}(\theta)) \sin(\gamma_{p})\dot{\gamma}_{p}\] \[= u\sin(\psi-\gamma_{p})+v\cos(\psi-\gamma_{p})+\underbrace{\dot{x }_{p}(\theta)\sin(\gamma_{p})-\dot{y}_{p}(\theta)\cos(\gamma_{p})}_{n_{1}}\] \[+\dot{\gamma}_{p}\underbrace{((x-x_{p}(\theta))\cos(\gamma_{p})+ (y-y_{p}(\theta))\sin(\gamma_{p}))}_{x_{e}} \tag{16}\]  
\(n_{1}\) can be rewritten as \(n_{1}=\dot{\theta}\sqrt{x^{\prime}(\theta)^{2}+y^{\prime}(\theta)^{2}}\sin( \gamma_{p}+\phi)\); where \(\phi=\arctan(-y^{\prime}(\theta),x^{\prime}(\theta))=-\gamma_{p}\).  
**Assumption 4**.: _Assume that \(\beta\) is small, so \(\sin(\beta)=\beta\) and \(cos(\beta)=1\). During path following, we can view \(\beta\) as a constant, so \(\dot{\beta}=0\)._  
Based on the conclusions above, we can get that:  
\[\dot{y}_{e}=U\sin(\psi-\gamma_{p})+U\cos(\psi-\gamma_{p})\beta \tag{17}\]  
The goal of the design is to put forward an ALOS guidance strategy, which can make the underactuated USV follow the desired geometric path \((x_{p}(\theta),y_{p}(\theta))\). Meanwhile, the unknown sideslip angle is compensated in real time, which is inevitable. It is worth mentioning that the ultimate goal of path following is to achieve \(x_{e}\to 0\) and \(y_{e}\to 0\) as \(t\rightarrow\infty\).