Available online at ScienceDirect. IFAC-PapersOnLine 48-1 (2015)

Similar documents
Chapter 2 Review of Linear and Nonlinear Controller Designs

Towards Reduced-Order Models for Online Motion Planning and Control of UAVs in the Presence of Wind

What is flight dynamics? AE540: Flight Dynamics and Control I. What is flight control? Is the study of aircraft motion and its characteristics.

FAULT DETECTION AND FAULT TOLERANT APPROACHES WITH AIRCRAFT APPLICATION. Andrés Marcos

CHAPTER 1. Introduction

Flight Dynamics, Simulation, and Control

Mech 6091 Flight Control System Course Project. Team Member: Bai, Jing Cui, Yi Wang, Xiaoli

Aircraft Maneuver Regulation: a Receding Horizon Backstepping Approach

Aim. Unit abstract. Learning outcomes. QCF level: 6 Credit value: 15

ANALYSIS OF AUTOPILOT SYSTEM BASED ON BANK ANGLE OF SMALL UAV

Stability and Control Analysis in Twin-Boom Vertical Stabilizer Unmanned Aerial Vehicle (UAV)

Multi-layer Flight Control Synthesis and Analysis of a Small-scale UAV Helicopter

Frequency Domain System Identification for a Small, Low-Cost, Fixed-Wing UAV

EE5102/6102 Multivariable Control Systems

Introduction to Flight Dynamics

Adaptive Augmentation of a Fighter Aircraft Autopilot Using a Nonlinear Reference Model

FLIGHT DYNAMICS. Robert F. Stengel. Princeton University Press Princeton and Oxford

Theory in Model Predictive Control :" Constraint Satisfaction and Stability!

Mechanics of Flight. Warren F. Phillips. John Wiley & Sons, Inc. Professor Mechanical and Aerospace Engineering Utah State University WILEY

Automatic Control II Computer exercise 3. LQG Design

COMBINED ADAPTIVE CONTROLLER FOR UAV GUIDANCE

Digital Autoland Control Laws Using Direct Digital Design and Quantitative Feedback Theory

NDI-BASED STRUCTURED LPV CONTROL A PROMISING APPROACH FOR AERIAL ROBOTICS

Pitch Control of Flight System using Dynamic Inversion and PID Controller

The PVTOL Aircraft. 2.1 Introduction

Investigating the Performance of Adaptive Methods in application to Autopilot of General aviation Aircraft

Integrator Backstepping using Barrier Functions for Systems with Multiple State Constraints

Simulation of Non-Linear Flight Control Using Backstepping Method

Modeling of a Small Unmanned Aerial Vehicle

Exam - TTK 4190 Guidance & Control Eksamen - TTK 4190 Fartøysstyring

EE C128 / ME C134 Feedback Control Systems

Autopilot design for small fixed wing aerial vehicles. Randy Beard Brigham Young University

Control Systems Lab - SC4070 Control techniques

Identification of Lateral/Directional Model for a UAV Helicopter in Forward Flight

DESIGN AND DEVELOPMENT OF THE LQR OPTIMAL CONTROLLER FOR THE UNMANNED AERIAL VEHICLE

MODELING OF DUST DEVIL ON MARS AND FLIGHT SIMULATION OF MARS AIRPLANE

Autonomous Mobile Robot Design

Fullscale Windtunnel Investigation of Actuator Effectiveness during Stationary Flight within the Entire Flight Envelope of a Tiltwing MAV

Introduction to System Identification and Adaptive Control

R. Balan. Splaiul Independentei 313, Bucharest, ROMANIA D. Aur

Adaptive control of time-varying systems with gain-scheduling

GAIN SCHEDULING CONTROL WITH MULTI-LOOP PID FOR 2- DOF ARM ROBOT TRAJECTORY CONTROL

Development and Design of the Landing Guidance and Control System for the S20 UAV

Nonlinear Landing Control for Quadrotor UAVs

CDS 101/110a: Lecture 8-1 Frequency Domain Design

A SIMPLIFIED ANALYSIS OF NONLINEAR LONGITUDINAL DYNAMICS AND CONCEPTUAL CONTROL SYSTEM DESIGN

Chapter 1. Introduction. 1.1 System Architecture

Nonlinear Observer Design for Dynamic Positioning

