A Collaborative UAV-WSN Network for Monitoring Large Areas

Large-scale monitoring systems have seen rapid development in recent years. Wireless sensor networks (WSN), composed of thousands of sensing, computing and communication nodes, form the backbone of such systems. Integration with unmanned aerial vehicles (UAVs) leads to increased monitoring area and to better overall performance. This paper presents a hybrid UAV-WSN network which is self-configured to improve the acquisition of environmental data across large areas. A prime objective and novelty of the heterogeneous multi-agent scheme proposed here is the optimal generation of reference trajectories, parameterized after inter- and intra-line distances. The main contribution is the trajectory design, optimized to avoid interdicted regions, to pass near predefined way-points, with guaranteed communication time, and to minimize total path length. Mixed-integer description is employed into the associated constrained optimization problem. The second novelty is the sensor localization and clustering method for optimal ground coverage taking into account the communication information between UAV and a subset of ground sensors (i.e., the cluster heads). Results show improvements in both network and data collection efficiency metrics by implementing the proposed algorithms. These are initially evaluated by means of simulation and then validated on a realistic WSN-UAV test-bed, thus bringing significant practical value.


Introduction
Wide area monitoring requires a robust and efficient data collection infrastructure, following the latest system design approaches of combining ground sensor nodes and unmanned aerial vehicles (UAVs) [1,2]. Currently, high level research focuses on and emphasizes intelligent data management for various critical infrastructure applications, such as border surveillance or large-scale crop monitoring for precision farming.
In the last years, due to the technological progress and wide spreading of the unmanned aerial vehicles they were introduced into sensor networks thus increasing the performances of large scale monitoring. Many challenges are still open like optimal ground sensor clustering, communication performance, saving energy, and trajectory planning for optimal data acquisition from ground sensors. For example, a cooperative framework for UAVs and ground wireless sensor networks (WSN) taking into account a k-means driven grouping approach, the communication performance, the position, and other factors can lead to higher performances [2]. By enabling the acquisition of site-specific measurements, data processing and local information sharing, WSNs have become one of the most promising technologies for wide area monitoring [3]. However, when WSNs are increasingly being deployed over large geographical areas, the limitations of the individual sensor nodes begin to hinder In [28] is approached the opportunity for in-network pre-processing of sensory data and also for the planning of the UAV's local tasks, aiming at increasing the efficiency of the data collection process. A gradient scheme to support decision-making tasks planning was introduced. Authors proposed and evaluated a general architecture for a wide area monitoring system and the use of decentralized sensor fusion mechanisms for efficient data mining, promising to overcome WSN constraints.
In this paper we proposed a hybrid UAV-WSN system [29] to improve the large area monitoring. We first describe a decentralised multilevel architecture, with an UAV fitted with a sink node, serving as data collector, used to enhance the connection between ground WSNs and central gateway (base station). Considering the random deployment WSN nature and therefore the clustered structure, we focus on describing an effective mechanism for ground WSN discovery, while ensuring certain support for the election of the most appropriate communication links and cluster grouping. Trajectory-wise, we consider two distinct stages. First, we plan a discovery trajectory, based on a photogrammetry algorithm, during which the sensor position is estimated and information about cluster structure is gathered. Second, we plan a trajectory for data acquisition, which passes through the neighbourhoods of the cluster heads, with guaranteed communication time and guaranteed obstacle avoidance.

Materials and Methods
To overcome the limits of large-scale WSN monitoring systems and to improve the global system, our solution uses a heterogeneous data collection architecture based on WSN-UAV collaboration. This heterogeneous architecture implies that the UAV will ensure the collection of WSNs data, providing a reliable channel for the transmission of information. Depending on each application and the specific data collection requirements, the UAV can behave as a communication relay to connect WSNs to the remote base station or simply record ground data collected for subsequent analysis.

