Improved Altitude Control Algorithm for Quadcopter Unmanned Aerial Vehicles

Abstract: Quadcopter unmanned aerial vehicles continue to play important roles in several applications and the improvement of their control performance has been explored in a great number of studies. In this paper, we present an altitude control algorithm for quadcopters that consists of a combination of nonlinear and linear controllers. The smooth transition between the nonlinear and linear modes are guaranteed through controller gains that are obtained based on mathematical analysis. The proposed controller takes advantage and addresses some known shortcomings of the conventional proportional–integral–derivative control method. The algorithm is simple to implement, and we prove its stability through the Lyapunov theory. By prescribing certain flight conditions, we use numerical simulations to compare the control performance of our control method to that of a conventional proportional–derivative–integral approach. Furthermore, we use a DJI-F450 drone equipped with a laser ranging sensor as the experimental quadcopter platform to evaluate the performance of our new controller in real flight conditions. Numerical simulation and experimental results demonstrate the effectiveness of the proposed algorithm.


Introduction
In recent decades, unmanned aerial vehicles (UAVs) have gained popularity in the scientific community due to their numerous advantages such as high maneuverability, diverse applicability, reliability, and economy. UAVs are used in a broad range of applications such as scientific research, civil engineering, military applications, aerial mapping, search and rescue operations, and risk zone inspection [1][2][3][4]. Quadcopters are an important class of UAVs that are superior in many ways: they have a simple structure, are quick to manufacture, and are inexpensive [4,5]. Controlling their position, in general, and altitude, in particular, has been the subject of numerous studies [6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][22][23] with ever more advanced algorithms having been proposed to address the quadcopter control problem.

Related Works
Many applications of quadcopters in the real world have been discussed in recent years. The most widely mentioned topics include autonomous landing on moving platforms [6][7][8][9], precision landing for autonomous docking and wireless self-charging system [10,11], and autonomous delivery tasks [12][13][14]. These applications are all, somehow, based on a reliable altitude controller. Therefore, designing an altitude controller with superior performance is one of the most common and important efforts that researchers all around the world are nowadays undertaking.
To that end, several papers have addressed the altitude control problem in the literature. Santos et al. [15] presented an algorithm to accomplish quadcopter trajectory tracking tasks by controlling the altitude through an adaptive dynamic controller that was capable of dealing with

Main Contributions
Motivated by the above observations, in this article, we propose an altitude control algorithm for quadcopter unmanned aerial vehicles. The main advantages of this new method are twofold: (1) while our method inherit the advantages of the PID approach, i.e., it is simple and straightforward, its multi-loop approach ensures that unlike other control algorithms [33][34][35][36][37][38], our controller requires less computational resources and exhibits a smooth performance at all times; and (2) compared to conventional PID controllers, our control algorithm delivers a greatly improved performance with regard to both raising time and error convergence speed.
We use the Lyapunov stability theory to validate the system's stability. We prescribe a maximum acceleration/deceleration of the vehicle which allows the controller to have the vehicle move at an appropriate acceleration before fast and hard approaching a target. This contributes to a safer and smoother flight performance of both single vehicles performing specific missions [5,14,41,42] and multi-agent systems flying in formation or switching their inter-communication topology [43,44]. For safety reasons, we firstly evaluate the performance of our new controller with numerical simulations and then we will conduct experimental flights to demonstrate the effectiveness of the proposed algorithm in real flight conditions.

Organization
The remainder of this paper is organized as follows: Section 2 presents the dynamical quadcopter model and Section 3 the control algorithm while the numerical simulation and experimental demonstration results and their discussions are provided in Section 4, before ending with the main conclusions.

