# Development and Testing of a Two-UAV Communication Relay System
## 4 Software Development
### Software Realization of Relay Process  
The presence of a relay implies that the relaying node (UAV \"Mom\" in this case) needs to handle a frame routing. When processing received frames, the UAVs made use of the \"Source ID\" and \"Target ID\" fields to filter and/or route the frames in the following manner. * UAV \"Son\" is the terminal receiver, which only receives frames over the relay from \"Mom.\" Therefore, \"Son\" only saves for further processing frames whose \"Target ID\" is equal to the ID of \"Son\" itself. * UAV \"Mom\" functions as a communication relay node, but it also receives control commands from GCS. Therefore, \"Mom\" will save for further processing frames whose \"Target ID\" is equal to the ID of \"Mom\" itself, and will re-transmit frames targeted at \"Son\" over Radio T2-1. The above-mentioned frame routing logic is elaborated in the following pseudocode (Algorithms 1 and 2) and flow chart in Figure 12.  
```
For(true) do: if(frame receive from T2-2) do: if(frame_target_id==id_son) do: save frame for local processing. else do: discard frame. end end
```  
**Algorithm 1**Frame Processing Logic, UAV Son  
```
For(true) do: if(frame receive from T1-2) do: if(frame_target_id==id_mom) do: save frame for local processing. else if(frame_target_id==id_son) do: send frame out from T2-1. end end end
```  
**Algorithm 2**Frame Processing Logic, UAV Mom  
```
For(true) do: if(frame receive from T1-2) do: if(frame_target_id==id_mom) do: save frame for local processing. else if(frame_target_id==id_son) do: send frame out from T2-1. end end end
```  
**Algorithm 3**Frame Processing Logic, UAV Com  
```
For(true) do: if(frame receive from T1-2) do: if(frame_target_id==id_mom) do: save frame for local processing. else if(frame_target_id==id_son) do: send frame out from T2-1. end



The last field of the frame contained a four-byte cyclic redundancy checking (CRC) code, which was computed using the IEEE 802.3 32-bit CRC polynomial. This CRC code was important because it helps verify data frame integrity and protect the system from the influence of error-corrupted data or messages. Error-corrupted data or messages could be dangerous, as they might be mistakenly understood by the UAV's mission control subsystem as wrong commands, resulting in unpredictable and potentially dangerous behavior. ### Mini GCS

A ground control software, named \"Mini GCS\", was developed in-house. Mini GCS is an integrated UAV control interface that is compatible with Windows 7, 8, and 10 systems. The functions of Mini GCS include handling data exchanges with UAVs, displaying information about the UAVs, and providing an interface for users to send commands to the UAVs. It allows users to monitor the status of both UAVs, and to control the mission of each UAV from a single, integrated interface, which makes it a crucial communication node in the communication relay network. Mini GCS was implemented using C#, and the graphic user interface (GUI) was constructed using Microsoft Windows.NET framework. Because the main focus of this work is to demonstrate a signal relay system for the UAV applications, details of this Mini GCS software are not emphasized in the manuscript and the source code is included in the section of Supplementary Materials for reference. Figure 13 shows a screenshot of Mini GCS. A number of features are available. * **UAV Status Display:** displays to users a selected set of important information about each UAV, including communication status, GPS status, flight mode, altitude, speed etc. * **UAV Command Line:** a command line interface that allows users to send specific commands to any UAV nodes in the network such as takeoff, land, return to launch, etc. * **UAV Position Display:** displays the real-time position and heading of both UAVs in a map of the mission area. Figure 12: Flow chart of mission control software for (**a**) UAV “Son” and (**b**) UAV “Mom”. ## 5 Performance Tests

To verify the performance of the system, a series of indoor and outdoor tests were carried out.