Collision Avoidance Algorithm Based on COLREGs for Unmanned Surface Vehicle

: Recently, unmanned surface vehicles (USV) are being actively developed. For USVs to be put to practical use, it is necessary to secure safety by preventing collisions with general ships. To this end, USVs must avoid opposing vessels based on international regulations for preventing collisions at sea (COLREGs, 1972). This paper proposes an algorithm for USVs to avoid collisions with opposing vessels based on COLREG rules. The proposed algorithm predicts dangerous situations based on distance to closest point of approach (DCPA) and time to closest point of approach (TCPA). It allows USVs to avoid opponent ships based on the dynamic window approach (DWA). The DWA has been improved to comply with COLREGs, and we implemented a simulation and compared the standard DWA with the COLREG-compliant DWA (CCDWA) proposed in this paper. The results conﬁrm that the CCDWA complies with COLREGs.


Introduction
An unmanned surface vehicle (USV) refers to a surface vehicle that can be remotely controlled or operated autonomously. There is growing demand for USVs to replace manned vessels in hazardous areas such as conflict or disaster zones. In particular, the necessity of developing USVs for military use has been greatly emphasized, and LIG Nex1 s sea sword was developed in Korea. Spartan Scout USV, ASW USV, and UISS of the US, C-Sweep of the UK, Mk2 of France, Dolphin of Canada, and Protector of Israel were also developed [1,2].
USVs must be able to recognize their current position, control the thrusters to move autonomously to the destination, and recognize and avoid static and dynamic obstacles during movement [3][4][5][6].
For USVs to autonomously navigate safely to their destinations while avoiding static and dynamic obstacles, it is necessary to first plan a path from current location to destination. The path plan can be divided into global and local path plans. The global path plan involves the entire travel route to the destination based on the environment map given before the USV departs for the destination; the local path plan involves safe avoidance paths that do not greatly deviate from the global path plan, allowing USVs to avoid unexpected obstacles [7]. The A* algorithm and rapidly-exploring Random Tree (RRT) algorithm are representative global path planning algorithms; the virtual force field (VFF) and vector field histogram (VFH) algorithms are local path planning algorithms.
The dynamic window approach (DWA) is used for local route planning and is a destination tracking algorithm that can avoid collisions by reflecting the dynamic state of the USV. The DWA can be applied via fusion with the global path control algorithm [8,9].
DWA is an algorithm that, by deriving the optimal linear velocity and angular velocity and evaluating the direction, velocity, and distance to the obstacle based on the object 2 of 10 function allows the USV to avoid obstacles and arrive at the destination. In addition, the DWA is a flexible local path control technique that can derive the desired result by adding an optimal condition to the object function. Through previous studies, the path line tracking performance was confirmed by adding a term for tracking the path line to the object function [9]. However, standard DWAs do not take into account the COLREG rules, so using DWAs to avoid obstacles can create dangerous situations.
In this paper, we propose a supplemented DWA that can comply with COLREG rules. This paper first describes the standard DWA and then the proposes the COLREG-compliant DWA (CCDWA). By implementing a simulation, comparison verification was performed between the standard DWA and the CCDWA.

Dynamic Window Approach
We applied the DWA as a local pass plan to avoid opposing vessels. The DWA creates a dynamic window representing the range of linear and angular velocities that can be output from the current ship's velocity for the next time. Then, from the pairs of linear velocity (v) and angular velocity (ω) in the dynamic window, the algorithm selects the pair that maximizes the value of the object function.
The dynamic window can be expressed as shown in Figure 1 [8,9]. The vertical and horizontal axes represent the linear and angular velocities. V s indicates the range of linear and angular velocity that the ship can output. V d is the area from the minimum velocity to the maximum velocity that the ship can output until the next time; it is expressed by Equation (1). The maximum acceleration and deceleration specifications of the vessel can be reflected in the algorithm through V d [8,9]. DWA is an algorithm that, by deriving the optimal linear velocity and angular velocity and evaluating the direction, velocity, and distance to the obstacle based on the object function allows the USV to avoid obstacles and arrive at the destination. In addition, the DWA is a flexible local path control technique that can derive the desired result by adding an optimal condition to the object function. Through previous studies, the path line tracking performance was confirmed by adding a term for tracking the path line to the object function [9]. However, standard DWAs do not take into account the COLREG rules, so using DWAs to avoid obstacles can create dangerous situations.
In this paper, we propose a supplemented DWA that can comply with COLREG rules. This paper first describes the standard DWA and then the proposes the COLREGcompliant DWA (CCDWA). By implementing a simulation, comparison verification was performed between the standard DWA and the CCDWA.