Flight Test Results for Circular Path Following by Model Predictive Control

Estimation of Wind Velocity on Flexible Unmanned Aerial Vehicle Without Aircraft Parameters

A model of an aircraft towing a cable-body system

The Role of Zero Dynamics in Aerospace Systems

Evaluation of different wind estimation methods in flight tests with a fixed-wing UAV

NEURAL NETWORK ADAPTIVE SEMI-EMPIRICAL MODELS FOR AIRCRAFT CONTROLLED MOTION

FLIGHT DYNAMICS ANALYSIS AND BASIC STABILIZATION STUDY IN EARLY DESIGN STAGES OF THE SAGITTA DEMONSTRATOR UAV

Suboptimal adaptive control system for flight quality improvement

Model Identification and Attitude Control Scheme for a Micromechanical Flying Insect

Model Reference Adaptive Control of Underwater Robotic Vehicle in Plane Motion

Control System Design

Aggressive Maneuvering Flight Tests of a Miniature Robotic Helicopter

DISTURBANCES MONITORING FROM CONTROLLER STATES

Turn Performance of an Air-Breathing Hypersonic Vehicle

Lecture 9. Introduction to Kalman Filtering. Linear Quadratic Gaussian Control (LQG) G. Hovland 2004

Aerobatic Maneuvering of Miniature Air Vehicles Using Attitude Trajectories

Aircraft Stability & Control

Fundamentals of Airplane Flight Mechanics

Chapter 4 The Equations of Motion

AFRL MACCCS Review. Adaptive Control of the Generic Hypersonic Vehicle

Coordinated Tracking Control of Multiple Laboratory Helicopters: Centralized and De-Centralized Design Approaches

Cross-Coupling Control for Slippage Minimization of a Four-Wheel-Steering Mobile Robot

Comparison of Feedback Controller for Link Stabilizing Units of the Laser Based Synchronization System used at the European XFEL

Department of Aerospace Engineering and Mechanics University of Minnesota Written Preliminary Examination: Control Systems Friday, April 9, 2010

DESIGN PROJECT REPORT: Longitudinal and lateral-directional stability augmentation of Boeing 747 for cruise flight condition.

State Estimation for Autopilot Control of Small Unmanned Aerial Vehicles in Windy Conditions

MATH4406 (Control Theory) Unit 1: Introduction Prepared by Yoni Nazarathy, July 21, 2012

MS-E2133 Systems Analysis Laboratory II Assignment 2 Control of thermal power plant

Lecture 7 : Generalized Plant and LFT form Dr.-Ing. Sudchai Boonto Assistant Professor

MODELING OF A SMALL UNMANNED AERIAL VEHICLE

Design and Implementation of an Unmanned Tail-sitter

Robust Model Predictive Control for Autonomous Vehicle/Self-Driving Cars

AEROSIM BLOCKSET Version 1.2 User s Guide

Optimal Control of Twin Rotor MIMO System Using LQR Technique

EXPERIMENTAL MODAL ANALYSIS OF AN ACTIVELY CONTROLLED SCALED METRO VEHICLE CAR BODY

Lecture #AC 3. Aircraft Lateral Dynamics. Spiral, Roll, and Dutch Roll Modes

Computer Problem 1: SIE Guidance, Navigation, and Control

Design and modelling of an airship station holding controller for low cost satellite operations

Real-time trajectory generation technique for dynamic soaring UAVs

Flight Controller Design for an Autonomous MAV

Aeroelastic Gust Response

Nonlinear Identification of Backlash in Robot Transmissions

A Comparison of Closed-Loop Performance of Multirotor Configurations Using Non-Linear Dynamic Inversion Control

Problem 1: Ship Path-Following Control System (35%)

GUIDANCE AND CONTROL FOR D-SEND#2

Nonlinear Model Predictive Control Tools (NMPC Tools)

Chapter 1 Lecture 2. Introduction 2. Topics. Chapter-1

Aircraft Pitch Attitude Control Using Backstepping

MECH 6091 Flight Control Systems Final Course Project

Gain-scheduled Linear Quadratic Control of Wind Turbines Operating at High Wind Speed

Acknowledgements. Control System. Tracking. CS122A: Embedded System Design 4/24/2007. A Simple Introduction to Embedded Control Systems (PID Control)

