Online Path Generation and Navigation for Swarms of UAVs

With the growing popularity of unmanned aerial vehicles (UAVs) for consumer applications, the number of accidents involving UAVs is also increasing rapidly. Therefore, motion safety of UAVs has become a prime concern for UAV operators. For a swarm of UAVs, a safe operation cannot be guaranteed without preventing the UAVs from colliding with one another and with static and dynamically appearing, moving obstacles in the flying zone. In this paper, we present an online, collision-free path generation and navigation system for swarms of UAVs. The proposed system uses geographical locations of the UAVs and of the successfully detected, static, and moving obstacles to predict and avoid the following: (1) UAV-to-UAV collisions, (2) UAV-to-static-obstacle collisions, and (3) UAV-to-moving-obstacle collisions. Our collision prediction approach leverages efficient runtime monitoring and complex event processing (CEP) to make timely predictions. A distinctive feature of the proposed system is its ability to foresee potential collisions and proactively find best ways to avoid predicted collisions in order to ensure safety of the entire swarm. We also present a simulation-based implementation of the proposed system along with an experimental evaluation involving a series of experiments and compare our results with the results of four existing approaches. The results show that the proposed system successfully predicts and avoids all three kinds of collisions in an online manner. Moreover, it generates safe and efficient UAV routes, efficiently scales to large-sized problem instances, and is suitable for cluttered flying zones and for scenarios involving high risks of UAV collisions.


Introduction
An Unmanned Aerial Vehicle (UAV) or drone is a semi-autonomous aircraft that can be controlled and operated remotely by using a computer along with a radio-link [4]. UAVs can be classified into different types based on their design, size, and flying mechanism. Among the existing types, the quadrotors or quadrocopters are particularly popular because of their simple design, small size, low cost, greater maneuverability, and the ability to hover-in-place. A quadrotor uses two pairs of identical, vertically oriented propellers of which one pair spins clockwise and the other spins counterclockwise. Commercially-available quadrotors are increasingly been used in a variety of applications such as monitoring and surveillance, search and rescue operations, geographic mapping, photography and filming, wildlife research and management, media coverage of public events, remote sensing for agricultural applications, and aerial package delivery [2,9,12,21]. Efficient and scalable solutions for these applications require an online path generation and navigation system for multiple UAVs.
UAVs are becoming increasing popular. In the United States, the Federal Aviation Administration (FAA) has projected that the number of small hobbyist drones is set to increase from an estimated 1.1 million in 2017 to 2.4 million by 2022 1 . With the growing popularity and use of UAVs for consumer applications, the number of accidents involving drones is also increasing dramatically. The FAA receives more than 100 reports every month of unauthorized and potentially hazardous UAV activity reported by pilots, citizens, and law enforcement 2 . In a recent incident 3 that took place in the United Kingdom, the runway at the London Gatwick Airport was shutdown for more than a day because two drones were spotted flying repeatedly over the airfield. The disruption affected about 110,000 passengers on 760 flights as no flights were able to take off or land. Such incidents on one hand show the importance of educational and training programmes for drone operators and stricter legislation for offenders, but on the other hand they also motivate the need for a collision-free path generation and navigation system for UAVs. Ensuring a hazard-free, safe UAV flight is also equally important for indoor applications. Therefore, motion safety of UAVs has become a prime concern for UAV operators. It refers to the ability of the UAVs to detect and avoid collisions with static and moving obstacles in the environment. The static obstacles include buildings, trees, and other similar stationary items, while movable items (for example birds) are considered as moving obstacles.
Some of the commercially-available quadrotors are capable of detecting and avoiding some obstacles. For example, DJI's Phantom 4 Pro 4 uses five-directional sensors to provide obstacle detection or sensing in five directions with a front and rear sensing range of up to 30 meters and up to 7 meters for left and right side. However, its obstacle avoidance mechanism does not work in all kinds of scenarios. In this work, we assume that each UAV is equipped with an adequate obstacle detection capability and can successfully detect all static and dynamically appearing, moving obstacles in its surroundings. Therefore, the emphasis of this work is not on obstacle detection. Instead, we focus on collision prediction and avoidance.
Multiple UAVs working in a cooperative manner can be used to provide powerful capabilities that a single UAV can not offer [9]. Therefore, for larger and highly complex applications and tasks which are either beyond the capabilities of a single UAV or can not be performed efficiently if only a single UAV is used, multiple UAVs can be used together in the form of a swarm or a fleet. In such scenarios, a safe operation can not be guaranteed without preventing the UAVs from colliding with one another and with static and dynamically appearing, moving obstacles in the flying zone. Therefore, in the context of UAV swarms, ensuring motion safety entails devising and implementing an online motion path planning, coordination, and navigation system for multiple UAVs with an integrated support for collision prediction and avoidance.
The problem of motion safety of UAVs is currently attracting significant research attention. Some comprehensive literature reviews on motion planning algorithms for UAVs can be found in [11,14]. The main focus of these approaches is on an off-line motion planning phase to plan and produce UAV paths or trajectories before the start of the mission. Augugliaro et al. [3] also presented a planned approach that generates feasible paths ahead of time. LaValle [15] and Karaman and Frazzoli [13] presented sampling-based path planning algorithms. Silva Arantes et al. [24] proposed a path planning approach for critical situations requiring an emergency landing of a UAV. Dong et al. [9] presented a software platform for cooperative control of multiple UAVs. Bürkle et al. [6] proposed a multi-agent system architecture for team collaboration in a swarm of drones. Ivanovas et al. [12] proposed an obstacle detection approach for UAVs. Olivieri [7] and Olivieri and Endler [8] presented an approach for movement coordination of swarms of drones using smart phones and mobile communication networks. Their work focuses on the internal communication of the swarm and does not provide a solution for collision-free path generation.
In this paper, we present an online, collision-free path generation and navigation system for swarms of UAVs. The proposed system uses geographical locations of the UAVs and of the successfully detected, static and dynamically appearing, moving obstacles to predict and avoid: (1) UAV-to-UAV collisions, (2) UAV-to-static-obstacle collisions, and (3) UAV-to-moving-obstacle collisions. It comprises three main components: (1) a Complex Event Processing (CEP) and collision prediction module, (2) a mutually-exclusive locking mechanism, and (3) a collision avoidance mechanism. The CEP and collision prediction module leverages efficient runtime monitoring and CEP to make timely predictions. The mutually-exclusive locking mechanism prevents multiple UAVs from attempting to fly to the same location at the same time. The collision avoidance mechanism tries to find best ways to prevent the UAVs from colliding into one another and with the successfully detected static and moving obstacles in the flying zone. A distinctive feature of the proposed system is its ability to foresee potential collisions and proactively find best ways to avoid the predicted collisions in order to ensure safety of the entire swarm. In contrast to the existing works [3,[6][7][8][9][11][12][13][14][15]18,19,24], our proposed system does not depend on a planning phase and produces efficient, collision-free paths in an online manner. We focus on collision prediction and avoidance and online path generation and navigation for swarms of UAVs.
We also present a simulation-based implementation of the proposed system along with an experimental evaluation involving a series of experiments and compare our results with the results of four existing approaches [13,15,24,25]. The results show that the proposed system successfully predicts and avoids all three kinds of collisions in an online manner. Moreover, it generates safe and efficient UAV routes, efficiently scales to large-sized problem instances, and is suitable for cluttered flying zones and for scenarios involving high risks of UAV collisions. Our proposed navigation system, its implementation, experiments, and results are not based on or limited to a particular application of UAV swarms. Instead, they are generic enough to be applicable to a wide range of applications. The work presented in this paper extends our preliminary approach and results reported in [2].
We proceed as follows. Section 2 sets up the terminology and context. The proposed online, collision-free path generation and navigation system for UAV swarms is presented in Section 3. In Section 4, we illustrate the main steps of our proposed approach on a small example. Section 5 presents some important implementation details along with the experimental evaluation. Section 6 reviews important related works. Finally, we present our conclusions in Section 7.