Quadcopter Dynamics Model
Here, we briefly summarize the quadcopter dynamics model as it has already been presented previously [45,46].
Let φ, θ, and ψ denote the three Euler angles roll, pitch, and yaw, respectively, where, φ < π/2, |θ| < π/2, and ψ ≤ π (see Figure 1). The symbols x, y, and z respectively represent the position of the quadcopter along the x, y, and z axes in an earth-fixed frame {E}. J x , J y , and J z denote the moments of inertia along the x, y, and z axes, respectively; m represents the mass, l the arm length of the vehicle, and g the gravitational acceleration. The quadcopter dynamics model can be described as follows [45,46]: where U i (i = 1, 2, 3, 4) denotes the control inputs which are: where F i = C t Ω 2 i denotes the thrust force generated by motor i; Ω i is the speed of motor i; C t and C d are the thrust and drag coefficients, respectively. Appl. Sci. 2019, 9, x 4 of 16

Quadcopter Control Scheme
The overall control scheme consists of position and attitude controllers ( Figure 2). Conventional PID controllers are used for both horizontal (x-and y-) position control and attitude control while a new algorithm is proposed for altitude control. It is worth noting that our new algorithm can also be used for horizontal position control.

Controller Design
The multi-loop PID-PID control scheme for quadcopter altitude control was introduced and verified in some existing studies [28,33,47]. In this section, we present our new altitude control algorithm which also consists of a multi-loop controller, i.e., outer-loop and inner-loop. We derive the outer-loop as a multi-mode (i.e., nonlinear and linear modes) control law while the inner-loop is a PID controller.
Let d z denote the desired attitude, and z v represent the vertical velocity of the vehicle. The altitude tracking error is then given by: Then the derivative of z e is: A multi-mode control law is chosen for the outer-loop of the altitude controller as:

Quadcopter Control Scheme
The overall control scheme consists of position and attitude controllers ( Figure 2). Conventional PID controllers are used for both horizontal (x-and y-) position control and attitude control while a new algorithm is proposed for altitude control. It is worth noting that our new algorithm can also be used for horizontal position control.

Quadcopter Control Scheme
The overall control scheme consists of position and attitude controllers ( Figure 2). Conventional PID controllers are used for both horizontal (x-and y-) position control and attitude control while a new algorithm is proposed for altitude control. It is worth noting that our new algorithm can also be used for horizontal position control.

Controller Design
The multi-loop PID-PID control scheme for quadcopter altitude control was introduced and verified in some existing studies [28,33,47]. In this section, we present our new altitude control algorithm which also consists of a multi-loop controller, i.e., outer-loop and inner-loop. We derive the outer-loop as a multi-mode (i.e., nonlinear and linear modes) control law while the inner-loop is a PID controller.
Let d z denote the desired attitude, and z v represent the vertical velocity of the vehicle. The altitude tracking error is then given by: Then the derivative of z e is: A multi-mode control law is chosen for the outer-loop of the altitude controller as:

Controller Design
The multi-loop PID-PID control scheme for quadcopter altitude control was introduced and verified in some existing studies [28,33,47]. In this section, we present our new altitude control algorithm which also consists of a multi-loop controller, i.e., outer-loop and inner-loop. We derive the outer-loop as a multi-mode (i.e., nonlinear and linear modes) control law while the inner-loop is a PID controller.
Let z d denote the desired attitude, and v z represent the vertical velocity of the vehicle. The altitude tracking error is then given by: Then the derivative of e z is: .

of 15
A multi-mode control law is chosen for the outer-loop of the altitude controller as: where, a max is a positive constant which represents the desired maximum acceleration of the vehicle; d l a positive constant at which the line (∆) k, e 0 positive constants, and e 0 < d l ; v z the control action which will be fed into the inner-loop (see Figure 3) as a velocity reference [31].
, k e positive constants, and 0 l e d < ; z v the control action which will be fed into the inner-loop (see Figure 3) as a velocity reference [31].
Manipulating (6) yields:  z d without any change of the relations between (S) and (∆). In order for the line (∆) to be tangential to the curve (S) at e z = d l , the followings must be satisfied: Manipulating (6) yields: Appl. Sci. 2019, 9, x 6 of 16  (3) with the parameters satisfying (6) then the system (1) is asymptotically stable and the tracking error is forced to zero.
Proof. Choose a Lyapunov candidate function as:  (3) with the parameters satisfying (6) then the system (1) is asymptotically stable and the tracking error is forced to zero.

