Attitude and Altitude Tracking Controller for Quadcopter Dynamical Systems

Unmanned aerial vehicle quadcopters have applications in different real-life areas. They are nonlinear systems that necessitate the utilization of nonlinear control techniques. In this paper, we propose a new quaternion-based tracking controller for an underactuated quadcopter based on the pseudo linear feedback linearization technique. The quadcopter dynamic model was derived using Newton and Euler equations, and the global asymptotic stability of the quadcopter was verified using the Lyapunov stability criterion. The proposed controller has been compared to three state-of-the-art quadcopter controllers. Through simulation results, it has been shown that the proposed model has an effective and better performance than others. The metrics used in this evaluation are the steady-state error, maximum error, overshoot, and settling time. The different metrics proved the good performance of the proposed model in most of the different states that are presented.


I. INTRODUCTION
Quadcopters are among the most popular unmanned aerial vehicles as they can be utilized in various tasks, such as search and rescue operations [1][2], military operations [3][4][5], and even agricultural processes (for spraying pesticides) [6][7]. Moreover, the vertical take-off and landing capabilities, hover capability, great mobility, and agility of quadcopters make them extremely versatile in various operations. However, their usability still faces many control challenges, such as ensuring stable operation despite high nonlinearity, underactuated systems, strong coupling, external disturbance, and the need for fast control responses with satisfying regions of convergence in the presence of uncertainties [8][9]. Controller development requires the development of a quadcopter dynamics mathematical model. A system dynamics model was previously obtained for a quadcopter using either the Newton-Euler or Euler-Lagrange methods [10], and the orientation of the quadcopter could be represented by rotation matrices, Euler angles, and quaternions. Quaternions were employed in [11][12][13][14] to control the quadcopter attitude and position, and optimum performance was proven. Quaternions were also employed in some studies [15][16] to solve the tracking problems of attitude and altitude with good performance. Moreover, the attitude tracking controller in [17][18][19][20] employed quaternions to avoid the issues of Euler angle representation.
In previous studies, variety of nonlinear techniques had been applied to quadcopters. For example, in [21], fuzzy PD and classical PD controllers were successfully implemented, and the performance of the Fuzzy PD controller was shown to be slightly better than the classical PD controller with regard to durability against noise and ease of implementation. To achieve good control for the position and the attitude of the quadcopter, a PID control technique has been proposed in [22]. The PID coefficients had been fine-tuned using a Genetic Algorithm (GA). The controller's robustness was evaluated in terms of sensor noise suppression, disturbance rejection, and sensitivity to model parameter uncertainty. The results of the robustness tests confirmed the efficacy and performance of the developed controller. A waypoint navigation controller was proposed in [23], using a fuzzy PID controller, which controlled a quadcopter to reach the desired position with good performance. In [24], a fuzzy PID controller was used instead of a traditional PID. Fuzzy controllers can improve quadcopter performance compared with classical PID controllers. In [25], the authors demonstrated how to adopt PID controllers in interferenceenhanced models. Among the preferred techniques, solutions relying on a backstepping control technique using quaternion representation were proposed in [25 -29]. The validity of the proposed controllers was verified by simulation and the Lyapunov stability criterion. In [31], a backstepping controller based on the Euler angle orientation technique was developed to control the altitude and attitude of quadcopter systems. The controller's validity was also assured by the Lyapunov function. The simulation results revealed transient and tracking responses with great precision. In [32][33], LQR controllers were used to control the attitude and position of quadcopters using the Euler angle orientation approach. To increase the control algorithm responsiveness, the LQR controller was integrated with the feedback linearization model. The sliding mode has the benefit of solving uncertain issues in nonlinear system control. For example, in [34], an altitude controller was proposed based on the second-order sliding mode technique. It has good performance compared with three reference controllers. An adaptive sliding tracking controller in [35], achieved a low tracking error compared with a classical sliding mode controller. Attitude and altitude tracking controllers, which are based on a combination of sliding mode techniques and PID techniques were proposed in [36]. This controller was compared to other state-of-the-art ( four types of sliding mode) [33][34], [37], all of which use the same external disturbances. The proposed controller's efficacy is demonstrated by the simulation results. In [38], a combination of integral sliding mode and backstepping sliding mode controllers was established with uncertainties, and the presence of disturbances to track the attitude and position to achieve good tracking performance. In [39], a hybrid model by using integral backstepping and sliding mode controller is proposed for an efficient controller to track position and orientation by integrating a recursive control approach. Three state of the art [38][39][40] are implemented to compare with this controller to prove its efficiency.
Over the years, feedback linearization has attracted a lot of interest. In [42], the authors proposed a feedback linearization technique using a Luenberger observer to rebuild the no measured variables required to improve the robustness and performance of the proposed controller. The control system (i.e., observer, estimator, and controller) showed to have an interesting contribution for controlling the systems equipped with a minimum number of sensors. In [43], two sub controllers (i.e., feedback linearization and two PD controllers) were used to control the quadcopter. The proposed model could simultaneously combine tilting and movement along the desired trajectories, and the validity of the control system was tested by simulation. In [44], the authors proposed attitude, altitude, and position controller to keep the quadcopter under control and stable. To prove the validity of this controller, it was compared with two state-of-the-art from the previous literature studies, and it was also tested experimentally. In [45], the authors presented a nonlinear output feedback control approach that achieved an asymptotic altitude and attitude trajectory tracking for a quadcopter system, and the external disruptions and model uncertainties were considered. To attain high performance and good stability, the authors in [46], proposed a hybrid model to control the position and the attitude of the quadcopter model. This model was linearized using feedback linearization approach, and a mixed sensitivity H∞ optimum controller was then built and synthesized. The controller was put to the test to see how well it can reject disturbances, reduce sensor noise, and deal with model uncertainties. In [47], the authors proposed a model based on feedback linearization side by side with backstepping. The proposed model presented satisfying results under high acceleration trajectory tracking and slowly varying wind conditions. Moreover, the authors in [48] proposed a hybrid system that relies on feedback linearization and LQR methods. The proposed technique was successful in tracking a predetermined trajectory and presenting small position errors under model inaccuracies, uncertainties, and disturbances. In our early work [49], the proposed controller task is to regulate the attitude and altitude of a quadcopter, but the regulation applications are less than the tracking applications. Also, new variables have been added to fit the proposed controller for tracking. The friction factor with air has also been added to make the proposed controller more realistic.
In this paper, the main contributions are as follows.
• A new quaternion-based feedback controller design is proposed for tracking quadcopter orientation and altitude.
• The proposed controller is not complex and allows low-end microcontroller-based implementations.
• A comparison with three controllers of the state-of-the-art quadcopter controllers (Non linear1, Non linear2, Non linear3) was conducted to demonstrate the effectiveness and performance of the proposed controller. The three controllers that were compared to the proposed model are summarized in the following three points.
➢ Non linear1 controller achieved locally asymptotic stability. Various aerodynamic and gyroscopic effects might be considered in quadcopter model. However, to keep the model as simple as possible, the authors ignored it. In altitude controller, it does not consider the first derivative of the desired altitude, this neglect has somewhat affected the performance compared to the proposed altitude controller.
➢ Non linear2 controller achieved locally asymptotic stability. It uses Euler angle representation that has singular configurations, in which the angular velocity loses one degree of freedom. These drawbacks can be avoided using unit quaternions that have proven good performance in comparison to the other representations.
➢ Non linear3 controller achieved almost global asymptotic stability. It uses quaternion representation that achieved good performance compared to Non linear1, and Non linear2. This controller takes into consideration attitude tracking problem but doesn't consider the altitude tracking problem. Moreover, the gyroscopic moment, and various aerodynamic is not included in this controller.