Preliminaries
The proposed system not only provides support for online collision prediction and avoidance, it also generates complete routes for all UAVs in the swarm. Unlike traditional motion path planning approaches that require that all obstacles and their precise locations must be known before the start of the mission, the proposed approach does not assume any a priori knowledge of the obstacles. In other words, we assume that the terrain of the flying zone is not known beforehand. Therefore, the proposed system does not make any assumptions on the number and locations of the static and dynamically appearing, moving obstacles. It does not require a preliminary, off-line motion planning phase to produce efficient routes for the UAVs. In our approach, the drones takeoff from their start locations and fly uninterruptedly towards their destinations until the proposed system predicts a collision and triggers our collision avoidance mechanism to prevent the predicted collision. Since the proposed system uses geographical locations of the UAVs to generate their paths and predict and avoid collisions, it requires correct and precise location information of all UAVs in the fleet. Imprecise and incorrect information can result in longer paths and in the worst case some UAVs can collide with other UAVs or with some static or moving obstacles.
Let the mission flying zone be represented by a finite set of locations AREA = {l 1 , l 2 , l 3 , ..., l M }, where each location l i is represented as a point in a three-dimensional space (x, y, z). In an outdoor mission, the dimensions x, y, z may correspond to latitude, longitude, and altitude or elevation. To ensure a suitable formation of the swarm, it is assumed that the distance between any two consecutive locations in AREA is less than or equal to the sensing range sen r of the UAVs and greater than or equal to the safe distance dis s for the UAVs. For example, the front and rear sensing range sen r of Phantom 4 Pro UAV is up to 30 meters. Therefore, if the swarm comprises Phantom 4 Pro UAVs, the maximum distance between any two consecutive locations l i , l j ∈ AREA | i = j should be less than or equal to 30 meters. The safe distance dis s for UAVs depends on their maximum speed Sp, obstacle detection and processing time P t, and wireless communication latency Cl [7]. For example, if two UAVs are found heading towards each other at a maximum speed Sp of 5 meter per second each and with an obstacle detection and processing time P t of 0.5 seconds and a wireless communication latency Cl of 0.2 seconds, the safe distance dis s can be estimated as which yields 9 meters. Therefore, in this example, the minimum distance between any two consecutive locations l i , l j ∈ AREA | i = j should be greater than or equal to 9 meters. As a simplification to the problem, we assume that all consecutive locations in AREA are a uniform, fixed distance apart from one another denoted as dis, such that dis s ≤ dis ≤ sen r . Hence, the flying zone AREA can be viewed as a three-dimensional grid. This simplification allows faster generation, comparison, and evaluation of solutions or UAV paths. For clarity, important terminology and notation used in this paper are summarized in Table 1.  such that ran(route i ) ⊆ AREA and where l in is the initial or start location and l f in is the final or destination location of d i . Similarly, each static and moving obstacle occupies a certain location in AREA. Moreover, the moving obstacles keep on moving arbitrarily until they leave the flying zone. We formulate three basic Safety Requirements (SRs) for a swarm of drones: SR2: ∀d i , d j ∈ SW ARM | i = j, d i and d j do not collide with each other.
SR3: ∀d i ∈ SW ARM, ∀mo j ∈ M OV OBS, d i does not collide with mo j .
Since the proposed system does not assume any a priori knowledge on the numbers and locations of the static and moving obstacles and does not depend on a preliminary, off-line motion planning phase, none of the SRs can be verified before the start of the mission. For SR1 which concerns static obstacles, it is necessary that the drones do not fly into a location where a static obstacle is situated. Our proposed system helps the drones to avoid all successfully detected static obstacles in an online manner by providing efficient collision prediction and collision avoidance mechanisms. Similarly, for SR2 which concerns collisions with other drones, it is required that at any given time t each location is occupied by at most one drone. The proposed system stops the drones from flying into other drones in the vicinity. The proposed mutually-exclusive locking and collision avoidance mechanisms prevent the drones from flying into any locations occupied by other drones at time t. For SR3 which concerns collisions with dynamically appearing, moving obstacles, the proposed system provides a similar approach as for SR1 that helps the drones to avoid all successfully detected moving obstacles in an online manner.
3 Collision-Free Path Generation and Navigation Figure 1 presents a high-level system architecture and overview of the proposed online, collisionfree path generation and navigation system for swarms of UAVs. The main components of the proposed system include: (1) a CEP and collision prediction module, (2) a mutually-exclusive locking mechanism, and (3) a collision avoidance mechanism. The inputs to the system are the UAV location updates, static obstacle detections, and moving obstacle detections. Based on these three inputs, the CEP and collision prediction module predicts: (1) UAV-to-UAV collisions, (2) UAV-to-static-obstacle collisions, and (3) UAV-to-moving-obstacle collisions. Our collision avoidance mechanism tries to find best ways to avoid or bypass collisions and computes collision-free routes for UAVs in an online manner. In a densely populated and cluttered flying zone, it might not be possible to immediately compute a bypass route for all drones. In such scenarios, the proposed system might put some of the drones into the hover-in-place mode until the situation improves and the routes clear. Additionally, it may also let some UAVs to temporarily retreat or backtrack to find more suitable, collision-free routes.
The proposed system implements a safety-first approach. Therefore, a hazard-free, safe operation of the swarm takes precedence over all of the other objectives including lengths of the UAV routes, timely arrival of the UAVs to their destinations, and achievement of any other mission-specific goals. As a consequence, we do not formulate the problem as an optimization problem. Instead, we implement a stochastic, greedy approach that tries to find safe and efficient routes. The UAVs takeoff from their start locations and fly uninterruptedly towards their destinations until the CEP and collision prediction module predicts a collision, in which case our collision avoidance mechanism is invoked to avoid the collision. In addition, our mutually-exclusive locking mechanism prevents multiple UAVs from attempting to fly to the