Dynamic Window Approach
We applied the DWA as a local pass plan to avoid opposing vessels. The DWA creates a dynamic window representing the range of linear and angular velocities that can be output from the current ship's velocity for the next time. Then, from the pairs of linear velocity (v) and angular velocity (ω) in the dynamic window, the algorithm selects the pair that maximizes the value of the object function.
The dynamic window can be expressed as shown in Figure 1 [8,9]. The vertical and horizontal axes represent the linear and angular velocities. Vs indicates the range of linear and angular velocity that the ship can output. Vd is the area from the minimum velocity to the maximum velocity that the ship can output until the next time; it is expressed by Equation (1). The maximum acceleration and deceleration specifications of the vessel can be reflected in the algorithm through Vd [8,9].
Vr is the area excluding the area colliding with the obstacle in the Vd area. This area is the input range for velocity control that allows safe movement in a range in which the vehicle can accelerate and decelerate from the current velocity [8,9].
V r is the area excluding the area colliding with the obstacle in the V d area. This area is the input range for velocity control that allows safe movement in a range in which the vehicle can accelerate and decelerate from the current velocity [8,9].
The objective function of the standard DWA is written as Equation (3).
where v and ω represent the linear and angular velocity within the dynamic window.
α, β, and γ are weighting factors. By adjusting these parameters, we can tune the propensity of the USV to head to the GOAL, avoid obstacles, and run quickly.
The velocity (v, ω) term is the vessel's speed, the heading (v, ω) term is the heading to the target after ∆t time, and the distance (v, ω) term is the distance from the ship's position to the obstacle after ∆t time.
By substituting the v, ω pair in the dynamic window into the objective function, the v, ω pair with the largest objective function value is selected as the control input value [8,9]. For the velocity term, the highest value is selected within the velocity range of the dynamic window, as in Equation (1).
At positions x, y, θ, when the ship moves with v, ω, the positions x , y , θ after ∆t time can be defined as Equation (4) [9].
When the angular velocity is 0, the position of the ship according to the linear velocity is defined as Equation (5) [9].
At positions x , y , θ , the heading (v, ω) and distance (v, ω) terms of the objective function are calculated. The distance from position x , y to position x ob , y ob of the other ship can be expressed as Equation (6) in consideration of the safety distance r [9].
In this way, the standard DWA selects linear and angular velocities at which collision avoidance is possible based on the relationship between the position of our own vessel and the position of the other vessel.

COLREG-Compliant DWA (CCDWA)
For the USV to be put to practical use, it is necessary to secure safety by preventing collisions with general ships. To this end, USVs are required to evade opposing vessels under the COLREG rules and to avoid creating danger to other vessels. Figure 2 shows the four main scenarios of COLREGs. The first scenario is a head-on situation. When two power-driven vessels meet on reciprocal or nearly reciprocal courses, each shall alter her course to starboard so that each shall pass on the port side of the other (Rule 14).
The second and third scenarios are crossing situations. When two power-driven vessels cross, the vessel that has the other on her own starboard side shall keep out of the way and shall, if the circumstances of the case admit, avoid crossing ahead of the other vessel (Rule 15). In other words, the USV shall give way in crossing when a dynamic obstacle approaches from the starboard side (second scenario). In addition, the USV shall keep course and speed in crossing when the dynamic obstacle approaches from the port side (third scenario).
The fourth scenario is an overtaking situation. Any vessel overtaking any other shall keep out of the way of the vessel being overtaken (Rule 13) [10,11].