Chapter 6 Feedback Control Designs

Transcription:

Available online at www.sciencedirect.com ScienceDirect IFAC-PapersOnLine 48-1 (215) 67 72 Co-Simulation of Matlab and FlightGear for Identification and Control of Aircraft Guilherme Aschauer Alexander Schirrer Martin Kozek Inst. of Mechanics & Mechatronics, Vienna University of Technology, Austria e-mail: guilherme.aschauer@tuwien.ac.at Abstract: The paper outlines the development of a co-simulation solution of Matlab and Flight- Gear in which the communication between these programs is done via UDP without needing further toolsets. The simulation and rendering is done by FlightGear. Flight measurement signals are sent to Matlab, which in turn sends back actuator input values computed by a flight control system. First, gray-box models of the aircraft dynamics are identified for different altitudes for longitudinal and lateral dynamics so that gain-scheduled controllers can be used. The output quantities to be controlled are altitude and heading and three state-space controllers (MPC, LQR and a gain-scheduled LQR) are designed and compared by tracking two reference signals including steps and ramps. At the end the robustness of the controllers are verified by flying in turbulent weather conditions. 215, IFAC (International Federation of Automatic Control) Hosting by Elsevier Ltd. All rights reserved. Keywords: Aerospace computer control, Automated guided vehicles, Co-Simulation, Parameter estimation, LQR control method, LQG control method, Predictive control 1. INTRODUCTION Considerable progress has been made in the past few years in affordable (X-Plane 1 ) or freely available (FlightGear 2 ) realistic flight simulation software. Both programs promise a large degree of realism and are even used in training cockpits for pilots. FlightGear offers the choice between several well-established flight dynamics models (FDM) on the basis of mostly nonlinear equations of motion like JSBSim (Berndt (24)) or the usage of a user-defined model. This is helpful where highly specialized aircraft like lighter-than-air aircraft are used, or a custom set of equations is available, and where FlightGear is just used for visualization purposes and for providing realistic environmental conditions. The drawback of this approach is that the user has to provide all the coefficients used in the FDM, including a parametrization over different flight parameters to increase the degree of realism. A completely different approach is taken by X-Plane where instead of an FDM the blade-element-theory is applied. Here, the geometry of the aircraft has to be modeled in detail because the forces and moments are directly calculated on its elements (e. g. wings). This offers the possibility to investigate the approximate flying behavior of a newly developed aircraft without having to build and test a prototype. Obtaining a mathematical model can also be easier with this approach since one does not need specific knowledge of the implemented/modeled physical processes but can rely on the computations of X-Plane and try to obtain a black- or gray-box model from input and output data. Of course, the geometry has to be modeled 1 www.x-plane.com 2 www.flightgear.org sufficiently well and still the results have to be taken with caution. This study will show how it is possible to run FlightGear or X-Plane in co-simulation with Matlab using the UDP communication protocol. This approach allows to run both programs on different platforms as long as they are in the same local network. In order to obtain high flexibility, Simulink and especially the Aerospace Toolbox have not been used since the latter one is so far only working with FlightGear and is not a standard package of Matlab. If Matlab is not available, the main functionality of the script can easily be implemented in C++ or any other high-level programming language. The flight simulator sends flight attitude data and receives actuator input values (throttle, elevator, aileron, and rudder). After establishing a working connection between the two programs, identification runs are made for longitudinal and lateral motion independent of each other for different altitudes with a chirp signal overlaid with low-pass filtered white noise as input data to guarantee sufficient excitation in the relevant frequency areas. With this input/output data a model estimation process can be performed, using a black-box model or, preferably, a gray-box model since the equations of motion for standard aircraft dynamics are available (e. g. Brockhaus (21)). These models are the starting point for the control design process. In this work, three different reference tracking controllers (heading and altitude) have been used: a model predictive controller (MPC), an LQR controller, and a scheduled LQR controller. The models and controllers are then validated by flying through turbulent weather conditions with reference test signals including steps and ramps. The airplane used throughout this paper is a Concorde which is theoretically capable of flying at supersonic speed. However, the 245-8963 215, IFAC (International Federation of Automatic Control) Hosting by Elsevier Ltd. All rights reserved. Peer review under responsibility of International Federation of Automatic Control. 1.116/j.ifacol.215.5.71