Collision-Free Paths
Mutually-Exclusive Locking Mechanism Figure 1: Overview of the proposed online, collision-free path generation and navigation system for swarms of UAVs same location at the same time. At each step, the proposed approach makes a stochastic, greedy decision for each UAV. It tries to find a next location for each UAV which is not only safe but also reduces the distance from the destination. The main components of the proposed system are described in the following subsections.

Complex Event Processing and Collision Prediction
Complex Event Processing (CEP) is a technique for realtime, fast processing of a large number of events from one or more event streams to derive and identify important complex events and patterns in the event streams. CEP has been successfully used in a variety of business domains including retail management, health-care, and cloud computing [20,26]. For example in retail management, CEP can be used to detect shoplifting and out-of-stock events. The basic or primitive events in CEP are processed into complex or composite events by means of event processing queries, which are written in a Structured Query Language (SQL)-like language. Therefore, CEP provides a similar functionality for realtime event streams that a relational database management system provides for persistent data.
One of the most widely used CEP tools is the Esper CEP engine 5 , in which the event processing queries are written in the Event Processing Language (EPL). There are three main steps for using Esper CEP engine: 1. In the first step, event types and sources of events are registered with the CEP engine.
An event class in Esper is written as a Plain Old Java Object (POJO).
2. The second step requires event processing queries to be written in EPL.
3. Finally, in the third step, event sinks are implemented which can be used to perform some suitable control and repair actions.
The CEP and collision prediction module in our proposed system uses a CEP engine to monitor and keep track of the current location of the UAVs and of the successfully detected static and moving obstacles. Table 2 presents the three types of events from the proposed system along with their properties. The UAVs generate and send location update events on regular intervals, for example every 50 milliseconds. A drone location event (DroneLocEvent) contains drone name of the concerned drone d i ∈ SW ARM , drone location l i in the three-dimensional flying zone AREA, and the event time t. The CEP engine receives and processes these events to Static obstacle name so i , obstacle location l i MObsEvent Moving obstacle name mo i , obstacle location l i , event time t predict possible UAV-to-UAV collisions in the swarm. Similarly, for each successfully detected static obstacle, a static obstacle event (SObsEvent) is generated and sent to the CEP engine. A static obstacle detection event contains obstacle name of the static obstacle so i ∈ ST A OBS and the location l i ∈ AREA of the static obstacle. The CEP engine processes all UAV location update events and static obstacle detection events to predict UAV-to-static-obstacle collisions. Finally, for successfully detected moving obstacles, moving obstacle events (MObsEvents) are generated and sent to the CEP engine. A moving obstacle detection event contains obstacle name of the moving obstacle mo i ∈ M OV OBS, the location l i ∈ AREA of the moving obstacle, and the event time t. The CEP engine processes UAV location update events and moving obstacle detection events to predict UAV-to-moving-obstacle collisions.
The proposed system implements three EPL queries to process the three types of events and determine if a drone is flying in a close proximity of another drone or a static or moving obstacle. Listing 1 presents the first query. It uses DroneLocEvents to check if two drones are in a close proximity of each other. If a match is found, the CEP engine triggers the concerned event sink, which may predict a UAV-to-UAV collision and then invoke the collision avoidance mechanism to prevent the UAVs from colliding into each other. The second query in Listing 2 uses DroneLocEvents and SObsEvents to determine if a drone is in close proximity of a static obstacle. Similarly, the third query in Listing 3 uses DroneLocEvents and MObsEvents to determine if a drone is in close proximity of a moving obstacle. In each case, the relevant event sink is triggered, which may predict a collision and invoke the collision avoidance mechanism. To predict the three different kinds of collisions, the event sinks use various parameters and rules. The parameters include the (current) locations of the drones and of the static and moving obstacles and the desired next locations of the drones. The collision prediction rules are presented in Algorithm 1. Rule 1 states that a UAV-to-UAV collision is predicted when the desired next location of a drone d i ∈ SW ARM is same as the current or the desired next location of another drone d j ∈ SW ARM | i = j. Similarly, Rule 2 is used for predicting UAV-to-static-obstacle collisions, which can occur if a drone d i ∈ SW ARM attempts to fly to a location occupied by a static obstacle so j ∈ ST A OBS. Finally, Rule 3 states that a UAV-tomoving-obstacle collision is predicted when the desired next location of a drone d i ∈ SW ARM is same as the current location of a moving obstacle mo j ∈ M OV OBS.

