# A Cyber-Physical System for Wildfire Detection and Firefighting
## 3 Materials and Methods
### Architecture  
The proposed architecture (Figure 2) is composed of different heterogeneous and distributed nodes, each of them serving a specific purpose:  
**Communication Sensor:** The communication between the sensors and the robots in our project is facilitated by the Robot Operating System (ROS) framework, which provides a flexible and robust infrastructure for building robotic systems. To enable data exchange between different components of the system, we utilize ROS topics, which employ a publish-subscribe mechanism. In our system, we employ a Jackal Rover as one of the robots, equipped with sensors such as the fire detection system powered by You Only Look Once (YOLO). These sensors communicate their data to other components using ROS topics. When a fire is detected, relevant information, including the status of the fire (extinguished or not), is published on a specific ROS topic. This enables other components, such as the Unmanned Aerial Vehicle (UAV) and the ground control station, to subscribe to the topic and receive the necessary data, facilitating coordinated actions. **Communication Unmanned Devices:** To establish communication between the UAV and the UGV, we utilize the ROS-Bridge package ([[http://wiki.ros.org/rosbridge_suite](http://wiki.ros.org/rosbridge_suite)]([http://wiki.ros.org/rosbridge_suite](http://wiki.ros.org/rosbridge_suite)), accessed on 28 April 2023). ROS-Bridge provides a WebSocket interface to ROS topics and services, facilitating the exchange of ROS messages over the internet using the Wi-Fi antenna equipped on the devices. By running the ROS-Bridge on a computer or embedded system acting as the ground control station, we establish a communication protocol between the UAV and the UGV. In our implementation, the ROS-Bridge launcher file is configured with the IP address of the ground control station, which serves as the communication endpoint. Once the ROS-Bridge server is launched on the ground control station machine, data flow between the UAV and UGV is facilitated through the ROS-Bridge, with the ground control station acting as an intermediary. For example, if the UAV needs to communicate GPS data to the UGV, the ground control station receives this data from the UAV via the ROS-Bridge WebSocket. Subsequently, the data are forwarded to the UGV, ensuring seamless coordination between the two robots. This communication process is also employed to establish communication between unmanned devices and the IoT device. ROS-Bridge enables the communication between both ROS-enabled and non-ROS-enabled devices, enabling wireless communication facilitated by the use of Wi-Fi technology, which is also equipped on the IoT device. **Wildfire Detection Node:** This is a prototype based on a low-power system of chip microcontroller (ESP32 Wroom 32) and equipped with multiple sensors such as temperature and humidity sensors, an infrared and a CO\({}_{2}\) sensor. The prototype uses a GPS module for fire localization and an IP ESP32 Camera that is linked to a real-time fire detection system based on YOLOv5. This integration enables the device to quickly and accurately detect the presence of a wildfire. The combination of these different sensors and technologies creates an advanced and all-encompassing solution for monitoring and detecting forest fires. **Unmanned Ground Vehicle (UGV):** This is an ROS-based Jackal Rover designed specifically for wildfire detection and extinguishing. Equipped with the YOLOv4-Tiny CNN model, it can search for fires after receiving the approximate location from the IoT node or the more precise location from the UAV device. The UGV can also detect the location of the fire by combining the YOLOv4-Tiny CNN model and Realsense depth cameras, allowing it to maintain a safe distance and direct the pump for extinguishing the fire. The UGV operates autonomously by following a navigation path and responding immediately without human intervention.