•
The gyroscopic moment, aerodynamic rotation, and translation drag are considered to achieve good accuracy. To the best of authors' knowledge, there are no solutions for attitude and altitude control in the literature used this technique without simplifying assumptions.
• The efficiency of the proposed controller is clearly shown when the quadcopter is in or near a corner pose due to his use of the quaternion representation instead of Euler angle representation.
• The stability analysis of the proposed controller meets Lyapunov stability conditions.
• The proposed controller achieved global asymptotic stability.
The rest of this paper is organized as follows. The model, kinematics, and dynamics of the quadcopter are detailed in Section II. The flight controller design and stability analysis are presented in Section III. The simulation results of the proposed controller are presented and discussed in Section IV. Finally, the conclusion is mentioned in Section V.

A. QUADCOPTER STRUCTURE
In general, a quadcopter is a rigid body that is subjugated by its mass (m) and inertia ( ). It is a flying vehicle with four propellers attached at the end of a cross frame, where one pair rotates clockwise, and the other pair rotates counterclockwise, both at equal distances from the vehicle center as shown in Fig.1. A body-fixed frame origin is typically placed to coincide with the center of mass. Around the normal direction, each propeller produces a normal force and a moment . The mobility of the quadcopter is based on a fixed Earth frame with axes [ ]. The origin vector of the quadcopter's body frame FIGURE 1. Quadcopter system coordinates.
. Moreover, ̇ denotes the quadcopter's velocity, ̈ denotes its acceleration, and denotes its angular velocity. Moreover, R denotes the quadcopter rotation matrix with respect to the ground frame. The control of a quadcopter is performed by varying the speed of each rotor. To generate vertical take-off and landing, the four rotors' speeds are equal.
To produce a rotation around the X-axis (roll rotation) coupled with motion along the Y-axis, the speed of the second and fourth rotors is changed. For a rotation around the Y-axis (pitch rotation) coupled with a motion along the X-axis, the speed of the first and third rotors is changed. To produce a rotation around the Z-axis (yaw rotation), the torque produced by each propeller pair must have a different polarity.