Mutually-Exclusive Locking Mechanism
The CEP and collision prediction module described in the previous section covers most of the scenarios that can lead to a UAV collision. However, since the UAVs may move fast and arbitrarily, some failures and collisions can still occur. For instance, during a mission, a location l i ∈ AREA is free and two UAVs d i , d j ∈ SW ARM | i = j concurrently decide to move to l i . If the CEP and collision prediction module takes slightly longer to predict the UAV-to-UAV collision, the collision avoidance mechanism might not be left with enough time to prevent the collision. However, if the CEP and collision prediction module quickly and correctly predicts the collision, the collision avoidance module can save the UAVs d i , d j by allowing only one of Algorithm 1 Collision prediction rules 1: {Rule 1} 2: ∀d i , d j ∈ SW ARM | i = j, let l i , l m ∈ AREA be the current and the desired next locations of d i and similarly l j , l n ∈ AREA be the current and the desired next locations of d j 3: if l m = l j ∨ l m = l n ∨ l n = l i then 4: predict a UAV-to-UAV collision 5: end if 6: {Rule 2} 7: ∀d i ∈ SW ARM, ∀so j ∈ ST A OBS, let l m ∈ AREA be the desired next location of d i and l j ∈ AREA be the location of so j 8: if l m = l j then 9: predict a UAV-to-static-obstacle collision 10: end if 11: {Rule 3} 12: ∀d i ∈ SW ARM, ∀mo j ∈ M OV OBS, let l m ∈ AREA be the desired next location of d i and l j ∈ AREA be the current location of mo j 13: if l m = l j then 14: predict a UAV-to-moving-obstacle collision 15: end if them to continue flying to l i . The other UAV will either be redirected to another location or will fail to move in the current iteration. To prevent such scenarios and failures, we augment our collision prediction approach with a mutually-exclusive locking mechanism.
The proposed system uses mutually-exclusive locks on the current and the immediate next locations of UAVs to prevent multiple UAVs from attempting to move to the same location at the same time. The lock state of each location l i ∈ AREA can be either locked or unlocked. The current location of each UAV is always considered locked for all other UAVs. Moreover, as soon as a UAV decides its next move, the system puts a mutually-exclusive lock on the immediate next location of the UAV so that the other UAVs do not attempt to move to the same location. Similarly, while deciding about their next moves, the UAVs first check the lock state of the possible next locations and only attempt to move to some of the unlocked locations. Moreover, if multiple UAVs d 1 , d 2 , ..., d N ∈ SW ARM concurrently attempt to lock the same location, only one of them acquires the lock. For scenarios involving very short time intervals, the mutually-exclusive locks may be acquired in one time interval and the moves may be performed in the next time interval. The UAVs release the locks of their previous locations as soon as they fly to their next locations. Figure 2 illustrates the proposed locking mechanism. It shows that a UAV always keeps a mutually-exclusive lock for its current location. Moreover, when deciding about a next move, it first checks the lock state of all possible next locations. It then attempts to lock one of the unlocked locations. After successful locking of the next location, it moves to the next location. Finally, it releases the lock of the previous location. In this way, two or more UAVs never attempt to move to the same location at the same time.

