## 3 Flight Coordination Control Methods
### Formation Flight Method  
For formation flights, we utilize a leader-follower model to accomplish the formation flight mission. In this model, one UAV is assigned as the leader, and the other UAVs follow its flight path while adjusting their positions relative to the leader. The leader UAV operates in active mode and receives commands sent from MS, which is responsible for planning the flight path of the leader. In contrast, the follower UAVs are operated in passive mode and autonomously adjust their flight path using information shared by the leader. Flowcharts of the proposed formation flight for the leader UAV and follower UAVs are shown in Figure 10(a), respectively.  
For the formation flight, we consider a function \(f_{n}\) defined as follows:  
\[(\hat{x}_{n},\hat{y}_{n},\hat{z}_{n})=f_{n}(x_{n,k},y_{n,k},z_{n,k}). \tag{7}\]  
This function is used to determine the position where the follower UAV\({}_{n}\) should be to maintain a given flying formation. Figure 10(b) illustrates an example of formation \(f_{n}\) used in our system. In Equation (7), \(x_{n,k}\), \(y_{n,k}\), and \(z_{n,k}\) represent the received position information shared by the leader UAV\({}_{k}\). \(\hat{x}_{n}\), \(\hat{y}_{n}\), and \(\hat{z}_{n}\) are the position where the follower UAV\({}_{n}\) should be. The outputs of \(f_{n}\) are then used by the follower UAVs to adjust their flight speed \(v^{\prime}_{n,n}\) and direction \(\theta^{\prime}_{n,n}\) to maintain the flight formation throughout the entire mission. The adjusted flight speed \(v^{\prime}_{n,n}\) is calculated by  
\[v^{\prime}_{n,n}=||(\hat{x}_{n},\hat{y}_{n},\hat{z}_{n})-(x_{n,n},y_{n,n},z_{n,n})||_{2}T^{-1}, \tag{8}\]  
Figure 10: Examples for UAV collision avoidance and formation scenarios.  
and the adjusted flight direction \(\theta^{\prime}_{n,n}\) of UAV\({}_{n}\) can be expressed by  
\[\theta^{\prime}_{n,n}=\left(\phi^{\prime}_{n,n},\phi^{\prime}_{n,n}\right), \tag{9}\]  
where \(\phi^{\prime}_{n,n}\) and \(\phi^{\prime}_{n,n}\) are defined as the adjusted azimuthal and polar angles, respectively, of UAV\({}_{n}\) in spherical coordinates. The values of \(\phi^{\prime}_{n,n}\) and \(\phi^{\prime}_{n,n}\) can be found by solving the following equations:  
\[\left\{\begin{array}{l}\hat{x}_{n}-x_{n,n}=v^{\prime}_{n,n}T\sin\left(\phi^{ \prime}_{n,n}\right)\cos\left(\phi^{\prime}_{n,n}\right)\\ \hat{y}_{n}-y_{n,n}=v^{\prime}_{n,n}T\sin\left(\phi^{\prime}_{n,n}\right)\sin \left(\phi^{\prime}_{n,n}\right)\\ \hat{z}_{n}-z_{n,n}=v^{\prime}_{n,n}T\cos\left(\phi^{\prime}_{n,n}\right)\end{array} \right.. \tag{10}\]  
The proposed formation flight algorithm for UAV\({}_{n}\) following leader UAV\({}_{k}\) is shown in Algorithm 2.  
```
1 Input:\(\mathbf{I}_{n,n}\), \(\mathbf{I}_{n,k}\), \(T\);
2 Output:\(v^{\prime}_{n,n}\), \(\theta^{\prime}_{n,n}\);
3\(\%\theta^{\prime}_{n,n}\) and \(v^{\prime}_{n,n}\) are adjusted flight direction and speed of UAV\({}_{n}\) after algorithm performance;
4 Run (7) to calculate \(\hat{x}_{n}\), \(\hat{y}_{n}\), and \(\hat{z}_{n}\);
5 Run (8) to calculate \(v^{\prime}_{n,n}\);
6 Run (9) and (10) to calculate \(\theta^{\prime}_{n,n}\);
7 Return;
```  
**Algorithm 2**Formation flight algorithm