Monitoring System Architecture
In [29], the advantages of a general architecture for a heterogeneous monitoring system (UAVs-WSNs) are discussed, tailored for large scale monitoring and information processing, through a decentralized fusion approach. Starting from the same decentralized multilevel architecture, a single UAV serves here as data collector for the on-ground sensing nodes clusters and is used to enhance the connection between ground WSNs and the central gateway (base station). Communication-wise, in this paper, we divide this decentralized architecture into several levels, thus, a multilevel architecture. Top-most, a single UAV serves as a data collector for the ground detection nodes which compose the lower levels.
In a multi-level representation, the proposed hybrid UAV-WSN is described as in Figure 1. Starting from the ground level, the monitoring system consists of an extended network of sensors, which can be divided into WSN subsystems, further referred to as clusters. The clustered sensor nodes (Level 2) collect sensory data using specific acquisition equipment (Level 3) and provide efficient data analysis through in-network data processing mechanisms.
The fusion of sensor data is optimally established using effective consensus schemes. Typically, under the consensus mechanism, each sensor node performs gross estimation of the global average value and continues to improve its value through local information exchange between cluster neighbors. The UAV (Level 1) exchanges data with each cluster through a single sensor node further referred as cluster head. Cluster heads are marked with red color in Figure 1. The measure of limiting UAV-WSN data exchange to a single node per cluster is adopted in order to substantially reduce the burden on the communication channel. We assume that the power consumption of intra-cluster communication is much less than the power required for direct sensor-UAV communication.
The relevant sensory information is transmitted by UAV to ground station (Center gateway-Level 0). Additionally, the UAV contributes to the dynamic clustering of ground sensor nodes and cluster head selection mechanism.
Several assumptions about the mission parameters and external environment must be considered: (1) The nodes are randomly scattered within the area of interest; either due to the lack of GPS coordination or because of perturbing factors such as wind gusts when doing aerial deployment. (2) The area of interest has restricted regions over which flights are not allowed such as: buildings, roads or other areas where humans are present. Several assumptions about the mission parameters and external environment must be considered: 1) The nodes are randomly scattered within the area of interest ; either due to the lack of GPS coordination or because of perturbing factors such as wind gusts when doing aerial deployment.
2) The area of interest has restricted regions over which flights are not allowed such as: buildings, roads or other areas where humans are present. The second item in particular raises some interesting operational limitations for the mission: the interdicted areas are ignored by the sensor network, being transparent from the communication viewpoint, but are seen as obstacles to be avoided from the UAV's viewpoint.
The overall data gathering problem is divided, due to its complexity and many requirements, into several sequential subproblems: 1) Assuming that the sensor position is unknown, a preliminary stage in which the UAV(s) gather location data is required. This can be assimilated to a photogrammetry procedure in which the surface of interest is crossed repeatedly to estimate the sensors' position and receive information about cluster grouping, decided at the WSN level. 2) Putting together the information about obstacles, cluster heads and communication restrictions, a list of possible reference trajectories for the UAV(s) is obtained. 3) Lastly, during flight, it is ensured via auto-pilot feedback that the reference trajectories are tracked within prescribed tolerance bounds.
While none of the issues mentioned above is completely new, we consider that the reciprocal influences between each stage are of interest and rise challengin g theoretical and practical issues. The paper concentrates on the first two items in this classification. The third is both usually The second item in particular raises some interesting operational limitations for the mission: the interdicted areas are ignored by the sensor network, being transparent from the communication viewpoint, but are seen as obstacles to be avoided from the UAV's viewpoint.
The overall data gathering problem is divided, due to its complexity and many requirements, into several sequential subproblems: (1) Assuming that the sensor position is unknown, a preliminary stage in which the UAV(s) gather location data is required. This can be assimilated to a photogrammetry procedure in which the surface of interest is crossed repeatedly to estimate the sensors' position and receive information about cluster grouping, decided at the WSN level. (2) Putting together the information about obstacles, cluster heads and communication restrictions, a list of possible reference trajectories for the UAV(s) is obtained. (3) Lastly, during flight, it is ensured via auto-pilot feedback that the reference trajectories are tracked within prescribed tolerance bounds.
While none of the issues mentioned above is completely new, we consider that the reciprocal influences between each stage are of interest and rise challenging theoretical and practical issues. The paper concentrates on the first two items in this classification. The third is both usually implemented over commonly available "autopilot" software and, in any case, requires access to the inner components of the UAV-which might not be welcomed due to warranty or security reasons. Figure 2 summarizes the operational flow of the proposed UAV-WSN large scale monitoring system. In the preliminary phase the WSN is deployed over the target region in an uncontrolled manner and the UAV system is set-up. Subsequently a WSN discovery phase is carried out by the UAV and cluster heads (CH) are selected from the set of ground sensor nodes. The WSN then self-organizes around the selected CHs and UAV trajectories for data collection are optimised. The main operational loop consists of periodically sampling the monitored parameters and relaying the corresponding events towards the UAV. CH changes can occur locally in order to balance the node battery levels or in the case of losing connection to some of the nodes. In this case the CH selection is reinitialized and the process repeats. implemented over commonly available "autopilot" software and, in any case, requires access to the inner components of the UAV-which might not be welcomed due to warranty or security reasons. Figure 2 summarizes the operational flow of the proposed UAV-WSN large scale monitoring system. In the preliminary phase the WSN is deployed over the target region in an uncontrolled manner and the UAV system is set-up. Subsequently a WSN discovery phase is carried out by the UAV and cluster heads (CH) are selected from the set of ground sensor nodes. The WSN then self-organizes around the selected CHs and UAV trajectories for data collection are optimised. The main operational loop consists of periodically sampling the monitored parameters and relaying the corresponding events towards the UAV. CH changes can occur locally in order to balance the node battery levels or in the case of losing connection to some of the nodes. In this case the CH selection is reinitialized and the process repeats.