Collision Avoidance Mechanism
Whenever the CEP and collision prediction module predicts a collision, it invokes our collision avoidance mechanism which tries to find best ways to avoid the predicted collisions and computes collision-free routes for UAVs in an online manner. Based on the severity of the predicted collision, its surroundings, and the overall situation of the SW ARM and of the successfully detected static and moving obstacles (ST A OBS and M OV OBS) in AREA, our collision avoidance mechanism uses one of the three collision avoidance techniques in the following order: (1) redirecting the UAV into another direction, (2) putting the UAV into the hover-in-place mode until the route is cleared, and (3) temporarily retreating or backtracking the UAV to explore some alternate collision-free routes. The pseudocode of the proposed collision avoidance mechanism is given as Algorithm 2. Our backtracking approach is described in the following section.
The first collision avoidance technique namely redirecting the UAV into another direction means changing the flying direction of the UAV. For example, if a UAV is flying in the x dimension of AREA, but the CEP and collision prediction module predicts a collision due to the presence of an obstacle or another UAV on the path, then the UAV can not continue a hazard-free flight in the x dimension any more. Therefore, the collision avoidance mechanism redirects the UAV to fly in the y or z dimension so the UAV may be able to avoid the collision. However, in a densely populated and cluttered flying zone, the collision avoidance mechanism might not be able to immediately compute a bypass route for all drones. Therefore, in such scenarios, the proposed collision avoidance mechanism activates the hover-in-place mode for some of the UAVs until the situation improves and the routes clear. Additionally and as a last resort, it temporarily backtracks some UAVs to explore some alternate collision-free routes. It should be noted that all three collision avoidance techniques incur some overhead, which might extend the routes and increase the flight durations for some of the UAVs. However, as explained previously, this is inevitable for a safety-first approach.

Backtracking Approach
The proposed backtracking approach temporarily retreats or backtracks a UAV so it may explore some alternate collision-free routes. As shown in Algorithm 2, the proposed backtracking algorithm is triggered in two situations: (1) if a UAV hovers for too long or (2) if a UAV keeps on moving but it does not find a suitable collision-free route to reach to its destination. In densely populated, cluttered flying zones, such situations are not unprecedented. Sometimes, a UAV keeps on hovering or moving near its destination, but it does not find a collision-free route to reach to the destination because some other UAVs or obstacles reside between the UAV and its destination location and thus obstructs the UAV's routes. In such situations, it is important to allow the UAV to temporarily retreat or backtrack so it may be able to explore some alternate routes to reach to its destination.
The pseudocode of the proposed backtracking algorithm is presented as Algorithm 3. The algorithm iterates until the required number of backtrack steps is successfully completed or the maximum number of backtrack attempts is reached (line 9). In each iteration, it attempts to move the UAV in the opposite direction of the UAV's destination. It randomly chooses one of the three dimensions (x, y, z) and tries to move the UAV so that the distance from the destination is increased. The backtrack algorithm does not disable the CEP and collision prediction module and the mutually-exclusive locking mechanism. Thus, in each iteration, the UAV either backtracks one step or if a collision-hazard is found or the UAV fails to lock the required location then it hovers at its current location. When the UAV returns to the normal flight mode (line 10), it explores some alternate collision-free routes to reach to its destination.

An Illustrative Example
In this section, we present a small example to illustrate the main components and steps of the proposed online, collision-free path generation and navigation system. Although the proposed system works for a realistic, three-dimensional flying zone, it is difficult to illustrate and demonstrate a three-dimensional flying zone on a paper. Therefore, we use a two-dimensional flying zone for a simpler illustration.