Theorem 1. If the control law is designed as Expression
Proof. Choose a Lyapunov candidate function as: It is clear that V > 0, ∀e z 0. We have: Substituting (4) into (9) and choosing control laws as (5), we have: Clearly, we have . V < 0, ∀e z 0 which means that the tracking error, e z , converges to zero as time t → ∞ . This completes the proof. Remark 1. When e z < −d l or e z > d l , the controller generates control actions that follow the curve (S). While this is the case, the slope of (S) is smaller than that of (∆) which means that the acceleration is limited, which in turn results in fewer overshoots and vehicle jerks. Whereas, when −d l ≤ e z ≤ d l , the control action follows the line (∆) which has a higher slope. This guarantees that the tracking error converges to zero in a prompt and hard manner.

Remark 2.
When −d l ≤ e z ≤ d l , the proposed controller becomes a proportional-PID (P-PID) control scheme, which implies that the parameter k can be obtained through a conventional PID tuning process. Moreover, at e z = -d l and e z = d l , the line (∆) becomes a tangent to the curve (S), resulting in smooth transitions when the controller switches control modes (between nonlinear and linear modes), with regard to both acceleration and velocity.

Numerical Simulation, Experimental Results and Discussions
In this section, we demonstrate the effectiveness of the proposed altitude control algorithm. The quadcopter dynamics from Expression (1) are used to verify the stability and advanced performance of our controller. By comparing our new method to a conventional PID controller, we highlight and discuss the effectiveness of the new method.

Hardware and Avionics Devices
We use a DJI-F450 quadcopter as the experimental platform ( Figure 5) which is operated by an onboard flight computer unit (FCU) Pixhawk [48,49]. The quadcopter attitude and acceleration are provided by an inertial navigation system (INS). We use a commercially available laser ranging sensor LidarLite V3 to measure the altitude and a commercial global positioning system (GPS) receiver to determine the position of the vehicle. Additionally, a power supplying system (including battery, power adapter module), a set of remote control transmitter/receiver for the manual pilot, and a set of radio telemetry transmitter/receiver for ground station monitoring are used. The quadcopter dynamical parameters are listed in Table 1.

Numerical Simulation, Experimental Results and Discussions
In this section, we demonstrate the effectiveness of the proposed altitude control algorithm. The quadcopter dynamics from Expression (1) are used to verify the stability and advanced performance of our controller. By comparing our new method to a conventional PID controller, we highlight and discuss the effectiveness of the new method.

Hardware and Avionics Devices
We use a DJI-F450 quadcopter as the experimental platform ( Figure 5) which is operated by an onboard flight computer unit (FCU) Pixhawk [48,49]. The quadcopter attitude and acceleration are provided by an inertial navigation system (INS). We use a commercially available laser ranging sensor LidarLite V3 to measure the altitude and a commercial global positioning system (GPS) receiver to determine the position of the vehicle. Additionally, a power supplying system (including battery, power adapter module), a set of remote control transmitter/receiver for the manual pilot, and a set of radio telemetry transmitter/receiver for ground station monitoring are used. The quadcopter dynamical parameters are listed in Table 1.    We implemented all vehicle altitude, position, and attitude controllers on the Pixhawk FCU running at frequencies of 100 Hz, 100 Hz, and 400 Hz, respectively. The altitude controller gains and reference values for altitude are listed in Table 2. It is worth noting that the horizontal position controller and attitude controller are beyond the scope of this paper and will not be presented in this section. The system signal flows are briefly described by the block diagram in Figure 6. We implemented all vehicle altitude, position, and attitude controllers on the Pixhawk FCU running at frequencies of 100 Hz, 100 Hz, and 400 Hz, respectively. The altitude controller gains and reference values for altitude are listed in Table 2. It is worth noting that the horizontal position controller and attitude controller are beyond the scope of this paper and will not be presented in this section. The system signal flows are briefly described by the block diagram in Figure 6.

