The Quadruped Robot Uses the Trajectory Planned by DIACO to Complete the Obstacle Avoidance Task

. Te difusion-improved ant colony optimization (DIACO) algorithm, as introduced in this paper, addresses the slow convergence speed and poor stability of the ant colony optimization (ACO) in obstacle avoidance path planning for quadruped robots. DIACO employs a nonuniformly distributed initial pheromone, which reduces the blind search time in the early stage. Te algorithm updates the heuristic information in the transition probability, which allows ants to better utilize the information from the previous iteration during their path search. Simultaneously, DIACO adjusts the pheromone concentration left by ants on the path based on the map information and difuses the pheromone within a specifc range following the artifcial potential feld algorithm. In the global pheromone update, DIACO adjusts the pheromone on both the optimal path and the worst path generated by the current iteration, thereby enhancing the probability of ants fnding the optimal path in the subsequent iteration. Tis paper designs a steering gait based on the tort gait to fulfll the obstacle avoidance task of a quadruped robot. Te efectiveness of the DIACO algorithm and steering gait is validated through a simulation environment with obstacles constructed in Adams. Te simulation results reveal that DIACO demonstrates improved convergence speed and stability compared to ACO, and the quadruped robot efectively completes the obstacle avoidance task using the path planning provided by DIACO in combination with the steering gait.