Algorithm 2 Collision avoidance mechanism
1: redirect the UAV into another direction 2: if not successful then 3: activate the hover-in-place mode until the UAV route is cleared 4: end if 5: if the UAV hovers for too long or if it takes too long to find a suitable collision-free route then 6: temporarily backtrack the UAV to explore some alternate collision-free routes 7: end if Figure 3 presents an illustrative example with four UAVs, two static obstacles, and four moving obstacles in a two-dimensional flying zone. The flying zone in our example is shown as a 7x7 grid, where all consecutive locations are a uniform, fixed distance apart from one another. The start and destination locations of each drone are also highlighted. The goal is to route the drones from their start locations to their destination locations while avoiding collisions with static and moving obstacles and with the other drones in the swarm.
It should be noted that the knowledge of the precise locations of the obstacles in this example is only for illustration purposes. As described previously, the proposed system does not make any assumptions on the number and locations of the static and moving obstacles in the flying zone. Similarly, although Figure 3a shows that all moving obstacles are present in the flying zone before the start of the mission, in a realistic scenario some moving obstacles (for example birds) may dynamically appear in the flying zone during the execution of the mission. Figure 3b presents a snapshot of the flying zone after five time intervals have elapsed since the start of the mission. It shows that each UAV started flying from its start location and flew towards its destination location while randomly choosing to fly in the horizontal or vertical dimension in each time interval. Figure 3b also shows that the left most moving obstacle from Figure 3a left the flying zone during the execution of the mission and that the remaining moving obstacles moved to some new arbitrary locations within the flying zone. Although the moving obstacles moved in an arbitrary fashion either horizontally or vertically, in five time intervals each moving obstacle moved only one step, that is, only to a next consecutive location in the flying zone. Therefore, the moving obstacles moved slower than the drones. This is a reasonable assumption because if the moving obstacles move faster than the drones, even the most advanced and fastest collision detection, prediction, and avoidance mechanisms will not be able to avoid UAV-to-moving-obstacle collisions.
The labelled, directional edges in Figure 3b show the collision-free UAV routes generated by the proposed system in an online manner. For example, in the top left corner of Figure 3b, the first downward edge labelled 1 means that UAV 1 flew in the downward direction. Similarly, the next edge in the same direction labelled 1,2 shows that UAV 1 and 2 used the same edge. However, two UAVs using the same edge does not mean a UAV-to-UAV collision. A UAV-to-UAV collision on an edge can happen when two UAVs fly at the same edge at the same time. In this example, UAV 1 and UAV 2 flew on the same edge, but in different time intervals. UAV 1 left the edge before UAV 2 arrived there and hence there was no collision-hazard between the two UAVs. Figure 3b also shows the current locations of the UAVs after five time intervals. It can be seen that all UAVs except UAV 3 flew five steps. UAV 3 flew four steps and then randomly choose one of the three dimensions (x, y, z) 3: attempt to move the UAV in the opposite direction of its destination 4: if a collision-hazard is found or the required location is locked by another UAV then  if the required number of backtrack steps is successfully completed or the maximum number of backtrack attempts is reached then 10: deactivate the backtrack mode and return to the normal flight mode 11: end if 12: end while hovered in the fifth time interval because the system could not find a collision-free move for UAV 3.
The UAVs in Figure 3 used the proposed mutually-exclusive locking mechanism at each step. As described in Section 3.2, each UAV first attempted to lock one of the unlocked next locations. After successful locking of their next locations, the UAVs moved to their next locations and released the locks of their previous locations. Therefore, at any time, two or more UAVs did not attempt to move to the same location in the flying zone. UAV 1 in Figure 3b started flying vertically in the downward direction and continued towards its destination until it detected a static obstacle. At this stage, our CEP and collision prediction module predicted a UAV-to-static-obstacle collision and invoked our collision avoidance mechanism, which redirected the UAV into the horizontal, rightward direction so the drone could continue flying towards its destination. However, in the same time interval, UAV  Figure 3: A simple illustrative example with four UAVs, two static obstacles, and four moving obstacles in a two-dimensional flying zone 3 tried to fly into the same location where UAV 1 was headed. The two UAVs detected each other and the CEP and collision prediction module predicted a UAV-to-UAV collision. As a result, our collision avoidance mechanism was invoked, which tried to redirect UAV 3 in the vertical, upward direction, but the UAV detected a moving obstacle at that location and the CEP and collision prediction module predicted a UAV-to-moving-obstacle collision. Therefore, the collision avoidance mechanism activated the hover-in-place mode for UAV 3, but let UAV 1 to lock and then move to the next location. Hence, UAV 3 flew only four steps in five time intervals. In this example, UAV 2 and 4 did not encounter a collision-hazard and flew normally towards their destinations. Moreover, none of the UAVs hovered for too long or took too long to find a suitable, collision-free route. Therefore, our backtracking algorithm was not invoked. Figure 3c shows a snapshot of the flying zone after the completion of the mission. It shows that how each drone found its way to its destination while avoiding obstacles and other drones on its way. Once again, the remaining three moving obstacles moved to some new arbitrary locations within the flying zone. In the sixth time interval, UAV 1 was redirected in the downward direction to avoid a collision with UAV 3. Similarly, after flying downwards for two time intervals, UAV 1 reached the end of the flying zone and was once again redirected to the horizontal, rightward direction. Finally, after flying for a few more intervals in the rightward direction, UAV 1 reached its destination. As can be seen in Figure 3c, all other UAVs found their ways in similar ways.

Implementation and Experimental Evaluation
To demonstrate and evaluate our proposed system, we have developed a software simulator. This section briefly describes some important implementation details along with an experimental evaluation involving a series of experiments. We also compare our results with the results of the following four approaches: 1. Particle Swarm Optimization (PSO) based approach: Sujit and Beard [25]'s PSO based path planning approach generates paths for a swarm of drones.
2. Greedy heuristics and Genetic Algorithms (GAs) approach: Silva Arantes et al. [24]'s approach uses greedy heuristics and GAs to generate and optimize paths for a UAV under critical situations.

Implementation Details
The implementation of the first main component of the proposed system called the CEP and collision prediction module is based on the Esper CEP engine and Algorithm 1. The second component, called the mutually-exclusive locking mechanism, implements the proposed locking mechanism presented in Figure 2. Similarly, the collision avoidance component implements Algorithm 2 and 3.
We have implemented a simple, controlled simulation platform that does not take into account complex physical phenomena and uncontrolled environment variables such as gravity and wind. The objective is to test and evaluate the proposed system in an ideal scenario while ignoring and minimizing the effects of external uncontrolled factors. Therefore, it is easier to  High risk of UAV  collisions  Flying zone  10x10x10 20x20x20  10x10x10  20x20x20  Number of UAVs  20  50  20  100  Static obstacles  20  50  40  50  Moving obstacles  20  50  40  50 analyze and interpret the results. The implementation assumes that all drones fly at the same speed and that there were no internal drone failures during the execution of the mission. We also assume that at least one feasible path exists for each UAV. Table 3 presents the experiment design. The experimental evaluation comprises four experiments. In each experiment, we ran our proposed approach, Sujit and Beard [25]'s PSO based approach, Silva Arantes et al. [24]'s greedy heuristics and GA based approach, LaValle [15]'s RRT algorithm, and Karaman and Frazzoli [13]'s RRT* algorithm 10 times and used a random seed every time. All results reported in this section are averaged over 10 runs. The experiments were run on an Intel Core i7-4790 processor with 16 gigabytes of memory. The length of the time interval used in the software simulator was 50 milliseconds. We measured the following dependent variables:

