# Intelligent Total Transportation Management System for Future Smart Cities
## 3 Results--Examples of Sub-Model Developments
### Managing Drones as a Formation to Avoid Obstacles in Smart Cities
#### 3.2.2 Obstacle Avoidance Model  
Along with the spreading trend of drone applications, the drone collision's flight safety with buildings, helicopters, and landscape becomes an urgent issue for civil and defense agencies. A collision avoidance system is a necessary module for drone flights, especially for autonomous drones in dense airspace shared with other aircraft, in order to guarantee airspace security. Conflict detection and collision avoidance are also valuable tools for highly automated and autonomous vehicles.  
It can be noted that the research on collision avoidance for drones has a high failure cost because the collision may destroy the drone if the avoidance fails. Therefore, several simulation systems for algorithm testing are designed in laboratories. The obstacle model is one of the critical parts of these systems, described as the following.  
Let \(B\) be the set of all obstacles for a given drone within its operating space. Assume that each obstacle is prescribed in a cylinder with the center \(C_{Bl}\) and radius \(r_{Bl}\), as shown in Figure 7.  
The surfaces of cylinders can then be used to form constraints for obstacle avoidance. Accurately, the safe distance \(d_{s,l}\) from the obstacle \(l\) is calculated from the cylinder center to its surface at the flying height as follows:  
\[d_{s,l}=\left\{\begin{array}{cc}\sqrt{r_{Bl}^{2}+\left(Z_{Mi,k}-Z_{Cbl}\right) ^{2}}&if\ Z_{Mi,k}\leq\ Z_{max,Cbl}\\ \sqrt{r_{Bl}^{2}+\left(Z_{max,Cbl}-Z_{Cbl}\right)^{2}}&if\ Z_{Mi,k}>\ Z_{max,Cbl} \end{array}\right. \tag{12}\]  
where \(z_{max,Cbl}\) is the height of the obstacle \(l\).  
To compute the violation cost between each generated path and obstacle centers, we first assumed that the formation is rigid and can be fit within a sphere with the radius:  
\[r_{s,l}=r_{d}+d_{s,l} \tag{13}\]  
where \(r_{d}\) is the radius of the drone, including propellers.  
The violation cost can be now derived as follows.  
For the \(l\)-th obstacle, compute the distance from its center \(C_{Bl}\) to the segment \(P_{i,k}\overrightarrow{P_{i,k+1}}\):  
\[d_{l,k}=\sqrt{\left(x_{Mi,k}-x_{Cbl}\right)^{2}+\left(y_{Mi,k}-y_{Cbl}\right) ^{2}+\left(z_{Mi,k}-z_{Cbl}\right)^{2}} \tag{14}\]  
where \(M_{i,k}=\{x_{Mi,k},\,y_{Mi,k},\,z_{Mi,k}\}\) is the midpoint of the segment as shown in Figure 8. At a given flying height \(z_{Mi,k},\,d_{l,k}\) is then compared with the safe distance to the obstacle. The comparison results in the following violation function:  
Figure 8: Centralized control strategy for large-scale systems: (**a**) pure centralized structure and (**b**) hierarchical centralized structure.  
Figure 7: Obstacle representation and safe distance calculation.  
This function ensures that the distance \(d_{l,k}\) must be larger than the safe distance for obstacle avoidance. The violation cost is then computed for all obstacles as:  
\[V_{l}=\frac{1}{B}\sum_{l=1}^{B}V_{l,k} \tag{15}\]  
For all \(m\) segments, the final violation cost on average is represented as:  
\[Q=\frac{1}{m}\sum_{l=1}^{m}V_{l} \tag{16}\]