Considering the characteristics of low-altitude combat environments, a three-dimensional integrated simulation scenario containing multiple heterogeneous obstacles was constructed. The scene replicates a typical complex terrain characterized by constrained spatial structures and dynamic threats. The static environment includes U-shaped obstacles, narrow passages, walls with windows, and clusters of tree-like obstacles. In addition, randomly moving cylindrical dynamic obstacles are introduced to emulate unknown threats.
5.2. Simulation Validation of the Formation Control Algorithm
In this section, the proposed control algorithm is validated through simulations. The UAV formation consists of five UAVs, denoted as follower U1, follower U2, follower U3, follower U4, and follower U5. The virtual leader U0 flies along the trajectory planned by DASRRT*. U1 tracks the virtual leader, while the remaining followers track U1 and maintain a V-shaped formation with a rear included angle of
. The formation information is listed in
Table 5, the parameters of the dynamic obstacles are given in
Table 6.
Figure 17a illustrate the flight trajectories of the UAV formation in three-dimensional space. Using the proposed algorithm, the UAVs successfully and safely traversed the complex environment, with a total flight time of 158 s. In the initial stage, the environment is relatively open, allowing the UAV swarm to maintain the V-shaped formation. Upon entering the obstacle region, under the dual-mode switching mechanism, each UAV responds rapidly to environmental changes and independently plans its obstacle-avoidance trajectory. After passing through the obstacle region, the UAVs quickly regain and maintain the desired V-shaped formation and reach the target point. The coordinated effect of the proposed dual-mode switching mechanism and the control law ensures both individual flight safety and formation integrity at the mission level.
Figure 17b presents snapshots of key moments during the formation flight on the Gazebo platform. It can be seen that the UAV formation successfully completes takeoff, obstacle traversal, and arrival at the destination, indicating that the proposed method can be reproduced on the Gazebo platform. This further verifies the implementability of the algorithm and its potential for engineering applications.
Figure 18,
Figure 19 and
Figure 20 illustrate the dynamic relationship among the environmental complexity
, mode switching, and the control-weight coefficients during flight. As shown in
Figure 19, the formation flight undergoes two distinct transitions between obstacle avoidance and formation recovery. When the formation approaches a narrow passage or a densely cluttered mixed-obstacle region, the local environmental complexity increases and
exceeds the threshold, causing the system to switch from the formation maintenance mode to the Emergency-Avoidance Mode. After passing through the obstacle region,
falls below the threshold, and the system returns to the formation maintenance mode. As further illustrated in
Figure 20, the variation in environmental complexity not only triggers mode switching, but also directly affects the allocation of control weights. In the formation maintenance mode,
dominates, while
and
remain relatively small, so the system mainly focuses on maintaining the V-shaped formation. In the Emergency-Avoidance Mode, as
increases,
decreases whereas
and
increase, with
showing a more pronounced response in highly cluttered regions. This indicates that the control focus shifts from formation constraints to obstacle avoidance and collision avoidance. After clearing the obstacle region, the formation reconverges to the desired configuration. The results show that the designed dual-mode switching mechanism and dynamic weight adjustment strategy can autonomously adjust the control law weights based on environmental complexity, achieving an efficient balance between formation maintenance and flight safety.
The environmental complexity threshold is set based on multiple simulation experiments and an analysis of formation flight risk changes. To verify whether this switching strategy leads to frequent mode switching and control oscillations, the state changes during the flight were further statistically analyzed. Throughout the entire flight process, the system only experienced 4 mode switches, with an average of one switch every 39.4 s, and no high-frequency oscillation near the threshold was observed. The average formation recovery time was 2.8 s, and the maximum oscillation amplitude was 0.032946 m, indicating that the mode switching process did not cause significant control oscillations or flight instability. These results suggest that the set threshold effectively meets the stable switching requirements in this simulation scenario. In subsequent engineering deployments, the threshold switching logic can be further combined with a hysteresis interval to enhance robustness against sensor noise and transient disturbances.
As shown in
Figure 21a, within the obstacle region, the minimum inter-UAV distance remains around 1 m, and no inter-agent collisions occur throughout the flight. This verifies the effectiveness of the inter-UAV collision-avoidance control law.
Figure 21b shows that when the UAVs enter the densely cluttered area, the minimum distance between the formation and obstacles stays at approximately 2.5 m and never drops to zero at any time. This indicates that the improved obstacle-avoidance control law—by incorporating a distance-adaptive factor and a dynamic velocity weighting—provides sufficient repulsive action to ensure safety while maintaining motion toward the goal.
As shown in
Figure 22, during the initial stage, the tracking errors of all UAVs rapidly converge to a small range near zero, verifying the fast convergence of the proposed control law. After entering the densely cluttered region, the system switches to the emergency-avoidance mode, and the priority on obstacle avoidance induces fluctuations in the tracking errors. Even during the narrow-passage traversal and dynamic avoidance phases, the mean error remains within a controlled range, while higher tracking accuracy is achieved in open areas. Notably, U1 exhibits a relatively large error around 90 s because it waits at the end of the narrow passage to avoid the first dynamic obstacle. The other UAVs perceive U1’s lag, move toward U1, and enter a waiting state. Once the dynamic obstacle passes, U1 immediately accelerates under the control input to catch up. Owing to the rapid convergence of the control law, the formation quickly returns to the prescribed configuration. The formation waiting stage is shown in
Figure 23.
As shown in
Figure 24a, the flight speed of all UAVs is strictly limited to a maximum of 3.5 m/s throughout the process. From
Figure 24b,c, it can be observed that during the formation maintenance phase, the heading changes of all UAVs are generally consistent. However, during the obstacle-avoidance phase, both the heading angle and angular velocity show significant fluctuations, reflecting the UAVs’ rapid attitude adjustments to adapt to local obstacle constraints. The orderly parameter
is a core indicator of the degree of consistency in the formation’s speed and direction. As shown in
Figure 24d, in the formation maintenance mode,
remains close to 1, indicating that the flight directions of all UAVs are highly consistent. In the obstacle-avoidance mode (e.g., around 18 s and 100 s),
significantly decreases, indicating that the UAVs have adopted differentiated avoidance actions. After the obstacle avoidance is completed,
quickly recovers to near 1, showing that the designed control framework has good cooperative recovery capability.
As shown in
Figure 25a, the UAV formation becomes stalled while attempting to traverse the obstacle region formed by narrow windows. From
Figure 25b, U4 fails to pass through the window in time and consequently departs from the formation. After
s, all position errors converge to nearly constant values, indicating that the system enters a deadlock state: the resultant force becomes zero, causing the formation to halt. This demonstrates that, without the dual-mode switching mechanism, the cooperative control law alone cannot balance formation maintenance and obstacle avoidance in extremely constrained spaces.
To validate the effectiveness of the proposed improved APF in mitigating the issue of unreachable targets caused by local minima in the traditional APF, a standard APF control group was constructed, and a comparative experiment was conducted under the same conditions. This control group removed the dual-mode switching strategy, adaptive weight allocation, and the target distance and velocity coupling terms in the improved potential field, relying solely on the traditional APF repulsive force for external obstacle avoidance and inter-UAV collision avoidance.
As shown in
Table 7 and
Figure 26, although the APF does not lead to any collision, it fails to reach the target point and becomes trapped in the obstacle region, indicating that the traditional APF is prone to falling into local minima in complex obstacle environments. Its minimum obstacle distance is only 0.1187 m, and the average formation error is 6.9879 m, suggesting a low obstacle-avoidance safety margin and difficulty in balancing obstacle avoidance with formation maintenance. In contrast, the improved APF successfully reaches the target point, with the minimum obstacle distance increased to 1.9698 m and the average formation error reduced to 4.1844 m, indicating that the improved APF provides better obstacle-avoidance safety and formation maintenance capability in complex dynamic environments. The maximum oscillation amplitude of the improved APF is higher than that of the traditional APF, mainly because the improved APF successfully enters and traverses the subsequent narrow passage and dynamic-obstacle region, during which local trajectory variations become relatively larger due to obstacle avoidance. By contrast, the traditional APF becomes trapped before entering the subsequent obstacle region; therefore, the oscillation amplitudes of the two methods are not measured at the same motion stage, and a direct comparison is not entirely fair. The maximum oscillation amplitude of the improved APF remains within an acceptable range and does not cause collisions or mission failure, and can therefore be regarded as a necessary maneuvering response during complex obstacle avoidance. Overall, compared with the traditional APF, the improved APF demonstrates superior performance in task completion, local-minimum suppression, obstacle-avoidance safety margin, and formation maintenance capability.
To further verify the adaptability of the proposed hierarchical cooperative control framework under environmental disturbances and formation configuration changes, experiments are conducted from three aspects: initial disturbance, dynamic obstacle velocity variation, and formation scale variation. The results are shown in
Table 8. Here, the average formation recovery time is defined as the average time it takes for the formation’s mean error to drop within the set threshold and remain there for several sampling steps after the system switches from Mode 2 to Mode 1.
In the initial disturbance experiment, Groups B and C achieved average formation errors of 3.5799 m and 3.703 m, respectively, both lower than the 4.15 m in the baseline scenario. The average recovery times were also shortened to 1.6 s and 0.9 s, indicating that the system can quickly absorb the formation deviation caused by the initial disturbance and restore cooperative flight. Although the minimum inter-UAV distances in both groups decreased, no collisions occurred, demonstrating that the controller maintains reliable safety constraints even under initial biases.
In the dynamic obstacle speed variation experiment, after adjusting the obstacle speed to 0.7 times and 1.3 times the baseline value in Groups D and E, the system still maintained zero collisions, with average formation errors further decreasing, and recovery times staying within a short range. In conditions with more frequent dynamic interactions, although the number of mode switches increased, the system was still able to quickly recover formation after safely avoiding obstacles. This indicates that the proposed dual-mode cooperative mechanism can adjust the control focus in response to time-varying environments and shows strong adaptability to changes in obstacle motion speed.
In the formation scale variation experiment, when the formation size was expanded from 3 UAVs to 7 and 9 UAVs, although the local interaction complexity increased significantly and both the minimum inter-UAV distance and minimum obstacle distance decreased, no collisions occurred in any of the scenarios. The average formation error and recovery time remained within acceptable ranges, demonstrating that the framework retains good task maintenance and cooperative recovery capabilities under scale variation conditions, reflecting a certain level of system scalability.