Trajectory Planning for the Estimation of Sensor Positions
As stated earlier, possible methods for the widespread dispersion of sensor nodes involve the use of air vehicles. Such a solution easily leads to an irregular distribution (characterized by a connected graph). Considering this aspect, it is mandatory to define a mechanism to obtain an estimate of the position of each sensor node placed on the ground. We start by defining a flight plan to ensure full coverage of the area of interest. Several specific parameters such as altitude of flying, UAV radio communication range, both for WSN nodes and UAV and others must be considered.
We consider therefore a multi-obstacle environment a priori known. That is, we consider a collection of obstacles O = {O } ⊂ R , as illustrated in the proof-of-concept example shown in Figure  2 (while the space dimension is = 3 or even = 2 if we assume the UAVs to fly at constant height, we keep to highlight that the results hold for a generic space dimension).
Within this environment we consider a collection of sensors = { } . Each sensor is characterized by its location ∉ and communication radius , the former to be determined at a later step. In Figure 3, a grid of 38 sensors (blue dots) are randomly distributed through the feasible domain (the complement of the union of three restricted areas (gray areas).
Assuming that the sensors are already deployed we require initial flights which cover the area of interest and, based on the information retrieved from the ground, provide the estimate ̂ of the true sensor location .

Trajectory Planning for the Estimation of Sensor Positions
As stated earlier, possible methods for the widespread dispersion of sensor nodes involve the use of air vehicles. Such a solution easily leads to an irregular distribution (characterized by a connected graph). Considering this aspect, it is mandatory to define a mechanism to obtain an estimate of the position of each sensor node placed on the ground. We start by defining a flight plan to ensure full coverage of the area of interest. Several specific parameters such as altitude of flying, UAV radio communication range, both for WSN nodes and UAV and others must be considered.
We consider therefore a multi-obstacle environment a priori known. That is, we consider a collection of obstacles O = {O l } ⊂ R n , as illustrated in the proof-of-concept example shown in Figure 2 (while the space dimension is n = 3 or even n = 2 if we assume the UAVs to fly at constant height, we keep n to highlight that the results hold for a generic space dimension).
Within this environment we consider a collection of sensors S = S j . Each sensor is characterized by its location z j / ∈ O and communication radius r j , the former to be determined at a later step. In Figure 3, a grid of 38 sensors (blue dots) are randomly distributed through the feasible domain (the complement of the union of three restricted areas (gray areas).
Assuming that the sensors are already deployed we require initial flights which cover the area of interest and, based on the information retrieved from the ground, provide the estimateẑ j of the true sensor location z j .
For a UAV following trajectory r(t), the estimation of the j-th sensor position is then given as: Equation (1) simply states that the sensor's position has to lie within all the circles centered on the points of the UAV trajectory where signal from the j-th sensor is received.
While the UAV trajectory r(t) can be arbitrary, it is much simpler to assume a regular trajectory: we consider a photogrammetry procedure in which the UAV covers the area with parallel lines separated by inter-distance ∆ and with measurements done along each line at distance δ as illustrated in Figure 4.
Equation (1) simply states that the sensor's position has to lie within all the circles centered on the points of the UAV trajectory where signal from the -th sensor is received.
While the UAV trajectory ( ) can be arbitrary, it is much simpler to assume a regular trajectory: we consider a photogrammetry procedure in which the UAV covers the area with parallel lines separated by inter-distance Δ and with measurements done along each line at distance as illustrated in Figure 4. Applying (1) for one sensor provides its location estimation (the blue region highlighted in the inset), as shown in Figure 5.  For a UAV following trajectory ( ), the estimation of the -th sensor position is then given as: Equation (1) simply states that the sensor's position has to lie within all the circles centered on the points of the UAV trajectory where signal from the -th sensor is received.
While the UAV trajectory ( ) can be arbitrary, it is much simpler to assume a regular trajectory: we consider a photogrammetry procedure in which the UAV covers the area with parallel lines separated by inter-distance Δ and with measurements done along each line at distance as illustrated in Figure 4. Applying (1) for one sensor provides its location estimation (the blue region highlighted in the inset), as shown in Figure 5. Applying (1) for one sensor provides its location estimation (the blue region highlighted in the inset), as shown in Figure 5. Strictly speaking any pair (Δ, ) which checks √ 2 + 2 < min guarantees that no sensor is missed (it will be "felt" at least once during the flight). In practice, we require that Δ and are sufficiently small to obtain a fair estimate of the position. Later on, we require that the UAV spends enough time in the neighborhood of a cluster head. If its position is uncertain we can no longer be sure that communication is ensured. As illustrated in Figure 5b we consider the estimated position of the sensor and find the smallest circle (defined by its center and radius ') which encloses it. The value of ' ultimately depends on the the pair of parameters (Δ,δ); thus, these have to be taken of appropriate values in order to obtain an acceptable value for the uncertainty radii '.
The pair of center and radius which over-approximated the uncertain region (2) is the result of Strictly speaking any pair (∆, δ) which checks √ ∆ 2 + δ 2 < min j r j guarantees that no sensor is missed (it will be "felt" at least once during the flight). In practice, we require that ∆ and δ are sufficiently small to obtain a fair estimate of the position. Later on, we require that the UAV spends enough time in the neighborhood of a cluster head. If its position is uncertain we can no longer be sure that communication is ensured. As illustrated in Figure 5b we consider the estimated position of the sensor and find the smallest circle (defined by its center c j and radius r j ) which encloses it. The value of r j ultimately depends on the the pair of parameters (∆,δ); thus, these have to be taken of appropriate values in order to obtain an acceptable value for the uncertainty radii r j . The pair of center and radius which over-approximated the uncertain region (2) is the result of the optimization problem: where C(c, r) denotes the circle of center c and radius r.

WSN Discovery and Clustering Support
Prior to the initial photogrammetry trajectory, the sensor network decides on its cluster partitioning and selects the cluster heads. This information is sent as well to the UAV during its initial flight. Thus, the second purpose of the "flight probe" is to classify and identify the best suitable sensor nodes for the CH position. Sensor nodes are evaluated according to a selection algorithm that uses several relevant indicators: • the number of unicast messages received by the aerial vehicle from each sensor node i denoted the broadcast sequence number t, which is used to distinguish nodes belonging to groups selection.
To be able to evaluate the node's parameters it is necessary to define a dynamic list in the program memory of the UAV's node. The node structure is composed of unique address, unicast number, signal strength and quality indicator, battery level and broadcast sequence (Algorithm 1).
For ease of implementation and understanding, we have defined a file in which the ground sensor responses are retained, including the unique address, the signal strength (RSSI) at the reception and the time label. Algorithm 1. Node structure and memory allocation pseudo-code.
(1) define the structure of a node{ (2) pointer to the next_node (in the list of nodes); RIME_address; (4) number of unicast messages received U; (5) energy level last_E; (6) maximum RSSI value RSSI_MAX; (7) maximum LQI value LQI_MIN; (8) broadcast sequence t; (9) } (10) perform memory allocation considering the number of (11) deployed nodes defined node structure; (12) create the list of nodes. The dialogue between sensor nodes is based on the RIME communication stack, using unicast and broadcast messages [30]. Two threads are required for this mechanism. Figure 6 illustrates the sequential diagram of the UAV-WSN survey dialogue.
The broadcast process (Algorithm 2) manages the broadcast packet transmission sequence. In order to meet the mandatory requirement, to fully cover the area of interest, the broadcast routine is periodically called at a specific sample time, which is closely related to the flight speed. UAV navigation speed during the experiments is around 3 m/s which had been found suitable to allow communication with the ground sensors. Packet collision is handled at the lower stack of the communication protocol using the CSMA/CA mechanism. Given the fact that we use a quadcopter system with no minimum navigation speed this allows good performance for WSN packet collection. Such a broadcast/unicast message exchange sequence is described in Figure 7. Time between broadcast calls is marked with t. Unicast responses of sensor nodes are illustrated with green concentric circles and denoted u i , where i is the current number of unicast received from the same ground sensor node at different sequences. Sensor node's radio cover range is marked with a grey dotted circle. Similarly, UAV's cover range is marked with red concentric circles. (6) maximum RSSI value RSSI_MAX; (7) maximum LQI value LQI_MIN; (8) broadcast sequence t; (9) } (10) pe rform memory allocation conside ring the number of (11) de ploye d node s de fined node structure; (12) cre ate the list of nodes.
The dialogue between sensor nodes is based on the RIME communication stack, using unicast and broadcast messages [30]. Two threads are required for this mechanism. Figure 6 illustrates the sequential diagram of the UAV-WSN survey dialogue.
The broadcast process (Algorithm 2) manages the broadcast packet transmission sequence. In order to meet the mandatory requirement, to fully cover the area of interest, the broadcast routine is periodically called at a specific sample time, which is closely related to the flight speed. UAV navigation speed during the experiments is around 3 m/s which had been found suitable to allow communication with the ground sensors. Packet collision is handled at the lower stack of the communication protocol using the CSMA/CA m echanism. Given the fact that we u se a quadcopter system with no minimum navigation speed this allows good performance for WSN packet collection. Such a broadcast/unicast message exchange sequence is described in Figure 7. Time between broadcast calls is marked with t. Unicast responses of sensor nodes are illustrated with green concentric circles and denoted ui, where i is the current number of unicast received from the same ground sensor node at different sequences. Sensor node's radio cover range is marked with a grey dotted circle. Similarly, UAV's cover range is marked with red concentric circles. The UAV enables the broadcast session by time ("survey_ON" is assigned true). A "PING" broadcast message including the broadcast sequence number t is sent. The s econd process thread manages the unicast messages received from ground sensor nodes. When sensor nodes receive a "PING" broadcast message, they respond to the UAV node with a unicast message in which the current battery level is transmitted. Collision avoidance for the unicast message replies is handled natively at the IEEE802.15.4 compliant radio transceiver by means of CSMA/CA protocol (Carrier Sense Multiple Access/Collision Avoidance). In practice this leads to a random communication back-off time for each of the colliding nodes, bounded by the superframe duration of the protocol. As a design choice of the communication architecture, the UAV discovers the ground sensor node The UAV enables the broadcast session by time ("survey_ON" is assigned true). A "PING" broadcast message including the broadcast sequence number t is sent. The second process thread manages the unicast messages received from ground sensor nodes. When sensor nodes receive a "PING" broadcast message, they respond to the UAV node with a unicast message in which the current battery level is transmitted. Collision avoidance for the unicast message replies is handled natively at the IEEE802.15.4 compliant radio transceiver by means of CSMA/CA protocol (Carrier Sense Multiple Access/Collision Avoidance). In practice this leads to a random communication back-off time for each of the colliding nodes, bounded by the superframe duration of the protocol. As a design choice of the communication architecture, the UAV discovers the ground sensor node positions in the initialization phase Additional data is received by the UAV along with the unicast message that includes the RIME address, the RSSI value, the LQI value.
We further discuss the routine called when the UAV node receives a unicast message from sensor nodes. First the algorithm (Algorithm 3) decides whether it has already been included in the node list or not. If the RIME address of the sender is not found in the list, a new entry is created and the node structure fields are initialized with the current info. Otherwise, if the node's address matches a position on the list, the values of interest are updated as follows: (a) the energy level is updated; (b) LQI_Min value is updated if the current value is lower than the stored value; Algorithm 2. Broadcast thread for UAV-WSN discovery (pseudo-code).
(1) define the Broadcast process thread{ (2) begin the process; (3) set up broadcast connection; (4) while (UAV is in survey_ON) do (5) Wait (time); (6) prepare the packet data; (7) send broadcast message; (8) update last broadcast position; (9) while end (10) end the process; (11) } If the stored sequence number t is equal to the current broadcast sequence number, the RSSI_MAX value is updated if the current value is greater than the old one and if the U i parameter is incremented. If t is different, then a RSSI comparison is carried out. If the current RSSI value is greater than the stored RSSI_MAX value, the t sequence number is updated and the value of the parameter U i is assigned 1. RSSI is updated as well. On the other hand, if RSSI is lower, only the U i parameter is updated.
(1) define the Broadcast process thread{ (2) begin the proce ss; (3) set up broadcast connection; (4) while (UAV is in surve y_ON) do (5) Wait (time ); (6) pre pare the packet data; (7) send broadcast me ssage; (8) update last broadcast position; (9) while end (10) end the proce ss; (12) } We further discuss the routine called when the UAV node receives a unicast message from sensor nodes. First the algorithm (Algorithm 3) decides whether it has already been included in the node list or not. If the RIME address of the sender is not found in the list, a new entry is created and the node structure fields are initialized with the current info. Otherwise, if the node's address matches a position on the list, the values of interest are updated as follow s: a) the energy level is updated; b) LQI_Min value is updated if the current value is lower than the stored value; If the stored sequence number t is equal to the current broadcast sequence number, the RSSI_MAX value is updated if the current value is greater than the old one and if the Ui parameter is incremented. If t is different, then a RSSI compar ison is carried out. If the current RSSI value is greater than the stored RSSI_MAX value, the t sequence number is updated and the value of the parameter Ui is assigned 1. RSSI is updated as well. On the other hand, if RSSI is lower, only the Ui parameter is updated.   The captured data analysis starts with dividing the list of sensor nodes based on the ranges appearing in the sequence number t. Intervals of such sequences are chosen by taking into account the network size. A cluster head is elected for each group of sensor nodes. The election method consists of a scoring system with different weights for the selection indicators.
This process uses a combined weight S i for each U i ∈ M tj i ∈ {1, . . . , n}, where M tj is the set of sensor nodes with the sequence value t j , where t i ∈ {t, . . . , t + m} and m is chosen as according to the size of the network as well. We chose it empirically as to include in the node discovery process a minimum number of ground nodes for each broadcast instance relayed by the UAV. The number of sequences m is inverse proportional with the ground sensor network deployment density. S i is defined as showing in (3): where ω 1 , ω 2 , ω 3 , ω 4 are the weights for each indicator, and B i is a binary parameter associated with the sensor U i taking the value "1" if the sensor responded to UAV and "0" else. Current experiments have used a larger value for ω for the RSSI and energy levels of the nodes but the mechanism is flexible to allow dynamic reconfiguration of the cluster head scoring. The cluster heads are elected for each M tj , by choosing the sensor node with the maximum S i value. Algorithm 3. UAV unicast message received from sensor node function (pseudo-code).

WNS Clustering Mechanism
Clustering is a suitable routing technology for large-scale monitoring systems, with a number of advantages such as scalability, data convergence, lower load, low power consumption, robustness [31]. The WSN clustering algorithm described in this paper is conceived from the premise that a number of sensor nodes have been selected and informed by the UAV node about their cluster head role. Thus, Figure 8 illustrates a simplified clustering sequence. The clustering mechanism is based on the RIME communication stack and exchanging of broadcast and unicast messages between neighbour nodes in a random manner.
Every node randomly broadcasts a message comprising its RIME unique address, current cluster membership, its role in the cluster (CH or simple) and an estimated number of cluster members. This is illustrated in Algorithm 4.
When a neighbor node receives a broadcast message, first it checks whether the sender node is or not in its list of neighbors. If it is not found, then it will be immediately added. Thereafter, it checks the sender information and decides whether to join or not the neighbor group. This decision is made depending on the number of hops to CH, the estimated signal strength (RSSI) and other criteria. This is illustrated in Algorithm 5. checks the sender information and decides whether to join or not the neighbor group. This decision is made depending on the number of hops to CH, the estimated signal strength (RSSI) and other criteria. This is illustrated in Algorithm 5.  Input: cluste rSize, cluster, isCH, hopsToCH Output: Broadcast_msg, seqNo (1) enable Broadcast call back function Broadcast_Recv (2) while(cluste rSize < limit) do (3) generate random_time ; (4) wait(random_time ); (5) msg.seqNo ← se qNo; (6) msg.cluster ← cluste r; (7) msg.isCH ← isCH; (8) msg.hopsToCH ← hopsToCH; (9) load msg; (10) send Broadcast(msg); (11) end while A node decides to join the sender's cluster starting from the main following rules: the node is not yet associated to a cluster; the node belongs to a different cluster but the number of hops to the CH is smaller or the number of hops is the same but RSSI is higher.
After decision, the node informs the sender whether it has joined or not the cluster, such that both can update the number of nodes inside the cluster.
After decision, the node informs the sender whether it has joined or not the cluster, such that both can update the number of nodes inside the cluster.
After receiving a unicast message, the node checks if the sender is included in the neighbor list and updates or adds the sender's information. The next step is to update the cluster size information. This routine is described in Algorithm 6. Note that cluster size information is only roughly calculated using an average consensus estimation. Average consensus estimation refers to the fact that each node within a cluster updates its local value for cluster size based on the values reported by its known neighbors. This occurs without the existence of a central entity propagating this value throughout the network but by means of a distributed process of message exchange among neighbors. Cluster sizes might vary during the deployment of the network as nodes might become unavailable or the UAV might reinitiate the CH assignment process.

Trajectory Design for Data Gathering
For further use we recapitulate some of the basic notions of B-spline parameterizations [32]. The B-spline of order d is described by the following recurrence relations (4) and (5): for d > 1, i = 0, 1 . . . n = m − d and the non-decreasing time instants (6) forming the so-called knot-vector.
The main difficulty of the mission is to efficiently cover the sensor heads such that all the information they provide is received. Note that this requirement imposes not only to pass near the node heads but also to stay enough time inside their communication range (such that the data is received).
The classic B-spline parameterization allows to pass though (or within a pre-defined neighborhood) of a way-point (the position of the cluster head of interest). The two principal issues are that both the total time for the trajectory and the intermediate times at which the sensor is passing near the way-points have to be a priori given [33]. In here we concentrate on the second issue but mention some heuristics for the first one as well.
First, we consider an iterative scheme where, for fixed way-points and a given permissible velocity interval, we estimate a total time for the UAV trajectory. Second, building on some preliminary work done in [33], we ensure that the UAV spends sufficient time inside the communication radius of each sensor head.
Typically, a collection of N + 1 way-points with associated time stamps is considered (10): Then, the UAV must pass through each way-point w k at the pre-specified t k , that is, y(t k ) = w k (where y(t) is the position component of the UAV state). These way-point constraints are needlessly restrictive and consequently impact negatively the trajectory generation procedure (even making the entire procedure unfeasible).
Previous results [33] partially alleviate these limitations by first relaxing the spatial restriction (the UAV position has to stay within a neighborhood of the way-point) and secondly by relaxing the temporal restriction (the time at which the UAV passes through the region of interest is not fixed a priori).
Let us associate to each way-point a communication region S k ⊂ R n x (we consider this region to be a polyhedral set). Then, inclusion (11): denotes the fact the trajectory spends enough time (in the interval t − k , t + k , such that t + k − t − k ≥ t min with t min an a priori fixed minimal time interval) near each of its cluster heads (characterized by position w k and communication region S k ).
Condition (11) is impractical since it requires the trajectory validation along a continuous time interval (i.e., t ∈ t − k , t + k ). To alleviate this issue we consider a sampling of the time interval by Remark 1. Choosing the sampling time interval ( t k+1 − t k ) is an important prerequisite: taking the step too large makes the problem formulation too rigid and taking it too small needlessly increases the computational complexity. For an appropriate choice, both the dimension of the sensing regions S k and the bounds on the UAV's velocity need to be taken into account.
The inclusion constraint (8) is discretized along the sampling instants and becomes: where α k,j ∈ {0, 1} are binary variables associated to the k-th sensing region S k and the j-th sampling time t j and M is a diagonal matrix of appropriate size whose diagonal entries are sufficiently large. Variables α k,j can be either "0" or "1": whenever it is "0" we have that the constraint is verified and whenever is '1' the constraint is ignored (due to the presence of the "big-M" term).

Remark 2.
Note that we do not specify when should the constraint be validated (we do not fix t − k and t + k ). (11) holds (or not), depending on the value taken by the associated binary variable α k,j . Proposition 1 [5]. For the given way-point and time-stamps collections (7), condition (8) is validated if: where t j and α k,j are taken as in (12).
Proposition 1 does not ensure that the time instants selected through the binary variables α k,j are contiguous. To solve this issue, we impose additional constraints on the binary variables.
Proof. (15) and (16) ensure that the binary variables are ordered along the time samples. That is, for each sequence ({β k,1 . . . β k, N } and {γ k,1 . . . γ k, N }), once there is a switch from "0" to "1", the value can no longer be changed. (17) ensures that the switch from "0" to "1" happens at latter time for γ: if the sequence of variables β becomes "1" at index k then γ can become "1" no earlier than index k+τ. Lastly, considering (13) it follows that sequence {α k,1 . . . α k, N } will always define a contiguous sequence of values "1" of length at least τ.
Adding the constraints of Corollary 1 to Proposition 1 means that we impose that once the trajectory enters the k-th sensing region it will not depart it for at least τ consecutive instants of time. Thus, it is in fact possible to replace (13) with (18): A couple of remarks are in order.

Remark 3.
Note that τ consecutive binary variables means that the UAV lies in the k-th sensing region for the time interval: t j . . . t j+τ . In other words, τ should be chosen such that the minimal communication time t min is verified, e.g., assuming that the sampling time T is constant (T = t j+1 − t j , ∀j), we have τ = t min T .

Remark 4.
Another aspect of interest (not followed here) is to maintain a constant (or at least bounded) velocity for the UAV. One possible solution is to use Corollary 1 from [21] to express the velocity bounds as a mixed-integer problem (the bound validation has a geometrical interpretation: the velocity vector has to lies in between two concentric circles).

Simulations
In what follows we consider the previously introduced environment with multiple obstacles and randomly positioned sensors. We apply the earlier theoretical results to give both location estimations and generate a trajectory which passes efficiently (do to its minimum length) near the cluster heads and, in the same time, avoids the obstacles.

Sensor Location Estimation and Trajectory Planning
To highlight the procedure for sensors' location estimation, in Figure 8 we illustrate the estimation results for a choice of parameters ∆ = 100 m, δ = 50 m and r j = 150 m, ∀j. Recalling the construction of the uncertain region from Section 2.2 we proceed as follows: at each point (denoted by red "x" symbols in Figure 8) along the trajectory where measurements are taken, the UAV gathers information from the sensors and, using its current position and the communication radius r j = 150 m provides an uncertain regionẐ j for each of the sensors as in relation (1).
As can be seen in Figure 9, the real sensor position (denoted by blue-filled circles), lies inside the yellow-filled uncertain regions (1). These, in turn, are over-approximated, as shown in optimization procedure (2), through circles (the red-filled shapes) characterized by centers c j (hollow blue circles) and radii r j as illustrated earlier in Figure 5.
gathers information from the sensors and, using its current position and the communication radius = 150 m provides an uncertain region ̂ for each of the sensors as in relation (1).
As can be seen in Figure 9, the real sensor position (denoted by blue-filled circles), lies inside the yellow-filled uncertain regions (1). These, in turn, are over -approximated, as shown in optimization procedure (2), through circles (the red-filled shapes) characterized by centers (hollow blue circles) and radii ′ as illustrated earlier in Figure 5.  Figure 9. Estimation of the sensor location in both exact and over-approximated (by circles).

Remark 5.
Note that the assumption of a known communication radius leads to a bounded uncertainty: while the actual position of the sensor is unknown it is, nonetheless, guaranteed to lie within the bounds of uncertain region (1).
For this particular example we observe that the uncertainty radii r j stay in the interval [10.51 m, 61.97 m]. Since the worst estimation, r j = 61.97 m is significantly less than the communication radius r j = 150 m we consider the identification procedure to be precise enough. Note as well that the worse uncertainties are for sensors near the obstacles. This happens because we assumed that no measurements are taken above the interdicted regions which means that there are fewer possibilities to assess the sensors' position.
Note for further use that the guaranteed communication region is given by the circle centered in c j with radiusr j = r j − r j . This allows later to consider the sensors as if they are centered in c j with radiusr j from the point of view of the subsequent trajectory generation procedures. The "worst" or "best" estimates are obtained a posteriori: once the UAV has done its initial passing, we proceed to bound the actual sensors' position through their associated uncertain regions (1) and to subsequently over-approximate these by circles of radii r j . If the approximation is unsatisfactorily (e.g., r j is comparable in size with the communication radius r j ) we need to repeat the procedure with modified parameters (smaller inter-line ∆, and intra-line spacings δ). Figure 10 shows various trajectories passing through or near the cluster heads. These trajectories are obtained as per the procedure highlighted in Section 2.4. Briefly: we assume that each trajectory is a weighted sum of basis functions (in our case, the B-splines defined in (4)-(6)) whose weights are the result of a constrained optimization procedure (the cost is the total trajectory length and the constraints are taken from (7)-(18)). We enumerate them in increasing order of complexity:(i) the dashed blue curve describes a trajectory which passes through the cluster heads (large black dots) ignoring the obstacles; (ii) the dotted green curve shows the slightly more complex case where the trajectory is required to pass through the neighbourhood of the cluster head (i.e., to be inside the communication radius-semi-transparent red regions), still ignoring the obstacles; (iii) the magenta solid curve shows a trajectory which ensures both the sufficient communication time constraint and the obstacle avoidance constraint.
For both cases, in the background are the obstacles (gray-filled regions), the sensors (blue dots) and the cluster heads (denoted by their estimated position-large black dots and estimated radius of communications-semi-transparent red regions).
complexity:(i) the dashed blue curve describes a trajectory which passes through the cluster heads (large black dots) ignoring the obstacles; (ii) the dotted green curve shows the slightly more complex case where the trajectory is required to pass through the neighbourhood of the cluster head (i.e., to be inside the communication radius-semi-transparent red regions), still ignoring the obstacles; (iii) the magenta solid curve shows a trajectory which ensures both the sufficient communication time constraint and the obstacle avoidance constraint .
For both cases, in the background are the obstacles (gray-filled regions), the sensors (blue dots) and the cluster heads (denoted by their estimated position-large black dots and estimated radius of communications-semi-transparent red regions).

Clustering
Experiments are based on TelosB/Tmote Sky platforms compatible with Contiki OS. We took advantage of the new available virtual tools for WSN prototyping, the simulation environment

Clustering
Experiments are based on TelosB/Tmote Sky platforms compatible with Contiki OS. We took advantage of the new available virtual tools for WSN prototyping, the simulation environment Contiki COOJA. The clustering results are obtained by implementation of the deterministic clustering mechanism presented in Section 2.4, with CH assignment by the UAV system.
Regarding the selected CHs, we imagined a navigation path over the nodes diagram and we arbitrary chosen the CHs as they would have been elected with the UAV's support using the scoring mechanism. Figure 11 illustrates a clustered WSN comprising the same deployment used as the one used for estimating the sensors' location and computing the trajectory planning. The layout of the network was obtained based on the simulation results of the proposed clustering mechanism. The network has divided in eight clusters with sizes ranging from three to seven sensory nodes. Cluster heads are circled with blue lines. Contiki COOJA. The clustering results are obtained by implementation of the deterministic clustering mechanism presented in Section 2.4, with CH assignment by the UAV system. Regarding the selected CHs, we imagined a navigation path over the nodes diagram and we arbitrary chosen the CHs as they would have been elected with the UAV's support using the scoring mechanism. Figure 11 illustrates a clustered WSN comprising the same deployment used as the one used for estimating the sensors' location and computing the trajectory planning. The layout of the network was obtained based on the simulation results of the proposed clustering mechanism. The network has divided in eight clusters with sizes ranging from three to seven sensory nodes. Cluster heads are circled with blue lines. In addition to the measured time required for WSN clustering, we made an online estimate of the power consumption for each sensor node using the powertrace feature available for Contiki OS, which let us know the time spent in the following states: CPU (active), LPM (low power mode), Transmit and Listen. Some results of simulations made on networks of different sizes are shown in Table 1. The standard deviation value reflects a large variation in both energy consumpt ion and In addition to the measured time required for WSN clustering, we made an online estimate of the power consumption for each sensor node using the powertrace feature available for Contiki OS, which let us know the time spent in the following states: CPU (active), LPM (low power mode), Transmit and Listen. Some results of simulations made on networks of different sizes are shown in Table 1. The standard deviation value reflects a large variation in both energy consumption and time. This is a predictable result due to the random mechanism and the uneven distributed topology. Mean power increases with WSN's expansion, while time required for the clustering mechanism is not affected, in fact clustering speed is increased because network density was increased and a large number of messages were exchanged at the same time.

Method Validation on Real Test-Bed
In order to further evaluate the proposed solution for UAV and ground WSN interlinking, some real implementations were developed. Lately we have paid a particular attention to this topic, involving significant efforts to create a real test-bed for validating the proposed strategies. This section showcases some of our experimental results drawn from test-beds simulations. Our test-bed experiments are based on TelosB/Tmote Sky platforms compatible with Contiki OS.
Regarding WSN discovery mechanism for estimating positions of sensor nodes, we created a test-bed comprising of five sensor nodes, CM3300, which is an IEEE 802.15.4 compliant wireless sensor node, designed by Advanticsys, based on the original open-source TelosB platform. The main specifications of the CM3300 mote are available in Table 2. Outdoor communication range values are specified in ideal conditions using a power amplifier and a high gain omnidirectional antenna. In a real environmental monitoring application, due to obstructions and vegetations, the expectation is for this to decrease by a factor between 4× and 10×. Four sensor nodes were configured to act as ground sensor nodes according to the described algorithms. To make it easier to spot them, they were placed over yellow colored boards (Figure 12a). The fifth one was configured to act as the UAV node and it was included in the UAV's payload (Figure 12b). Specifications regarding the UAV used-DJI MATRICE 600 PRO-are available in Table 3. and a high gain omnidirectional antenna. In a real environmental monitoring application, due to obstructions and vegetations, the expectation is for this to decrease by a factor between 4 × and 10×. Four sensor nodes were configured to act as ground sensor nodes according to the described algorithms. To make it easier to spot them, they were placed over yellow colored boards ( Figure  12a). The fifth one was configured to act as the UAV node and it was included in the UAV's payload (Figure 12b). Specifications regarding the UAV used -DJI MATRICE 600 PRO-are available in Table 3.  For this experiment, a flight plan was defined, with an elevation of 35 m above the ground, designed to explore an area of interest of 3 ha. The average cruise speed was 3 m/s, and the flight time was 10:47 min. Using the available flight record w e generated the following flying path illustrated in Figure 13.  For this experiment, a flight plan was defined, with an elevation of 35 m above the ground, designed to explore an area of interest of 3 ha. The average cruise speed was 3 m/s, and the flight time was 10:47 min. Using the available flight record we generated the following flying path illustrated in Figure 13.  After processing the logged data from the UAV's node, the following representations for WSN's response positions could be generated ( Figure 14). In each representation, the currently referred sensory node is marked with a large black dot. The red dots represent UAV positions at which packets from the current sensor are received.
To simplify the representation, only responses with a signal strength indicator above a sensitivity limit were retained. Sensor nodes are uniquely identified inside the network by means of their RIME communication stack addresses. For this particular example we observe that better placed nodes inside the area described by the flying path (24.125 and 112.104) can be accurately estimated, while nodes located at the border get the worst estimates. This was previously highlighted in Section 3.1.1. After processing the logged data from the UAV's node, the following representations for WSN's response positions could be generated ( Figure 14). In each representation, the currently referred sensory node is marked with a large black dot. The red dots represent UAV positions at which packets from the current sensor are received.
To simplify the representation, only responses with a signal strength indicator above a sensitivity limit were retained. Sensor nodes are uniquely identified inside the network by means of their RIME communication stack addresses. For this particular example we observe that better placed nodes inside the area described by the flying path (24.125 and 112.104) can be accurately estimated, while nodes located at the border get the worst estimates. This was previously highlighted in Section 3.1.1.
their RIME communication stack addresses. For this particular example we observe that better placed nodes inside the area described by the flying path (24.125 and 112.104) can be accurately estimated, while nodes located at the border get the worst estimates. This was previously highlighted in Section 3.1.1. Sensors' estimated location over -approximated by ellipsoidal shapes are illustrated in Figure  15. For node 4.130 which is located at the edge of the monitored area, it was not possible to define an Sensors' estimated location over-approximated by ellipsoidal shapes are illustrated in Figure 15. For node 4.130 which is located at the edge of the monitored area, it was not possible to define an estimated position. For the rest of the nodes we consider the identification procedure to be precise enough (the uncertain radius r j is significantly smaller than the communication radius r j ).  Variability of vegetation density during the year, weather conditions, and antenna orientation after uncontrolled aerial deployment are known as critical factors impacting node communication performance [15,16]. In our scenario through the experimental deployment we observe such phenomena for sensor node 4.130, graphically illustrated in Figure 16, which has been deployed at the edge of the field with surrounding vegetation. This particular sensor node also illustrates the induced variability through vegetation effects in the wireless communication performance. To mitigate such situations a probabilistic approach can be implemented which establishes reliable bounds on the RSSI values and availability of the sensor nodes. Als o, areas with reduced RSSI can be compensated by increasing the node coverage density e.g., increasing the number of nodes in a Variability of vegetation density during the year, weather conditions, and antenna orientation after uncontrolled aerial deployment are known as critical factors impacting node communication performance [15,16]. In our scenario through the experimental deployment we observe such phenomena for sensor node 4.130, graphically illustrated in Figure 16, which has been deployed at the edge of the field with surrounding vegetation. This particular sensor node also illustrates the induced variability through vegetation effects in the wireless communication performance. To mitigate such situations a probabilistic approach can be implemented which establishes reliable bounds on the RSSI values and availability of the sensor nodes. Also, areas with reduced RSSI can be compensated by increasing the node coverage density e.g., increasing the number of nodes in a given area.
Using the data available from the UAV's node logs we further analyze the RSSI evolutions illustrated in Figure 16. It can be seen how the RSSI's evolution changes depending on the position of the UAV.

Discussion
In this paper we proposed a hybrid UAV-WSN system, which, compared with [19], improves the monitoring of large areas and is dedicated especially to agricultural applications. Monitoring of large geographical areas require efficient data collection strategies, based on collaborative entities, able to overcome the challenges faced and achieve an improved overall system. The main challenges introduced by sparse WSN deployment, which creates an uneven distribution of sensing nodes, were pointed out. Starting from the hypothesis of an unknown sensor distribution over the area of interest, we have defined a strategy that starts with a photogrammetry procedure in which the surface of interest is crossed repeatedly by an UAV to estimate the sensors' position and receive information required for cluster grouping. Once this data becomes available, a scoring system can be called through which most suitable sensor nodes are proposed for clusters' head positions. The next step consists of running the clustering algorithm within the WSN nodes. Then we plan a trajectory which passes through the neighbourhoods of the cluster heads with guaranteed communication time and guaranteed obstacle avoidance.
As stated earlier, the main interest of this paper lies in the interplay between various components of the overall heterogeneous WSN surveillance. In particular, we are interested in how the trajectory generation procedures combine with the WSN communication restrictions. Beyond the directions studied in this paper we may consider as being worthwhile for further study: - The data acquired from the initial, sensor localization, trajectory may be used in the configuration of the sensor clusters (to account for geometrical restrictions: line of sight; distance between nodes, etc.). -Dynamic reconfiguration of the data-gathering trajectory: each cluster provides a list of potential cluster heads and multiple trajectories are computed (for various combinations of cluster heads). -Ultimately, we may consider a WSN in which the ground network and the UAV collaborate dynamically to create clusters and design the data-gathering trajectory (with the result depending and being updated by the current UAV position, sensor battery charge and amount

Discussion
In this paper we proposed a hybrid UAV-WSN system, which, compared with [19], improves the monitoring of large areas and is dedicated especially to agricultural applications. Monitoring of large geographical areas require efficient data collection strategies, based on collaborative entities, able to overcome the challenges faced and achieve an improved overall system. The main challenges introduced by sparse WSN deployment, which creates an uneven distribution of sensing nodes, were pointed out. Starting from the hypothesis of an unknown sensor distribution over the area of interest, we have defined a strategy that starts with a photogrammetry procedure in which the surface of interest is crossed repeatedly by an UAV to estimate the sensors' position and receive information required for cluster grouping. Once this data becomes available, a scoring system can be called through which most suitable sensor nodes are proposed for clusters' head positions. The next step consists of running the clustering algorithm within the WSN nodes. Then we plan a trajectory which passes through the neighbourhoods of the cluster heads with guaranteed communication time and guaranteed obstacle avoidance.
As stated earlier, the main interest of this paper lies in the interplay between various components of the overall heterogeneous WSN surveillance. In particular, we are interested in how the trajectory generation procedures combine with the WSN communication restrictions. Beyond the directions studied in this paper we may consider as being worthwhile for further study: - The data acquired from the initial, sensor localization, trajectory may be used in the configuration of the sensor clusters (to account for geometrical restrictions: line of sight; distance between nodes, etc.). -Dynamic reconfiguration of the data-gathering trajectory: each cluster provides a list of potential cluster heads and multiple trajectories are computed (for various combinations of cluster heads).
-Ultimately, we may consider a WSN in which the ground network and the UAV collaborate dynamically to create clusters and design the data-gathering trajectory (with the result depending and being updated by the current UAV position, sensor battery charge and amount of data to be transferred within the network).
All of the above require advanced optimization tools in order to handle the (usually conflicting) constraints. This raises interesting questions of memory and power resources; feature extraction and communication restrictions (capacity, safety and the like).

Conclusions
Throughout the paper we have shown that trajectories which pass sufficiently near the estimated positions of the cluster heads and, simultaneously avoid the obstacles, can be computed via a mixed-integer based optimization procedure. The proposed clustering mechanism enables effective WSN topology subsystems, optimized for energy consumption balance and fast data exchange. Our experimental results obtained both from comparative simulations and from real implementation showed that this collaborative approach for wide area monitoring is feasible and effective.
Author Contributions: D.P. conceived the system. D.P., L.I. and F.S. contributed to system implementation and wrote the paper. G.S. and C.D. designed and perform the experiments for WSN node clustering mechanism. F.S. elaborates the trajectory control.
Funding: This research received no external funding.