**1. Introduction**

In the wake of sustained growth within the maritime and shipbuilding industries, the significance of oceanic transport has become increasingly conspicuous. According to estimations by the International Maritime Organization (IMO), approximately 90% of global commerce is conducted via sea transportation [1]. Nevertheless, ship collision incidents are becoming progressively prevalent. The prevention of inter-ship collisions and the avoidance of surface obstacles are integral components of successful navigation. Statistical data regarding ship collisions reveal that human factors are the primary cause, with approximately 96% of accidents attributed to human error [2]. In an effort to mitigate such errors, autonomous vessels supporting intelligent navigation have garnered significant interest, with automatic collision avoidance and path planning constituting a pivotal challenge in the development of intelligent ships [3]. Path-planning technology directly influences the degree of vessel intelligence. In accordance with the International Regulations for Preventing Collisions at Sea (COLREGs) [4], vessels must continually adapt their collision avoidance and obstacle evasion plans during navigation, adjusting the obstacle trajectory accordingly [5]. Consequently, it is imperative to investigate a swift and effective path-planning method for implementation in autonomous ship control systems [6].

Currently, prevalent ship path-planning and collision avoidance algorithms include APF, genetic algorithm (GA) [7], ant colony optimization (ACO) [8], particle swarm optimization (PSO), model predictive control, and deep reinforcement learning, among others [9]. However, these methods have certain limitations in practical applications. For instance, while the APF method is simple and easy to implement, it is prone to local

**Citation:** Li, M.; Li, B.; Qi, Z.; Li, J.; Wu, J. Optimized APF-ACO Algorithm for Ship Collision Avoidance and Path Planning. *J. Mar. Sci. Eng.* **2023**, *11*, 1177. https:// doi.org/10.3390/jmse11061177

Academic Editor: Mihalis Golias

Received: 11 May 2023 Revised: 29 May 2023 Accepted: 2 June 2023 Published: 4 June 2023

**Copyright:** © 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

optima [10]; the GA is suitable for handling complex mathematical models and nonlinear constraint problems but has higher computational complexity [11]. Consequently, researchers often improve or combine multiple methods to overcome their respective drawbacks and enhance path planning and collision avoidance performance.

Numerous scholars have achieved significant advancements in the fusion and optimization of various path-planning algorithms. Xia Chen et al. [12] addressed the shortcomings of the rapidly exploring random tree star (RRT\*) algorithm, such as slow convergence speed and large randomness in the search range, by proposing a UAV trajectory planning method based on a goal-biased APF-RRT\* algorithm. This method employs a goal-biased strategy to guide the generation of random sampling points, accelerating the convergence speed of the algorithm, and introduces an improved APF method into the random search tree to significantly reduce the number of iterations, generate higher quality new nodes, and decrease path length. M. F. D. Santos et al. [13] addressed the issue of robust control for surface vessels, employing a robust optimal control approach based on continuous loop closure and optimal control theory. They adjusted the PID controller to handle uncertainties arising from different parameter variations. Y. Su et al. [14] conducted asymptotic dynamic positioning of ships in the presence of constraints on the actuators and partial failures of the actuators. The authors put forth a nonlinear PD fault-tolerant controller. Yangsheng Liu et al. [15] presented an improved simulated annealing-APF (SA-APF) algorithm to address path-planning problems in 3D space. This method uses the simulated annealing (SA) algorithm to optimize distance costs and combines it with the APF, realizing large-scale multi-objective 3D space path planning. Zhe Zhang et al. [16] designed a fusion algorithm combining an improved APF method and rolling window method for the local pathplanning problem of unmanned underwater vehicles. The rolling window method models the local environment detected by UUV sensors, and the position factor is introduced into the repulsive force equation of the traditional APF method, making the approach effective and real-time. Hang Zhang et al. [17] developed an adaptive particle swarm optimization APF method. By using the APSO algorithm to preliminarily obtain the global virtual path, the method improves the APF approach and solves the local minimum value problem in traditional APF. Sarada Prasanna Sahoo et al. [18] proposed a hybrid algorithm combining grey wolf optimization (GWO) and GA and extended the hybrid path-planning to the cooperative path-planning application for autonomous underwater vehicles.

Moreover, numerous scholars have conducted extensive research on dynamic collision avoidance decision algorithms. Yanshuang Du et al. [19] addressed flight safety issues in dynamic airspace for unmanned aerial vehicles by proposing a real-time reactive collisionfree path generation method, capable of adjusting the safe distance based on the relative motion of surrounding obstacles. Wenjun Zhang et al. [20] examined the relationship between a ship's encounter state and the COLREGs in the context of collision avoidance for ship path planning, which can help reduce the cost of planned routes. Hongguang Lyu et al. [21] introduced an autonomous trajectory planning algorithm based on a modified APF, aimed at ensuring that ships or unmanned surface vessels effectively address collision avoidance problems in dynamic environments while adhering to the COLREGs. Yufei Zhuang et al. [22] proposed a waypoint generation algorithm that considers USV turning radius constraints by establishing an obstacle detection mechanism, reducing redundant turning angles and path lengths when USVs traverse obstacles. They devised a multidimensional path evaluation function for reasonably assessing planned routes, enabling improved USV path planning in complex environments. Zhongxian Zhu et al. [23] proposed a precise environmental potential field model based on electronic navigational chart (ENC) surface objects and an improved APF, which can obtain collision-free paths under different weather conditions and in narrow waters. Sung-Wook Ohn et al. [24] considered open-sea, restricted-water interactions between two or multiple vessels and the COLREGs while constructing optimal local path-planning routes for ships.