Introduction
Making a quadruped robot navigate through an environment with obstacles has been a research hotspot in recent years, specifcally the selection of a collision-free shortest path between the start and target points [1]. As scholars delve deeper into the subject, path planning algorithms have become diverse and rapidly evolving. Te dynamic window method (DWA) [2] has a good performance in local path planning, and its advantage lies in the simple structure of the algorithm and strong real-time performance. However, DWA has disadvantages such as the inability to fnd the target point, the wrong path planning when facing multiple obstacles, and the slow convergence speed. Zhang et al. [3] proposed an optimization algorithm for the problems presented by DWA. Te weight of the objective function was adaptively adjusted according to the size of the velocity space and the distance from the target point. Te adjusted DWA could efectively reduce the computing time and fnd a reasonable optimal path. Te artifcial potential feld (APF) method has the advantages of simple mathematical structure and calculation speed [4]. However, in practical applications, the APF will generate a zero point on the map due to the attractive force generated by the target point and the repulsive force generated by the obstacle, which causes the robot to fall into a dead point and be unable to move forward [5]. Aiming at the problem of the APF, Hu et al. [6] overcome the issue of the local optimal solution by correcting the repulsive function generated by the obstacle and adding corresponding intermediate points along the path. Te genetic algorithm (GA) obtains the optimal solution by simulating natural evolution, as initially proposed by Professor Holland [7,8]. Te advantage of the GA is that it does not require prior knowledge and carries out a parallel search for multiple routes. However, the search efciency is low, and it is easy to obtain the local optimal solution. In view of the disadvantages of GA, Karaboga, and Akay [9], according to the shortest path planning and adaptive smoothness, the ftness function is redesigned. By adjusting the proportion of the two factors in the ftness function, we avoid the local optimal solution and improve the convergence speed of the genetic algorithm. Karaboga and Akay proposed the artifcial bee colony algorithm (ABC) [9][10][11] based on the honey-collecting behavior of bees. Te advantages of ABC include its simple structure, few control parameters, and high searching precision. Nevertheless, this algorithm has some problems, such as premature convergence and search stagnation. Nayyar et al. [12] improved the ABC based on the Arrhenius equation, balancing the capabilities between search and development. Xu et al. [13] introduce a coevolution framework and the globally optimal pilot bee into the ABC, which speeds up the convergence rate of the ABC and overcomes its dependence on the search dimension. Particle swarm optimization (PSO), proposed by James Kennedy and Russell Eberhart [14,15], is a compelling heuristic optimization method. PSO is widely used in the trajectory planning of mobile robots [16], but it may face premature convergence. Wen Li et al. [17], aiming at the problem of PSO, proposed an inertial positioning strategy to make the robot have the ability to predict obstacles in advance. According to the expected obstacle position, the robot path can be generated by cubic spline interpolation.
Te ant colony algorithm (ACO) is a kind of biological intelligence optimization algorithm proposed by Xiong et al. [18][19][20] in his doctoral dissertation. Ants are a kind of social insect. Te foraging behavior of an individual ant is random. Trough the exchange of information between each other, the ant colony will fnd the shortest foraging path. Essentially, the ant colony algorithm is a parallel algorithm. ACO has the advantages of fewer initial parameters, strong robustness, extensive search range, and fast operation speed. ACO also faces disadvantages, such as the local optimal solution and slow convergence.
Many scholars have improved ACO and applied it to robot path planning. Deng et al. [21] added ant species. Diferent species of ants exchange information through the coevolution mechanism. Te pheromone concentration on the optimal path is enhanced in the global pheromone update. In the TSP problem simulation, the modifed ACO efectiveness is verifed. Akka and Khaber [22] added a stimulus factor to the transition probability and changed the original fxed step length to a free step length, which increased the feld of vision of the ants during the search process. Te convergence speed is improved in the pathfnding simulation. Zeng et al. [23] adopt the free gait ant colony algorithm. Ants can move in their feld of vision and improve the local pheromone update rules. Te result of the path-fnding simulation experiment proves the efectiveness of the improvement. Another way to enhance the ant colony algorithm is to integrate it with other algorithms. Chen and Liu [24] fused the artifcial potential feld algorithm with the ACO and combined the direction of the artifcial potential feld at diferent positions to determine the probability of the ant choosing the next position. In an environment with obstacles, the algorithm can be smoothed to fnd the optimal path. Liu et al. [25] used the potential energy algorithm to construct pheromone diffusion rules and geometrically optimized the optimal path generated by the ACO. Te simulation results showed that the convergence speed and path smoothness were significantly improved.
After sorting out the above works of literature, it can be found that the ant colony algorithm still has ample space for improvement. In view of the slow convergence rate of the ant colony algorithm and the problem that it is easy to fall into the local optimal solution, this paper proposes a difusion improved artifcial ant colony algorithm (DIACO), which improved ACO in the four parts. First, the nonuniformly distributed initial pheromone is used to reduce the time of blind search in the early stages of the ant colony algorithm. Secondly, by adding the pheromone difusion rule, the pheromone left by the ant in the walking process is not limited to a specifc grid but spreads to a certain range, making it easier for the next ant to obtain pheromone information. Tirdly, change the heuristic information and dynamically adjust the weight of heuristic information in the transition probability with the number of iterations so that the ants can better use the pheromone information. Finally, change the global pheromone update rules so that the path information of this iteration has better enlightenment for the next iteration.
In order to enable the quadruped robot to complete the obstacle avoidance task along the path planned by the DIACO algorithm, this paper designs a steering gait based on the trot gait. Finally, a simulation environment with obstacles is established in Adams to verify the efectiveness of the steering gait and the obstacle avoidance path planned by DIACO.
Te remaining content structure of the full text is as follows: Section 2 describes the traditional ant colony algorithm; Section 3 describes the difusion improved ant colony algorithm; Section 4 describes the steering gait plan; Section 5 describes the experiment; and Section 6 provides the conclusion.

Traditional Ant Colony Algorithm
In the ACO algorithm, divide the environment containing obstacles into grids, and each grid is numbered, as shown in Figure 1. Grid number 1 in the upper left corner represents the starting position of ants, and grid number 400 in the lower right corner represents the food location. Te grid numbers are arranged from left to right and top to bottom. Black grids represent obstacles. Place m ants in the number 1 grid, set the same initial pheromone τ on each grid, and set a taboo table.
At the beginning of the algorithm, the ants determine the possibility of going to the next location based on the transition probability p k ij (t), as shown in the following equation: 2 Complexity where τ ij is the pheromone concentration of position j, and η ij (t) � 1/d ij is the heuristic information from position i to position j. αβ are the constants representing the weight of the pheromone concentration and heuristic information in the transition probability. Selecting the next position is done by the roulette method. In order to prevent the ants from looking for a path back, the position passed by the ant is added to the taboo table. Each ant will leave the same amount of pheromone in the passing position during walking. Te local pheromone update rule is shown in the following equation: According to equation (2), the concentration of pheromone left by the ant is related to its walking distance. Te shorter the walking distance, the higher the concentration of pheromones left. Te following ant can use this pheromone information in path selection. A global pheromone update is required when all ants have completed a path-fnding task. Te global update rule is shown in the following equation: where the constant ρ ∈ [0, 1] is the pheromone volatilization coefcient, and the initial pheromone concentration in the next iteration is the sum of the residual pheromone concentration and the newly added pheromone.