68 Guilherme Aschauer et al. / IFAC-PapersOnLine 48-1 (215) 67 72 present study only considers subsonic operation. Future work could consist of an adaptive controller which is not only dependent on altitude (as used in this work) but also on speed, so that a transition from sub- to supersonic flight would be possible. Since the aerodynamic center of lift of the Concorde changes when this happens, fuel is transferred inside the plane to different tanks in order to shape balance and trim. This of course changes the center of gravity and therefore the flight behavior. So the challenging task of designing an efficient controller which is capable of flying the plane in sub- and supersonic domains was not considered in this paper. A co-simulation coupling between X-Plane and Matlab has already been established for example by Ribeiro and Oliveira (21), who, however, only investigated the roll dynamics for creating a roll attitude autopilot system. Nusyirwan (211) developed a connection between Matlab and FlightGear by using Python. A custom set of equations was used for the flight dynamics and a simple PID altitude-hold and heading-hold was developed. The visualization is done via FlightGear on a multi-monitor setup. Sorton and Hammaker (25) used FlightGear with a custom flight dynamics model in JSBSim and Matlab with a C++ interface for the simulation of an autonomous unmanned aerial vehicle and afterwards a Hardware-inthe-Loop testing was done with a self-developed actuator. In this work the flight calculations are done by FlightGear and this program is assumed to be a black box to Matlab, just as a real plane would be. This approach benefits from the high degree of realism provided by FlightGear which already uses well-established, realistic FDMs, which are based on the nonlinear equations of motion and therefore avoids the use of potentially over-simplified flight dynamics models. Also, different planes and flying objects can be used. Since just a computer with Matlab and FlightGear is needed, the developed framework has high potential in educational use as different controllers can easily be implemented and tested on potentially highly challenging plants (for example fighter aircrafts in their nonlinear operation area or the already mentioned transition from sub- to supersonic speeds). 2. METHODOLOGY The linearized equations of motion are taken from Brockhaus (21) and are extended with a fifth state (altitude respectively heading) which also functions as the controlled output afterwards. The linearized longitudinal dynamics are described by: ẋ Lon = A Lon,4 4 x Lon + B Lon,4 2 u Lon (1) where the specific entries of the matrices A and B depend on the altitude and have to be estimated. The state vector x Lon =[q,α,v,γ] T consists of the quantities pitch rate q, the angle of attack α, the velocity v, and the angle of climb γ. In some books (e. g. Stevens and Lewis (23)) instead of γ the pitch angle θ is used, but since the linearized relation γ = θ α holds, both choices are valid. The input quantities u Lon =[δ F,η] T are the throttle δ F and the elevator η. A fifth state the altitude is introduced and its derivative is only dependent on γ. The lateral dynamics are described by: ẋ Lat = A Lat,4 4 x Lat + B Lat,4 2 u Lat (2) The state vector x Lat =[r,β,p,φ] T now consists of the yaw rate r, the sideslip angle β, the roll rate p, and the roll angle φ. The introduced output state is the heading Ψ (often also called yaw) and its derivative is only dependent on the yaw rate r. The input quantities u Lat =[ξ, ζ ] T are the aileron ξ and the rudder ζ. These two sets of equations are the linearized equations of motion for a conventional aircraft linearized around level-trimmed flight conditions. Then the longitudinal and lateral dynamics are mutually decoupled. The angle of attack α and the sideslip angle β are called aerodynamic angles and describe the direction of the relative wind from the airplane-fixed coordinate system through the body s center of mass. Roll, pitch, and yaw describe the orientation of the airplane in space with angles about the center of mass and are also referred to as the aircraft s principal axes. The angle of climb γ is defined as the vertical angle between the flight path and the Earth. One can also interpret it as the ratio between the height change and the distance covered. Therefore, the altitude change is (linearly) only dependent on γ. Both continuous-time models are of the standard form ẋ(t) =A c x(t)+b c u(t), (3) y(t) =Cx(t). (4) Since the state vectors consist of physical states, the C matrices just select the output states. The discrete version of the state equation is written as: x(k + 1) = A d x(k)+b d u(k), (5) y(k) =Cx(k). (6) The computation of the discrete state space matrices is possible from their continuous counterparts and depends on the sampling time T s as for example shown in Ogata (1995): A d = exp m (A c T s ), (7) ( ) Ts B d = exp m (A c τ)dτ B c = A 1 c (A d I) B c, (8) τ= where a zero-order-hold (piecewise constant) input u is assumed and exp m denotes the matrix exponential. Since the output of most black-box estimation procedures is a discrete-time representation of the system dynamics, from now on the index d is omitted when referring to the state space matrices. After the estimation and validation of a model different controllers are designed. The discrete-time LQR (linear quadratic regulator) minimizes a cost function of the following form: ( J = x(k) T Qx(k)+u(k) T Ru(k) ), (9) k= where Q>and R>are the weighting matrices for the state error and input actions. The state vectors are augmented by the integrated output error to account for offset errors, changing operating conditions such as fuel usage and wind as well as model mismatch. As shown in Ogata (1995) an optimal solution of the form: u(k) = Kx(k), (1)