In practical scenarios, the schematics of ship trajectory planning and collision evasion necessitate a holistic consideration of an array of determinants encompassing vessel

dynamics, marine environments, and established navigational safety norms [1]. Hence, the cruciality of selecting and fine-tuning apt methodologies to circumnavigate real-world dilemmas becomes paramount. The APF algorithm exhibits structural clarity and computational swiftness, making it an indispensable asset in local ship route planning and dynamic obstacle avoidance. Despite the algorithm's inherent drawbacks in terms of global planning and intricate movements, its theoretical framework is nonetheless amenable to enhancements and pragmatic applications. Further, the synergistic application of the APF and ACO algorithms, particularly if the ACO algorithm can bolster its computational speed and global planning within a broad scale, could offer a more precise resolution to the extensive obstacle path-planning problem. Throughout the research journey, simulation experiments and practical trials can serve as credible tools to authenticate the effectiveness and applicability of the chosen methods, providing invaluable insights for the ongoing study and advancement of intelligent ship navigation.

## **2. Problem Description**

In light of the current research landscape and inspiration, this paper proposes an optimized artificial potential field method for ship collision avoidance and path planning, adhering to COLREG requirements. This approach achieves superior global and local path planning for vessels while facilitating avoidance decision making for both static and dynamic obstacles. The research primarily addresses three issues.

Given the current state of research and inspiration, this study proposes an optimized artificial potential field method for ship collision avoidance and path planning. In comparison to prior methodologies, this novel approach fully considers ship dynamics, marine environment, and COLREG requirements. Through the innovative integration of APF and ACO algorithms, it addresses path planning among large-scale obstacles and local optimum issues, achieving global and local path planning for ships and providing support for collision avoidance decision making against static and dynamic obstacles. This research primarily addresses the following three issues:


#### **3. Ship Collision Avoidance Rule Modeling**

In open-water navigation, examining ship collision avoidance decision-making and path-planning algorithms requires the integration of the COLREGs as constraints. Key aspects include the following: (1) Feasibility of real-time environmental data collection during navigation and concurrent hazard assessment; (2) Determination of ship collision avoidance decisions, timing, and evasive actions; (3) Consideration of ship dynamics and COLREGs within decision making and trajectory planning.

In compliance with the COLREGs, vessels must ensure that other ships remain outside the safe encounter distance throughout their journey, necessitating navigation beyond the safe encounter distance as a performance criterion.

When evaluating collision risks with obstacles, the vessel safety field and safety distance are commonly used as vital factors. Unlike static obstacles, dynamic obstacles call for the consideration of both the current safety field and safety distance, as well as the prediction of safety field and safety distance trends for future temporal dynamic obstacles. As illustrated in Figure 1, assume our vessel is located at point O, and the obstructing vessel moves from point A to point B, decreasing the distance between the two vessels from OA to OB and altering the azimuth angle Δ*δ* between them.

**Figure 1.** Relationship between distance and bearing among vessels.

The ship safety field is an area centered on the vessel's center of gravity. Although various safety field models with different shapes and judgments are employed in ship safety research, the safety distance standard remains widely utilized in the navigation process. The selection of a ship safety field must consider numerous factors. Existing research that overemphasizes the form of the ship safety field may not be conducive to the practical application of domain models.

For computational convenience, this paper treats the safety field of ships and other obstacle ships as circles, as illustrated in Figure 2. *P*<sup>0</sup> represents the center of gravity of our ship's safety field circle, while *P*<sup>1</sup> denotes the center of gravity of other ships. *Lpp* signifies the total length of ships contained within the circumcircle, *s*<sup>0</sup> and *s*<sup>1</sup> are the adequate safety margins for both ships. When selecting the safety margin, the position data of the own ship and other ships should be considered, as well as the increase in field range due to the proportional effect of the ship. The product of *Lpp* and the set factor *μ* indicates that the radii of the expanded circles for the ship and other obstacle ships are *R*<sup>0</sup> and *R*1, respectively.

**Figure 2.** Diagram Depicting Ships Safety Distance.

By treating the safety field of ships and other obstacle ships as circles, the proposed method simplifies calculations while still providing a reasonable safety margin for both ships. This approach enables efficient and effective collision avoidance, considering the position data of both the own ship and other ships in the navigation process.

