LQR Controller with Kalman Estimator Applied to UAV Longitudinal Dynamics 37 LQR controller followed by a Kalman filter based

The aim of this study is designing an optimal controller with linear quadratic regulator (LQR) method for a small unmanned air vehicle (UAV). To better evaluate the effect of disturbances on the obtained measurements, a Kalman filter is also used in the system. For this purpose a small UAV that is normally used as a radio controlled plane is chosen. The linearized equations for a wings level flight condition and the state space matrices are obtained. An optimal controller using LQR method to control the altitude level is then designed. The effect of the disturbances on the measurements are taken into account and the effectiveness of the Kalman filter in obtaining the correct measurements and achieving the desired control level are shown using the controller designed for the system. The small UAV is commanded to the desired altitude using the LQR controller through the control inputs elevator deflection and thrust rate. The LQR effectiveness matrices are chosen to find the gains necessary to build an effective altitude controller. Firstly the controller is tested under the situation where disturbances are absent. Then a Kalman filter is designed and the system under disturbances is tested with the designed controller and the filter. The results reveal the effectiveness of the Kalman filter and the LQR controller.


Introduction
Unmanned air vehicles (UAVs) have become a popular research subject in the last years.These vehicles can be used for many different missions including rescue, data gathering and military missions.
To design a control system for an UAV defining the dynamic model and finding the aerodynamic coefficients are the first steps.The non-linear model can then be linearized to design a linear controller for the UAV [1].The characteristic values of different motions which show how the aircraft normally behaves must also be investigated at this stage.Finally the controller and filter can be designed considering the required specifications.
The optimal control technique linear quadratic regulator (LQR) is chosen to design a controller for the longitudinal motion of a small fixed-wing type UAV.Kalman filter technique is then applied to see how the controller is affected by disturbances.The effectiveness of the controller with and without the Kalman filter is also shown through simulations.Linear quadratic control is an optimal control technique that is used for controlling the aircraft.This control technique aims to decrease the energy that is used to control the aircraft.This technique can be applied together with a filtering technique (Kalman filter etc.) in cases where some of the states are not available for measurement or when the measurements are noisy.
Studies that include LQR control design for different types of aircraft are present [2].In [3], a linear, quadratic regulator method is used to control the trajectory and mission paths of the autonomous helicopter.Nonlinear motion dynamics is linearized at certain operating points and linear model is obtained by Taylor's series expansion.By using LQR methodology, the attitude of the autonomous Puma helicopter is controlled.The study [4] shows that the LQR controller is quite effective in the vertical flight mode for all possible yaw angles.In [5] the design procedure for a gain-scheduled LQR controller for an autonomous airship is presented.Two types of control sub-systems (lateral, longitudinal) have been designed from the nonlinear 6DOF airship model to fulfill different goals (yaw as well as speed and position control).In references [2][3][4][5], LQR controller is not applied together with a filtering technique.
In some studies filtering techniques are used to analyze the effects of LQR design and increase the effectiveness of the controller.The paper [6] depicts the application of linear quadratic optimal control to the longitudinal flight motion of an UAV which has elevon control only.The LQR controller followed by a Kalman filter based estimator for unmeasurable states.The LQR controller is then combined with the Kalman estimator using the separation principle to investigate the feasibility of altitude control.The simulation results show improvements compared with classical design counterparts in the sense that the combined approach offers more design flexibility and is able to tolerate the noisy environments.Some advanced techniques including robust and adaptive control techniques are also used in UAV control.For example in one study by Johnson and Calise, Hinfinity technique is used to design a velocity and altitude controller that follows a determined model [7].However in this study these advanced techniques are only investigated to design a better controller and are not used.
In this study an altitude controller is designed for a small UAV using the optimal LQR control method with Kalman estimator.Finally the effectiveness of the controller with the gains found by LQR method is investigated under the effect of disturbances and with the Kalman filter.

Mathematical Model of the UAV
In this study the longitudinal motion of the small UAV is investigated.We can find the longitudinal equations of motion for the UAV by linearizing the equations for wings-level flight.
The longitudinal state model is given below: (1) where  and t  are the elevator and throttle control inputs, u is the forward velocity, w is the vertical velocity, q is the pitch rate, θ is the pitch angle and h is the altitude, e M  are the dimensional stability derivatives.
The mathematical model ( 1) can be presented in the matrix form: where is the control distribution matrix and  is the vector of control input.

Stability Analysis
Characteristic equations are investigated firstly to analyze the stability of the UAV.The longitudinal equations can be calculated using the transfer functions.The characteristic equation for the longitudinal motion is as follows: 15.043 78.0719 0.587 1.1174 0 Longitudinal motion can be represented by two different modes, namely short period and phugoid mode.Phugoid mode has the characteristic of longer period times and lower damping factors and can be easily controlled.Phugoid mode can be described as the change in kinetic and potential energy in which attack angle changes are significantly smaller than the changes in velocity and pitch angle.Short period mode occurs in a smaller time period where the change in pitch and attack angles are significant and it also has high damping factor.The longitudinal roots show a stable motion.Some of the characteristic values for these longitudinal motions are given in Table 1.

