Abstract
The diffusion-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. The 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 diffuses the pheromone within a specific range following the artificial potential field 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 finding the optimal path in the subsequent iteration. This paper designs a steering gait based on the tort gait to fulfill the obstacle avoidance task of a quadruped robot. The effectiveness of the DIACO algorithm and steering gait is validated through a simulation environment with obstacles constructed in Adams. The simulation results reveal that DIACO demonstrates improved convergence speed and stability compared to ACO, and the quadruped robot effectively completes the obstacle avoidance task using the path planning provided by DIACO in combination with the steering gait.
1. Introduction
Making a quadruped robot navigate through an environment with obstacles has been a research hotspot in recent years, specifically 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. The 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 find 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. The weight of the objective function was adaptively adjusted according to the size of the velocity space and the distance from the target point. The adjusted DWA could effectively reduce the computing time and find a reasonable optimal path. The artificial potential field (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. The genetic algorithm (GA) obtains the optimal solution by simulating natural evolution, as initially proposed by Professor Holland [7, 8]. The advantage of the GA is that it does not require prior knowledge and carries out a parallel search for multiple routes. However, the search efficiency 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 fitness function is redesigned. By adjusting the proportion of the two factors in the fitness function, we avoid the local optimal solution and improve the convergence speed of the genetic algorithm. Karaboga and Akay proposed the artificial bee colony algorithm (ABC) [9–11] based on the honey-collecting behavior of bees. The 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.
The ant colony algorithm (ACO) is a kind of biological intelligence optimization algorithm proposed by Xiong et al. [18–20] in his doctoral dissertation. Ants are a kind of social insect. The foraging behavior of an individual ant is random. Through the exchange of information between each other, the ant colony will find 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. Different species of ants exchange information through the coevolution mechanism. The pheromone concentration on the optimal path is enhanced in the global pheromone update. In the TSP problem simulation, the modified ACO effectiveness is verified. Akka and Khaber [22] added a stimulus factor to the transition probability and changed the original fixed step length to a free step length, which increased the field of vision of the ants during the search process. The convergence speed is improved in the path-finding simulation. Zeng et al. [23] adopt the free gait ant colony algorithm. Ants can move in their field of vision and improve the local pheromone update rules. The result of the path-finding simulation experiment proves the effectiveness of the improvement. Another way to enhance the ant colony algorithm is to integrate it with other algorithms. Chen and Liu [24] fused the artificial potential field algorithm with the ACO and combined the direction of the artificial potential field at different positions to determine the probability of the ant choosing the next position. In an environment with obstacles, the algorithm can be smoothed to find 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. The 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 diffusion improved artificial 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 diffusion rule, the pheromone left by the ant in the walking process is not limited to a specific grid but spreads to a certain range, making it easier for the next ant to obtain pheromone information. Thirdly, 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 effectiveness of the steering gait and the obstacle avoidance path planned by DIACO.
The remaining content structure of the full text is as follows: Section 2 describes the traditional ant colony algorithm; Section 3 describes the diffusion improved ant colony algorithm; Section 4 describes the steering gait plan; Section 5 describes the experiment; and Section 6 provides the conclusion.
2. 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. The 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 , as shown in the following equation:where is the pheromone concentration of position j, and 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. The 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. The shorter the walking distance, the higher the concentration of pheromones left. The following ant can use this pheromone information in path selection. A global pheromone update is required when all ants have completed a path-finding task. The global update rule is shown in the following equation:where the constant is the pheromone volatilization coefficient, and the initial pheromone concentration in the next iteration is the sum of the residual pheromone concentration and the newly added pheromone.
3. 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. This section will modify the ACO algorithm to accelerate its convergence speed and stability.
3.1. Enhanced Ant Colony Algorithm
The 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. The initial pheromone distribution is shown in the following equation:where is the linear distance between different positions and the starting position, is the linear distance between different positions and the food, is the initial pheromone concentration constant, and is the number of exits at different positions. The shorter the length and the fewer obstacles near the position, the initial value assigned pheromone higher.
The heuristic information relates to the distance between the current and the following positions in the ACO algorithm. Although the shortest distance can be satisfied 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 , the distance between the next position and the food should also be considered. The changed heuristic information is shown in the following equation:where and are the constants, respectively, represent the weights of and in the heuristic information. The specific 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 which ensures a balance between search diversity and convergence speed in the path exploration, and K is the total iteration number. The modified heuristic factor 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 modified local pheromone rule is related to the number of obstacles near different positions on the path. The 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 is the gain coefficient increases as the number of iterations increases, is the optimal path in this iteration, and is the worst path in this iteration. Adding variable gain coefficients ensures the diversity of path searches in the early stages of the algorithm and also improves the probability of finding the optimal path in later iterations.
The improvement of the ACO algorithm mainly focuses on strengthening pheromone information and pheromone update rules. While ensuring the diversity of path-finding, the next ant can make better use of prior knowledge to enhance the stability of the ACO algorithm.
3.2. Pheromone Diffusion Rules Based on Artificial Potential Field
In the ACO algorithm, the local pheromone update of the ants in the path-finding process is limited to the current and following positions. This 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 different degrees in a natural state. In this case, the pheromone left by the ant is not confined to a particular location. However, it expands to a specific 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 diffusion rule based on the artificial potential field.
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 diffusion 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 is the vertical upward unit vector, 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 diffusion area, it is also necessary to set the maximum diffusion range, and the diffusion amount decreases as the distance increases, as shown in the following equation:where is the pheromone diffusion constant, is the pheromone diffusion distance, and is the farthest pheromone diffusion distance.
The artificial potential field algorithm is a classic robot path-finding algorithm. The 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. The 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. The robot moves to the target point under the action of the resultant force, where the attractive field is expressed bywhere is the attractive constant, is the current robot position, 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. The repulsive field is expressed bywhere is the position of the nearest obstacle to the robot; is constant represents the dangerous distance, usually set as twice the moving step length of the robot; is the repulsion constant; is a constant. The resultant force on the robot can be expressed as follows:where is a vector representing the resultant force of the current position.
Decomposing the resultant force into two components along the positive x-axis and the positive y-axis . The amount of horizontal diffusion of pheromone is determined by , and the amount of vertical diffusion is determined by , as shown in the following equation:where is the pheromone concentration at the th iteration position i. Combining (11) and (15) can get the following pheromone diffusion rule:
The artificial potential field easily falls into the dead-point problem in practical applications. The resultant force at a specific position is 0, as shown in Figure 3. In order to ensure that the pheromone diffusion rule can be realized in different positions, it is stipulated that at the position where the resultant force is 0, a force vector is added, which points to the food. The magnitude is shown in the following equation:

In some cases, the effect of pheromone diffusion on the improvement of the algorithm is not obvious. As shown in Figure 1, at position 121, regardless of whether diffusing the pheromone, the ant will move to position 141. Therefore, it is necessary to add a threshold that triggers the pheromone diffusion mechanism shown as follows:where is the total number of exits, and is the number of obstacles at the current position. The Matlab pseudocode of the DIACO algorithm is shown in Algorithm 1.
|
4. 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 different 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.

The rotation matrix between the body coordinate system at the initial moment of steering and the body coordinate system after steering iswhere is the steering angle, and is the CoM position transformation vector.
4.1. Steering Gait Foot Displacement
The 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, this paper completes the body steering task by different displacements of each foot. The change of foot position in a single steering gait cycle is shown in Figure 6.

In Figure 6, is the angle that the robot can rotate in a gait cycle, is the forward distance of the fuselage, and is the lateral displacement of the body. The transformation matrix between the body coordinate system after rotation and the initial body coordinate system is as follows:
After the steering of the quadruped robot is completed, each foot returns to the initial position of the relative coordinate system , and the coordinates are as follows:
According to (20) and (21), the coordinates of the foot coordinate in the coordinate system 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:
4.2. Steering Foot Trajectory Planning
This paper plans the foot trajectory based on the cycloid trajectory. The 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. That 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.(3)For the leg to complete the lateral movement, it is necessary to ensure that the foot height reaches 50% of the maximum height in the swing phase.
Since the hip-pitch joint and the knee-pitch joint control the foot’s motion in the Z direction and the hip-swing joint controls the foot’s motion in the Y direction, the swing phase trajectory of the foot can be decoupled.
First, determine the acceleration in the Z direction as follows:
Integrate equation (30) to get the velocity in the Z direction as follows:
According to the trajectory speed constraint of the foot , it can be obtained as follows:
Integrate the velocity in the Z direction to get the displacement in the Z direction as follows:
According to the trajectory displacement constraint of the foot, the Z-direction displacement is divided into four parts, and the corresponding functions are calculated as follows:
In order to ensure that the acceleration and velocity in the Z direction are continuous, the (31) is organized as follows:
The X-direction trajectory needs to determine the displacement of the foot.
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 X-direction 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 is the displacement of the foot in the Y-direction.
The trajectory of the swing phase is as follows:
The foot displacement in the support phase causes the CoM to move in the desired direction. The trajectory of the foot support phase can be obtained as follows:
5. Experiment
In order to verify the path-finding effect of DIACO in an environment with obstacles, the experiment is carried out in MATLAB and Adams. The size of the experiment environment is , as shown in Figure 7. The simulation environment containing obstacles built in Adams according to the MATLAB grid diagram is shown in Figure 8. The 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. The 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.


5.1. Obstacle Avoidance Path Planning Experiment
The ACO and the DIACO are set with the same number of ants and iteration times, and comparative experiments are carried out. The convergence curve in the experiment environment is shown in Figure 9, and the robot movement trajectory in the environment is shown in Figure 10.


(a)

(b)
The 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. The 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 significant smoothness, especially during the 5th to 8th turns, providing the quadruped robot with sufficient turning space, a vital aspect for efficient 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. Therefore, it can be seen that DIACO has obvious advantages in path planning quality.
5.2. Steering Gait Experiment
In order to verify the effectiveness 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). The simulation process depicted in Figure 11 includes distinct moments: the initiation of the turn, the moment RF-LH begins in lateral swing, the moment LF-RH begins lateral swing, and the completion of the turn.

The 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 significantly 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.

The angular velocity of the fuselage around the Z-axis is shown in Figure 13. According to the data analysis in the figure, 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 significant than the initial steering due to the center of mass change of the body. The 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.

5.3. 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. The 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 first 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. The 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 effectiveness of the obstacle avoidance path planned by the DIACO algorithm and the steering gait.
6. 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 effectiveness of the obstacle avoidance path planned by DIACO.
The DIACO algorithm, proposed for offline 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 refining the algorithmic framework, optimizing the code, employing parallel computing, or leveraging high-performance GPUs. The goal is to enable online path planning in more complex environments for quadruped robots.
Data Availability
The data used to support the findings of this study are included within the article.
Conflicts of Interest
The authors declare that they have no conflicts of interest.