Building upon this, the distance between the expanded boundaries of the ship and other obstacle ships is denoted as *Ds*. This distance considers the maneuverability parameters of the ship and other ships, their respective speeds, relative speeds, hydrological conditions, and other factors. During the voyage, the distance is also related to the respective headings of the own ship and other ships. Different encounter situations necessitate varying *Dm* values. The radius of the ship safety field established in this paper is the safety distance between the ship and other ships, expressed as follows:

$$D\_m = R\_0 + D\_s + R\_1.\tag{1}$$

The illustration of ship safety field is shown in Figure 3.

**Figure 3.** Illustration of ship safety field.

It is worth noting that there is a distinct difference between the ship safety field calculated based on the own ship and the ship safety field calculated according to other obstacle ships. The *Ds* of the other ship differs from ours. Factors contributing to this difference include vessel size and maneuverability.

The expression for the ship safety distance *Ds* is as follows:

$$D\_{\mathfrak{s}} = \int |v| dt + \mu\_{\mathfrak{c}} D\_{\mathfrak{c}} + \mu\_{\mathfrak{w}} D\_{\mathfrak{w}\mathfrak{s}} \tag{2}$$

where *dt* is the sampling period; |*v*| is the absolute value of the speed at which the two ships approach each other; *Dn* is the safe distance in the current navigation environment; *De* is the safe distance in the current environment; *Dw* is the safe distance in the current waters; *μ<sup>e</sup>* and *μ<sup>w</sup>* are the adjustment coefficients of *De* and *Dw*, respectively. In practical computations, according to the type of vessel and its suitable navigational waters, the values of *De* and *Dw* typically range from 0.3 to 1.2 nautical miles. Moreover, the values of *μ<sup>e</sup>* and *μ<sup>w</sup>* are adjusted based on the current environment and waters.

In order to effectively avoid collisions during a ship's navigation, it is essential to have a well-designed collision avoidance decision algorithm that considers various factors and stages of the collision development process. The stages include long distance without danger, collision risk, emergency situation, urgent danger, and final collision. These stages represent the process of the distance between the own ship and the obstacle ship developing from near to far.

The collision avoidance decision algorithm should be capable of taking the most appropriate action to best avoid a collision when other ships are not maneuvering in accordance with the COLREGs or if the two ships are in close proximity due to some other reason. The algorithm should also be able to determine when to initiate collision avoidance maneuvers, as initiating them too early or too late could negatively impact the ship's navigation.

When analyzing risk situations, the influence of other factors must be considered, particularly the distance between our ship and other obstacle ships as a constraint. Figure 4 elucidates that in compliance with the COLREGs, the most crucial aspect is the closest point of approach *DA* between the obstacle ship and the own ship and the collision risk detection distance *Dc*, which represents the distance allowing the vessel to undertake collision avoidance measures upon identifying a collision risk situation.

**Figure 4.** Distance closest point of approach.

In this paper, *Dc* is defined as the sum of the safety field radius *Dm* and the potential field influence range radius *αo*. The value of *α<sup>o</sup>* is determined by the maximum value of the product of *fk* times the obstacle's bulking circle radius and *αomin*, with *αomin* set at 0.4. This definition allows for a comprehensive assessment of collision risk, considering both the safety and the potential fields' influence on the ship's navigation.

$$D\_c = D\_m + \mathfrak{a}\_o \tag{3}$$

In this context, *α<sup>o</sup>* = *max*{*Df* ·*R*1, *αomin*}, *Df* is a proportional coefficient referred to as the obstacle distance influence factor, which adjusts the potential field's influence range depending on the distance between the ship and the obstacle.

#### **4. Path Planning Based on Optimized APF**

During the navigation process, the ship can use the APF method to take appropriate collision avoidance actions according to the COLREGs. Once the risk of collision is eliminated, the ship can resume sailing on the planned route and continue towards its destination. The APF method can adapt to changing environmental conditions and the movements of other ships, making it a suitable choice for intelligent ship navigation systems.

### *4.1. Construction and Calculation of Attractive Potential Field*

At present, in the artificial potential field algorithm, the potential energy equation of the destination's attractive potential field is usually transformed into a standard parabolic equation; *Pa*(*p*, *v*) is the attractive potential field; *D*(*p*0, *ps*) is the distance between the ship and the goal; *D*(*v*0, *vs*) is the equation of the resultant velocity of our ship and the goal.

$$\begin{cases} P\_a(p, v) = P\_a(p) + P\_a(v) \\ P\_a(p) = \frac{1}{2} \sigma\_p D^2(p\_0, p\_s) \\ \quad P\_a(v) = \frac{1}{2} \sigma\_v D^2(v\_0, v\_s) \end{cases} \tag{4}$$

where *σ<sup>p</sup>* is scale weight factor for location, *σ<sup>v</sup>* is speed factor, *p*<sup>0</sup> is the current position of the ship, *ps* is the current position of the goal, *v*<sup>0</sup> is the current speed of the ship, *vs* is the current speed of the goal. When the ship sails in the two-dimensional space on the sea surface, the attractive potential field that the ship experiences is non-negative. Only when the relative position *D*(*p*0, *ps*) and relative velocity *D*(*v*0, *vs*) of the ship and the target point are all 0, is the attractive potential field 0.