Diffusion Improved Ant Colony Algorithm
Although the ACO algorithm performs well in robot obstacle avoidance path planning, some inherent problems lead to its slow convergence speed and poor stability. Tis section will modify the ACO algorithm to accelerate its convergence speed and stability.

Enhanced Ant Colony Algorithm.
Te ACO setting the same initial pheromone concentration for each position will increase the blind search time in the beginning. In this paper, the initial pheromone concentration with nonuniform distribution is used to reduce the blind search time in the initial stage of the algorithm. Te initial pheromone distribution is shown in the following equation: where d is is the linear distance between diferent positions and the starting position, d ie is the linear distance between diferent positions and the food, E 0 is the initial pheromone concentration constant, and N out i is the number of exits at diferent positions. Te shorter the length d is + d ie and the fewer obstacles near the position, the initial value assigned pheromone higher. Te heuristic information relates to the distance between the current and the following positions in the ACO algorithm. Although the shortest distance can be satisfed for each position selection, the map information is not considered, and it is easy to fall into a local optimal solution. In order to obtain the global optimal path, in addition to considering the distance between the current position and the next position d ij , the distance between the next position and the food d je should also be considered. Te changed heuristic information is shown in the following equation: where σ 1 and σ 2 are the constants, respectively, represent the weights of d ij and d je in the heuristic information. Te specifc values of these constants need to be determined based on the experimental environment. At the same time, as the number of iterations increases, the role of pheromone information in the transition probability gradually increases, and the role of the heuristic gradually weakens, so the heuristic factor is changed to a variable that decreases with the number of iterations, as shown in the following equation: where β 0 ∈ [1, 5] which ensures a balance between search diversity and convergence speed in the path exploration, and K is the total iteration number. Te modifed heuristic factor Complexity gradually decreases due to the number of iterations, strengthening the pheromone concentration role in the transition probability and speeding up the ant search path.
In the ACO algorithm, the ants leave the same amount of pheromone in the passing position. In the algorithm's early stage, it can guarantee the diversity of the ant search path, but increase the convergence speed. Furthermore, the same pheromone concentration cannot show obstacle information on the map. In order to make the next ant make better use of the information obtained by the previous ant in the path search and avoid areas with multiple obstacles, the obstacle information is added to the local pheromone update rule, as shown in the following equation: where ε is a constant, and the modifed local pheromone rule is related to the number of obstacles near diferent positions on the path. Te fewer the obstacles nearby, the higher the concentration of pheromone left by the ants.
In order to obtain more prior knowledge in the next iteration, the pheromone on the optimal path and the worst path in the previous iteration are dynamically adjusted in the global pheromone update rule, as shown in equation: where e m � e(k/K) is the gain coefcient increases as the number of iterations increases, L bs is the optimal path in this iteration, and L worst is the worst path in this iteration. Adding variable gain coefcients ensures the diversity of path searches in the early stages of the algorithm and also improves the probability of fnding the optimal path in later iterations. Te improvement of the ACO algorithm mainly focuses on strengthening pheromone information and pheromone update rules. While ensuring the diversity of path-fnding, the next ant can make better use of prior knowledge to enhance the stability of the ACO algorithm.