Experiment Design and Setup
• Average Route Length (ARL): the average UAV route length measured as the number of UAV moves in the discretized flying zone. A UAV route is a sequence of moves or steps from UAV's start location to UAV's destination location. To be minimized to generate shorter routes.
• Length of the Longest Route (LLR): the total number of steps in the longest generated route. To be minimized to generate shorter routes.
• Number of Collisions (NC): the number of UAV collisions. To be minimized to generate safer routes.
• Computation Time (T): computation time of the algorithm in milliseconds (ms). It is the time that the algorithm takes to run and produce the results. To be minimized to reduce the computation overhead.
Experiment 1 was designed to simulate a small problem instance. The main objective was to evaluate the collision prediction and avoidance capabilities of the proposed system in a simpler scenario. The experiment used a 10x10x10 flying zone with 20 drones, 20 static obstacles, and 20 moving obstacles. Experiment 2 used a large problem instance involving a larger flying zone and a higher number of drones and obstacles and was designed to evaluate the proposed system for a larger problem instance. The experiment used a 20x20x20 flying zone with 50 drones, 50 static obstacles, and 50 moving obstacles.
The third experiment evaluated the proposed system for a densely populated, cluttered environment involving a large number of static and moving obstacles. Experiment 3 used a similar experiment design as Experiment 1, but with twice as many static and moving obstacles. Finally, the objective of Experiment 4 was to evaluate the proposed system in a scenario involving high risks of drone collisions. The experiment used a similar experiment design as Experiment 2, but with twice as many drones.
All drones and obstacles were placed randomly. However, to ensure that the drones do not collide during takeoff, unique start locations were used and no obstacles were placed at the drone start locations. Similarly, the destination locations for the drones were also chosen randomly, but it was ensured that all destination locations are unique and that no obstacles were present at the destination locations.

Results and Analysis
The results are presented in Table 4. The best results in the table are highlighted in bold font. The results in the ARL and LLR columns show that the RRT* algorithm [13] produced the shortest drone routes in all experiments, while RRT [15] generated the second shortest routes. The NC column shows that the proposed approach produced the safest routes in all experiments, while the greedy heuristics and GA based approach [24] produced the second safest routes. In terms of T, RRT performed the best, while the proposed approach performed second best in Experiment 2 and 3, and the greedy and GA based approach performed second best in Experiment 1 and 4. The PSO based approach [25] did not perform best or second best with respect to any dependent variable.
In the first experiment, the ARL for the proposed, PSO based, greedy and GA based, RRT, and RRT* algorithms was 17, 25, 26, 16, and 15, respectively. Similarly, the LLR for the proposed, PSO based, greedy and GA based, RRT, and RRT* algorithms was 36, 49, 47, 36, and 29, respectively. The five approaches also produced similar results in Experiment 2 to 4. Therefore, the RRT* algorithm produced the shortest routes in all experiments.
Although the proposed approach did not produce the shortest routes, it produced the safest routes in all four experiments. The NC column in Table 4 shows the number of collisions or crashes for the proposed, PSO based, greedy and GA based, RRT, and RRT* algorithms. The total number of crashes in all experiments was 0, 14,9,18, and 29, respectively. As stated in Section 3, the proposed system provides a safety-first approach in which a hazard-free, safe operation of the UAV swarm takes precedence over any other objectives including the route length. This safety-first aspect of the proposed approach is evident in all experiments. The proposed approach generated slightly longer routes by trading route length for UAV safety. As a result, all UAV-to-UAV, UAV-to-static-obstacle, and UAV-to-moving-obstacle collisions were avoided and all drones successfully completed their maneuvers.
The last column in Table 4 shows the T results of the five algorithms in milliseconds. The results show that the RRT algorithm took the least amount of time to run and produce the results in all experiments, while the proposed approach performed second fastest in Experiment 2 and 3, and the greedy and GA based algorithm performed second fastest in Experiment 1 and 4. Therefore, the results show that the proposed algorithm has a low computation overhead and it generates safe and efficient routes in a reasonable amount of time.
Experiment 1 results show that the proposed system is suitable for smaller problem instances. The performance and scalability of the proposed system are further demonstrated in the results of Experiment 2 which produced drone routes for a larger problem instance. In Experiment 3, the drones encountered more obstacles on their ways because the flying zone was cluttered with static and moving obstacles. It forced them to take longer routes to their destinations, but the proposed approach managed to successfully avoid all obstacles and collisions and routed all drones to their destinations. It shows that the proposed system is also suitable for densely populated, cluttered flying zones. Finally, Experiment 4 results show that the proposed approach is also suitable for complex problem instances involving high risks of drone collisions.  [25], a greedy heuristics and GA based approach [24], and two sampling-based path planning algorithms called RRT [15] and RRT* [13] intensive problem that the only viable solution is a computation of the next safe states and navigation within them. Their solution supports navigation of a single vehicle. In our work, we have discretized the flying zone and have developed a highly efficient system that computes the next safe states for an entire swarm and provides a mechanism for online path generation and collision avoidance.
A comprehensive literature review on motion planning algorithms for UAVs can be found in [11]. The approaches reviewed in [11] are applicable to a preliminary, off-line motion planning phase to plan and produce an efficient path or trajectory for a UAV before the start of the mission. Our proposed system does not depend on a planning phase and produces efficient, collision-free paths for an entire swarm in an online manner. A more recent survey on motion planning of UAVs can be found in [14].
Augugliaro et al. [3] presented an algorithm for generating collision-free trajectories for a quadrotor fleet. They focused on a planned approach that generates feasible paths ahead of time. LaValle [15] and Karaman and Frazzoli [13] presented sampling-based path planning algorithms called RRT and RRT*, respectively. RRT was designed to efficiently explore highdimensional spaces by incrementally building a tree. RRT* is an extension of RRT. It was designed to plan optimal paths.
Majd et al. [18,19] proposed a path planning and navigation approach for swarms of drones. They combined offline path planning with an online navigation approach and used machine learning and evolutionary algorithms to generate efficient paths while maximizing safety of the drones in the swarm. They also used collision prediction and drone reflexes to prevent collisions with unforeseen obstacles. In comparison, this paper presents an online, collision-free path generation and navigation approach, which does not need offline path planning.
Dong et al. [9] presented a software platform for online cooperative control of multiple UAVs. Their work focuses on monitoring and control of multiple UAVs from a ground control station. The approach does not generate paths for the UAVs. Instead, the complete flight information (including the UAVs paths) are provided to the ground control station that sends control commands to the UAV fleet. Olivieri [7] and Olivieri and Endler [8] presented an approach for movement coordination of swarms of drones using smart phones and mobile communication networks. They used CEP, but only to analyze and evaluate the formation accuracy of the swarm. Moreover, their work focuses on the internal communication of the swarm and does not provide a solution for collision-free path generation. Bürkle et al. [6] proposed a multiagent system architecture for team collaboration in a swarm of drones. They also developed a simulation platform for patrolling or surveillance drones which monitor a protected area against potential intrusions. However, they did not address path planning and collision avoidance for the swarm.
Ivanovas et al. [12] proposed an obstacle detection and avoidance approach for a UAV. Their approach uses computer vision techniques for detecting static obstacles in stereo camera images. The main focus of their approach is on how some block matching algorithms can be used for obstacle detection. They did not present a path planning and collision avoidance approach for multiple UAVs. Barry and Tedrake [5] proposed an obstacle detection algorithm for UAVs that allows to detect and avoid collisions in an online manner. Similarly, Lin [16] presented an online path planner for UAVs that detects and avoids moving obstacles. These approaches are only applicable for individual UAVs and do not provide support for a swarm of UAVs. In our work, we assumed that each UAV is equipped with an adequate obstacle sensing and detection capability and does not require any additional support for obstacle detection. Therefore, we focused on collision prediction and avoidance and online path generation and navigation for swarms of UAVs.
Sujit and Beard [25] proposed a PSO based path planning algorithm for swarms of drones. In their approach, whenever a drone detects a moving obstacle, the PSO based algorithm generates a new path for the drone depending on the time allowed to compute a new path before the collision can occur. Silva Arantes et al. [24] presented a UAV path planning approach for critical situations requiring an emergency landing of the UAV. Their approach uses greedy heuristics and GAs to generate and optimize feasible paths under different types of critical situations caused by equipment failures.
In Section 5, we have presented a comparison of the results of our proposed approach with Sujit and Beard [25]'s PSO based approach, Silva Arantes et al. [24]'s greedy heuristics and GA based approach, LaValle [15]'s RRT algorithm, and Karaman and Frazzoli [13]'s RRT* algorithm. The results show that our proposed approach produced the safest routes in all four experiments. Therefore, the proposed approach outperformed the PSO based, greedy heuristics and GA based, RRT, and RRT* approaches with respect to drone safety.