According to the attractive potential field equation *Pa*(*p*, *v*), the attractive forces of equation *Fa*(*p*, *v*) can be obtained:

$$F\_a(p,v) = \frac{\partial P\_a(p,v)}{\partial p} + \frac{\partial P\_a(p,v)}{\partial v} \tag{5}$$

The attractive forces equation *Fa*(*p*, *v*) can be rewritten as

$$\begin{cases} F\_a(p, v) = F\_a(p) + F\_a(v) \\ F\_b(p) = \varepsilon\_p D(p\_0, p\_s) \mu\_p \\\ F\_a(v) = \varepsilon\_v D(v\_0, v\_s) \mu\_v \end{cases} \tag{6}$$

where the attractive force *Fa*(*p*) represents the magnitude of the location-based influence, while *μ<sup>p</sup>* denotes the position vector. Additionally, *Fa*(*v*) signifies the magnitude of the velocity-based attractive force, ensuring that the ship's speed aligns with the target endpoint's speed in both magnitude and direction upon arrival. *Fa*(*v*) exhibits a positive correlation with *D*(*p*0, *ps*), with the direction coinciding with the target point's movement relative to the ship and *μ<sup>v</sup>* representing the unit vector in the direction of velocity.

#### *4.2. Construction and Calculation of Repulsive Potential Field*

When the relative position between the vessel and other ships falls within the collision risk detection threshold, our vessel should adhere to the COLREGs and implement collision avoidance measures to achieve dynamic and static obstacle avoidance. The equation for the repulsive potential field of dynamic obstacles *Prd* in complex waters is

$$\begin{cases} P\_{rd} = \varepsilon\_d R\_1 \omega^\* \left( D\_d^\* \right)^2 d\_s^2 \\ \quad \omega^\* = \left| e^{\omega\_0 - \omega} - 1 \right| \\\ D\_d^\* = \frac{1}{D - D\_m} - \frac{1}{\rho\_0} \end{cases} \tag{7}$$

where *ε<sup>d</sup>* represents the proportional coefficient of the repulsive potential field generated by the dynamic obstacle, *ω*<sup>0</sup> denotes the maximum relative position line angle, and *ds* is the distance between the vessel and the goal.

The equation for the repulsive potential field of a static obstacle *Prs* in open water is

$$\begin{cases} P\_{rs} = \varepsilon\_s R\_1 \left( D\_d^\* \right)^2 d\_s^2 \\ D\_s^\* = \frac{1}{D - D\_L} - \frac{1}{\rho\_0} \end{cases} \tag{8}$$

where *ε<sup>s</sup>* represents the proportional coefficient of the repulsive potential field generated by the obstacle.

When ship encounters a static obstacle, the repulsive potential field it experiences depends on the distance between the ship and the static obstacle. Unlike the traditional repulsive potential field model, this model introduces a smaller constant: *DL*. In this paper, *DL* is chosen as the product of *γ* times the *LPP* of the ship as the radius.

$$D\_L = \gamma \cdot L\_{PP\_\prime} \tag{9}$$

where *γ* is an adjustment factor with a value range from 1 to 3. Its value is determined by considering factors such as the maneuverability of our ship, the ship's length, the accuracy of sensor data (particularly position and distance), and an appropriate safety margin. The circle with the ship's position as its center and *DL* as its radius represents an area where no obstacles are allowed to enter. If any obstacle enters this area, it is considered a collision accident, so this area is called the forbidden zone. Within this range, the repulsive potential field is large enough and bounded to prevent our ship from colliding with other obstacles.

The total repulsive potential field equation is

$$P\_r = P\_{rd} + P\_{rs}.\tag{10}$$

By calculating the negative gradient of the repulsive potential field function *Pr*(*p*, *v*) with respect to position and velocity, the corresponding repulsive force function expression *Fr*(*p*, *v*) can be derived:

$$F\_r(p,v) = -\frac{\partial P\_r(p,v)}{\partial p} - \frac{\partial P\_r(p,v)}{\partial v} \tag{11}$$

The equation of the ship under the resultant force is

$$F(p, v) = F\_a(p, v) + F\_r(p, v) \tag{12}$$

Considering the presence of multiple static obstacles and dynamic obstacle ships, the resulting expression for the repulsive force acting on our vessel is as follows:

$$F\_r = \sum\_{i=1}^{n} F\_{r\_i \prime} \tag{13}$$

where *Fri* represents the repulsive force exerted by the *i*-th ship or obstacle on the vessel and n refers to the total number of obstacles and other ships encountered by the vessel.

#### *4.3. Ant Colony Optimization Algorithm*

In path planning, the quality of a route often depends on multiple factors, such as distance, safety, and time consumption, thus forming a multi-objective optimization problem. The ant colony algorithm is a nature-inspired heuristic algorithm, drawing inspiration from the path optimization behavior of ants in search of food and avoidance of obstacles [26]. Utilizing the global search capability and parallelism of the ant colony algorithm, satisfactory solutions can be effectively found in multi-objective optimization problems.

