#### Abstract

In this paper, the design of a controller for the altitude and rotational dynamics is presented. In particular, the control problem is to maintain a desired altitude in a fixed position. The unmanned aerial vehicle dynamics are described by nonlinear equations, derived using the Newton–Euler approach. The control problem is solved imposing the stability of the error dynamics with respect to desired position and angular references. The performance and effectiveness of the proposed control are tested, first, via numerical simulations, using the Pixhawk Pilot Support Package simulator provided by Mathworks. Then, the controller is tested via a real-time implementation, using a quadrotor Aircraft F-450.

#### 1. Introduction

Quadrotors have recently attracted the attention of many researchers due to their interesting applications. As a matter of fact, the potential applications of such devices are countless. Examples of such applications include searching and surveillance, monitoring, and rescuing tasks. From a methodological point of view, the interest relies on the fact that a quadrotor is a complex underactuated system with high nonlinearities and strong dynamical couplings. Furthermore, it is affected by aerodynamic disturbances, unmodeled dynamics, and parametric uncertainties. Therefore, the quadrotors represent an interesting testbed for testing new control techniques.

There are a large number of works dealing with quadrotors. As far as the mathematical model is concerned, in Bouabdallah et al. [1], Zeng and Zhao [2], and Nagaty et al. [3], a Newton–Euler model was presented. Furthermore, Magnussen et al. [4] and Valenti et al. [5] considered quaternions to describe the angular kinematics, whilst Antonio-Toledo et al. [6] applied the Euler–Lagrange equations to obtain the whole quadrotor mathematical model. Regarding the control of quadrotors, many control techniques have been proposed. In Panomruttanarug et al. [7] and Pounds et al. [8], the linear quadratic regulator control and the proportional integral derivative control, respectively, were exploited to design a control law. However, these controllers ensure only local stability. In order to enlarge the basin of attraction, nonlinear control techniques have also been considered. Examples are sliding model control Luque–Vega et al. [9], backstepping Bouabdallah and Siegwart [10], and adaptive control Matouk et al. [11]. Moreover, a global fast dynamic terminal sliding mode control method was proposed for position and attitude tracking control in Xiong and Zhang [12]. An adaptive command filtered backstepping control law was designed for trajectory tracking in Choi and Ahn [13]. In Liu et al. [14], a robust adaptive attitude tracking control for a quadrotor with an unknown inertia matrix and bounded external disturbances was proposed. A command filtered implementation of an adaptive backstepping was proposed in Dong et al. [15], and the stability of the closed loop system was proved via the Lyapunov direct method. Finally, in Islam et al. [16], an observer-based adaptive fuzzy backstepping controller was designed for trajectory tracking, in the case of a quadrotor undergoing wind gusts and with parametric uncertainties. All these aforementioned methods provide good dynamic performance and robust stability and are tested mainly considering numerical simulations.

The main contribution of this paper is the design of a controller for the attitude and altitude of a quadrotor helicopter. This controller has been designed using the backstepping technique and has been tested using numerical simulations and real-time experimentation. In particular, the focus of this paper is to obtain a controller ensuring hovering so that(1)The reference attitude is zero for the Euler angles describing the quadrotor angular position(2)The reference altitude is a constant value

The performance and effectiveness of the proposed controller has been first tested with numerical simulations using the Pixhawk Pilot Support Package (PSP). Then, the real-time implementation has been performed implementing the proposed controller on a real F-450 quadrotor equipped of a Pixhawk and tested under environmental perturbations.

The paper is organized as follows. Section 2 introduces the description and the mathematical model of the quadrotor. In Section 3, the control problem is solved. In Section 4, numerical simulations and real-time tests are provided to show the effectiveness of the proposed controller. Finally, some concluding remarks are commented in Section 5.

#### 2. Mathematical Model

The quadrotor considered in this work consists of a rigid frame equipped with four rotors. The rotors generate the propeller force , proportional to the propeller angular velocity , . The propellers 1 and 3 rotate counterclockwise, and the propellers 2 and 4 rotate clockwise.

Denote and as the frames fixed with the Earth and the quadrotor, respectively, with coincident with the center of mass of the quadrotor (see Figure 1). The quadrotor absolute position in is described by , whereas its attitude is described by the Euler angles , where are the pitch, roll, and yaw angles, respectively. The sequence 3–2–1 has been considered by Huges [17]. Moreover, and are the linear and angular velocities of the center of mass of the quadrotor, expressed in and in , respectively.

The translation dynamics (in ) and rotation dynamics (in the ) of the quadrotor arewhere is the mass of the quadrotor, is the inertia matrix of the quadrotor, and (expressed in ), andis the so-called dyadic representation of ,are the forces and moments produced by the propellers (inputs), with as the distance between the center of mass to the rotor shaft. Moreover, is the force due to the gravity expressed in .

The vectors expressed in are transformed into vectors in by the rotation matrix:with , , and . The angular velocity dynamics are expressed using the matrix:with and .

The rolling torque is produced by the forces and . Similarly, the pitching torque is produced by the forces and . Due to Newton’s third law, the propellers produce a yawing torque on the body of the quadrotor, in the opposite direction of the propeller rotation. Moreover,is the gyroscopic torque due to the propeller rotations, with the propeller moment of inertia with respect to its rotation axis. Finally, and are the forces and torques due to the external disturbances, which are assumed negligible here.

