3.4.7. Compensation

When the quadrotor is under a certain vertical distance from the landing platform and it is centered with respect to it, the horizontal tracking (Section 3.2) and the vertical compensation (Section 3.3) tasks generate the position setpoints. In this state, to compensate for the catamaran's oscillations, the vertical position setpoints are generated using the estimations coming from the Kalman filter and the equations reported in Section 3.3. The measures coming from the ultrasonic sensor are the only ones used, due to their higherfrequency updating.

#### 3.4.8. Landing

When the quadrotor is sufficiently close to the platform and the relative velocity between the two agents is under a certain threshold, the finite state machine enters the landing state, where the motors of the quadrotors are shut down, allowing it to land on the catamaran. Due to the criticality of this decision, the altitude and velocity thresholds have been set to very low values, to prevent crashes or mishaps.

#### **4. Software Architecture**

To process information coming from the various sensors and generate the setpoints necessary to fulfill the assigned tasks, the quadrotor needs to be equipped with a set of software tools communicating with each other, which were chosen strictly due to the hardware components that were installed on the quadrotor itself, presented in Section 2.2. An overview of the considered software architecture is presented in Figure 6.

**Figure 6.** The main blocks composing the software architecture in the ROS2 simulation environment.

#### *4.1. Gazebo*

Gazebo is software that makes it possible to simulate accurately and efficiently the dynamic behavior of populations of robots in complex environments. It offers an environment where the dynamics of the quarotor are approximately simulated. This was a necessary tool to test the developed algorithms, as an intermediate preparation for outdoor tests on real hardware.

#### *4.2. PX4*

PX4 is open-source flight control software for quadrotors and other unmanned vehicles. In this project, it is mainly used as a means to translate the pose setpoints coming from ROS2 nodes into PWM signals that are directly injected into the motors.

#### *4.3. ROS2*

ROS2 is a real-time version of the more common ROS (Robot Operating System), a set of open-access software libraries and tools for building robot applications. Its tools allow structuring the software in different modules interacting with each other through well defined message-based interfaces. In our study, ROS2 was used to create a workspace composed by a set of different modules, each one implementing a different feature: from packages collecting and processing the data coming from the camera and the ultrasonic sensor, to the ones handling the information transfer between the PX4 and the guidance controller. When performing a simulation, the sensors were replaced by their software counterparts implemented in Gazebo, and ROS2 nodes retrieved the data via RTPS (realtime publish–subscribe; see Section 4.6). Other software packages included the Kalman filter and the vision system described in Section 3.1. The vision system node is asynchronous and processes the compressed images coming from the camera whenever they are available (20 fps), requiring an average computational time of ∼7.0 ms. The measured maximum

computational time was 29.86 ms, and the minimum was 1.56 ms; it depends on the number of visible markers. The node implementing the Kalman filter instead is synchronous with the ultrasonic sensor's refresh rate of 30 ms, processing the coming data in an average of ∼3.0 ms; 4.7 ms maximally and 2.0 ms minimally.