Specifically regarding local optima, the search may stall or cycle infinitely among several singular points when a local optimum or singularity is encountered. However, the ant colony algorithm selects the next node to visit based on the roulette wheel selection method, rather than choosing directly according to the size of the probability [27]. This method expands the search range, enabling the search to possibly escape local optima and find the global optimum. The application of the ant colony algorithm in a global optimization strategy not only effectively enhances search efficiency but also avoids becoming trapped in local optima.

At time *t*, ant *k* selects the direction of travel from point *i* to point *j* based on the calculation of the state transition probability. By calculating the transition probability *P<sup>k</sup> ij*(*t*) of the available paths adjacent to point *i*, the transition probability of moving to grid point *j* is determined using the roulette wheel selection rule:

$$P\_{ij}^k(t) = \begin{cases} \frac{\left[ph\_{ij}(t)\right]^\gamma \left[hf\_{ij}(t)\right]^{v}}{\sum\_{j \in m} \left[ph\_{ij}(t)\right]^\gamma \left[hf\_{ij}(t)\right]^{v}} & , j \in m, \\ 0 & , j \notin m \end{cases} \tag{14}$$

where *m* is the set of available nodes for the ant's next step, *P<sup>k</sup> ij*(*t*) is the node transition probability, *phij*(*t*) is the pheromone concentration on the path, *h f ij*(*t*) is the heuristic function, *γ* is the pheromone concentration coefficient, and *σ* is the heuristic function coefficient. The definition of the heuristic function *h f ij*(*t*) is

$$hf\_{ij}(t) = \frac{1}{D\_{ij}}\tag{15}$$

In the formula, *Dij* represents the Euclidean distance between node *i* and node *j*. The definition of *Dij* is

$$D\_{ij} = \sqrt{\left(\mathbf{x}\_i - \mathbf{x}\_j\right)^2 \left(y\_i - y\_j\right)^2} \tag{16}$$

To prevent an abundance of pheromones from leading subsequent ants astray in their path selection, the information along the path will be updated using the following method after each generation of ants completes their search:

$$ph\_{ij}(t+1) = ph\_{ij}(t) - \beta ph\_{ij}(t) + \Delta ph\_{ij}(t, t+1) \tag{17}$$

In the formula, *β* represents the pheromone evaporation coefficient, and Δ*phij*(*t*, *t* + 1) denotes the increment of pheromones between points *i* and *j* during the current iteration.

$$
\Delta p h\_{ij} = \sum\_{a=1}^{N} \Delta p h\_{ij}^{\;a} \tag{18}
$$

where *N* represents the predefined number of ants in the colony, and Δ*phij <sup>a</sup>* refers to the pheromones released by ant *a* as it traverses the path. The definition of Δ*phij <sup>a</sup>* is

$$
\Delta p h\_{\rm ij}{}^{a} = P / D\_{a} \tag{19}
$$

*P* represents the initial pheromone value; *Da* denotes the total length of the path traversed by ant *a*.

In traditional ant colony algorithms, the initial distribution of pheromones in the environment is set to the same value, leading to a certain degree of blindness in the initial path search by ants. This affects the search efficiency of the algorithm and increases the search time. In this paper, an improved method for initial pheromone distribution is proposed. This method calculates the initial pheromone *phij*(0) amount based on the number of obstacles surrounding a node. The specific implementation is as follows:

$$ph\_{ij}(0) = \theta \cdot f(j) \tag{20}$$

$$f(j) = \frac{1 - \mathbb{C}\_{ll}(m)}{8} \tag{21}$$

In the formula, *ϑ* is an enhancement coefficient that can be determined based on the actual situation; *f*(*j*) is an obstacle avoidance coefficient; *CU* represents the complement symbol; and *U* is the set of adjacent pixels for the current pixel position. The *f*(*j*) function can be used to calculate the proportion of free pixels among the eight adjacent pixels of the current pixel. When there are fewer obstacle pixels in the neighborhood of the pixel, the initial pheromone of the pixel is larger; otherwise, the initial pheromone is smaller. This guides ants to advance and avoid searching in areas with too many obstacles, thus accelerating the convergence speed of the algorithm.

### *4.4. Collision Avoidance and Path Planning Algorithm Design*

The method proposed in this paper first extracts key information from electronic chart data, such as ships, obstacles, and target points. The electronic chart is then converted into a rasterized image, where each grid cell represents either a navigable area or an obstacle. The system employs an ant colony algorithm for global path planning, initializing the ant population, heuristic information, and improved pheromone allocation, allowing ants to search and select the next grid cell on the rasterized image. Upon reaching the target point, the pheromone concentration is updated, the path length is recorded, and iterations are repeated, with the shortest path chosen as the global plan.