Figure 2.
Main COLREG scenarios (the keywords in [10] was used; the composition and meaning of the picture are similar to [11,12]).
The second and third scenarios are crossing situations. When two power-driven vessels cross, the vessel that has the other on her own starboard side shall keep out of the way and shall, if the circumstances of the case admit, avoid crossing ahead of the other vessel (Rule 15). In other words, the USV shall give way in crossing when a dynamic obstacle approaches from the starboard side (second scenario). In addition, the USV shall keep course and speed in crossing when the dynamic obstacle approaches from the port side (third scenario).
The fourth scenario is an overtaking situation. Any vessel overtaking any other shall keep out of the way of the vessel being overtaken (Rule 13) [10,11].
To apply COLREGs, it is necessary to know where the other ship is located in relation to our own ship. Figure 3 provides a diagram that shows the position of the other ship relative to our own ship [12]. According to the locations of head-on, starboard, port, and stern, situations can correspond to head-on, crossing from the right, crossing from the left and overtaking scenarios of the main COLREGs scenarios, respectively. Main COLREG scenarios (the keywords in [10] was used; the composition and meaning of the picture are similar to [11,12]).
To apply COLREGs, it is necessary to know where the other ship is located in relation to our own ship. Figure 3 provides a diagram that shows the position of the other ship relative to our own ship [12]. According to the locations of head-on, starboard, port, and stern, situations can correspond to head-on, crossing from the right, crossing from the left, and overtaking scenarios of the main COLREGs scenarios, respectively.

Figure 2.
Main COLREG scenarios (the keywords in [10] was used; the composition and meaning of the picture are similar to [11,12]).
The second and third scenarios are crossing situations. When two power-driven vessels cross, the vessel that has the other on her own starboard side shall keep out of the way and shall, if the circumstances of the case admit, avoid crossing ahead of the other vessel (Rule 15). In other words, the USV shall give way in crossing when a dynamic obstacle approaches from the starboard side (second scenario). In addition, the USV shall keep course and speed in crossing when the dynamic obstacle approaches from the port side (third scenario).
The fourth scenario is an overtaking situation. Any vessel overtaking any other shall keep out of the way of the vessel being overtaken (Rule 13) [10,11].
To apply COLREGs, it is necessary to know where the other ship is located in relation to our own ship. Figure 3 provides a diagram that shows the position of the other ship relative to our own ship [12]. According to the locations of head-on, starboard, port, and stern, situations can correspond to head-on, crossing from the right, crossing from the left, and overtaking scenarios of the main COLREGs scenarios, respectively.  In the typical vessel interaction, shown in Figure 4, TCPA and DCPA for the position of our own ship (x o , y o ) and the position of the other ship (x t , y t ) are expressed by Equations (7) and (8), respectively [13]. If TCPA is positive, ships are approaching. In addition, if DCPA is less than the safe distance, the ships are in a dangerous situation.
At this point, Figure 3 is referenced to determine which COLREG scenario is appropriate for the situation, and our own ship must get out of the dangerous situation by following COLREGs through obstacle avoidance control. In a vessel avoidance situation, if TCPA is negative, ships are moving away and are out of danger, so the vessel should stop its avoidance movements and continue the existing voyage. The flow chart of USV control, including the above process, is shown in Figure  5.
In this paper, the DWA is selected for obstacle avoidance control. To apply the COLREG rules to the DWA, we propose to divide the dynamic window into two regions, left and right, as shown in Figure 6a. To change the course of our own ship to starboard, we deactivate the left area of the dynamic window. On the other hand, to change the course of our own ship to port, the right area of the dynamic window is deactivated. At this point, Figure 3 is referenced to determine which COLREG scenario is appropriate for the situation, and our own ship must get out of the dangerous situation by following COLREGs through obstacle avoidance control.
In a vessel avoidance situation, if TCPA is negative, ships are moving away and are out of danger, so the vessel should stop its avoidance movements and continue the existing voyage. The flow chart of USV control, including the above process, is shown in Figure 5.  In this paper, the DWA is selected for obstacle avoidance control. To apply the COLREG rules to the DWA, we propose to divide the dynamic window into two regions, left and right, as shown in Figure 6a. To change the course of our own ship to starboard, we deactivate the left area of the dynamic window. On the other hand, to change the course of our own ship to port, the right area of the dynamic window is deactivated.  In the active dynamic window region, the v and ω values that cause the objective function to reach its highest value are derived. In this way, an avoidance movement that satisfies the COLREG rules is made using the derived v and ω. For example, in ahead-on situation, our own ship must turn to the right to avoid the obstacle ship. Therefore, the CCDWA deactivates the left area of the dynamic window, as shown in Figure 6b. Our own ship turns to the right using the v and ω derived through the DWA in the active right area of dynamic window. On the other hand, when our own ship has to move to the left to avoid obstacle ship, the CCDWA deactivates the right area of the dynamic window, as shown in Figure 6c.

