## 5 Multi-Drone Guidance Law
### Guidance Law of Every Drone
Under Equation (3), the \(n\)-th drone's waypoint in the inertial frame is  
\[\mathbf{w}_{n,k}=\mathbf{r}_{0,k}+\mathbf{M}_{R}(\psi_{k},\theta_{k})* \mathbf{w}_{n,k}^{B}. \tag{39}\]  
The axis of the grid formation is oriented towards the target \(\mathbf{r}_{k}^{t}\) since \(\mathbf{u}^{R}=\frac{\mathbf{r}_{k}^{R}}{\|\mathbf{r}_{k}^{R}\|}\), where \(\mathbf{r}_{k}^{R}=\mathbf{r}_{k}^{t}-\mathbf{r}_{0,k}\). In other words, the planar grid formation is oriented such that it is perpendicular to \(\mathbf{r}_{k}^{R}\). We next calculate the planar grid formation's orientation (normal vector), \(\psi_{k}\), and \(\theta_{k}\) in Equation (39), associated with \(\mathbf{u}^{R}\) in Equation (38). We apply \(\mathbf{u}^{R}(1)=c(\psi_{k})*c(\theta_{k})\), \(\mathbf{u}^{R}(2)=s(\psi_{k})*c(\theta_{k})\), and \(\mathbf{u}^{R}(3)=-s(\theta_{k})\). Here, \(\mathbf{u}^{R}(j)\) indicates the \(j\)-th element of \(\mathbf{u}^{R}\). Under Equation (38), we obtain  
\[\theta_{k}=atan2(-\mathbf{u}^{R}(3),\sqrt{\mathbf{u}^{R}(1)^{2}+\mathbf{u}^{R }(2)^{2}}). \tag{40}\]  
Under Equation (38), we derive \(\psi_{k}\) as follows. If \(c(\theta_{k})\geq 0\), then we use  
\[\psi_{k}=atan2(\mathbf{u}^{R}(2),\mathbf{u}^{R}(1)). \tag{41}\]If \(c(\theta_{k})<0\), then we use  
\[\psi_{k}=atan2(-\mathbf{u}^{R}(2),-\mathbf{u}^{R}(1)). \tag{42}\]  
Recall that \(\mathbf{w}_{n,k}\) defines the waypoint assigned to the \(n\)-th drone at sample-index \(k\). The heading command of the \(n\)-th drone is set towards \(\mathbf{w}_{n,k}\) at every sample-index \(k\). _The heading vector \(\mathbf{u}_{n,k}\) from Equation (5) is set as follows._  
\[n[i,j]\in\{1,2,\ldots,M=G^{2}\}. \tag{34}\]0  
_At every sample-index \(k\), the \(n\)-th drone sets its speed command \(v_{n,k}\) from Equation (5) as_  
\[n[i,j]\in\{1,2,\ldots,M=G^{2}\}. \tag{34}\]1  
The control commands, Equations (43) and (44), are used to satisfy  
\[n[i,j]\in\{1,2,\ldots,M=G^{2}\}. \tag{34}\]2  
if possible. Once Equation (45) is met for all \(n\in\{1,2,\ldots,M\}\), then all drones form a grid formation at sample-index \(k+1\). Consider the case where \(\|\mathbf{r}_{n,k}-\mathbf{w}_{n,k}\|<v_{max}*T\) at every sample-index \(k\). In this case, Equation (45) is met at every sample-index \(k\). At sample-index \(0\), all drones are located inside the ship. At sample-index \(0\), all drones form the initial grid formation, as presented in Equation (37). Note that each drone is assigned to a waypoint that is in the body-fixed frame of the virtual agent. See Equation (39) for waypoint assignments. Moreover, [48] can be used to assign a drone to each waypoint, such that the makespan (time for all robots to reach their waypoints) is minimized while also preventing collisions among drones. The authors of [48] mentioned that their assignment algorithm scales well, such that it can compute the mapping for 1000 robots in less than half a second. In the worst case, there may be a case where a drone meets another drone while moving toward its assigned waypoint. This case can happen due to localization errors or environment disturbance, such as wind. The drone then uses reactive collision avoidance controls, such as [49; 50; 51; 52], to avoid an abrupt collision with another drone. Under reactive collision avoidance controls, the drone can change its speed and heading to avoid a sudden collision. We acknowledge that a drone may not reach its waypoint, as it performs evasive maneuvers to avoid a sudden collision with another drone. For instance, suppose that a drone slows downs to avoid a sudden collision at sample-index \(k\). At the next sample-index \(k+1\), the drone needs to speed up to reach its new waypoint at sample-index \(k+1\). Control of the Side Length in the Grid Formation  
Considering the uncertainty in the target position, it is desirable to make the formation cover as large of an area as possible. However, in the case where the formation is too sparse, the target can get through the formation without being captured by a drone.