B. KINEMATIC MODEL
Three coordinate frames are considered when building the mathematical model of a quadcopter: Earth fixed frame, body frame, and desired frame, as illustrated in Fig.1. The position and gravitational force of the quadcopter are measured in reference to the Earth fixed frame. However, the angular velocity and thrust of the quadcopter are measured in reference to the body frame. A unit quaternion is used to represent the orientation of the body frame relative to the Earth frame [50]. For a body frame rotation about a unit axis with an angle − < < , a unit quaternion is expressed as shown in (1).
The derivative of the quaternion is described by Eq. (2).

̇= ⊗
where = [ 0 /2 ] and the operator ⊗ is denoted for the quaternion multiplication operator and is the body frame angular velocity.

C. DYNAMICS
Two subsystems explain the dynamic model of the quadcopter body: a rotating subsystem (attitude) and a translational subsystem (altitude (z), x, and y). The Euler torque equation describes the rotational motion, while the Newton force describes the translational motion of the quadcopter body.

1) ROTATIONAL DYNAMICS
The rotational movement of the quadcopter is described in the body frame (i.e., to have the inertia matrix invariant with time) by Eq. (3) as mentioned in [14].
where denotes the vehicle's angular velocity, J ∈ × is the symmetric positive definite moment of inertia matrix of the vehicle, is the rotors' inertia, = 1 − 2 + 3 − 4 , is the aerodynamic rotation drag coefficients, and is the total torque acting on the quadrotor body.

2) TRANSLATIONAL DYNAMICS
The quadcopter's translation equations of motion are based on Newton's Second Law [51], and they are calculated with regard to the Earth's fixed frame [14], as shown in Eq. (4) .
where represents the aerodynamic translation drag coefficients.
Assume that the propeller speeds can be instantly altered, and that the system has four inputs, and F b . The quadcopter system's input vector is specified as

III. FEEDBACK LINEARIZATION CONTROL
In this section, the developed pseudo nonlinear feedback linearization tracking controller for the attitude and altitude of quadcopter systems is described. The quadcopter's nonlinear dynamics were converted into linear equivalent dynamics using the feedback linearization control technology. A block diagram of the feedback system is shown in Fig.2. In the beginning, a state-space model was derived. The actual angular velocity =[ p q r ] T , the orientation represented by the axis angle , position , and velocity ̇ were used as feedback signals. Moreover, the value of the desired angle , the desired angular velocity , and the desired acceleration were considered as inputs for the controller. The controller calculates the values of u 1 , u 2 , and u 3 to ensure that the quaternion error is equal to = [1 0 0 0] T . Additionally, it specifies the control input u 4 to ensure that the quadcopter altitude is equal to the desired altitude. Then, the propeller speeds ω i are calculated depending on the values of u 1 , u 2 , u 3 , and u 4 .