Simulation and Analysis
Simulation was performed to compare the CCDWA proposed in this paper and the In the active dynamic window region, the v and ω values that cause the objective function to reach its highest value are derived. In this way, an avoidance movement that satisfies the COLREG rules is made using the derived v and ω. For example, in ahead-on situation, our own ship must turn to the right to avoid the obstacle ship. Therefore, the CCDWA deactivates the left area of the dynamic window, as shown in Figure 6b. Our own ship turns to the right using the v and ω derived through the DWA in the active right area of dynamic window. On the other hand, when our own ship has to move to the left to avoid obstacle ship, the CCDWA deactivates the right area of the dynamic window, as shown in Figure 6c.

Simulation and Analysis
Simulation was performed to compare the CCDWA proposed in this paper and the standard DWA, and to verify the performance of the CCDWA. The standard DWA, the CCDWA, and the simulation environment were implemented in C# programming language. Table 1 shows the parameters of the standard DWA and the CCDWA. The weighting factors α, β, and γ were set to 0.25, 0.5, and 0.25 values. By substituting the v, ω pair in the dynamic window defined by Table 1 into the objective function including the weighting factor, the v, ω pair with the largest objective function value is selected as the control input value. The selected v and ω do not exceed the maximum velocity value. The ship's position x , y after ∆t time according to the speed was calculated and updated through Equations (4) and (5). In addition, the algorithm operation pattern according to the passage of time was confirmed.  was displayed in the simulation to express the dangerous situation between our own ship and the obstacle ship. The CPA of our own ship and the CPA of the obstacle ship can be expressed by Equations (9) and (10), respectively.
The CPA of our own ship (CPA o ) and the CPA of the obstacle ship (CPA t ), which change in real time according to the movement of our own ship, are expressed with red and blue dots, respectively. DCPA can be checked through the distance between CPA o and CPA t shown in the figure. The simulation time is indicated in the upper right of the figures. In addition, the grid was drawn at 100m intervals on the horizontal and vertical axes of the figures.
First, the standard DWA and the CCDWA were compared through simulation in a head-on situation with a dynamic obstacle. As an initial setting, our own ship was set to move in the right direction at a speed of 10 m/s, and the obstacle ship was set to move at a speed of 10 m/s in the front direction of our own ship at a distance of 600 m from our own ship. Figure 7a shows the simulation results when applying the standard DWA in a head-on situation with a dynamic obstacle. In the first figure, TCPA of our own ship and obstacle ship is 25 s and the DCPA is 34 m. That is, they get closer to 34 m after 25 s. In the second figure, since the obstacle ship (T1) is approaching from the slightly right side in front of our own ship (O), the velocity pair located on the left side of the dynamic window is selected as the input value by the objective function. Accordingly, our own ship turned to the left to avoid the obstacle ship. The DCPA at this moment is 102 m. In the third picture, TCPA is negative and ships are moving away and are out of danger. However, it was confirmed that the standard DWA does not follow the COLREG rules in a head-on situation. Figure 7b shows the simulation results when applying the CCDWA in a head-on situation with a dynamic obstacle. In the first figure, TCPA of our own ship and the obstacle ship is 29.5 s and the DCPA is 34 m. At this time, TCPA is positive, and DCPA is less than the safe distance (100 m); the ships are in a dangerous situation. Referring to Figure 3, it is a head-on situation. In the second figure, the CCDWA deactivates the left area of the dynamic window. Accordingly, our own ship turned to the right to avoid the obstacle ship. In the third picture, TCPA is negative and DCPA is greater than the safe distance; ships are moving away and are out of danger. As a result, when applying the CCDWA, our own ship turned to the right to avoid the obstacle ship. It was confirmed that the CCDWA complies with the COLREG rules in a head-on situation. Second, we compared the standard DWA with the CCDWA through simulation in the intersection situation with dynamic obstacles. As an initial setting, our own ship was set to move in the right direction at a speed of 10 m/s, and the obstacle ship was set to move in a direction to the right side of our own ship at a distance of 500 m from our own ship at a speed of 10 m/s. Figure 8a shows the simulation results when applying the standard DWA in the in-

