# UAV Path Optimization for Precision Agriculture Wireless Sensor Networks
## 4 Simulation Methodology  
In this line of study, due to the high cost of autonomous UAV platforms, it is very common to use simulators for mathematical validation of the route models, and to analyze the experimental results generated through them. Many researchers use general purpose systems such as Network Simulator [35], Matlab [36], The One [37], or even OMNet++ [38] for results generation and analysis. Furthermore, there are open source platforms developed specifically for UAV simulations, such as the OpenUAV [39] project, or even the Dronecode [40] that provide a library for graphical development applied to this area. Still, several authors choose to develop their own simulators instead of using a ready-made solution. We have followed the latter path and chose to develop our own graphic simulator: UAV Simulator. Our platform was developed using Visual Studio 2017 as IDE and C-Sharp language; the source code is freely available at GitHub [41]. The reason for the development of a new system was the creation of a graphical interface that allows for the real-time monitoring of the UAV flight path, along with the activation and hibernation status from each SN in the scenario. Besides that, it provides the visualization of the ad hoc connections created by the approximation between UAV and SN/BS, and also permits easy monitoring of the sensory data transfers from SN to UAV, UAV to UAV, and UAV to BS in a clean and intuitive interface to the viewer. The simulator also allows the generation of logs of all states and elements involved in the scenario, ensuring detailed and accurate information for further analysis, and study of the proposed model. Figure 12 shows the main interface of the UAV simulator [41]. In terms of features and functionality, the graphical UAV Simulator allows the use of up to 30 SNs, along with up to 30 UAVs; resizing of the simulation area is also possible. It allows configuration of the communication range and connections from the UAV with SNs, other UAVs and BS. The management of the UAV autonomy by flight time, the SNs active time, and UAV time over each SN to collect the sensory data (called here as Reading Time) are also configurable. The simulator has real-time monitoring of the active and hibernation timers from each SN, and their assigned timeslots. Furthermore, the simulator has a text panel, informing the viewer of each step and decision made by the UAV, and individual events from all SNs. For each simulation scenario, the simulator registers the following information:  
* Number of UAVs needed to reconfigure all SNs;
* Flight distance of each UAV;
* Flight time of each UAV;
* Total flight time;
* Number of hops by each UAV;
* Number of decisions taken by each UAV;
* UAVs pre-calculated path length;
* Timeslots assigned to the scenario;
* Timeslots elapsed until all SNs are reconfigured;
* UAV coordinates as a function of flight time/TS;
* SNs states as a function of time/TS;
* UAVs connections with each SN as a function of time/TS;
* SNs missed flights by UAV;
* SNs Active Time (before and after reconfiguration);
* Battery percentage and UAV autonomy as a function of time/TS. The proposed strategy was evaluated through simulation, considering five different scenarios (\(S_{1}\), \(\ldots\), \(S_{5}\)), which are presented in Table 1. The parameters adopted for flight autonomy and the UAV speed were based on the DJI manufacturer (DJI, Shenzhen, Guangdong, China) [42], Phanton 4 Pro, Matrice 200 and Mavic 2 Enterprise models, recommended for use in agriculture due to the ease of its graphical interface mapping and flight plan. The flight time of the mentioned UAVs varies between 10 and 30 min, depending on the flight speed, used resources, and weather conditions. Furthermore, authors such as [PERSON] et al. [27] and [PERSON] et al. [43] adopt 10 min of flight autonomy in published studies. Authors in [8; 44; 45] also cite UAVs in the context of sensory data gathering  
Figure 12: UAV Simulator main interface presenting the UAV’s path between the SNs.