# PK-APF: Path-Keeping Algorithm for USVs Based on Artificial Potential Field
## 3 Experiments
### MATLAB Implementation
#### 3.1.1 Path Planning with Local Minimum Point  
When the obstacle is on the line between the start point and the goal point, the traditional APF will fall into the local minimum point because the attractive force of the goal point near the obstacle is equal to the repulsive force of the obstacle but in the opposite direction. As a result, the USV has zero resultant force at the local minimum point and cannot continue to move to the goal point. Under the action of the attractive force field, the USV begins to sail in the direction of goal point. Figure 4a shows a 30 \(\times\) 30 m map and obstacles set at _(10,10)_ and _(20,20)_; thus, the USV falls into a local minimum point because the resultant force of the USV is zero when it is close to the first obstacle. Each point in Figure 4b represents the magnitude value of resultant attractive force by the goal point and virtual foot points. The main reason for the larger values of _(0,30)_ and _(30,0)_ are that this position is furthest from the original \begin{table}
\begin{tabular}{l l l l l} \hline \hline  & **Variable** & **Value** & **Variable** & **Value** \\ \hline \multirow{3}{*}{Planner} & \(r_{0}\) [m] & 2.0 & \(\eta\) [1] & 0.03 \\  & \(\kappa\) [1] & 8.0 & \(\mu_{u}\) [1] & 70 \\ \cline{1-1}  & \(\xi\) [1] & 3.0 & \(\mu_{l}\) [1] & 4 \\ \cline{1-1}  & \(\text{Start}\) [m m] & [0 0] & Goal [m m] & [30 30] \\ \hline \hline \end{tabular}
\end{table} 
Table 1: MATLAB simulation parameters setting. Figure 3: Temporal force to avoid local minimum point. planned path, and virtual foot points provide attractive forces to help the USV return to the original path. The white area in Figure 4c is the location of obstacles, and the direction of the repulsive force of the obstacle is 360 degrees. The color bar in Figure 4 represents the magnitude of three forces, respectively. The attractive force provided by the goal point, the attractive force provided by the virtual foot points, the repulsive force provided by the obstacle, and the resultant force are calculated by Equations (2), (4), (3), and (1), respectively. Figure 5 shows the planning path of PK-APF and APF algorithms with temporal force. In Figure 5a, we add temporal force to the USV when it falls into a minimum point; thus, APF can escape from the local minimum point and reach the goal point successfully. However, after being affected with the repulsive force of the obstacle, APF cannot return to the original path to achieve the high-precision path-keeping. In the vicinity of the first obstacle, due to the repulsive force, the USV moves out of the repulsive force influence range and sails in the attractive force direction of the goal point. When approaching the second obstacle, the USV continues to deviate from the original path due to the repulsive force of the second obstacle, as can be seen from time step \(2.5\times 10^{4}\) in Figure 6.  
Figure 5b shows the planned path of PK-APF with temporal force; the USV escapes the balance of forces by temporal forces when it is at the local minimum point. Meanwhile, after escaping from the local minimum point, the USV deviates from the path to avoid obstacles. By setting up virtual goal points, the USV is guided to approach the original path  
Figure 4: APF path planning and local minimum point. Figure 5: Path planning with temporal force. (**a**) APF path planning with temporal force; (**b**) PK-APF path planning with temporal force. to achieve high-precision path-keeping. As the repulsive force of the obstacle is related to the distance to the goal point, the repulsive force of the second obstacle is reduced because it is close to the goal point. Thus, the deviation distance of the USV is reduced compared with that near the first obstacle. Further, the virtual foot points provide attractive force to guide the USV's return to the original planned path, and the maximum deviation is reduced compared to APF.