# Riverbank Following Planner (RBFP) for USVs Based on Point Cloud Data
## 3 Methodology of RBFP
### Controller Design  
For the controller design of the USV, we have adopted the Proportional-Integral-Derivative (PID) for feedback control [39]. Following comprehensive testing in the Virtual RobotX high-fidelity simulation environment, our USV demonstrated strong performance in all these areas. Therefore, we can assert that the PID controller design we have adopted is highly effective for the motion control of USV. A PID controller in Figure 3 continuously calculates an error signal \(e(t)\) by the difference between the reference signal \(r(t)\) and a measurement \(y(t)\) and then the sum of proportional, integral, and derivative terms as the feedback signal \(u(t)\). The USV distance from the riverbank is defined as \(d_{0}\), and the angle between the first LiDAR line and the riverbank is set as \(\theta_{0}\) during riverbank scans. As described in Figure 4,  
Figure 3: PID Controller. when the relative distance between USV and the riverbank is greater than or less than \(d_{0}\), PID control helps the USV maintain the required linear velocity and angular velocity of the relative distance between the USV and the riverbank. After rapid adjustment, the path planning is continued according to the shape of the riverbank after the regression to the relative distance \(d_{0}\). For instance, the reference signal for each control loop is the \(e_{v}\) and \(e_{\omega}\). The measurement is the estimated speed and yaw angle of the USV using the onboard sensors. The feedback signal is the setpoint of the linear velocity and angular velocity. In our implementation, the PID controller is implemented to track the yaw speed error setpoint \(\theta_{sp}\) and the velocity setpoint \(v_{sp}\). Since the controller is formulated on the body frame, we omit the prefix of the coordinate frame. Let \(\theta\in\mathbb{R}\) and \(v_{usv}\in\mathbb{R}^{2}\) in world frame \(\{\mathcal{W}\}\) represent the velocity and heading of the USV. The error of yaw speed and velocity that need to be compensated is denoted as  
\[e_{v}(t) =v_{sp}(t)-v_{usv}(t) \tag{6}\] \[e_{\omega}(t) =\theta_{sp}(t)-\theta_{usv}(t) \tag{7}\]  
To compensate for the error, we implement PID controllers to track the error, which are denoted as  
\[u_{v}(t) =K_{\text{p2}}e_{v}+K_{\text{i2}}\int_{0}^{t}e_{v}(\tau)\text{d} \tau+K_{\text{d2}}\frac{\text{d}e_{v}}{\text{d}t} \tag{8}\] \[u_{\omega}(t) =K_{\text{p1}}e_{\omega}+K_{\text{i1}}\int_{0}^{t}e_{\omega}( \tau)\text{d}\tau+K_{\text{d1}}\frac{\text{d}e_{\omega}}{\text{d}t} \tag{9}\]  
where \(K_{p1}\), \(K_{\text{i1}}\), \(K_{\text{d1}}\), \(K_{\text{p2}}\), \(K_{\text{i2}}\), \(K_{\text{d2}}\) are parameters of the PID controller. For differential thrust with fixed two aft thrusters configuration, the simplified differential drive-based equations of motion of the USV are written as [40]  
\[v_{usv} =\alpha(T_{r}+T_{\ell}) \tag{10}\] \[\omega_{usv} =\beta(T_{r}-T_{\ell}) \tag{11}\]  
where \(T_{r}\) and \(T_{\ell}\) represent the proportion thrust of the right engine and left engine, respectively. \(\alpha\) and \(\beta\) are scaling coefficients, depending on the size of the USV and the distance between the two engines. However, the model (10) and (11) is not natural to understand how fast the USV is moving and turning. Then, we represent the motion of the USV using wheel velocities in terms of variables \(v\) and \(\omega\) by algebraic operations in order to intuitively allocate motion control. The inverse kinematics of the USV is denoted as  
Figure 4: PID controller solves the USV path deviation. \[T_{r} =\frac{\beta v_{usv}+\alpha\omega_{usv}}{2\alpha\beta} \tag{12}\] \[T_{\ell} =\frac{\beta v_{usv}-\alpha v_{usv}}{2\alpha\beta} \tag{13}\]  
The motion control mixer maps the linear velocity and angular rate of the USV to proportion thrusts based on our USV configuration. The thrust command is proportional to the pulse-width modulation (PWM) setpoint.