LQR Application for the UAV
In this study, LQR is adopted as an optimal control technique for the UAV.Considering a system with state space model (2), the optimal control vector is as follows: In order to determine the optimal control inputs, while optimizing the state variables at the same time, the following cost function (also called quadratic performance index) has to be minimized [8], Copyright © 2013 SciRes.POS where Q is a semi-positive definite symmetric matrix and R is a positive definite symmetric matrix.Q and R weight matrices are chosen to control each state effectively using little control effort according to the performance index (5).
The gain matrix of the optimal control vector can be computed by the following equation: Therefore, optimal control equation becomes: If one positive definite P matrix can be calculated by the following Ricatti equation then the system is said to stable: Under some special conditions the LQR controller can be designed using the Riccati Equation ( 8) without changing the state and control matrices to find the optimal gain matrix [8].
The optimal filter can also be considered in cases where some unknown states are present [9].
For this system without adding an integrator we can use the previously determined A and B matrices together with the control and state weight matrices Q and R to find the optimal gain matrix K that will let us find the control input .the simulations.Also the effect of using different weight matrices is shown using different Q matrices.

 
The effectiveness matrices used in LQR controller are given below: 1 0 0 0 0 0 1 0 0 0 , 0 0 1 0 0 0 0 0 100000 0 0 0 0 0 10 It is understood that LQR controller works well for longitudinal UAV control system.By changing Q we may change the results of the state variables according to the requirements.With Q 1 as can be seen in Figure 2 little change in forward velocity can be achieved.

Kalman Filter for UAV State Estimation
In this study an LQR controller is designed without taking the effect of the disturbances on the measurements.The system equations are discretized using the Euler approach.Firstly the LQR altitude controller without the effect of disturbances is tested then the response of the system with the controller under the disturbances is tested with and without Kalman filter.The effectiveness of the Kalman filter is shown using the results.
Kalman filter uses state equations (state space matrices) and initial values to calculate the residue and gain values and to estimate the real signal value.The steps of the Kalman filter can be explained using linear discretized state and measurement equations: In the state equation   x k is the state vector of the system, A is the system transition matrix, is the input vector, B is the control distribution matrix, w k is the random Gaussian noise vector (system noise) with zero mean and known covariance structure, G is the transition matrix of the system noise.In the measurement equation   y k is the measurement vector, H is the measurement matrix, is the measurement noise vector with zero mean and known covariance structure.There is no correlation between the system noise and the measurement noise   v k .The covariance matrices for the and vectors are given by: Here E is the expected value operator,   kj  is the Kronecker symbol.
The optimum linear Kalman filter that estimates the state vector of the system (9) is expressed with the following recursive equations system: Equation of the extrapolation value, The innovation sequence, Equation of the estimation value, Gain matrix of the optimum linear Kalman filter, The covariance matrix of the filtering error is, The covariance matrix of the extrapolation error is, where d X is the desired vector, I is the identity matrix.Kalman filter tries to estimate the real signal from the signal with disturbance which has Gaussian distribution using the described steps and decreasing the value between two signals [9,10].

Simulations of LQR Controller with Kalman Estimator
The model of longitudinal motion (2) can be discretized using Euler approach and determining time period dt.Thus the new discretized A and B matrices to be used in the filtering approach can be found by 1 The discretized UAV model can be given as follows: In our case disturbance with Gaussian white noise characteristics generated by Matlab commands is applied to the real values found using our UAV model.Kalman filtering technique is then applied and its effectiveness is shown.In the real scenario the disturbances in measurements and process is usual and have an effect on the controller.Thus using a filtering technique is important.
The values of the states can be calculated using Equation (17) that includes the control rule.The disturbances on the states of course must be determined firstly and applied to the system.Finally Kalman filter can be applied to the system with the disturbances to develop an effective controller.To do this a Matlab code is written.The results are given in Figures 4-7.The Kalman filter that works as an optimal observer is estimating the new values of the states correctly and decreasing the error.
As seen from Figures 4-7, in case of disturbances, using a Kalman filter to estimate the values of the states clearly increase the effectiveness of the LQR controller.

Conclusion
In this study an altitude control system is designed for a small UAV using the optimal control method LQR.This method which is effective in controlling the longitudinal motion of the UAV is based on the acceptance that all      states can be measured truly however in real cases it is not generally possible.To make the controller more effective Kalman filter approach is used in the study.A Kalman filter is designed and added to the system and the response of the controller with and without disturbances and the Kalman filter is tested.The simulations show that in case of disturbances using a Kalman filter to estimate the values of the states clearly increase the effectiveness of the LQR controller.In conclusion it is found that an LQR controller with Kalman filter is effective in controlling the longitudinal motion of the UAV and can be used for such applications.

Figure 3 .
Figure 3. LQR controller result in forward velocity (Q is used).

Figure 4 .
Figure 4. Change in altitude with LQR controller and Kalman filter.

Figure 5 .
Figure 5. Change in altitude with LQR controller and Kalman filter (zoomed view).

Figure 6 .
Figure 6.Error differences in altitude with disturbances (with KF).