Pheromone Difusion Rules Based on Artifcial Potential
Field. In the ACO algorithm, the local pheromone update of the ants in the path-fnding process is limited to the current and following positions. Tis pheromone update method has limited guidance for the next ant. For example, when the previous ant passes through position 205 in Figure 1, the pheromone information left can be obtained only when the next ant passes through 8 grids around position 205. Otherwise, the current ant cannot obtain the information left by the previous ant.
Moreover, due to environmental factors, such as wind, the pheromone in each position will spread to diferent degrees in a natural state. In this case, the pheromone left by the ant is not confned to a particular location. However, it expands to a specifc area, so the next ant can quickly get the pheromone information left by the previous ant. In order to simulate this natural situation, this paper proposes a pheromone difusion rule based on the artifcial potential feld.
First, divide the area near the ant's passing position into eight areas in a clockwise direction, as shown in Figure 2.
Secondly, the pheromone difusion area at the current position is judged according to the angle between the direction vector pointing to the food at the current position and the vertical direction, as shown in (9) and (10): where y → is the vertical upward unit vector, E i is the direction vector pointing to the food at the current position, and ξ is the area number arranged in a clockwise direction. After determining the pheromone difusion area, it is also necessary to set the maximum difusion range, and the difusion amount decreases as the distance increases, as shown in the following equation: where ζ ∈ [0, 1] is the pheromone difusion constant, D dif is the pheromone difusion distance, and D max is the farthest pheromone difusion distance. Te artifcial potential feld algorithm is a classic robot path-fnding algorithm. Te operating principle of the algorithm is that the target position generates an attractive force on the robot, and the obstacle generates a repulsive force on the robot. Te closer the robot is to the target point, the smaller the attractive force on the robot, and the closer the obstacle, the greater the repulsive force on the robot. When the robot reaches the target point, the attractive force is 0. Te robot moves to the target point under the action of the resultant force, where the attractive feld is expressed by where ς is the attractive constant, x r � (x r , y r ) is the current robot position, x g � (x g , y g ) is the target position, and δ is a constant. In order to prevent the robot from entering the obstacle area, set a dangerous distance. When the distance between the robot and the obstacle is less than this dangerous distance, the obstacle will generate a repulsive force on the robot and push it away from the obstacle. Te repulsive feld is expressed by 4 Complexity is the position of the nearest obstacle to the robot; D d is constant represents the dangerous distance, usually set as twice the moving step length of the robot; L is the repulsion constant; c is a constant. Te resultant force on the robot can be expressed as follows: where F all is a vector representing the resultant force of the current position. Decomposing the resultant force into two components along the positive x-axis F allx and the positive y-axis F ally . Te amount of horizontal difusion of pheromone is determined by F allx , and the amount of vertical diffusion is determined by F ally , as shown in the following equation: where τ k i is the pheromone concentration at the k th iteration position i. Combining (11) and (15) can get the following pheromone difusion rule: Te artifcial potential feld easily falls into the deadpoint problem in practical applications. Te resultant force at a specifc position is 0, as shown in Figure 3. In order to ensure that the pheromone difusion rule can be realized in diferent positions, it is stipulated that at the position where the resultant force is 0, a force vector F food is added, which points to the food. Te magnitude is shown in the following equation: In some cases, the efect of pheromone difusion on the improvement of the algorithm is not obvious. As shown in Figure 1, at position 121, regardless of whether difusing the pheromone, the ant will move to position 141. Terefore, it is necessary to add a threshold that triggers the pheromone difusion mechanism shown as follows: where N all is the total number of exits, and N obs is the number of obstacles at the current position. Te Matlab pseudocode of the DIACO algorithm is shown in Algorithm 1.

Steering Gait Planning
After obtaining the obstacle avoidance path of the quadruped robot through the DIACO algorithm, it is necessary to complete the obstacle avoidance task with the steering gait. In order to ensure the continuity of the gait, this paper completes the turning task based on the tort gait and uses diferent foot displacements to complete the body steering. Considering that the CoM has no displacement in the Z direction during the steering process, the steering motion is limited to the XOY plane, as shown in Figure 4. Te rotation matrix between the body coordinate system at the initial moment of steering s { } and the body coordinate system after steering s 1 is where β is the steering angle, and p � [p x , p y ] T is the CoM position transformation vector.