Guilherme Aschauer et al. / IFAC-PapersOnLine 48-1 (215) 67 72 69 exists, with K obtained from the solution of the associated Riccati equation, K = ( R + B T PB ) 1 B T P A, P = Q + A T ( P PB ( R + B T PB ) 1 B T P ) A, which minimizes the cost function (9). The integrator in discrete time is realized by the Forward-Euler formula: x i (k + 1) = x i (k)+t s e(k), where e(k) is the control error between the reference r(k) and the output y(k): e(k) =r(k) y(k). In the gain-scheduled version of the LQR controller, the gain matrix K is computed for different altitudes and then linearly interpolated between two resulting gains depending on the actual altitude. The second controller used is an MPC (model predictive controller), also called receding horizon controller. In every iteration, a (constrained) optimization problem is solved and the first step of the resulting control strategy is applied. A prediction horizon n p is specified as the number of time instants (samples) for which the predicted output y p is calculated when control action is applied for n c samples. Often, n c is chosen much shorter than n p to reduce computation time since the optimization problem size has to be solved faster than the sampling time T s which was set to.1 s in this work. The implementation of the predictive controller follows the approach in Wang (29) in which the differences of the control and state vectors are used: x(k) =x(k) x(k 1), u(k) =u(k) u(k 1). Then the augmented state vector is defined as x aug (k) = [ x(k) T, y(k) T] T to finally obtain an augmented state space model on which the optimization process is based: [ x(k + 1) y(k + 1) ] [ ][ A x(k) = CA I y(k) [ ] [ ] x(k) y(k) = I y(k) ] [ ] B + u(k), CB With this approach, integrators are implicitly added for the outputs. Then a constrained optimization problem is formulated that is solved by quadratic programming. Limitations on the absolute values as well as on the rate of change of the actuator inputs and plant outputs can directly be cast into linear inequality constraints. 3. FRAMEWORK The main part of the communication between Matlab and FlightGear is done via UDP (user datagram protocol), an IP-based network protocol with a simple transmission model and very little overhead. There is no handshake dialogue before a communication and therefore no guarantee of successful delivery and ordering. Also, packages can be received out of order, a missing package cannot be detected easily, and there is no error checking provided within the protocol itself. In real-time systems with timesensitive applications, UDP is often used when package loss is preferable to waiting for resent packages. The sampling time at which FlightGear sends and receives data actuator input data FlightGear Matlab Fig. 1. UDP communication block diagram flight attitude data can be chosen freely and was set to.1 s. Care must be taken that Matlab does not take longer than that amount of time to compute and send the actuator input values, because otherwise the packages are being buffered and Matlab receives out-dated flight attitude data which may lead to unintended flight behavior due to wrong actuator inputs calculations by the controller. A simplified outline of the communication is shown in Figure 1. A sample file that describes the communication protocol used between Matlab and FlightGear is shown in Listing 1. Listing 1. Example communication protocol file <?xml version="1."?> <PropertyList> <generic> <binary_mode>true</binary_mode> <line_separator></line_separator> <var_separator></var_separator> <input> <chunk> <node>/controls/engines/engine/throttle</node> <name>throttle</name> <type>float</type> <format>%f</format> </chunk> <chunk> <node>/controls/flight/elevator</node> <name>elevator</name> <type>float</type> <format>%f</format> </chunk> </input> <output> <chunk> <node>/position/altitude -ft</node> <name>altitude -ft</name> <type>float</type> <format>%f</format> </chunk> </output> </generic> </PropertyList> In this example FlightGear receives the throttle and elevator input values and sends the current altitude. This is done on UDP ports that have to be specified via parameters when FlightGear is started, as well as the rate at which packets are sent. More values can easily be accessed by adding them in chunk blocks inside the protocol definition. Additionally, FlightGear can start a local HTTP server to manipulate a large number of variables that can be read out and written to in a normal web browser as well as by opening URLs from inside Matlab. Opening the URL http://localhost:555/controls/gear/ brake-parking?value=1&submit=update, for example enables the parking brake if the server has been started on port 555. If the variable should only be read then the part of the URL after the question mark has

