# A Cyber-Physical System for Wildfire Detection and Firefighting
## 3 Materials and Methods
### Nuclio Serverless Function
* **Fire Approaching Launcher:** To achieve fire detection and extinguishing, an ROS-based control logic system is implemented for the UGV. This system facilitates coordination among various ROS nodes responsible for GPS localization, obstacle avoidance, mapping, fire detection, and localization. The control logic, implemented as Python code, acts as the robot's brain, enabling collaboration between these nodes. GPScoordinates of the fire are received, and a series of waypoints is generated to cover a wider detection area. Custom ROS nodes handle navigation and fire detection, utilizing algorithms and neural networks. The robot incrementally approaches the fire, maintains a safe distance, extinguishes it, and returns to the base. This control logic ensures efficient and effective firefighting operations for the UGV. ## 4 Simulation

This section presents the results achieved by simulating the CPS system for wildfire detection and extinguishing. Through frameworks such as ROS, Gazebo, and RViz, it was possible to simulate, test, and continuously develop the system. By partially incorporating hardware, such as IoT sensors, a Software-in-the-Loop system was created, allowing for seamless integration between software and physical components. This approach enables a comprehensive evaluation of the system's performance and functionality, ensuring its effectiveness in real-world scenarios and providing a graphical representation of the mission that the UAV and UGV will conduct after the notification of the fire from the wildfire detection system. ### Unmanned Aerial Vehicle

The UAV's behavior has been extensively tested and validated through simulations conducted in Gazebo, a popular robot simulation environment. The simulations were performed on a machine with an Intel Core i7 2.8 GHz Quad-Core CPU and AMD Radeon R9 M370X 2 GB, running Ubuntu 20.04 LTS with ROS version Noetic. These specifications ensured sufficient computational power and compatibility with the ROS framework for accurate simulation results. In the simulations, we created a realistic forest environment, incorporating vegetation and fire representation. The fire spots were represented by a cube, while trees acted as obstacles that the UAV had to navigate around. To evaluate the UAV's performance, we conducted a series of tests:

* **Test 1. UAV Navigation:** The first test, we can see how the UAV, after receiving its mission, begins its navigation by following the path as shown in Figure 10. Then, the UAV passes from one waypoint to another in search of the fire. If the fire is not found during the first generated navigation mission, the system, based on the initially received coordinates, generates a new navigation path with greater coverage, a higher number of waypoints, and a higher altitude. This is done in order to increase the probability to detect the fire. Figure 10: UAV waypoints and navigation path. Figure 11 depicts the sequence of actions taken by the UAV to initiate and carry out a mission autonomously. Once the wildfire detection system notifies the UAV of a fire, it will _arm_ the motor, switch to _offboard mode_, and navigate through the waypoints. If no fire is detected in the initial zone, it will increase its coverage range (Figure 11). However, if it detects a fire, it will return to its _home base and land_. * **Test 2. UAV Fire Detection:** The second test, the scenario depicted in Figure 12, shows how the UAV on a mission identifies the fire approximately at waypoint three. Then, a simulation of a fireball extinguisher release takes place, followed by sending the coordinates to the UGV node. Finally, the UAV returns to its home base. * **Test 3. UAV Obstacle Avoidance:** The third test represents the simulation results for testing a collision avoidance system, using the 3 DVFH+ algorithm in a 3D environment. Figure 13 illustrates the movement of the UAV in the presence of obstacles.