LQR controller design for quad-rotor helicopters

: This paper presents an analysis and performance of a LQR control algorithm for quadrotor helicopters. For a successful analysis, first the dynamic model has been developed for the quadcopter and then the controller was designed, tuned, and tested. In tuning the LQR, much attention was given to the feedback gain matrix (K). The controller's performance was verified in terms of delay time, rise time, overshoot, settling time, and tolerance limits. The overall performance of the LQR controller was analysed.


Introduction
In recent years, unmanned aerial vehicles (UAVs) have attracted more attention due to their high manoeuvrability, simplicity of construction, low maintenance costs, and low noise. Quadcopters are rotary wing machines that make use of four propellers in achieving vertical take-off and landing and other flight manoeuvrings. UAVs have become very useful not only for military purposes but in many areas such as; aerial photo and video shooting, farm irrigation and crop monitoring, border patrol and rescue missions, electric power line and gas pipeline monitoring and many others. Works are underway to see UAVs fully fledged in door-to-door delivery of goods bought over the Internet through Amazon, Google, and others.
Generally small in size, quadcopters use a variety of sensors to achieve a high level of stability and control, allowing them to navigate even in narrow spaces. Additionally, because each rotor is small, they require less power during flight, which makes quadcopters much safer both to human operators and to the flight environment. Finally, quadcopters are generally low cost and easy to construct. All these factors contribute to making them the rotorcraft of choice for most academic and research purposes. Design of control system for quadrotor helicopters is an ongoing and growing research field. The controller is the main part in designing any autopilot system for aviation and quadrotor helicopter in particular. For a stable control, the throttle, roll, pitch, and yaw have to be controlled successfully so that the vehicle navigate its terrain, while maintaining steady, stable flight, and controlled movement.
The goal of this paper is to present a step-by-step design of the LQR controller for intelligent control of Quadrotor helicopter. The emphasis will be on the linearised state modelling of the quadrotor helicopter, system's performance index (state and control weighting matrices, (Q and R), the feedback gain matrix (K), and the tuning.

LQR controller
Linear quadratic regulator (LQR) is a modern control technique that uses state-space to analyse and design a system. The statespace representation of the quadcopter has been developed and used in designing an effective LQR controller. The state-space equations are usually of the form, (1) [1][2][3]: where x is the state vector, y is the output vector, u is the input/ control vector. A, B, C, D are system matrix, input matrix, output matrix, and feed forward matrix, respectively. The state vector x derived from (18), Appendix, is given by x = (ϕ, φ, θ, θ˙, ψ, ψ , x, x˙, y, y˙, z, z˙) T and the input vector u is given be u = (u 1 , u 2 , u 3 , u 4 ) T .

Derivation of the quadcopter's state-space equation
Using aerodynamic laws, as in (18) where the input vector, u is defined, as in (3).
Effective LQR designs are only based on linear state-space models [2]. However, (3) is non-linear and thus, needs to be linearised.

Linearisation of the quadcopter
In linearising, the designer has to choose and work around the stable operating regions of the system which is to be controlled [3].
Here, the stable hovering position of the quadcopter was seen as the stable operating region suitable for the design and, thus chosen. Therefore, linearisation of (3) and other linearisation required in the LQR design would be done around this stable hovering position. Equation (4) holds true for the quadcopter at its stable hovering position according to [3]. Where subscript h denotes hovering.
Applying linearised equations to this LQR design was a bit difficult since their state-space equations would not conform to the format as in (1). According to [4], Taylor series could be applied in linearising non-linear equations. However, in the LQR design, linearisation was simply achieved by approximating (2). Using the linearisation process removes the offsets from the dynamics of the system. These offsets are accounted for in the controller design after the gains are calculated and found to achieve satisfactory results [1]. The same technique was implemented in this application to design the LQR controller. Equation (5) shows the linear equations that were achieved after applying this technique [1].
where u x = cos ϕsin θcos ψ + sin ϕsin ψ u y = cos ϕsin θsin ψ − sin ϕcos ψ Another technique that was adopted in this LQR design was the reduction technique [1]. This was implemented in order to simplify the mathematical calculations here. With this technique, the state vector which is given as X = (ϕ, φ, θ, θ˙, ψ, ψ , x, x˙, y, y˙, z, z˙) T , though consists of 12 members, will be reduced into the following; altitude, attitude, and position controls as in (7). The altitude control would be characterised by z, z˙T, while the attitude control would be characterised by (ϕ, φ, θ, θ˙, ψ, ψ ) T . On the other hand, the position control would be characterised by x, x˙, y, y˙T .
As noted in (2), only linear and angular accelerations were considered in writing the state-space equation. However, with the above categorisation of the state vector (X) into altitude, attitude, and position controls, new and much reduced state space-equations had to be considered. In the state-space equation, as in (8) (for attitude), the following were considered; (a) attitude of the quadcopter is characterised by (ϕ, φ, θ, θ˙, ψ, ψ ) T ; where (7); (3) and, in (5), it was realised that; In order to obtain the state-space equation for attitude to conform to the format ẋ = Ax + Bu as in (3), x had to be made equal to both In deriving the state-space (9), the following were considered; (a) position of the quadcopter is characterised by x, x˙, y, y˙T; (b) From (7), (x, ẋ y, y˙) T is equal to (x 7 , x 8 , x 9 , x 10 ) T . From (5), it was realised that In order to make sure that the state-space equation conforms to the ẋ = Ax + Bu format, x had to be equal to both x, x˙, y, y˙T and (x 7 , x 8 , x 9 , x 10) T . Its derivative ẋ be equal to both (x˙, x¨, y˙, y¨) T and where symbol a in matrix B is equal to 1/m U 1 . In writing the state-space equation for altitude, as in (10), the following were considered; (a) Altitude of the quadcopter is characterised by z and z˙; (b) from (7), z is equal to x 11 and z˙ is equal to x 12 ; (c) and in (5) After obtaining these state-space equations, they were verified using them on the quadcopter plant, the system would be both controllable and observable.