Local planning is achieved through an optimized artificial potential field method, calculating the attractive potential field (pointing towards the target) and repulsive potential field (moving away from obstacles) for static and dynamic obstacles. The composite potential field is obtained by combining these fields, which is used to calculate the ship's moving direction. Dynamic obstacles are detected, and repulsive potential fields are applied, realizing local static and dynamic collision avoidance. The ship's position is updated, and steps are repeated until the target is reached.

The global planning path of the ant colony algorithm and the local planning path of the optimized artificial potential field method are integrated to form the final ship path. The visualized final path is output for further analysis and use. Through this process, the combination of the optimized artificial potential field method and the ant colony algorithm is achieved, realizing ship path planning and dynamic collision avoidance in complex environments.

The traditional APF algorithm often encounters multiple local optima during the computation process. When it reaches these points, the search may stagnate or loop infinitely among several singular points, rendering the program unable to stop. Therefore, the search is likely to become trapped in these local optima, preventing it from finding the global optimum. To address this situation, this study proposes a fusion algorithm that incorporates an optimized ant colony algorithm to implement a global optimization strategy. The algorithm employs a roulette wheel selection method to choose the next node to visit, rather than making a direct choice based on the size of the probability. This approach broadens the search range, thereby locating the global optimum and avoiding becoming mired in local optima. For the optimization of the local planning APF method, a maximum number of iterations is set in this study. If the search exceeds this number without finding a satisfactory solution, the search is forcibly halted. The algorithm process proposed in this paper is illustrated in Figure 5.

**Figure 5.** Algorithm flow chart.

#### **5. Results and Analysis**

In this study, the traditional artificial potential field algorithm was optimized by considering ship types and parameters in the waters, as well as adhering to the requirements and specifications of the COLREGs. This enabled the establishment of a collision avoidance decision system for static and dynamic obstacles at sea and the realization of the ship's autonomous obstacle avoidance decision and path-planning algorithm. To further validate the effectiveness, reliability, and real-time performance of the ship obstacle avoidance decision-making and path-planning algorithms based on the artificial potential field method, a simulation test of autonomous collision avoidance and navigation planning was conducted using the aforementioned ship autonomous collision avoidance system.

To meet real-world navigational task requirements, multiple simulation validations have been conducted in this study. Initially, tests for static avoidance and planning in three types of water areas, such as coastlines, islands, and reefs, were carried out to validate the performance of the proposed algorithm under varying static obstacles. Subsequently, tests were conducted under mixed dynamic and static obstacles to verify the algorithm's stability and robustness under composite obstacle interference. Last, based on the COLREGs' classification of vessel encounters, multiple encounter simulation tests were performed under different meeting patterns, simulating navigational situations in real waters. An in-depth discussion and analysis of the results followed the simulations.

In the simulation experiment, the positive direction of the vertical axis in the coordinate system represents north, while the positive direction of the horizontal axis represents east. The planned path of our ship is depicted by a blue trajectory, dynamic obstacle ships are represented by red dotted lines, and static obstacles are indicated by black color blocks.

#### *5.1. Preprocessing of Electronic Nautical Chart Image Data*

Prior to implementing the proposed algorithm, electronic nautical chart image data must undergo preprocessing. As shown in Figure 6, this preprocessing includes image binarization and rasterization, which simplifies the data for subsequent simulation and validation. First, the electronic nautical chart image is binarized, converting elements, such as ships, obstacles, and target points, into black and white pixels to streamline the image information. Next, rasterization divides the electronic nautical chart into regular smaller areas, with each raster cell representing a navigable area or an obstacle. The raster cell size can be adjusted based on specific requirements and computational resources. In this study, the raster window value is set to five to reduce computation time without sacrificing accuracy.

**Figure 6.** Image preprocessing: (**a**) Original electronic nautical chart; (**b**) Binarization; (**c**) Binarization inversion; (**d**) Rasterization.

This preprocessing method helps to simplify the geographical environment, providing clear and easily processed input data for the subsequent simulation and validation of the ant colony algorithm and the optimized artificial potential field method, thereby enhancing the efficiency and accuracy of path planning.

### *5.2. Static Obstacle Avoidance Simulation*

In order to avoid collisions in restricted water areas, vessels need to consider different types of static obstacles. In this simulation experiment, an environment map corresponding to the electronic chart is established to accomplish autonomous ship obstacle avoidance decision-making and route-planning experiments. Analyses are conducted for coastlines, islands, and reefs, based on their specific characteristics.


For ships navigating in restricted waters to avoid collisions, different types of static obstacles must be considered individually. In this section's simulation experiment, obstacles are categorized into three types: coastlines, islands, and reefs, which are analyzed separately. The basic parameters of the subject vessel are presented in Table 1.

**Table 1.** Basic parameters of target ship.


Based on the electronic chart, a corresponding water environment map is created to carry out the ship's autonomous collision avoidance decision-making and path-planning experiments.

Simulation results are shown in Figure 7, where black represents the projection of obstacles on the horizontal plane, and white areas indicate navigable regions for the ship. The simulation statistics are shown in Table 2.

**Figure 7.** Trajectory schematics amidst static obstacles: (**a**) Coastlines; (**b**) Islands; (**c**) Reefs.



