# Real-Time UAV Trash Monitoring System
## 2 System Description  
The real-time UAV trash monitoring system consisted of nine parts, including UAVs, a message queuing system, database, video streaming server, connector, UAV control station, web service, UAV map, and data analysis, as shown in Figure 1. The video streaming server, Kafka, Kafka connector, MongoDB, and web service were built in the ground station.  
Figure 1: The structure of real-time unmanned aerial vehicle (UAV) trash monitoring system.  
The UAV system included an intelligent UAV controller and a power system. The intelligent UAV controller used the master and slave structure to control the UAV. The power system was responsible for the lifting power of the UAV. A schematic of the UAV system is shown in Figure 2, where ESC is the electric speed controller.  
In a master and slave structure, the slave performs low-level control and is responsible for the stability of the flight. The master performs high-level control and sends the flight command to the slave, that is, intelligent applications. For the slave of the intelligent UAV controller, we used the Pixhawk flight controller [16] equipped with an Ublox M8N GPS module [17] to control the stability of the flight. The GPS error was 2 to 6 m, which depended on the GPS signal. We fine-tuned the UAV's proportional, integral, and derivative (PID) parameters in the UAV testing flight. The PID parameters were tuned in-flight. It used the auto-tuning technique [18], which is based on the Ziegler-Nichols closed-loop method. Figures 3 and 4 show the proposed quadrotor and the PID parameters.  
Figure 3: The proposed quadrotor.  
Figure 2: The layout of the unmanned aerial vehicle (UAV) system.  
For the master of the intelligent UAV controller, we used the NVIDIA-embedded system Jetson Xavier NX [19] as the UAV onboard computer to carry out high-computational trash detection. The master was equipped with a Logitech BRIO webcam [20] and a Huawei E8372 4G dongle [21]. For the UAV trash detection task, we uploaded the predefined waypoints to the UAV first. Then, the UAV was controlled by the onboard computer to patrol the coastline along these waypoints automatically. While flying between two waypoints, the UAV took pictures, detected trash, and calculated the trash area. After data analysis, the image and the information regarding the trash were sent to the server of base station. Then, the UAV flew to next waypoint and repeated image processing and data transmission. After all waypoints were checked, the UAV flew back to the home position. A flowchart of the UAV trash detection task is shown in Figure 5.  
We can calculate the detected trash pollution area by Equations (1)-(4), where \(\alpha\), \(\beta\), \(H\), \(L\), \(W\), \(W_{i}\), \(L_{i}\), \(W_{o}\), \(L_{o}\), \(A_{o}\), and \(A_{g}\) are the camera's horizontal and vertical angle of view, the UAV's height, the camera's horizontal and vertical of view, the width and height of the camera's image, the width and the height of detected trash in the image, detected trash's area in the image, and the area of the detected trash in the real world, respectively, as shown in Figure 6, where FOV is field of view.  
\[L=2\times H\times tan\left(\frac{\alpha}{2}\right) \tag{1}\]  
\[W=2\times H\times tan\left(\frac{\beta}{2}\right) \tag{2}\]  
\[A_{o}=W_{o}\times L_{o} \tag{3}\]  
\[A_{g}=A_{o}\times\left(\frac{W_{o}}{W_{i}}\right)\times\left(\frac{L_{o}}{L_{i }}\right) \tag{4}\]  
The proposed quadrotor was set up based on a practical performance evaluation method [22]. This method provided necessary parameters' values for electric multi-copters. The performance of our proposed quadrotor is shown in Figure 7. The total weight of the quadrotor was 5.05 kg with a frame size of 700 mm. The quadrotor could fly for about 21.8 min at a minimum battery capacity of 25%.  
Figure 4: The proportional, integral, and derivative (PID) parameters of the quadrotor.  
Figure 5: A flowchart of the UAV trash detection task.