7 Guilherme Aschauer et al. / IFAC-PapersOnLine 48-1 (215) 67 72 to be omitted. Thus all FlightGear variables can either be accessed via UDP or HTTP. The latter option has the advantage of manipulating variables only when there is a need to do so. It is therefore not necessary to send data at every sample interval in UDP packages. On the other hand, if called repeatedly, the HTTP operations are too slow for real-time usage. So this option is chosen to control the autopilot, the flaps during take-off, and the parking brake. Inside Matlab, the communication is done via two UDP objects (one for reading and one for writing) which have to match the ports specified in FlightGear. Then these objects can be treated like normal files by calling fread and fwrite. URLs are called by the command url and no further initialization has to be done. A sample command line execution of FlightGear with providing some options is: fgfs --turbulence= --wind=@ --aircraft=concorde --timeofday=noon --httpd=555 --enable-clock-freeze --generic=socket,out,1,localhost,551,udp,simple --generic=socket,in,1,,552,udp,simple This starts FlightGear with the Concorde aircraft in paused mode (clock freeze) standing on the standard airport with mild weather conditions (no wind and turbulence). A local webserver is started on port 555 to access the property tree for getting access to all internal variables via a web browser. On port 551 FlightGear sends UDP packages at a rate of 1 Hz in the form described in the file simple.xml and on port 552 it waits for UDP packages. 4. MODELLING Highly accurate nonlinear sets of equations exist to describe the standard flight motion of an aircraft (see for example, Stevens and Lewis (23) and Brockhaus (21)). As long as the plane is flying in conditions usually occuring during scheduled flights, a linearized version of these equations are sufficient for long-distance maneuvers like heading and altitude changes. Brockhaus (21) lists the state matrices for lateral and longitudinal dynamics for different flight conditions for six different aircraft. Throughout this paper, the Concorde was used because an initial model for the estimation process could be obtained from the literature and the model of the airplane in FlightGear is sufficiently accurate. Furthermore, more advanced controllers capable of supersonic flight could be developed in the future. In order to obtain input/output data for the estimation process the plane s built-in autopilot is used to reach steady state conditions on a specified altitude. After turning off the autopilot, the actuators for the longitudinal dynamics (throttle and elevator) are excited with a chirp signal overlaid with low-pass filtered white noise, and the input and output (the whole state vector) are logged via Matlab and stored in a matrix. Then the procedure with reaching steady state with the autopilot and excitation is repeated for the lateral dynamics (aileron and rudder). Care has to be taken that there are no relevant signal contents above the Nyquist frequency which is half the sampling frequency. An example of a throttle and elevator input action as well as their power spectra are depicted in Figure 2. Elevator,Throttle power spectral density (db/hz).1.1.2.8.3 5 1 15 2 25 3 2 2 4 6 8.5 1 1.5 2 2.5 3 frequency (Hz) Fig. 2. Throttle (gray) and elevator (black) input for obtaining identification data and their power spectra r e x i u x y K FlightGear C Fig. 3. Integrating LQR controller with full state feeback Figure 2 shows that there are no relevant information above.5 Hz and 1.5 Hz for the throttle and elevator inputs, respectively. The aileron and rudder characteristics are similar to the elevator since their time constants are on a comparable scale. Higher frequency inputs not violating the Nyquist criterion are possible, but show no relevant dynamical effects on the aircraft for the modeling goals. The dynamics of the throttle-actuated thrust are even slower than those of the other actuators and so there is no need for high-frequency inputs. At this point it also has to be mentioned that at the moment the model of the Concorde in FlightGear does not seem to represent realistic actuator dynamics except for the throttle and rudder inputs, which also discourages the use of high-frequency inputs. Excitation runs are then made for different altitudes, each 2 m, starting at 2 m until 16 m. At high altitudes the excitation runs had to be repeated occasionally, because the estimation process sometimes failed. One possible reason for this is the trans-sonic speed regime reached even without using the afterburner. 5. CONTROLLER AND OBSERVER DESIGN The first tested controller type are LQR controllers with integration of the output error and full state feedback. The structure is shown in Figure 3. The curled magenta lines indicate UDP communication while the rest of the block diagram is processed in Matlab. The reference value r is either the heading Ψ r for the lateral or the reference altitude H r for the longitudinal dynamics. Since both dynamics are linearly decoupled, two separate controllers are designed. The integrated output error is appended to the state vector. The new state vector is multiplied by the controller gain matrix K obtained 1.1 1.9