A. ATTITUDE TRACKING CONTROL DESIGN
The attitude stability of quadcopters has drawn a lot of attention, and its value may be seen in both flexible and challenging movements. The attitude controller aims to ensure that the body frame is aligned with the desired frame. For this reason, the desired attitude of a quadcopter is represented by the desired frame, which is denoted by [X d Y d Z d ] . The corresponding rotation matrix of the desired frame with respect to the Earth frame is denoted by Rd ∈ SO (3). The desired unit quaternion is defined as = [q 0d , ], which is used to describe the orientation of the desired frame with respect to the Earth fame. The relationship between the coordinate frames is shown in Fig.  1. The desired angular velocity, which is denoted by , is the angular velocity of the desired body frame. A quaternion error must be defined to design an attitude tracking controller. The quaternion error is to measure the discrepancy between the desired quaternion and the actual quaternion . is defined by Eq. (6).
To reach the desired orientation, rotation by the quaternion error is required. To calculate the time derivative of , both sides of the above equation are differentiated with respect to time.
The time derivative of is defined as in Eq.
(2) and is given by the following form: Taking the conjugate of the time derivative of the equation leads to: Eq. (7) in view of Eq. (2) and Eq. (8) leads to: The time derivative of the unit quaternion error is also defined like that of ̇ .
The following equation is the dynamical equation for the angular velocity tracking error ∈ The quadcopter system's variables were changed from and to and , where is defined as follows.  17): To calculate ̇, both sides of Eq. (15) are differentiated with respect to time as follows: The state equation of is represented in the body frame as follows: By substituting Eq. (18) into Eq. (3), the following equation is obtained: Eq. (19) in view of Eq. (17) leads to the following equation: In the state space of and e , Eq.