Under the assumption of small angles, matrix reduces to the identity matrix. This assumption is justified by the fact that the control objective is to maintain the quadrotor in an hover position Nagaty et al. [3]. This leads to a simplified mathematical model of the quadrotor given bywhere the control variables are defined aswhere is the distance of the center of mass to the rotor shaft, is the drag factor, and is the so-called rotor relative speed. The parameters used in (7) and their values are defined in Table 1.

#### 3. Control Design

##### 3.1. Attitude Control

To design the attitude control law, let us define the following variables:so that system (7) can be rewritten aswhere are the measured signals. The control objective is to match the UAV attitude to a desired reference:

To this aim, let us define the tracking errors aswith . Note that implies , . Deriving the error system (12) with respect to (10) is possible to calculate the error dynamics:

Using the following control law [18],with gains , in (13), the tracking error dynamics becomewhere , which converge exponentially to zero. In fact, considering the Lyapunov candidateand differentiating along the error dynamics (15), one obtainswith solution of the equation for a fixed matrix . Therefore,so that the tracking error converges globally exponentially to zero [19].

##### 3.2. Altitude Control

For the altitude control, let us consider the altitude dynamics:

The control problem is to maintain the quadrotor at a desired constant altitude , . The tracking errors are defined as

Choosingwith , we obtainwhere and

The stability proof is similar to that of the previous section.

#### 4. Simulation and Experimental Results

In this section, the performance of the attitude and altitude controllers (14) and (21) is tested considering an F-450 quadrotor. First, numerical simulations are carried out. Then, real-time experimental tests are performed, showing the effectiveness of the control design.

##### 4.1. Simulation Results

For the numerical simulations, the quadrotor model provided by the Pixhawk PSP, in Simulink, has been used. This model contains the attitude and altitude flight control model called px4 demo attitude control, which shows a good performance in predicting the dynamic quadrotor behavior, very close to the real drone dynamics.

Controllers (14) and (21) use the nominal values of Table 1 and the gains of Table 2. The simulations have been performed in two steps. In the first one, the quadrotor is stabilized in altitude. In Figure 2, the altitude is shown. In the second step, the quadrotor is stabilized in attitude. The pitch, roll, and yaw angles are shown in Figure 3. The initial conditions considered are , , , and . The reference values are m and .

**(a)**

**(b)**

**(c)**

##### 4.2. Experimental Results

In this section, we describe the physical setting of the embedded control that allows stabilizing the quadrotor. An embedded control system generally consists of three elements: sensors, actuators, and a microcontroller. The microcontroller interacts with the continuous dynamics of the plant via the sensors and actuators, and its major function is to compute and generate control commands for the actuators that are based on sensor measurements. The onboard electronic system consists of a flight controller, a hardware setup, and some ultrasonic sensors.

###### 4.2.1. Flight Controller

The 3DR-PIXHAWK is a high-performance autopilot-on-module suitable for fixed wing, multi rotors, helicopters, cars, boats, and other mobile robotic platforms. Its processor can run to 168 MHz/252 MIPS Cortex-M4F with 256 KB in RAM and 2 MB flash and has 14 PWM/Servo outputs and abundant connectivity options for additional peripherals, such as 5x UART (serial ports), one high-power capable, 2x with HW flow control, 2x CAN, Spektrum DSM/DSM2/DSM–X® Satellite compatible input, PPM sum signal input, RSSI (PWM or voltage) input, I2C, SPI, 3.3 and 6.6 V ADC input. Moreover, the 3DR-Pixhawk has different sensors, such as ST Micro L3GD20H 16 bit gyroscopes, ST Micro LSM303D 14 bit accelerometers/magnetometers, Invensense MPU 6000 3-axis accelerometers/gyroscopes, and MEAS MS5611 barometers.

###### 4.2.2. Hardware Setup

The structure of the quadrotor is composed by an F-450 frame with integrated PCB wiring, whereas the rotors are brushless motors manufactured by E–max, with 935 rpm/V and a 10 4.5″ propellers. Turnigy speed drivers (ESC) are BHC type at 18 A max. The battery used in this setup is a 3S, 2800 mAh, 25C. The radio-transmitter is a Turnigy with 9 PPM channels working at 2.4 GHz.

An LV-MaxSonar-EZ4 sensor with a resolution of 2.54 cm, 20 Hz reading rate, 42 kHz ultrasonic sensor measures, a maximum Range of 645 cm, operating in the range of 2.5–5.5 VDC was used to measure the altitude.

For the real-time running, the same parameter values and gains shown in Table 2 were used. The initial condition for the altitude was m. For the pitch, roll, and yaw angles, the initial condition were chosen at , , and . Figures 4 and 5 show the dynamic behavior of the altitude and the pitch, roll, and yaw angles, respectively. It is worth noticing that these experimental tests were performed in an outdoor environment, without using the GPS sensor.

**(a)**

**(b)**

**(c)**

#### 5. Conclusions

In this paper, a controller based on the stabilization technique for the altitude and attitude error has been proposed for a quadrotor. The simulation results have been performed using the Pixhawk PSP. Then, the controller has been implemented on a laboratory quadrotor. The simulation and experimental results show a good performance, even in outdoor environment, showing some degree of robustness in the presence of environmental disturbances.

#### Data Availability

The figures, tables, and other data used to support this study are included within the article.

#### Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

#### Acknowledgments

This paper has been partially supported by the European Project ECSEL–JU RIA–2018 “Comp4Drones” and project “Coordination of autonomous unmanned vehicles for highly complex performances,” Executive Program of Scientific and Technological Agreement between Italy (Ministry of Foreign Affairs and International Cooperation, Italy) and Mexico (Mexican International Cooperation Agency for the Development), SAAP3.