International Journal of Applied Sciences and Smart Technologies International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 101 On the Synthesis of a Linear Quadratic Controller for a Quadcopter Hendra G. Harno Department of Aerospace and Software Engineering, Gyeongsang National University, Jinju 52828, Republic of Korea Corresponding Author: h.g.harno@gmail.com (Received 31-05-2019; Revised 17-10-2019; Accepted 17-10-2019) Abstract This paper discusses about synthesizing a state-feedback controller for a quad copter based on an optimal linear quadratic control method. The resulting light control system enables the quad copter to maintain stability and to track a reference input. The solution to this control problem involves solving an algebraic Riccati equation. The reference-input tracking capability is simulated to show the capability of the quadcopter flight control system. Keywords: flight control, quadcopter, linear quadratic control, tracking. 1 Introduction Versatility of a quad copter has been celebrated by different communities, including, but not limited to, hobbyists, entrepreneurs, medical officers, defence forces, engineers and scientists. It has been used for various purposes (both civilian and military) that can benefit from the quadcopter as a flying vehicle. This is realizable because the quad copter is relatively easier to operate as compared to a full-scale conventional rotorcraft. Moreover, users also do not need a runway, an airport or a helipad to operate the quadcopter. In some applications, the quadcopter can even be controlled remotely in a International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 102 cost-effective manner to accomplish particular missions. It is also true that the quad copter has a relatively simple design with an uncomplicated structure. Thus, operational and maintenance costs pertaining to quadcopter operations tend to be low. All these features have indeed signify the merit of the quadcopter for a wider usage nowadays and in the future [1, 2]. These advantages will be more meaningful for the users if the quadcopter carrying payloads is equipped with appropriate flight control, instrumentation and communication systems. The flight control system has particularly served as an indispensable part that enables the quadcopter to perform various maneuvers in its operation [3]. Thus, we will only discuss about synthesizing a linear controller to enable the quadcopter to fly properly. There are different sorts of control methods that can be applied to develop the flight control system such as PID control, or linear quadratic control, control, sliding mode control and adaptive control (see e.g. [4, 5, 6]). To construct the linear controller for the quad copter, a linear time-invariant state space model is used to represent the quad copter dynamics at a chosen trim condition (equilibrium point). In this case, the linear model was derived through the Taylor series expansion as presented in [7]. Parameters of this model were identified and validated based on the comprehensive identification from frequency responses (CIFER) method [8]. This system identification method is well known as one that is able to yield a representative linear model for synthesizing a flight controller. Another system identification method that is also suitable for unmanned flying vehicles is referred to as the modeling for flight simulation and control analysis (MOSCA) method [9]. In this paper, the linear quadratic control method is applied to construct a state feedback controller for the quadcopter. This controller is obtained by minimizing a linear quadratic cost function that is subject to the quadcopter linear dynamics [10]. It is the nassumed that information about all state variables of the quad copter is available for feedback control. The aims of applying this controller are to stabilize the quadcopter at the equilibrium point and also to allow the quad copter to track a reference input [11]. An example based on the quad copter model for hovering flight [7] is presented to illustrate the performance of the resulting linear quadratic controller. International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 103 The rest of this paper is organized as follows. Section 2 presents the equations of motion of the quadcopter underlying the derivation of the linear state-space model used for synthesizing the linear quadratic controller. Section 3 shows an example about applying the optimal linear quadratic control method to synthesize the stabilizing controller for the quadcopter. Finally, concluding remarks are presented in Section 4. 2 Problem Formulation 2.1 Equations of Motion A quadcopter is commonly considered as an aircraft which can move freely in six degrees of freedom within an air space. Thus, during its flight, the quadcopter is capable of simultaneously performing translational and rotational motions driven by external forces and torques/moments, respectively. To properly utilize the quadcopter for practical applications, it is then necessary to grasp such motions through a mathematical model derived based on physical laws. A suitable mathematical model about the rigid- body dynamics of the quadcopter is usually presented in terms of equations of motions. These equations can be derived based on the Newton’s second law of motion and the kinematic principles of a moving reference frame [12, 13]. That is, ̇ (1) ̇ Each physical quantity vector of the quadcopter dynamics equations (1) has three components in the space (except ) and is described as follows: external forces and torques/moments acting on the quadcopter, mass and moment of inertia, translational velocities and angular rates where [ ] [ ] [ ] [ ] and [ ] Thus, the quadcopter equations of motion are expressed as follows: [ ] [ ̇ ̇ ̇ ], (2) International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 104 [ ] [ ̇ ( ) ̇ ̇ ( ) ]. The quadcopter is typically powered up by four motors mounted on the tips of its arms. A fixed-pitch propeller is installed on each motor to produce thrust that can be varied to propel and control the quadcopter’s motion. Thus, incorporating the gravitational and control forces, the equations of motion in (2) can be enhanced to have the form as follows: { ̇ ̇ ̇ ̇ ( ) ̇ ̇ ( ) (3) 2.2 A Linear State-Space Model The quadcopter’s dynamic equations in (3) can concisely be written in the form of a single nonlinear differential equation as follows: ̇ (4) where [ ] is the state vector [ ] is the control input vector and f(·) is a vector-valued nonlinear function of and . Eachcomponent of and are described as follows [7]: longitudinal, lateral and vertical velocities, roll, pitch and yaw rates, roll, pitch and yaw angles, heave control input, roll control input, International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 105 pitch control input, yaw control input. For the purpose of linear controller design, it is reasonable to linearize the nonlinear dynamic equation (4) about an equilibrium point ( ) via the Taylor series expansion. At the equilibrium point ( ) the quadcopter is said to be in a trim condition, where all forces and moments acting upon the quadcopter are balance. Consequently, the nonlinear dynamic equation (4) is equal to zero, that is ( ) . The state trajectory and control input of the quadcopter about the equilibrium point ( ) are given by (5) Thus, by taking only the first-order terms of the Taylor series expansion of the nonlinear dynamic equation (4), one may obtain a linear state-space model as follows: ̇ , (6) where ⁄ and ⁄ are Jacobian matrices evaluated at the equilibrium point ( ). For simplicity, the symbol in (6) will be removed subsequently. Referring to (3), one may obtain the and matrices in (6) as follows [7, 8]: [ ] [ ] (7) Here, is the gravitational acceleration and other unknown non-zero entries of the and matrices denote the stability derivatives of the forces and moments with respectto the corresponding state variables and control inputs . International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 106 2.3 Optimal Linear Quadratic Control Stabilization problem. Given the linear time-invariant state-space model (6), (7) of the quadcopter, one may design a state-feedback controller by minimizing a linear- quadratic cost function as follows [10]: ∫[ ] (8) Where are weighting matrices. The desirable state-feedback controller is of the form (9) where is the state-feedback controller gain matrix. Applying the state feedback controller (9) to the open-loop state-space model (6) and (7) of the quadcopter, one obtains a closed-loop system given as follows: ̇ (10) Thus, the controller gain matrix K is such that the matrix is Hurwitz in order to result in an asymptotically stable closed-loop system. This control problem is commonly known as a stabilization or regulation of an open-loop linear system around its equilibrium point and is solvable if is stabilizable. The resulting closed-loop system is then enabled to return to the equilibrium point by eliminating the effect of any non-zero initial conditions. Such a controller is then called a linear quadratic regulator [12, 13]. To obtain such a stabilizing controller that minimizes the cost function (8), one is then required to find a symmetric matrix as a solution to an algebraic Riccati equation: (11) Therefore, the controller gain matrix can be constructed as (12) and the minimal cost function value is given as (13) International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 107 When synthesizing a desirable controller to satisfy stability and performance criteria of a closed-loop system, one has to appropriately determine the weighting matrices and . To serve this purpose, it is quite common to choose and as diagonal matrices. Thus, they can be interpreted as penalties corresponding to each state and control input variables, respectively. Although the weighting matrices and are in general not unique, one may follow the Bryson’s rule to set their diagonal entries [10]. That is, (14) Tracking problem. In practice, one may not only be interested in stabilizing the open loop system, but also in tracking a reference input. To achieve this control objective, one needs to first define an output variable required to follow the reference input . That is, , (15) where is the output matrix. Thus, to design a state-feedback controller of the form (9) such that the output will track the reference input one may follow the same procedure to design the controller gain matrix as above. In other words, the tracking control problem can be solved by transforming it into the stabilization problem. In this regard, an error variable variable is defined such that (16) ̇ Now, combining (6), (15) and (16), one may obtain an augmented open-loop system: ̇̅ ̅ ̅ ̅ (17) ̅ ̅ where ̅ [ ] ̅ [ ] ̅ [ ], [ ], ̅ [ ] (18) Note that and are zero and identity matrices with appropriate dimensions, respectively. To track the reference input it is thus necessary to stabilizer the International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 108 augmented open-loop system (18) by applying the state-feedback controller of the form (9). That is, ̅ ̅ ̅ [ ] (19) where . The resulting closed-loop system can then be written as ̇̅ ̅ (20) where [ ] (21) is Hurwitz. Since the closed-loop system (20) is asymptotically stable, ̇ and ̇ will converge to zero as time goes to infinity. This implies that will be equal to at the steady state. In this way, the tracking control problem has been solved by incorporating an integral control action into the closed-loop system (20). In fact, this approach will also render the closed-loop system (20) robust against perturbations due to bounded exogenous disturbances. 3 Controller Synthesis In this section, a state-feedback controller is designed for the quadcopter based on a linear dynamic model for hovering flight. Thus, the parameter values in the linear statespace model (6) and (7) are given as follows [7]: , (22) and the gravitational accelaration . Let us consider the case where the quadcopter is required to track lateral (roll), longitudinal (pitch) and directional (yaw) reference inputs. The state-feedback controller can be obtained by applying the linear quadratic control method described in sub- International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 109 Section 2.3. For this example, the weighting matrices [ ] [ ] are chosen to be diagonal matrices with the following entries: (23) Here, the subscripts denote the state and control input variables of the augmented open-loop system (17). The controller gain matrix ̅ can then be computed using the command lqr of MATLAB. Moreover, the efficacy of the resulting controller can be demonstrated using Simulink. Examples of tracking reference inputs for roll, pitch and yaw angles are considered, respectively. The time responses of these angular quantities are shown in Figures 1, 2, and 3. It is obvious that the resulting controller is indeed able to stabilize the closed-loop system and also to allow the respective state variables to track the given reference inputs with zero steady-state errors. Figure 1. The time response of the roll angle due to the sinusoidal reference input International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 110 Figure 2. The time response of the pitch angle due to the step reference input Figure 3. The time response of the yaw angle due to the step reference input 4 Conclusions This paper has presented the optimal linear quadratic control method to synthesize a state-feedback controller for the quadcopter. The resulting controller is effective not only to stabilize the quadcopter, but also to enable some state variables to track the given reference inputs. The tracking capability is facilitated by the integral control action incorporated into the closed-loop system. If the reference input is considered as a International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 111 perturbing exogenous input, it is then clear that the closed-loop system is robust against such a perturbation. The current results can be extended to consider other control methods to address an output-feedback control problem with uncertainty related to the quadcopter model. Furthermore, a more complex control problem can also be considered where there are multiple quadcopters flying in formation within a network. Acknowledgements This work was supported by the Laboratory of Distributed Aerospace Systems and Control within the Department of Aerospace and Software Engineering, Gyeongsang National University, Jinju, Republic of Korea. The author also would like to thank Dr. Sudi Mungkasi for the opportunity to publish this paper in the International Journal of Applied Sciences and Smart Technologies. References [1] G. Cai, J. Dias, and L. Seneviratne, “A survey of small-scale unmanned aerial vehicles: Recent advances and future development trends,” Unmanned Systems, 2 (2), 175–199, 2014. [2] M. Hassanalian and A. Abdelkefi, “Classifications, applications, and design challenges of drones: A review,” Progress in Aerospace Sciences, 91, 99–131, 2017. [3] G. Hoffmann, H. Huang, S. Waslander, and C. Tomlin, “Quadrotor helicopter flight dynamics and control: Theory and experiment,” in Proceedings of the AIAA Guidance, Navigation and Control Conference and Exhibit, 1–20, August 2007. [4] F. Rinaldi, S. Chiesa, and F. Quagliotti, “Linear quadratic control for quadrotors uavs dynamics and formation flight,” Journal of Intelligent & Robotic Systems, 70 (1–4), 203–220, 2013. [5] J. -J. Xiong and E. -H. Zheng, “Position and attitude tracking control for a quadrotor UAV,” ISA Transactions, 53 (3), 725–731, 2014. [6] H. Mo and G. Farid, “Nonlinear and adaptive intelligent control techniques forquadrotoruav a survey,” Asian Journal of Control, 21 (2), 989–1008, 2019. International Journal of Applied Sciences and Smart Technologies Volume 1, Issue 2, pages 101-112 p-ISSN 2655-8564, e-ISSN 2685-9432 112 [7] W. Wei, M. B. Tischler, and K. Cohen, “System identification and controller optimization of a quadrotor unmanned aerial vehicle in hover,” Journal of the American Helicopter Society, 62 (4), 1–9, 2017. [8] M. B. Tischler and R. K. Remple, Aircraft and Rotorcraft System Identification, American Institute of Aeronautics and Astronautics, Virginia, 2012. [9] M. L. Civita, W. C. Messner, and T. Kanade, “Modeling of small-scale helicopters with integrated first-principles and system-identification techniques,” Proceedings ofthe 58th Forum of the American Helicopter Society, pp. 2505–2516, June 2002. [10] J. P. Hespanha, Linear Systems Theory, Princeton University Press, New Jersey, 2nd edition, 2018. [11] M. Kanamori and M. Tomizuka, “Dynamic anti-integrator-windup controller design for linear systems with actuator saturation,” Journal of Dynamic Systems, Measurement and Control, 129 (1), 1–12, 2007. [12] B. Mettler, Identification Modeling and Characteristics of Miniature Rotorcraft, Springer, New York, 2003. [13] G. D. Padfield, Helicopter Flight Dynamics, Blackwell Publishing, Oxford, 2nd edition, 2007.