B. STABILITY ANALYSIS
The Lyapunov stability theorem was utilized to demonstrate the correctness of this controller. The candidate Lyapunov function V( , ) is defined as follows. Substituting for gives: V̇( , ) = 0.5α 1 k 1 q 0e − k 2 ( + k 1 ) T ( + The T term can be defined by the parallel and normal components of as follows: ( + k 1 ) T ( + k 1 ) = ( + + k 1 ) where and are normal. Therefore, where V̇( , ) should be positive definite to meet the Lyapunov stability requirement and the controller parameters k 1 , k 2 are assumed to always be positive. Hence, V̇( , ) is positive definite if k 1 k 2 (α 1 + 1) 2 − 0.5 α 1 q 0e > 0, which can be simplified as follows: This equation's discriminator is given by: where q 0e is constrained to be positive. Hence, if 0 < q 0e 4 k 1 k 2 < 2, D is smaller than zero (D < 0), implying that the requirement given in Eq. (29) can be held for any value of α 1 . Given that q 0e < 1, by putting the constraint k 1 k 2 > 1 8 on the system, for any values of and , the system can be stabilized. Finally, V̇(x e , Ω e ) is deduced as follows: where the constant k 12 = k 1 (k 1 k 2 (α 1 + 1) 2 − 0.5α 1 q 0e ) is positive if the constants k 1 and k 2 satisfy the condition that k 1 k 2 >

C. ALTITUDE CONTROLLER
In this section, we describe the designed feedback control scheme for the altitude stabilization of the quadcopter. To this end, Eq. (6) was used; however, we were concerned with controlling the altitude z. As a result, the used quadcopter altitude dynamics equation is expressed as follows: where 33 is the last row and last column element of the rotation matrix R.
Eq. (32) can be linearized by applying the following control law : 33 where v is a newly added control input. This change is correct whenever r 33 ≠ 0. In a modified form, the altitude dynamics may be stated as follows: Eq. (33) represents an ordinary linear system with a control input v. It may be utilized to stabilize a system like this by employing a PD controller in the following way: where is the desired altitude.
A good combination of 3 and 4 can stabilize the system indicated by Eq. (34). The following equation describes the altitude control law: The attitude controller is independent from the altitude controller, but the attitude affects the altitude controller. As the quadcopter orientation gets nearly vertical, we lose the ability to control the altitude because propellers forces are nearly horizontal. If the quadcopter orientations change by more than 90 degs, the propellers effectively push the quadcopter down in the same direction of gravity force; therefore, we cannot control the quadcopter altitude.

IV. SIMULATION RESULTS
This study is a follow-up to a previous publication [49] whose task is to regulate the attitude and altitude of a quadcopter. In this part, we compare the proposed tracking controller to the three state-of-the-art controllers (Non linear1, Non linear2, Non linear3) described in [48], [44], and [52], respectively. A case study is conducted on a quadcopter with physical parameters provided in [53]. Hence the initial conditions and nominal parameters have been presented in Table 1. The simulations were run on a PC with 8GB of RAM, a 64-bit operating system, and an Intel(R)z Core (TM) i5-10300H CPU running at 2.50GHz.
For the proposed controller, the value of the control parameters is determined to improve the step responses by selecting a suitable value for the settling time and overshoot (2 sec, 5%), then the system poles are determined to achieve this performance. The gains are determined based on the value of the obtained poles. Then, the authors performed fine tuning and selected the proper value of the gain to get the best performance under the conditions that we deduced from the Lyapunov theory, which states that (k 1 k 2 > where c, s, and t are shorthand forms for the cosine, sine, and tangent functions, respectively. is the vector of state variables is the transformed input variables vector obtained from four singleinput single-output chains of two integrators.
For Non linear1, analyzing the step responses was used to evaluate the gains. The Q and R matrices used in each subsystem's optimum gains computation are listed in Table 2 in [48].

2) NON LINEAR2 CONTROLLER EQUATION
The second controller's equation (Non linear2) is expressed as follows [44]. where ( , , ) denotes the rotations around the X, Y, and Z axes to characterize the quadcopter's orientation, and 1~8 are positive constants. The terms 1~8 refer to the errors related to the attitude and altitude dynamics, which could be determined using the below formulas. For Non linear2, the following values had been chosen for the control parameters: c 1 ∼ c 4 = 2.5, c 5 , c 6 , c 7 = 2.2, c 8 = 0.5 (see simulation results section in [44]).
The constants 1 and 2 are both positive constants. The vector parts of the unit quaternions and ~ and ~, respectively. The unit quaternion tracking error ( ) is the difference between the actual unit quaternion Q and the desired unit quaternion . The difference between the unit quaternion tracking error ( ) and the auxiliary feedback unit quaternion signal − is denoted by the letter ~. For this controller, − is the output of the auxiliary system.
For Non linear3, the following values had been chosen for the control parameters: α 1 and α 2 = 30 (see simulation results section in [52]).

B. ACTUATOR EFFORTS
The propeller speeds (which represent actuator efforts) for the proposed controller and the other three candidate controllers are shown in Fig. 3 for a step-change in orientation by θ = 45°. The propeller speeds must at least support the quadcopter weight and extra loading due to quadcopter dynamics and air friction. Practical propeller actuators have a physical speed limit. This speed limit is included in our simulation model (450 rad/s).

C. RESPONSE TO VARIOUS TRAJECTORY
The performances of the four controllers were evaluated through some trajectories, such as step trajectory in Fig.4, ramp trajectory in Fig.5, and parabolic trajectory in Fig.6. The performances of all controllers along step trajectory, ramp trajectory, and parabolic trajectory were illustrated in chronological order. We studied four cases to prove the stability in different states for the proposed controller and the three previous work controllers.

1) STEP TRAJECTORY
Four cases were studied: (1) response to desired θ = 45°, (2) response to desired θ = 60°, (3) response to desired z = 1, and (4) response to desired θ = 30° , θ = 45°, z = 1. Various quality metrics, including the steady-state error and settling time, were performed to illustrate the validity and efficiency of the proposed controller with various reference controllers. For the proposed controller, the steady-state error for the attitude and altitude in the four cases was zero. Also, the steady-state error for the three reference controllers was roughly zero with respect to the attitude response. Moreover, Nonlinear1 suffered from a noticeable overshoot. The altitude response for the two references (Non linear1, Non linear2) controllers suffered from a noticeable error as shown in Fig.4.Also, Non linear2 controller had a big error because it does not consider friction air in its controller. The settling time of the proposed system and the controllers in [48], [44], and [52], for step trajectory is presented in Table.2. Non linear3 controller showed the fastest response; however, it had a noticeable error in the transient response. Nonlinear1 and Nonlinear3 controllers showed the fastest responses with respect to the attitude response. The proposed controller was moderate with respect to the time response and the settling time for the attitude response; however, it showed the best altitude response.

