## 3 Four-Dimensional Dynamic Cooperative Path Planning Algorithm
### Overall Framework  
Algorithm 1 shows the executive process of the 4D dynamic cooperative path planning algorithm for multiple UAVs.  
In the pre-cooperative planning based on the initial environment (lines 02-07), the algorithm first initializes the search tree \(T_{i}\) and sets the start and goal \([s_{i},g_{i}]\) of any UAV\({}_{i}\), as well as the initial planning space \(\mathcal{X}\). Then, the classical RRT* shown in Algorithm 1 is used to plan the optimal path for all UAVs without considering the 4D cooperative constraints. After the UAV planning is completed, the shortest coordination time \(t_{co}\) of the UAVs is determined through the process _ETA_Len_. Then, the DPRRT* algorithm is used to plan the paths of all UAVs that meet the 4D cooperative constraints in the initial planning space \(\mathcal{X}\). Finally, all UAVs execute their respective cooperative paths.  
The purpose of the process _ETA_Len_ is to obtain the minimum coordination time \(t_{co}\) of all the UAVs by calculating the minimum flight time set for all UAVs and calculating the maximum value in the set. It should be noted that all UAVs can achieve the shortest path (Line 03) through classical RRT*. In other words, all UAVs are able to achieve the shortest flight time without considering 4D cooperative constraints. We assume that the minimum flight time UAV\({}_{i}\) is \(t_{i}\), the minimum flight time UAV\({}_{j}\) is \(t_{j}\), and that \(t_{i}>t_{j}\). Since \(t_{i}\) and \(t_{j}\) are already the shortest flight times, the only way to ensure that UAV\({}_{i}\) and UAV\({}_{j}\) satisfy the time coordination constraints and ensure the shortest coordination time is to increase \(t_{i}\) so that it is equal to \(t_{j}\).  
If the UAV detects a sudden threat \(\Delta\mathcal{X}_{new}^{threat}\) in planning space \(\mathcal{X}\) during flight, the cooperative path based on the previous planning space may be affected, resulting in the failure of the path to cooperate. Therefore, cooperative replanning needs to be executed in the new planning space containing \(\Delta\mathcal{X}_{new}^{threat}\). We use the _Conflicts_occurred_ process to find the UAV set \(\mathbf{UAV}_{conflict}\) (and its conflict path \(\sigma_{conflict}\)) affected by \(\Delta\mathcal{X}_{new}^{threat}\) from among all UAVs. Then, HAPF is applied to all UAVs in the set \(\mathbf{UAV}_{conflict}\) for the efficient online onboard replanning of paths. As HAPF is a local conflict avoidance algorithm, it can only ensure that the UAV meets the spatial coordination constraints in the 4D coordination constraints. Therefore, we choose the path node \(\sigma_{conflict}\) which, as the generation node of the attractive potential field of \(\mathbf{UAV}_{conflict}\), is not reached and not affected by the threat, thus enabling \(\mathbf{UAV}_{conflict}\) to return to the previous 4D cooperative path after avoiding the sudden threat. At the same time, the UAVs not affected by \(\Delta\mathcal{X}_{new}^{threat}\) continue to fly along the previously planned coordinated path. When the \(\mathbf{UAV}_{conflict}\) avoids sudden threats, the DPRRT* is used to replan the path from the current position of the UAVs to their destination, while meeting the 4D cooperative constraints for all UAVs. If the planning space is not changed, all UAVs fly along the current initial path until they reach the goal and the algorithm is terminated. Otherwise, when new sudden threats are detected, lines 08-22 of Algorithm 1 are executed until the goal is reached.