The simulation results presented in Figure 7 and Table 2 allow us to compare the trajectory planning of the traditional APF method and the optimized algorithm under three common marine environment obstacles. As can be seen clearly from Figure 7a,b, the path of the optimized algorithm is shorter than that of the traditional APF method. By repeating this experiment 10 times, each result exhibits minor differences, demonstrating some randomness. The average path length is reduced by 17%, and the simulated curve is smoother.

Moreover, as shown in Figure 7c, the traditional APF algorithm, under complex environmental conditions, stagnates due to the influence of multiple repulsive potential fields or becomes trapped in an infinite loop between several singular points, causing the program to become non-responsive. The path planning becomes stuck in these local optimal solutions, unable to find the global optimum. However, the optimized ant colony algorithm in this paper implements a global optimization strategy. It uses a roulette wheel selection method to choose the next node to be visited, instead of directly selecting according to the size of the probability. This strategy broadens the search range to find the global optimum and avoids falling into local optima, effectively resolving the local optimum problem present in the traditional APF method. However, due to the complexity of the optimized algorithm, the simulation computation time is longer than that of the traditional APF method, indicating a certain limitation.

#### *5.3. Dynamic Obstacle Avoidance Simulation*

Dynamic obstacle collision avoidance simulation refers to target ship navigating through and encountering obstacle ships, the parameters for the obstacle ship is delineated as depicted in Table 3.


**Table 3.** Basic parameters of obstacle ship.

When the obstacle ship maintains its sailing state unchanged, our ship makes an emergency collision avoidance decision outside the safety domain. The starting position of my ship is designed, with an initial heading angle of −45◦ and a maximum speed of 16 knots. The obstacle ship has a sailing direction angle of 45◦ and maintains a speed of 10 knots. Under these circumstances, the simulation results of the proposed optimized algorithm are compared with the traditional dynamic APF method. The simulation results are illustrated in Figure 8.

**Figure 8.** *Cont*.

**Figure 8.** Path-planning trajectory diagram under dynamic obstacles: (**a1**) The ship and the obstacle ship form a cross encounter situation; (**a2**) Ships form a cross encounter situation; (**b1**) The ship is directed to turn left to avoid; (**b2**) The ship is directed to turn right to avoid (**c1**) The ship ends collision avoidance operation and resumes sailing; (**c2**) The ship end avoidance and resume navigation; (**d1**) The ship arrives at the finish line after avoiding static obstacles; (**d2**) The ship reaches its terminus subsequent to circumvent stationary impediments.

The simulation statistics are shown in Table 4.

**Table 4.** Statistical analysis table for dynamic obstacles.


Analyzing the simulation results using the traditional dynamic artificial potential field method for collision avoidance simulations, the target vessel performs a 71◦ left turn when encountering a crossing situation with the obstacle vessel due to the lack of constraint from the vessel collision avoidance rule model, as shown in Figure 8(b1). Furthermore, the distance between the target vessel and the obstacle ship is too small in Figure 8(c1), and the vessel does not resume its course after avoiding the collision. These actions do not comply with COLREG requirements for vessel handling and safe navigation.

In contrast, as shown in Figure 8(a2) and based on the optimized algorithm proposed in this paper, the target vessel detects an impending obstacle ship outside the safe zone. In Figure 8(b2), it promptly takes evasive action and performs a collision avoidance maneuver by turning right 49◦. This complies with COLREG requirements for vessel handling, adhering to the principle of turning right at an appropriate angle to yield and effectively clears the path in Figure 8(c2). After completing the collision avoidance maneuver, the vessel resumes its course and eventually reaches its destination. During the path planning and collision avoidance process, the minimum distance between the target vessel and the obstacle ship is significantly greater than *R*<sup>0</sup> + *R*1, fulfilling the safety requirements for collision avoidance. After conducting this segment of the experiment five times, it is evident that the results of each trial vary slightly due to the stochastic roulette wheel structure of the ant colony algorithm. Despite the inherent randomness, the stability of the system remains unaffected. The average navigational distance is 18.84 n miles, with the greatest recorded distance being 19.30 n miles.

#### *5.4. Validation of Multi-Ship and Multi-State Collision Avoidance*

As per the COLREG ship encounter categorization, the encounters between the target ship and the obstacle ships are divided into three types: overtaking, head-on meeting, and crossing. This section will carry out multiple encounter simulation tests under different encounter modes, simulating the navigation situation in real waters. The parameters of the obstacle ships in the three typical meeting situations are shown in Table 5.


**Table 5.** Parameters of the obstacle ships in three typical encounter scenarios.

The experiment is set in an open-water scenario, where three distinct obstructive vessels intersect the path of the target ship in different encounter scenarios. Figure 9 demonstrates the result of the multi-vessel, multi-state collision avoidance test.

**Figure 9.** *Cont*.