2) RAMP TRAJECTORY
A saturated ramp is used instead of a normal ramp to prevent the quadcopter from spinning around itself. Four cases were studied: (1) response to desired θ = t, from t = 0 to t = 15s and then stabilization at θ = 45°; (2) response to desired θ = t, from t = 0 to t = 15s and then stabilization at θ = 60°; (3) response to desired z = t; (4) response to desired θ = t , θ = t, from t = 0 to t = 15s, z = t and then stabilization at θ = 30°, θ = 45°. The results of the four controllers were compared, as shown in Fig.5. For the attitude and altitude responses, the proposed controller showed the fastest response compared with the other three controllers. The integral absolute error IAE = 1 ∫ ( ) 0 , was used to summarize the trajectory tracking for the ramp trajectory, as shown in Table 3. For the attitude , and the altitude response, the proposed model achieved the smallest IAE (almost zero) compared with the three reference controllers.

3) PARABOLIC TRAJECTORY
A saturated parabola is used instead of a normal parabola to prevent the quadcopter from spinning around itself. Four cases were studied: (1) response to desired θ = 2 , from t = 0 to t = 15s and then stabilization at θ = 45°; (2) response to desired θ = 2 , from t = 0 to t = 15s and then stabilization at θ = 60°; (3) response to desired z = 2 ; (4) response to desired θ = 2 (θ = 2 , from t = 0 to t = 15s, z = 2 ) and then stabilization at θ = 30°, θ = 45°. The four controllers were compared, as shown in Fig.6. For the attitude and altitude responses, the proposed model showed the fastest response compared with the three reference controllers. Table 4 illustrates the IAE of trajectory tracking for parabolic trajectory. For the attitude response, the proposed model had a constant IAE (almost zero), unlike the two reference controllers. Moreover, for the altitude response, the proposed model had the lowest IAE. The Non linear2 controller had a big error in case 1.
Based on the previous results of the three trajectories, the proposed nonlinear feedback linearization tracking controller for attitude and altitude displayed accurate tracking and convergence performances compared with the three reference quadcopter controllers. . Transient response of the step trajectory for the proposed system and the controllers proposed in [48], [44], and [52] (a) response to desired =°, (b) response to desired =°, (c) response to desired = , and (d) response to desired =° , =°, = .

D. FLIGHT SCENARIO
Trajectory tracking performance is tested by applying various motion scenarios. Two motion scenarios were examined:

2) SINE WAVE
The quadcopter is assumed to be hovering at a height of 2m and follows a sine wave trajectory. The desired attitude can be expressed as: In this flight scenario, the proposed controller also achieved the best performance in both the attitude and the altitude as shown in Fig.8.

V. CONCLUSION
In this paper, we propose a controller for tracking the attitude and altitude of quadcopter systems based on pseudo feedback linearization. The simulation results have been presented followed by comparisons between three quadcopter controllers from literature to demonstrate the proposed controller's performance. Moreover, in comparison with the reference controllers, by preserving the restrictions of the control inputs, the proposed quadcopter system can effectively track the necessary trajectories with a reasonable tracking error. As well as a quadcopter mathematical model has been developed considering the aerodynamic rotation, translation drag, and moment, which were ignored in most of the previous studies on this topic that making the controller is more realistic. The control strategy's stability was demonstrated under various trajectories (i.e., step, ramp, and parabolic trajectory) by using different metrics. The simulation presented a variety of states for the three controllers to demonstrate their stability in different states. Moreover, trajectory tracking performance is tested by applying two different flight scenarios. For both flight scenarios, the results proved the superior performance of the proposed controller compared to the comparative controllers. The Lyapunov stability theorem has been used to verify the proposed controller's global asymptotic stability.