Determining the weighting matrices of the cost function
In LQR designs, the system's performance index is characterised by a cost function (J) for which the controller seeks to minimise [4]. This cost function is given by the formula; where Q is the state weighting matrix with real symmetry and positive semi-definite in nature. R is the control weighting matrix of real symmetry but positive definite in nature [5]. These weighting matrices help determine the relative importance of the existing error as well as the energy expenditure of the system [4]. It is, therefore, important that, for a successful LQR design, these parameters be chosen accurately.
Here, a hybrid form of the classical approach based on the Bryson's method [6] and the trial-and-error methods are combined. This method was chosen for its ability to offset the disadvantages of just using the trial-and-error or Bryson's method. The Bryson's method was first used in determining the initial Q and R weighting matrices. The trial-and-error, then, was relied on to fine-tune these two parameters to achieve a better performance of the controller [7]. The Bryson's Rule: According to this rule, Q and R are diagonal matrices whose diagonal elements are, respectively, expressed as the reciprocals of the squares of the maximum acceptable values of the state variable (X) and the input control variable (u). The diagonal elements Q ii of matrix Q, thus, can be written as [7]; The diagonal elements R jj of matrix R, also, can be written as [5];

Obtaining the feedback gain matrix through Riccati equation
After obtaining the Q and R matrices above, they had to be substituted into the algebraic Riccati equation, as in (14) to solve for P [8].
With P solved, the feedback gain matrix (K) would then be calculated using (15) [8].
MATLAB was used as it provides a convenient way of solving for K by just using the following command The MATLAB command, as in (16), was also used to derive the K values for attitude, position, and altitude controllers. In the altitude controller, for instance, where

Closed-loop system with LQR controller
With the feedback gain matrix (K) and state-space equations obtained, the closed-loop system of the quadcopter can now be developed, Fig. 1.
Where the state-space model is of the format, as in (1) and the state feedback (F) obeys the optimal control law, which is expressed by (17) After realising the closed-loop system with the quadcopter using LQR controller, simulations have been conducted to ascertain its performance in terms of meeting the design specifications.

Tuning the LQR controller
In tuning the LQR controller, much attention was given to the feedback gain matrix (K). This is because, until the right K values have been reached, the performance of the LQR controller would not be satisfactory. With the calculated feedback gain, K = [1 1.7321] (for altitude), the closed-loop system of the quadcopter was simulated at different throttle positions as seen in Figs. 2 and 3. It was realised from the above simulations, that the LQR controller could control the dynamic response of the plant with no overshoot. It was, also, able to optimally change the plant's state to zero (in ∼5 s). These met the design specifications required. However, the rise time and settling time which were expected to be around 2 s remained same in both simulations (at 5 s). These did not meet the expected specifications, thus, the need to re-tune the feedback gain, K.
Since Q and R weighting matrices have corresponding effects on the values of K, some guidelines were followed to obtain the right values for K [9]; • The larger the values of R, the lower K becomes and the slower the state variables approach zero. • The lower the values of R, the higher K becomes and the faster the state variables approach zero. • The larger the values of Q, the higher K becomes and the faster the state variables approach zero. • The lower the values of Q, the lower K becomes and the slower the state variables approach zero. It was realised from the response curves that, the lower K became, not only did the state variables slowly change to zero but the controller's response became faster (as rise time became shorter). There were overshoots and the response never settled at the commanded value as can be seen in Fig. 4. Also the higher K became, not only did the state variables change to zero faster but the controller's response became slower (as its rise time became longer). It also never reached the commanded value as seen in Fig. 5.
In Fig. 6, the value of Q was maintained at [1 0; 0 1], while R was varied from 1 to 0.1 and, then, 0.006. These corresponded to K values of [1 1.7321] to [3.1623 4.0404] and, then, to [12.9099 13.8740], respectively. Since in both cases, K was being increased, the state variables changed to zero faster and the controller's response became slower (as its rise time became longer) and never reached the commanded value. It should be noted that, despite the number of attempts to tune the rise time and settling time of the LQR controller to 2 s, they proved difficult. For this reason, the tuning finally settled on K = [1 1.7321], since it had no overshoot, no steady-state error and was robust.

Conclusion
A linearised LQR dynamics Simulink model controller for quadrotor helicopter has been developed. The model verification was successful, and it has been seen that the model dynamics faithfully responds to the commanded inputs. The designed LQR controller was able to meet the performance parameters in terms of overshoot, setting time, and response time.
The developed controller was simulated with under various conditions and the effect the Q and R weighting matrices on the feedback gain matrix K. It was found that for lower values of K, the controller's response was faster with some issues in the overshoots and settling time. It was, also, found that controller's stability hinges on the right tuning parameter of the gain matrix K.