Numerical Simulation and Discussions
The experimental quadcopter parameters and controller gains are used for the simulation. The controllers are implemented based on Matlab/Simulink with the sampling time is chosen identically as the operating frequency of the controllers in the experimental system. The initial vehicle altitude and vertical velocity are all zero, i.e., (0) 0 . The vehicle is armed on a horizontal level surface with the attitude stabilization controller enabled. We present two test scenarios to evaluate the effectiveness of our proposed algorithm, namely the tracking of (1) a step altitude reference; and (2) a moving altitude reference. For comparison, we also simulated the performance of a conventional PID controller for both scenarios.

Scenario 1: Tracking Step Altitude References
This scenario consists of three stages: (i) initialization; (ii) take-off; and (iii) descent. During the first five seconds the vehicle is initialized, i.e., it is armed and prepares for take-off. The altitude, vertical velocity, and acceleration are all zero (Figures 7-10) and the control signal, 1 U , increases from the initial value of zero to the hovering value of about 19.62 N ( Figure 11). During the second stage (from 5 t = to 30 t = s), the quadcopter takes off and ascends to the desired altitude of 15 m. The altitude responses are nearly identical for both controllers during the early stage of the flight ( 5 9 t ≤ < s in Figure 7). Initially, the conventional PID controller responds

Numerical Simulation and Discussions
The experimental quadcopter parameters and controller gains are used for the simulation. The controllers are implemented based on Matlab/Simulink with the sampling time is chosen identically as the operating frequency of the controllers in the experimental system. The initial vehicle altitude and vertical velocity are all zero, i.e., z(0) = 0 and . z(0) = 0. The vehicle is armed on a horizontal level surface with the attitude stabilization controller enabled.
We present two test scenarios to evaluate the effectiveness of our proposed algorithm, namely the tracking of (1) a step altitude reference; and (2) a moving altitude reference. For comparison, we also simulated the performance of a conventional PID controller for both scenarios.

Scenario 1: Tracking Step Altitude References
This scenario consists of three stages: (i) initialization; (ii) take-off; and (iii) descent. During the first five seconds the vehicle is initialized, i.e., it is armed and prepares for take-off. The altitude, vertical velocity, and acceleration are all zero (Figures 7-10) and the control signal, U 1 , increases from the initial value of zero to the hovering value of about 19.62 N ( Figure 11).
During the second stage (from t = 5 to t = 30 s), the quadcopter takes off and ascends to the desired altitude of 15 m. The altitude responses are nearly identical for both controllers during the early stage of the flight (5 ≤ t < 9 s in Figure 7). Initially, the conventional PID controller responds slightly faster than our new controller (see Inset 1 in Figure 7). This is reversed during the later stages of the flight when the tracking error becomes smaller than d l (e z ≤ d l ≈ 5.1 m) and the controller smoothly switches to the linear mode. For 9 ≤ t < 30 s our new controller exhibits a significantly superior performance compared to the conventional PID. With our algorithm, the tracking error converges to a small range closed to zero (e z is less than 0.5%) at t ≈ 21 s while the conventional PID only reaches this range around t ≈ 25 s (Inset 1 in Figure 8). The velocity, acceleration, and control signal of the conventional PID controller exhibit large amplitudes and slow converging speeds (Figures 9-11).
In order to evaluate the performance of our controller when the step amplitude is smaller than d l , during the third stage (30 ≤ t ≤ 50 s), the quadcopter is commanded to descend from the current altitude of 15 m to the desired altitude of 12 m (corresponding to a step of 3 m). If we look at the insets 2 in Figures 7 and 8, it is clearly seen that our controller aggressively responds and quickly reaches the altitude reference at t ≈ 45 s while the conventional PID controller only reaches this reference at t ≈ 49 s. l d , during the third stage ( 30 50 t ≤ ≤ s), the quadcopter is commanded to descend from the current altitude of 15 m to the desired altitude of 12 m (corresponding to a step of 3 m). If we look at the insets 2 in Figures 7 and 8, it is clearly seen that our controller aggressively responds and quickly reaches the altitude reference at 45 t ≈ s while the conventional PID controller only reaches this reference at 49 t ≈ s.   altitude of 15 m to the desired altitude of 12 m (corresponding to a step of 3 m). If we look at the insets 2 in Figures 7 and 8, it is clearly seen that our controller aggressively responds and quickly reaches the altitude reference at 45 t ≈ s while the conventional PID controller only reaches this reference at 49 t ≈ s.

