# Research on Obstacle Avoidance Replanning and Trajectory Tracking Control Driverless Ferry Vehicles
## 4 Obstacle Avoidance Algorithm and Transverse Controller Design
### Design of MPC Controller with Planning Module  
#### 4.2.1 Trajectory Planning Layer Design  
In this study, a new trajectory planning and tracking controller was obtained by adding a planning module to the MPC trajectory tracking controller. The added trajectory planning layer meets the following three conditions:  
1. The deviation between the desired trajectory of the vehicle obtained by the planning module and the reference trajectory obtained by the global planning should be as small as possible. 2. The expected trajectory obtained by the planning module should meet the dynamic constraints of the ferry vehicle. 3. The added trajectory planning module should be able to avoid obstacles. The most important content in the trajectory planning module is the trajectory replanning algorithm. The main function of the trajectory replanning algorithm is to design a  
Figure 15: Estimation results of tire cornering stiffness under different road adhesion coefficients. reasonable evaluation function, which can realize the obstacle avoidance function of the driverless ferry vehicle when the evaluation function satisfies various constraint conditions. And, in the whole tracking control process, the deviation between the driverless ferry and the global reference trajectory is as small as possible. (1) Obstacle avoidance function  
The obstacle avoidance function used for the thesis modifies the function value's magnitude based on the variation in the distance between the obstacle point and the ferry vehicle. Specifically, as the distance increases, the function value decreases; conversely, as the distance decreases, the function value increases. The following formula is the obstacle avoidance function:  
\[J=\frac{S_{wf}v_{obs}}{\left(x_{\text{obs}}-x_{0}\right)^{2}+\left(y_{\text{ obs}}-y_{0}\right)^{2}+\xi} \tag{23}\]  
where \(S_{wf}\) is the weight coefficient; \(v_{ego}=v_{x}^{2}+v_{yy}^{2}\) in the vehicle coordinate system, the obstacle point's coordinate is \(\left(x_{i},x_{y}\right)\); \(\left(x_{0},y_{0}\right)\) is the vehicle centroid coordinate; and \(\xi\) is a little positive number that prevents the denominator from being 0. By adjusting the weight coefficient in the formula to make the ferry avoid obstacles, The greater the weighting coefficient's value, the more conservative the results behave, which will cause the planned path to avoid obstacles. When there are no obstacles on the road, the function will not have any impact on the planning [20]. (2) Point-mass model  
Considering the control effect of the algorithm and the calculation speed, the planning module uses a point-mass model that treats the entire vehicle as a point with mass. [21]. For the mass vehicle dynamics model of the driverless ferry vehicle point, the resultant transverse and longitudinal forces of the ferry tire should satisfy the constraint of the friction circle. \[F_{x}^{2}+F_{y}^{2}\leq(k\mu F_{z})^{2} \tag{24}\]  
where \(k\) is the proportionality factor, and \(k\leq 1\), limiting the tire friction saturation. The vehicle point mass model is as follows:  
\[\left\{ \begin{array}{l}\ddot{y}=a_{y}\\ \ddot{x}=0\\ \dot{\varphi}=\frac{a_{y}}{\dot{x}}\\ \dot{Y}=\dot{x}\sin\varphi+\dot{y}\cos\varphi\\ \dot{x}=x\cos\varphi-\dot{y}\sin\varphi\end{array} \right. \tag{25}\]  
After considering the dynamic constraints of the vehicle, the constraints are added, as shown below:  
\[\left|a_{y}\right|<ug \tag{26}\]  
Finally, the point mass model can be simplified as follows:  
\[\dot{\xi}(t)=f(\xi(t),\mu(t)) \tag{27}\]  
\[\left|\mu(t)\right|<\mu g \tag{28}\]  
In the formula, \(\xi=\left[\dot{y},\dot{x},\dot{\varphi},Y,X\right]^{T}\), and there are a total of five state variables, namely the speed of the ferry vehicle on the \(y\) and \(x\) axes, the heading angle of the ferry vehicle, the longitudinal position of the ferry vehicle, and the lateral position of the ferry vehicle. In addition, \(u\) is the control quantity.