Conclusions
In this paper, we presented an online, collision-free path generation and navigation system for swarms of Unmanned Aerial Vehicles (UAVs). The proposed system uses geographical locations of the UAVs and of the successfully detected, static and dynamically appearing, moving obstacles to predict and avoid: (1) UAV-to-UAV collisions, (2) UAV-to-static-obstacle collisions, and (3) UAV-to-moving-obstacle collisions. It comprises three main components: (1) a Complex Event Processing (CEP) and collision prediction module, (2) a mutually-exclusive locking mechanism, and (3) a collision avoidance mechanism. The CEP and collision prediction module leverages efficient runtime monitoring and CEP to make timely predictions. The mutually-exclusive locking mechanism prevents multiple UAVs from attempting to fly to the same location at the same time. The collision avoidance mechanism tries to find best ways to prevent the UAVs from colliding into one another and with the successfully detected static and moving obstacles in the flying zone. Therefore, a distinctive feature of the proposed system is its ability to foresee risks of collisions in an online manner and proactively find best ways to avoid the predicted collisions in order to ensure safety of the entire swarm.
We also presented a simulation-based implementation of the proposed system along with an experimental evaluation involving a series of experiments and compared our results with the results of four existing approaches. The results showed that the proposed system successfully predicts and avoids all three kinds of collisions in an online manner. Moreover, it generates safe and efficient UAV routes, efficiently scales to large-sized problem instances involving dozens of UAVs and obstacles, and is suitable for densely populated, cluttered flying zones and for scenarios involving high risks of UAV collisions.
As part of our future work, we plan to implement the proposed system in a more realistic simulation environment that allows to take into account complex physical phenomena and uncontrolled environment variables. Moreover, we want to test and evaluate our system for heterogeneous drones that may have diverse capabilities and fly at different speeds. Finally, an adequate support and online mechanisms to handle and control the situations arising from imprecise information of UAV locations and internal drone failures during mission execution are also planned as future works.