**Figure 9.** Results of multi-vessel, multi-state collision avoidance validation: (**a**) Numerous ships navigate concurrently within the same maritime expanse; (**b**) The ship and OS1 constitute a head-on encounter scenario; (**c**) The ship turns right to avoid and continues to sail; (**d**) The ship and OS2 constitute a overtaking encounter scenario; (**e**) The ship turning right at a wide angle to avoid; (**f**) The ship resume navigation after completing a right turn to avoid; (**g**) The ship and OS3 constitute a crossing encounter scenario; (**h**) The ship arrives at the end of the line after completing avoidance.

Based on the validation curves presented in Figure 9, the statistical data garnered from simulation results, encompassing multiple vessels and diverse circumstantial collision avoidance, are articulated as exhibited in Table 6.

**Table 6.** Statistics of the simulation data results for multi-vessel and multi-condition collision avoidance validation.


According to the validation results in Figure 9a, the target vessel has a course of −45◦ and is heading straight to the destination along the pre-planned route. Despite the presence of several obstructing vessels in this open sea, the distances between them are considerable and do not yet invade the safety distance criterion. Consequently, the target vessel is not within the influence range of the repulsive force field of the obstructing vessels and therefore does not take evasive actions.

Figure 9b shows that over time, both the target vessel and the obstructing vessel OS2 have traveled a certain distance, forming a head-on meeting situation. The target vessel enters the influence range of OS2's repulsive field and makes a significant 42◦ right turn. The closest point of approach is 1.20 nautical miles, which meets the COLREGs and safety requirements, fully demonstrating the robustness and stability of the algorithm.

Figure 9c–e illustrate that after successfully avoiding OS2 with a right turn, the target vessel encounters a situation of overtaking OS1. Upon entering OS2's repulsive field, the vessel makes a substantial 46◦ right turn following the algorithm's constraints on vessel operations. The closest point of approach is 1.05 nautical miles. After evasion, the vessel resumes its course to the endpoint, meeting COLREG requirements.

Figure 9f–h demonstrate that after resuming its course, the target vessel intersects with the obstructing vessel OS3. The target vessel executes a substantial 53◦ right turn and passes from the rear side of OS3. The closest point of approach is 1.42 nautical miles. After completing the evasion, the vessel resumes its course and eventually reaches the endpoint.

Through the multi-vessel and multi-condition collision avoidance validation simulation, the algorithm's capability to handle multiple meeting scenarios under COLREGs and multiple encounters in real waters is proven. The algorithm shows stability and robustness, and the evasive actions meet the normative requirements of the COLREGs.

In summary, the three sets of experiments validate the algorithm's performance in static evasion and planning in restricted waters, collision avoidance under mixed static and dynamic obstacles, and collision avoidance in multiple encounters. The vessel's evasive actions comply with regulations, and the planned route meets safety requirements. This indicates that the algorithm can prevent collisions in emergencies and that the planned route is a smooth curve, demonstrating its practicality.

#### **6. Conclusions**

This paper primarily investigates collision avoidance and path-planning problems for ships encountering dynamic and static obstacles during navigation. To address these challenges, a collision avoidance and path-planning algorithm based on an optimized APF-ACO algorithm is proposed. First, a ship collision avoidance constraint model is established according to the COLREGs, enhancing the algorithm's safety and applicability. Subsequently, by introducing factors such as velocity, position, and shape parameters, the traditional APF method is optimized, creating a dynamic APF gradient to enable collision avoidance decision making for dynamic obstacles. Furthermore, this research combines the optimized APF method with an ant colony optimization algorithm, improving the latter to resolve inherent local optimality issues in the APF method and achieve collision avoidance

decision-making and trajectory-planning methods for static/dynamic obstacles in complex waters based on the APF method.

Comparative simulation experiments demonstrate the feasibility and effectiveness of the proposed algorithm in accomplishing dynamic ship collision avoidance and pathplanning tasks. This research holds significant practical implications for the safe navigation of ships in complex environments and offers valuable insights for the development and study of intelligent ship navigation systems. Future research may focus on further optimization of the algorithm to enhance its performance in handling more complex scenarios and diverse obstacle types, laying the foundation for the realization of intelligent and automated ship navigation.

**Author Contributions:** Conceptualization, B.L. and M.L.; methodology, J.L. and M.L.; software, M.L. and Z.Q.; validation, B.L. and M.L.; formal analysis, Z.Q. and J.L.; writing—original draft preparation, M.L., B.L. and J.W.; project administration, J.L. and J.W.; funding acquisition, J.L. and J.W.; writing—review and editing, M.L., B.L. and Z.Q. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the Natural Science Foundation of Heilongjiang Province grant number KY10400210217, Fundamental Strengthening Program Technical Field Fund grant number 2021-JCJQ-JJ-0026, Natural Science Foundation of Heilongjiang Province (LH2019E035), the Project of Education Science Planning in Heilongjiang Province (GJB1320064), and the Harbin Engineering University Education and Teaching Program (JG2021B06).

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** The data used to support the findings of this study are included within the article and are also available from the corresponding authors upon request.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **References**


**Disclaimer/Publisher's Note:** The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