Guilherme Aschauer et al. / IFAC-PapersOnLine 48-1 (215) 67 72 71 r ŷ e Disturbance Noise x i u y ym K FlightGear OBSERVER B + ˆx k+1 + + H z 1 Fig. 4. Integrating LQR controller with state observer using Matlab s lqi command. In case that not the entire state vectors are measurable, an observer is utilized to reconstruct the states. Here, a standard Luenberger-observer is designed for demonstration purposes. The uncertainty of the process model and appearance of the measurement noise is just considered with one parameter during the design process. This parameter describes to which extent the system relies on the measurements in favor of its own process model. Since the measurement noise has artificially been added in Matlab its standard deviation is perfectly known and the process noise s deviation can be estimated depending on the weather conditions (in the Matlab model, no wind and weather data were taken into account). These two variables were used to additionally build a Kalman filter to calculate the optimal observer gain matrix H. The full configuration is shown in Figure 4 but the outer feedback loop of the estimated output ŷ to the reference was omitted for clarity and space reasons. Again, the curled magenta lines indicate UDP communication between Matlab and FlightGear. The controller and observer gains for MPC and LQR have been chosen to achieve acceptable performance for small- to medium-sized steps (maximum of 4 degrees change in heading direction and 4 m in altitude). Larger reference steps would require a feed-forward command shaping, lowering the feedback gains, or implementing error saturations and anti-reset windup logics in Matlab. When full state feedback was used, all five states were considered measurable without noise and directly used to calculate the next input action. When observers were used, only the heading and altitude were measured and additionally overlaid by noise. This means that four states had to be estimated from one noisy measurement. 6. RESULTS The identification process results are highly satisfying, although sometimes the excitation process has to be repeated for higher altitudes, presumably because the plane is too close to Mach 1. Most of the time, though, and especially for altitudes below 14 m, the estimation results are in good agreement with the measurement data as can be seen in Figure 5 where the measurements are compared with the output of the estimated model for the vertical dynamics at 1 m. The root-mean-squared-error-based fit values for these examples are as follows: A ˆx k C + ŷ ˆx pitch rate alpha speed gamma altitude 1 2 5 5 5 1 15 2 25 3 4 1 2 2 2 4 5 1 15 2 25 3 1.9.8.7.6 5 1 15 2 25 3 1 2 5 5 1 5 1 15 2 25 3.55.5.45 5 1 15 2 25 3 Fig. 5. Comparison between the (normalized) input/output data (gray) and the the output of the estimated model (black). pitch rate 82.6 % yaw rate 89.9 % alpha 78.3 % sideslip angle 96.6 % speed 89.7 % roll rate 88.7 % gamma 85.6 % roll angle 93.2 % altitude 88.5 % heading 86. %. The estimation results for different altitudes and also for the horizontal dynamics are of similar, high quality. After designing the controllers, a flight path with changing reference altitude and heading values was created to be used by all three controller types. For the predictive controller the control horizon was set to 15 samples (1.5 s) and the prediction horizon was set to 3 samples. With these values it was just possible to run the co-simulation on a standard notebook in simulated real-time. At first, mild weather conditions were assumed for the validation of the controllers. The results are plotted in Figure 6 for the scheduled LQR case with full state feedback. No further parameter tuning was done after the controllers showed satisfying behaviour (following a reference trajectory in turbulent weather conditions). Especially after about 85 s in Figure 6 the mutual influence of the lateral and longitudenal dynamics on each other can be seen. During a turn maneuver (ramp for changing the heading) the aircraft s motion was disturbed by a large step in the reference altitude which led to large elevator action and the plane leaving the linear operation range where both dynamics are decoupled. Then, the same runs were repeated with enabled turbulences (they were set to.75 in a range from zero to one). With these severe disturbances even FlightGear s built-in autopilot had sometimes trouble with reaching respectively holding the desired heading. Figure 7 shows a part of the same reference flight path as Figure 6, but in turbulent weather conditions using a model predictive controller. Only the altitude and heading were measurable