Conclusions
USVs need to secure safety by preventing collisions with other ships. To do this, USVs must avoid opposing vessels in collision-hazardous situations according to the COLREGs rules. In this paper, we proposed a USV algorithm to allow vessels to avoid collisions with opposing vessels based on the COLREG rules. First, we define the main collision risk situations of COLREGs and propose a method to improve DWA to comply with the COLREG rules according to collision risk situations. In addition, we implement the simulation and compare the standard DWA with the CCDWA proposed in this paper. As a result, it is confirmed that the CCDWA complies with COLREG.
In future works, the proposed assistance technique will be integrated into the operating system of USVs. Then, the validity of the proposed CCDWA will be verified by conducting a sea operation experiment on the USVs.  Second, we compared the standard DWA with the CCDWA through simulation in the intersection situation with dynamic obstacles. As an initial setting, our own ship was set to move in the right direction at a speed of 10 m/s, and the obstacle ship was set to move in a direction to the right side of our own ship at a distance of 500 m from our own ship at a speed of 10 m/s. Figure 8a shows the simulation results when applying the standard DWA in the intersection situation with dynamic obstacles. In the first figure, the TCPA of our own ship and the obstacle ship is 33 s and the DCPA is 70 m. Therefore, they get closer to 33 m after 70 s. In the second figure, our own ship turned in the direction of the obstacle ship. At this time, the DCPA was 18 m, which made the situation more dangerous than the situation in the first figure. In the end, it was confirmed that the ships collided in the third figure. Figure 8b shows the simulation results when applying the CCDWA in the intersection situation with dynamic obstacles. In the first figure, the TCPA of our own ship and the obstacle ship is 32 s and the DCPA is 76 m. At this time, the TCPA is positive and the DCPA is less than the safe distance (100 m); the ships are in a dangerous situation. Referring to Figure 3, it is a situation crossing from the right. In the second figure, the CCDWA deactivates the left area of the dynamic window. Accordingly, our own ship turned to the right to avoid crossing ahead of the other. In the third picture, the TCPA is negative and the DCPA is greater than the safe distance; the ships are moving away from each other and are out of danger. As a result, it was confirmed that the CCDWA complies with the COLREG rules in the intersection situation with dynamic obstacles.

Conclusions
USVs need to secure safety by preventing collisions with other ships. To do this, USVs must avoid opposing vessels in collision-hazardous situations according to the COLREGs rules. In this paper, we proposed a USV algorithm to allow vessels to avoid collisions with opposing vessels based on the COLREG rules. First, we define the main collision risk situations of COLREGs and propose a method to improve DWA to comply with the COLREG rules according to collision risk situations. In addition, we implement the simulation and compare the standard DWA with the CCDWA proposed in this paper. As a result, it is confirmed that the CCDWA complies with COLREG.
In future works, the proposed assistance technique will be integrated into the operating system of USVs. Then, the validity of the proposed CCDWA will be verified by conducting a sea operation experiment on the USVs.