Scenario 2: Tracking a Moving Altitude Reference
Here, the vehicle tracks a moving altitude reference using the same controller gains as in Scenario 1. The moving altitude reference is given as a sine function of time t as: Clearly, the altitude performance of our new algorithm is superior to a conventional PID controller ( Figure 12). While the moving reference altitude reaches 10 m altitude at time t ≈ 15.7 s, our controller reaches the peak about 3.8 s later (at t ≈ 19.5 s), while the conventional PID controller lags by 9.7 m, reaching the maximum altitude at t ≈ 21.1 s. Due to this significant delay, the conventional PID does not even reach the full altitude. In addition, the tracking error of the PID controller exhibits large amplitude oscillation and a slow response compared to our algorithm ( Figure 13). controller ( Figure 12). While the moving reference altitude reaches 10 m altitude at time 15.7 t ≈ s, our controller reaches the peak about 3.8 s later (at 19.5 t ≈ s), while the conventional PID controller lags by 9.7 m, reaching the maximum altitude at 21.1 t ≈ s. Due to this significant delay, the conventional PID does not even reach the full altitude. In addition, the tracking error of the PID controller exhibits large amplitude oscillation and a slow response compared to our algorithm ( Figure  13).  controller lags by 9.7 m, reaching the maximum altitude at 21.1 t ≈ s. Due to this significant delay, the conventional PID does not even reach the full altitude. In addition, the tracking error of the PID controller exhibits large amplitude oscillation and a slow response compared to our algorithm ( Figure  13).

Experimental Demonstration and Discussions
In this subsection, we present the experimental results of a step-altitude-reference-tracking flight to evaluate the performance and demonstrate the effectiveness of our new controller in real flight conditions. After arming, the quadcopter stays on the ground and prepares for take-off during the first ten seconds (Figure 14). The altitude reference of 15 m is commanded at time t ≈ 10 s leading the vehicle to ascend. It is clear that, initially, the conventional PID controller performance is considerably faster than our proposed controller. However, similarly to the simulation results, our new controller exhibits a superior performance compared with the PID controller when the tracking error becomes smaller. If we look at the inset in Figure 14, it is seen that the response of our proposed controller is about 5 s faster than that of the conventional PID controller. The experimental vertical velocity and acceleration performance (Figures 15 and 16) also prove the stability and the effectiveness of the proposed algorithm. new controller exhibits a superior performance compared with the PID controller when the tracking error becomes smaller. If we look at the inset in Figure 14, it is seen that the response of our proposed controller is about 5 s faster than that of the conventional PID controller. The experimental vertical velocity and acceleration performance (Figures 15 and 16) also prove the stability and the effectiveness of the proposed algorithm.  error becomes smaller. If we look at the inset in Figure 14, it is seen that the response of our proposed controller is about 5 s faster than that of the conventional PID controller. The experimental vertical velocity and acceleration performance (Figures 15 and 16) also prove the stability and the effectiveness of the proposed algorithm.  The way our new algorithm exhibits the performance promises a smooth system response when the vehicle starts a movement and a fast target approaching speed when the tracking error becomes small. These properties are useful in performing tasks that require high accuracy and smooth performance such as precision landing, obstacle avoidance, and autonomous delivery to high The way our new algorithm exhibits the performance promises a smooth system response when the vehicle starts a movement and a fast target approaching speed when the tracking error becomes small. These properties are useful in performing tasks that require high accuracy and smooth performance such as precision landing, obstacle avoidance, and autonomous delivery to high buildings, etc.

Conclusions
This paper presented a new altitude control algorithm for quadcopters. The experimental validation and the numerical simulation results clearly demonstrated that our algorithm performs significantly better compared to a conventional PID controller. While taking advantage of the strength of conventional PID approaches, our method successfully tackles some of their shortcomings. Our algorithm is simple to design and implement, and can be applied to a large range of position control applications for unmanned vehicles. Future work is dedicated to precision landing control design with our proposed controller for an autonomous quadcopter docking and self-charging system.