Steering Gait Foot Displacement.
Te quadruped robot constructed in this paper has a front elbow and back knee structure, as shown in Figure 5. Four legs have the same mechanical structure, and each has three active joints: the hip-pitch joint, the hip-swing joint, and the knee-pitch joint. At the same time, a damping spring is added between the leg and foot to absorb the impact force when the foot makes contact with the ground. Name the four legs clockwise as RF (right front leg), RH (right hind leg), LH (left hind leg), and LF (left front leg).
In the trot gait, divide the legs into LF-RH and RF-LH. When the LF-RH is in the swing phase, the RF-LH is in the support phase, and the two groups of legs alternately move to complete the quadruped robot forward motion. Under the premise of not changing the motion state of the legs, Complexity this paper completes the body steering task by diferent displacements of each foot. Te change of foot position in a single steering gait cycle is shown in Figure 6.
In Figure 6, c is the angle that the robot can rotate in a gait cycle, l x is the forward distance of the fuselage, and l y � tan l x is the lateral displacement of the body. Te transformation matrix between the body coordinate system after rotation s′ and the initial body coordinate system s { } is as follows: After the steering of the quadruped robot is completed, each foot returns to the initial position of the relative coordinate system s′ , and the coordinates are as follows: According to (20) and (21), the coordinates of the foot coordinate in the coordinate system s { } is given in the following equation: According to the geometric relationship shown in Figure 6, the displacement of the foot when body steering can be obtained as follows:

Steering Foot Trajectory
Planning. Tis paper plans the foot trajectory based on the cycloid trajectory. Te trajectory must satisfy the following requirements: (1) In order to ensure the continuity of the movement during the swing phase, the velocity in the X, Y, and Z directions is 0 when the foot leaves the ground, reaches the highest point, and touches the ground.
(2) To ensure that the foot does not slip on the ground, try to reduce the impact force generated when the foot falls. Tat is, the acceleration in the X, Y, and Z is 0 when the foot leaves the ground, reaches the highest point, and touches the ground.     8 Complexity According to (33), the velocity and acceleration along the X-direction when the foot movement can be obtained as follows: According to the calculation, at the start and end times of the foot movement, the foot speed and acceleration in the Xdirection are 0, satisfying the requirement of no sudden change in speed and acceleration during the foot movement.
Since only the hip-swing joint controls the movement of the leg in the Y-direction, it can be designed according to the X-direction foot swing phase curve: where S m y is the displacement of the foot in the Y-direction. Te trajectory of the swing phase is as follows: Te foot displacement in the support phase causes the CoM to move in the desired direction. Te trajectory of the foot support phase can be obtained as follows:

Experiment
In order to verify the path-fnding efect of DIACO in an environment with obstacles, the experiment is carried out in MATLAB and Adams. Te size of the experiment environment is 30 * 30, as shown in Figure 7. Te simulation environment containing obstacles built in Adams according to the MATLAB grid diagram is shown in Figure 8. Te upper left corner is the starting position of the quadruped robot, the lower right corner is the target position, the black grid represents the obstacle, and the white grid represents the barrier-free area. Te experiment environment is as follows: Ubuntu18.04; the processor is an Intel i7-6800; the main frequency is 2.8 GHz; the memory is 32 GB; and the experiment software are matlabR2019b and Adams 2016.

Obstacle Avoidance Path Planning Experiment.
Te ACO and the DIACO are set with the same number of ants and iteration times, and comparative experiments are carried out. Te convergence curve in the experiment environment is shown in Figure 9, and the robot movement trajectory in the environment is shown in Figure 10. Te red curve in Figure 9 is the convergence curve of the ACO, and the blue curve is the convergence curve of the DIACO. It can be seen from the data in Figure 9 that the ACO obtains the shortest path in the 211th iteration and entirely converges at the 428th iteration. Te DIACO gets the shortest path at the 40th iteration and fully converges. Figure 10(a) is the robot movement trajectory planned by the ACO and 10(b) is the robot movement trajectory planned by the DIACO. Upon comparison, it can be observed that the path planned by ACO presents a few more twists and turns than the one planned by DIACO. More crucially, the path generated by DIACO exhibits signifcant smoothness, especially during the 5th to 8th turns, providing the quadruped robot with sufcient turning space, a vital aspect for efcient movement. Consequently, the advantages of DIACO in terms of path quality are quite apparent.
By comparing the paths generated by the two algorithms under the same conditions, it can be seen that DIACO is superior to ACO in terms of convergence speed and stability. In addition, the obstacle-avoiding path planned by DIACO is more reasonable, mainly because it provides a more intuitive and expected path for the quadruped robot, showing excellent adaptability in complex environments. Terefore, it can be seen that DIACO has obvious advantages in path planning quality.

