# A Method of Dual-AGV-Ganged Path Planning Based on the Genetic Algorithm
## 3 Proposed Dual-AGV-Ganged Path-Planning Method
### Introducing the Starting-Point and Goal-Point Pose for Path Initialization
(4) Calculate the cost value of the dual-AGV-ganged steering: The current angle of the follower AGV and the goal angle is set as \(\theta_{A}\) and \(\theta_{B}\) respectively, and the number of obstacle points between \(\theta_{A}\) and \(\theta_{B}\) is first calculated. Subsequently, the steering cost value between \(\theta_{A}\) and \(\theta_{B}\) is computed using the dual-AGV-ganged steering cost function. The steering process for the dual AGVs is illustrated in Figure 3, and the function is represented by Equation (7):  
\[C_{\text{Turn}}= \begin{cases}1&\text{if }N_{\text{Obstacle}}=0\\ N_{\text{Obstacle}}\times 100&\text{if }N_{\text{Obstacle}}>0^{\prime}\end{cases}  \tag{7}\]  
where \(C_{\text{Turn}}\) is the cost of turning, and \(N_{\text{Obstacle}}\) is the number of obstacle points. If \(\theta_{A}\) and \(\theta_{B}\) are equal, then \(N_{\text{Obstacle}}\) is 0; if they are not equal, then, with the current node as the center and \(R_{\text{Turn}}\) as the radius, adjust the x and y coordinates of the center by adding and subtracting the radius to form a range for intersection traversal. Within this range, find the coordinates where the distance from the center is less than or equal to the radius and falls within the specified angular region. Then, count the number of obstacles in this area to determine \(N_{\text{Obstacle}}\);  
(5) Generate a path considering the starting-point pose: Sequentially, the node with the minimum \(C_{\text{Turn}}\) as the next node is selected, and then the current node for the leader AGV is designated. Then, this node is added to the path and the corresponding \(\theta_{\text{point}}\) is rotated clockwise by 180\({}^{\circ}\) to set the current angle for the follower AGV. Repeat these steps until an initial path to the goal point is generated;  
Part II: Initialization of the Path Goal-Point Poses  
(6) Obtain the angle of the goal-point: Subscribing to the ROS topics published by RVIZ, and in following Step (1), the angle \(\theta_{\text{goal}}\) of the goal point is obtained, the goal point is set as the current node for the leader AGV, and \(\theta_{\text{goal}}\) is set as the current angle for the follower AGV;  
(7) Conduct a search of the surrounding free nodes and sort: In the initialized path obtained from Step (1), a path point is randomly selected and is designated as the goal point. Then, following Step (2), the free nodes around the current node of the leader AGV are retrieved and sorted;  
(8) Working backwards to calculate the angle forming a vector: With the current node of the leader AGV as \(P_{B}\) and the preselected path point as \(P_{A}\), and in following Step (3), the angle of the vector formed by the two nodes is reverse calculated to obtain \(\theta_{\text{point}}\). This angle points from the preselected path point to the current node. After rotating it clockwise by 180\({}^{\circ}\), it is set as the goal angle for the follower AGV;  
(9) Reverse calculation of the dual-AGV-ganged steering cost value: In following Step (4), \(C_{\text{Turn}}\) is calculated and selected with the node with the smallest \(C_{\text{Turn}}\) as the next node. This is then set as the current node, which is then rotated \(\theta_{\text{point}}\) clockwise by 180\({}^{\circ}\) to determine the current angle for the follower AGV. The next node is then continually selected according to the aforementioned steps until the path to the random path point is found;  
Figure 3: Schematic diagram of the dual-AGV-ganged steering. (10) Generate a path considering the goal-point pose: The path from the starting point to the random path point is combined with the path introducing the pose of the goal point in reverse order, generating a path that simultaneously considers the poses of both the starting point and the goal point;  
Finally, determine whether the initial population requirements are met: if yes, output the initial population; if no, proceed to Step (6) and continue the initialization process. The algorithm initialization process is illustrated in Figure 4.