72 Guilherme Aschauer et al. / IFAC-PapersOnLine 48-1 (215) 67 72 altitude (km) heading ( ) actuators 14 12 1 8 6 4 3 2 1 1.3.2.1.1.2.3 elevator aileron 1 2 3 4 5 6 7 8 9 1 11 12 Fig. 6. Reference trajectory (dashed line) and real altitude and heading by an integrating scheduled LQR controller with full state feedback (all states measurable without noise) and mild weather conditions. The third plot shows the normalized actuator input values (between 1 and 1) of the elevator (black) and aileron (red)..3.2.1.1.2.3 altitude (km) heading ( ) 12 1 8 6 4 2 3 2 1.2.2 4 6 8 1 115 elevator Fig. 7. Reference trajectory (dashed line) and real altitude and heading by a model predictive controller with a state estimator (only altitude and heading were measurable and corrupted by noise). but corrupted with white noise, and the other states had to be estimated. Depending on how aggressive the controller is tuned the actuators seem to be excited with highly dynamic inputs. However, further investigations showed that the maximum rate of change of the elevator was less than 1 per second, and for the aileron and rudder commands even less demanding inputs were observed. The lateral dynamics are much more influenced by severe turbulence and appear noisy while the error dynamics of the longitudinal dynamics are less affected by gusts. A cause for the strong weather influence on the heading is also the larger penalty imposed on the aileron and rudder inputs in the optimization problem when designing the controllers. They were chosen to avoid large roll angles which give rise to nonlinear dynamics and sometimes led to crashes, especially when combined with low speeds due to climbing maneuvers. 7. CONCLUSION The developed framework is able to establish a connection between FlightGear and Matlab and works with different types of aircraft. The realistic, open-source flight simulator FlightGear offers great flexibility in accessing internal variables via external interfaces and it was shown that an aircraft can be controlled with Matlab. The whole process of starting FlightGear, selecting a specific aircraft, establishing a UDP connection, take-off, identification, controller design and following a reference trajectory is all fully automated by a Matlab script, which offers the possibility to easily design scheduled controllers. Different types of controllers and state observers have been implemented and their performance tested on a well visualized, complex dynamic system. The design task can be made more challenging by changing weather conditions, failure of aircraft parts, leaving the linear operating range or guaranteeing passenger comfort, and thus lends itself to use cases in control education. REFERENCES Berndt, J.S. (24). JSBSim: An Open Source Flight Dynamics Model in C++. In AIAA Modeling and Simulation Technologies Conference and Exhibit. Citeseer, Providence, Rhode Island. Brockhaus, R. (21). Flugregelung. Springer, 2 nd edition. Nusyirwan, I.F. (211). Engineering flight simulator using Matlab, Python and Flightgear. In Simtect. Melbourne, Australia. Ogata, K. (1995). Discrete-Time Control Systems. Prentice Hall, 2 nd edition. Ribeiro, L. and Oliveira, N.M.F. (21). UAV autopilot controllers test platform using Matlab/Simulink and X-Plane. In Frontiers in Education Conference (FIE), 21 IEEE, S2H 1 S2H 6. Sorton, E. and Hammaker, S. (25). Simulated flight testing of an autonomous unmanned aerial vehicle using Flightgear. In Infotech@Aerospace, 25 AIAA. Stevens, B.L. and Lewis, F.L. (23). Aircraft Control and Simulation. Wiley-Interscience. Wang, L. (29). Model Predictive Control System Design and Implementation Using Matlab. Springer, 1 st edition. 72