Steering Gait Experiment.
In order to verify the efectiveness of the steering gait proposed in this paper, kinematic simulation experiments were carried out on Adams. Some simulation parameters are as follows: the support phase time is 2 s, the swing phase time is 2 s, and the simulation time is 20 s (2 s before the simulation experiment, the LF-RH is in the support phase, which is used to simulate the state at the end of straight walking). For single steering gait body steering 22.5°, the motion parameters of each foot end are calculated by equation (22). Te simulation process depicted in Figure 11 includes distinct moments: the initiation of the turn, the moment RF-LH begins in lateral swing, the Complexity 9 moment LF-RH begins lateral swing, and the completion of the turn. Te yaw angle change curve of the body is shown in Figure 12. According to Figure 12, it can be seen that the yaw angle of the body changes slightly because the LF leg and the RH leg push the ground sideways. When the RF leg and the LH leg enter the support phase, the body is driven to move sideways, and the yaw angle of the body has signifcantly changed. When the lateral movement of the LF leg and the RH leg ends, since the body is a rigid object and the four legs return to the initial position, the change in the yaw angle of the body at this stage is relatively small, which is consistent with the mathematical model above. In 4 steering gait cycles, the body turned 83.8°in total, and the average single steering gait could turn 20.9°. Considering the change of the center of gravity during the turning process of the body, this angle meets expectations.
Te angular velocity of the fuselage around the Z-axis is shown in Figure 13. According to the data analysis in the fgure, when the quadruped robot starts to steer, the body will generate an angular velocity around the Z-axis due to the lateral thrust of the LF leg and RH legs on the ground. When the LF leg and the RH leg are in the supporting stage, the angular velocity around the Z-axis gradually decreases, which proves that the body completes the steering motion smoothly. When the next steering gait starts, the angular velocity of the body around the Z-axis will be slightly more signifcant than the initial steering due to the center of mass change of the body. Te curve does not gradually become more extensive, which proves that the steering gait designed in this paper can make the feet of the quadruped robot return to the initial position and ensure the body's stability.

Obstacle Avoidance Experiment.
In order to verify whether the path planned by DIACO can meet the obstacle avoidance requirements of the quadruped robot, an obstacle avoidance experiment was conducted in Adams.
Considering the steering angle and the stability of the body in a single gait cycle, the simulation parameters for this part are set as follows: the support phase and swing phase time are set to 5 s, the forward step length is set to 250 mm, and the simulation time is set to 850 s. Te simulation results are shown in Figure 14. Figure 15 depicts the key moments in the obstacle avoidance process of the quadruped robot: the beginning of obstacle avoidance, the start of the frst turning gait, the end of the last turning gait, and the completion of the obstacle avoidance. In order to avoid the large obstacles in the environment, the quadruped robot uses two straight walking gaits and four steering gaits to complete the obstacle avoidance task. Figure 16 shows the movement curve of the body's center of mass during the obstacle avoidance path. Te curve analysis shows that the robot's center of mass can move to the target position through the obstacle avoidance path, and the curve is continuous and smooth.
In conclusion, the obstacle avoidance path obtained by the DIACO algorithm combined with the steering gait can ensure the quadruped robot completes the obstacle avoidance task, which proves the efectiveness of the obstacle avoidance path planned by the DIACO algorithm and the steering gait.

. Conclusions
Compared with ACO, the DIACO algorithm proposed in this paper is greatly improved in terms of convergence speed and stability. Combined with the quadruped robot's steering gait, it can complete the obstacle avoidance task, which proves the efectiveness of the obstacle avoidance path planned by DIACO.
Te DIACO algorithm, proposed for ofine path planning for obstacle avoidance in quadruped robots, may require longer computation time as the complexity and scope of the planning scenario increase, despite its fast convergence and stability. Future research will focus on addressing this challenge by refning the algorithmic framework, optimizing the code, employing parallel computing, or leveraging high-performance GPUs. Te goal is to enable online path planning in more complex environments for quadruped robots.

Data Availability
Te data used to support the fndings of this study are included within the article.

Conflicts of Interest
Te authors declare that they have no conficts of interest.