Computational Simulation of flight behavior of Flying Wing UAV

The aim of this work is to model and simulate a Flying Wing Aircraft and acquire flight data from two different simulations. The framework proposed constitutes of the development of a graphical model as well the use of a mathematical model of the aircraft. In order to simulate realistic flight conditions, we used a commercial flight simulation environment, X-plane 10. We performed the real time flight data collection from the simulator, as well as the software-in-the-loop feedback control through MATLAB/Simulink. Key-words: UAV, Software In the Loop, Hardware In the Loop, X-Plane, Simulink , Flying Wing

Abstract-The aim of this work is to model and simulate a Flying Wing Aircraft throughout a combination of two software and an automated system to compare the flight data acquired from two different simulations.The framework proposed constitutes of the development of both graphical and mathematical model of the aircraft aimed at flight data collection.In order to implement the Software-in-the-Loop (SIL), we used a commercial flight simulation environment, X-plane 10, which simulates the dynamics of the aircraft through the Blade Element Theory, and the software MATLAB/Simulink, which simulates and implement the control laws.Data transfer between X-Plane and Simulink was made possible through UDP (User Datagram Protocol), which enables process-to-process communication and works in conjunction with higher level protocols to help manage data transmission services.We collected the flight data from the simulator, as well as the responses of the mathematical model based on equations of motion and the aerodynamic derivatives, which were computed via the Digital DATCOM software.Both analytical simulation and the SIL simulation were performed with the same flight conditions, validating the longitudinal dynamic of the computational model.This framework allows further studies on aircraft simulation to be developed, reinforcing the collection, storage and processing of flight data.

I. INTRODUCTION
N the recent years, computational simulation has been an important tool for data acquisition, and in providing essential information about the behavior of mechanical systems [1].In the aerospace industry, simulations are used throughout the development of all aircraft, and they evaluate the control algorithm allowing for easy manipulation of the early model.This allows for data creation for the aircraft model, for faster development of the product, as well as minimizing the number of experimental flights.Thus, reducing the number of persons involved and consequently the final cost of the project [2].However, it is necessary to develop more reliable models of aircraft.
Several commercial simulators are available and used as a tool, known as Software-In-the-Loop (SIL), for the implementation of flight dynamics, navigation control, and for validating models in a precise fashion before field tests [2].SIL couples partially integrated software with an environment simulation and allows a direct information-technical communication between the two, for simple data creation, collection, and processing.
This also offers the possibility to execute tests before the hardware is available.Despite simulation-based testing being a very important part of the product development, Hardware-Inthe-Loop (HIL) simulation tests should be adopted whenever it is possible in order to validate together both the hardware and the software under realistic conditions [3].
In the specific case of Unmanned Aerial Vehicles (UAV) the mathematical model, as well as the implementation of SIL and HIL were describe by [4].It not only describes the physics of the system but also the behavior of the low-level autopilot, and the state estimation routines.UAVs are of high interest for prospective military and civilian applications due to their several advantages such as maneuverability, and lack of need for direct human interaction [5].The literature shows several works of multirotor aircraft modeling [6] [7].However, more detailed modeling of flying wings and their integration with SIL and HIL are still a growing field of high interest [8].Therefore, the literature does not provide many resources on this type of aircraft.
Since there is a lack of mathematical modeling that describes the behavior of flying wings because of their design complexity and aerodynamic instability, this paper presents the longitudinal dynamic modeling of a flying wing UAV through the derivatives of stability and control as well as the equations of motion, and through the Blade Element Theory.The mathematical model describes the system by its aerodynamic derivatives and equations of motion that establish the relationship among a set of variables, which provides an explicit expression of the systems behavior pattern and how it would work before building it.The behavior of each variable shows immediately in the equation, which in return allows the system to be analyzed and optimized.Whereas, through simulation modeling, it creates and analyses a digital prototype of a physical model to predict its performance in the real world with environment effects on it.

I
The purpose of the present work is to, first, mathematically and graphically model the flying wing.Second, to simulate both models aiming to compare and review the dynamic response from the introduction of longitudinal oscillations during cruise flight, using the commercial flight simulator X-Plane (Laminar Research©) and the mathematical software MATLAB/Simulink (MathWorks©).Finally, perform several flight simulation tests in order to apply refined adjustments to the aircraft parameters and to improve the control of flight stability.The results of both simulation methods were analyzed and compared.This model will allow the development of future projects from what has already been accomplished in this, thus helping the advance of new research with flying wing flight data creation, its software data storage and even a tool for embedded systems.
This paper is organized as follows: Section II introduces the software X-Plane and its Plane-Maker platform, and then the procedure used for the modeling through the Blade Element Theory.Section III describes the UDP communication between the X-Plane and MATLAB/Simulink, the necessary configuration for the interface, and the implementation of the control system through Simulink for the simulations of the UAV.Section IV demonstrates mathematically the flight dynamics of a fixed wing UAV through the derivatives of stability and control.Section V presents the results obtained and discussions.The last section concludes the importance of this work and presents the research that still needs to be done as future work.

II. PLANE-MAKER MODELING
The flying wing was modeled using the platform Plane-Maker, built into X-Plane 10, which enables the creation of any aircraft.With its graphical interface, the user can have a visual feedback of the in-flight behavior of the aircraft once all the physical characteristics are applied to the model.X-Plane 10 is a realistic flight simulator certified by the Federal Aviation Administration (FAA), and a viable tool due to its aircraft creation environment and its ability to simulate the aircraft dynamics.Through the combination of both these assets, we obtained the graphical model of the UAV.
The UAV chosen for this project was a commercial RC Flying Wing (Fig. 1), and its characteristics are shown below in Table I.This specific model did not exist in the X-Plane database; therefore, we modeled it from scratch (Fig. 2).The dimensioning of the reference model is very important because X-Plane separates the aircraft into small sections to calculate several aerodynamic factors on each, ensuring that the entire aircraft is being computed.This methodology is based on a theory called Blade Element, which is explained by [6].The model was created in the Plane-Maker according to the specifications of the actual model and following the guidelines recommended by the platform's manual [9].
The UAV is powered by a brushless electric motor and its parameters of the thrust and power are approximated according to the manufacturer's datasheet [EMAX 2822 Brushless Motors datasheet].Because X-Plane is an aircraft flight simulator on real scales, there is a difficulty in making the reaction time of the engines of a small UAV compatible with the real model.Several in-flight tests were performed to fine-tune the parameters, specifically in the engine and CG position.The suitable engine specifications are:

1) Maximum allowable Power: 166W; 2) Engine RPM: 12000; 3) Propeller: 10x5;
The static thrust of the propeller was computed via the program JavaProp.This feature describes the geometry of the airfoil to be tested, assigns the appropriate Reynolds number, generates the aerodynamic coefficients, and therefore thrust.A file is generated and then exported to Plane-Maker.

III. SOFTWARE-IN-THE-LOOP IMPLEMENTATION
MATLAB/Simulink is an environment for simulation of dynamic systems.It provides a customizable set of block libraries that enables the user to design, simulate, and test a variety of systems time-varying.This platform presents ready blocks for performing communications with external environments, allowing data exchange.Therefore, a block diagram was created in Simulink aiming to send flight control to the model built in the platform X-Plane.The controls details for the architecture used for this project can be found at [10].
UDP is a transport layer protocol, where each output operation of a process produces exactly one UDP datagram, causing one Internet Protocol (IP) datagram to be sent, an indepth description can be found in [6].The simulation constitutes of two computers that use an Ethernet network with IP addresses defined for each, which allows data exchange between MATLAB/Simulink and X-Plane, as illustrated in Fig. 3.Both software were configured for sending and receiving packets and data, following the guidance at [2].
The MATLAB/Simulink PC generates the error signal through a reference signal and feedback data provided by X-Plane.Then, it uses the error signal as input to the control law, thus generating a command signal for the motors that will be sent back to X-Plane.Finally, X-Plane PC receives the command data for the engine, executes the interactions and sends the new data position to the MATLAB/Simulink PC again [11].This communication procedure is explained in detail by [12] [13].

A. X-Plane Settings
After modeling the UAV in Plane-Maker, an extension *.acf file is generated, which is loaded into X-Plane to perform inflight simulations.An adjustment on the number of flightmodel per frame was necessary in order to establish the amount of time that the flight simulator calculates the forces in each frame.A value between 6 and 10 is recommended to ensure a better performance of the model during the simulations [2].
For the analysis of the simulations, obtaining the flight data is required.X-Plane has several ways to view this data, it can be displayed on the main screen of the simulator and sent via Ethernet using UDP.The configuration can be done in Setting / Data Input Output.For this work, the following output data was configured: 1) Angular position (, , ); 2) Scalar position (x, y, z); 3) Angular velocity (Q, P, R); 4) Scalar velocity (Vx, Vy, Vz).
Another important adjustment is the UDP rate/s and disk rate/s values to match the response frequency of the X-Plane with MATLAB/Simulink, which was set as 60.00 for both.
Each output generates a set of nine groups of 4 bytes each [14].The first four bytes represent the type of packet, the fifth byte is an internal policy, and the next group of four bytes represent the parameter label that is being sent as shown in Fig. 4. For each label, X-Plane sends a packet with eight data and all of them take over the format of single-precision floating point of 32 bits [3] [6].
To send commands to X-Plane, the packet must be built with the same architecture.

B. Control System
After modeling and adjusting all parameters of the Flying wing in Plane-Maker, following the same dimensions, weight and CG of the real aircraft, we implemented the control laws using the software MATLAB/Simulink, in order to test control algorithms and navigation of the aircraft.
The Flying Wing is a tailless fixed-wing aircraft that has no definite fuselage.Due to the lack of conventional stabilizing surfaces and the associated control surfaces, this type of aircraft suffers from the inherent disadvantages of being dynamically unstable and difficult to control.This means that the amplitude of any oscillatory motions induced by disturbances eventually increase with time infinitely relative to a steady-state flight condition as shown in Fig. 5.
Dynamic instabilities can be tolerated by a human pilot or by automatic controls for feedback controllers, which is known as "closed-loop stability".Therefore, to perform the flight tests for both analytical and graphical methods, a PID (Proportional-Fig.3. Simulation loop.Modified from [11].Fig. 4. Data packet from [6].Fig. 5. Graphical example of dynamically unstable aircraft motion from [15].Fig. 6.Graphical example of dynamically stable aircraft motion from [15].Integral-Derivative) Controller system for the control loops of pitch and roll was developed in Simulink as shown in Fig. 7.It allowed us to perform the simulations at a constant velocity, oscillating only the pitch attitude degrees of freedom.

C. Simulink Settings
In order to use the data received by X-Plane in the control and guidance laws implemented in Simulink, the packets need to be broken in variables.According to [6], this interface has five main blocks as illustrated bellow in Fig. 8.The blocks "Receiving data" and "Sending data" are responsible for closing the system control loop, and the blocks Graphical Interface and the Simulation Analyze act on every interface.
Simulink presents some blocks that send and receive data through the UDP protocol.The first block is the UDP receiver, it receives the packets sent from X-plane, it is necessary to configure it according to the guidance at [2].An unpacking block must be provided to extract the data, and the Byte Reversal to adapt the byte because X-Plane exports the data in big-endian format where the most significant one is the first byte, whereas MATLAB work in little-endian format, which the most significant byte comes last.Then, the control laws for a fixed wing aircraft are implemented through Simulink.The code interprets the UDP data.Fig. 9 illustrates the flowchart of the implemented program.And at the end the data is shown on the output displays.
The UDP Sending is similar to the receiving process.The data packet must be mounted with the same architecture that X-Plane sends commands as illustrated in Fig. 4.

IV. MATHEMATICAL MODELING
The dynamics for fixed-wing aircraft can be approximately decomposed into longitudinal motion.Aiming to obtain the mathematical model that describes the longitudinal dynamics, a series of considerations are made to obtain the equations, some are described below: 1) The Earth is the inertial reference system; 2) The aircraft is a rigid body and its weight is a constant; 3) Acceleration of gravity does not change with flight altitude; 4) The Reynolds number and Mach number effects are approximately constant; 5) The Sideslip Angle () is considered null; 6) The disturbances around the equilibrium are small, with small variations to the pitch angle (θ); 7) The deflection of the elevator does not alter any force, only the moment of pitch.
An aircraft usually has 6 degrees of freedom (6DoF), which can be described by equations of forces and moments acting on it and presents nonlinear dynamics [16].Using these nonlinear equations of the longitudinal dynamics, and the calculation of the forces and moments through the stability and control derivatives we can finally simulate the flight of the UAV.

A. Stability and control derivatives via USAF DATCOM
The stability and control derivatives determine the static and dynamic stability of the aircraft.The static stability refers to the direction of aerodynamic moments as the aircraft oscillates its nominal flight condition, where the tendency of restoring the initial position defines if the aircraft is statically stable.The dynamic stability refers to the dynamic behavior of the airframe in response to disturbances, where the aircraft is defined as dynamically stable if its response dampens the disturbance out over time as shown in Fig. 6.
The stability and control derivatives can be estimated or identified through wind tunnels tests or via flight tests [10].According to the literature, the most feasible method for obtaining these derivatives in cruise flight conditions is through calculations based on empirical data since wind tunnels is not always accessible.
The Data Compendium (DATCOM) has been widely used for the estimation of the aircraft derivatives.It was developed by the United States Air Force (USAF) and is based on empirical data (wind tunnel data history and in-flight testing of certain types of airfoils and fuselages) and simplified analytical methods, this method is known as semi-empirical.Given an aircraft configuration, declared in FORTRAN language, DATCOM easily provides the estimation of aerodynamic coefficients and their stability derivatives.
All the models parameters and specifications for the analytical modeling were the same as those used for modeling in Plane-Maker.The model was created in DATCOM following the guidelines recommended by the manual [17].Table II contains the numerical values of the longitudinal aerodynamic derivatives of the flying wing.  is referred to as the longitudinal static stability derivative,   is referred to as the

B. Aerodynamic coefficients for forces and moment
Aerodynamic forces and moments have a complex dependence on several variables, resulting in a complicated nonlinear correlation between each variable [10].These variables, known as aerodynamic coefficients, are dimensionless and depend on the derivatives of stability and control for a flight condition, and are described below: 1) Lift Coefficient: 2) Drag Coefficient: 3) Pitching Moment Coefficient: Where:   is the elevator control deflection, and  is the attack angle.

C. Aerodynamic Forces and Moment
As the aircraft passes through the air, a pressure distribution, or aerodynamic force, is generated around its body.The air velocity (  ), air density ( ) and the shape and attitude of the aircraft are all variables of the distribution of pressure acting on the aircraft.Hence, in order to capture the effect of the pressure with a combination of forces and a moment, the dynamic pressure (  ̅ ) is given by 2 and the variables that define the shape of the aircraft body are given by the planform area of the aircraft wing (), and the mean chord of the wing (̅ ).
The aerodynamic forces and moment are obtained from the dimensionless aerodynamic coefficients at a given flight condition as follows: A complete modeling of the engine with the propeller and its dynamic thrust are quite complicated and beyond our scope; however, a simplified model for the calculation of the propulsion force is the approximation by given as follow.
Assuming that engine provides enough torque to the propeller and the thrust delivered by the propeller is entirely dependent on the aerodynamics of the propeller, the thrust force can be calculated as described in [10]: Therefore,   is the propeller radius, Ω is the rotational speed, and   is an approximation at a given advance ratio value that is computed from the flight speed and the rotational speed of propeller at each instant.The propeller efficiency considered for the calculations was of 70%.

D. Linear State-space model of the UAV
The equations of motion for an aircraft are a set of 12 nonlinear, coupled, first-order, ordinary differential equations and are describe in [8].In order to produce reduced-order transfer function and state-space models more feasible for control system design, we linearized and decoupled the equations of motion.The transfer function model for the longitudinal dynamics are organized by the following variables: the pitch angle (θ), the angle of attack (), the pitch rate (), the altitude (ℎ), and the airspeed (  ).The control signals used to influence the longitudinal dynamics are the elevator (  ) and the throttle ( ℎ ).The nonlinear longitudinal equations of the system are described below: where: .̅ .( .+  . ) ]   (12) ℎ =   . () Considering that the objective of this work is to simulate modes of flight and control in cruise level flight, the state-space model linearized about the trim condition for the longitudinal dynamics is represented as follows.In other words, we solved the non-linear equations of the longitudinal dynamics for null derivatives with respect to the output and input state variables.The vector of states of the longitudinal dynamics ( 14) is formed by the airspeed, Euler angles, and altitude, which are the variables of interest for the chosen flight conditions.The control input vector (15) is composed of the deflection of the elevator control surface of the UAV plus the level position of the throttle.
The Jacobian of equations (8)(9)(10)(11)(12)(13) were derived and linearized at trim condition.Utilizing the state-space notation (16), we can rewrite the linearized system in the matrix form as described in section V.
= .  + .  (16)   = .  + .  Where the vector of state and control of the linearized equation are: After performing the Jacobian, we obtained the linearized transfer function model and replaced all forces, moment, thrust force, the gravity acceleration (), and other variables that have been previously defined.
The detailed steps and calculations for the mathematical modeling of the longitudinal dynamics of a fixed wing UAV are described in [5].The analytical simulation was developed in a MATLAB language code.Through the datcomimport function, the stability and control derivatives of the model generated by DATCOM (Table II) are exported to MATLAB and introduced in the calculations of the coefficients and aerodynamic forces and moment.Then, all the values were replaced in the linearized equations of the longitudinal dynamics to obtain the state-space model.

V. RESULTS AND DISCUSSIONS
Based on the real RC Flying Wing specifications, the Flying Wing was successfully modeled in Plane-Maker environment, as illustrated in Fig. 2.Then, flight tests were performed in X-Plane as shown in Fig. 10, using the same flight conditions as on the analytical flight tests.
A model is based on approximate representation of some aspect of a real system, rather than exact values, therefore, its predictions are only as accurate as the data and assumptions used in its construction and operation.X-Plane separates the aircraft into small sections to calculate several aerodynamic factors on each, thus, the dimensioning of the reference model was fundamental to ensure that the entire aircraft was being computed.
X-Plane has proven to be a reasonably accurate tool in predicting the flight characteristics of an aircraft if its input parameters are correct.This is seen in the very close correlation of obtained flight test stall speeds to flight manual data, as well as the correlation of maximum level flight acceleration and speeds to flight manual data.
With the Flying Wing model in flight, it was necessary to adjust the PID Controller, in order to enter the cruise flight phase at a specific velocity and no roll attitude.Thus, once on a cruise flight, the aerodynamic coefficients, propulsive, and aerodynamic forces were obtained and could be compared directly with those calculated by the analytical method.This comparison is shown in Table III.It is important to emphasize that X-Plane considers the wing area as the wing area plus the area of the horizontal stabilizer, differently from the normal way adopted by the aerodynamic concept.Thus, this factor together with the fact that X-Plane also calculates the environment effects on the model, can be the reasons of the differences found.
Some advantages that X-Plane model has over the analytical model were found, such as a digital model may be more easily modified and recalibrated than the analytical model, which will allow increasingly accurate simulations as more data become available; the digital model should provide faster responses to complex maneuvers; and the digital model program has the capability to simulate changes in the aerodynamic performance resulting from environment effects.A series of tests were run on both the analytical and the digital models to compare solutions and to verify that the digital version was accurate and could produce the same results as the mathematical model.The results at trim conditions from both simulations were significantly close, which allow us to conclude that the digital prototype modeled in X-Plane is a reliable model of the Flying Wing aircraft enabling the implementation of HIL simulation as further studies.This method was also proved to be a solid tool for flight data creation, transmission, storage and processing, thus contributing significantly for the aeronautical industry.
The communication and processing flight data between MATLAB/Simulink and X-Plane required a lot of study in communication and information systems and revision of the content available in the literature.One of the biggest challenges was to understand the configuration needed to exchange data between the simulator and the external software (SIL).As well as platform response frequency compatibility for more realistic results.We obtained an acceptable integration between the X-Plane and Simulink platforms through UDP communication using a response frequency of 60.00 rate/s.
The aircraft has unstable modes in the longitudinal degree of freedom.These open loop instabilities make the aircraft challenging to fly manually.Fortunately, since the longitudinal dynamics is controllable, the unstable poles were shifted to the open left side of the s-plane during the design of the controller, ensuring closed-loop stability and enabling flight attitude control.In order to compare the analytical and X-Plane simulations, in-flight tests were performed using controllers to stabilize the unstable dynamic of the model enabling us to control necessary flight condition for the simulations, such as the altitude, velocity and roll attitude.
Therefore, the nonlinear equations of the longitudinal dynamic (8-13) were linearized at trim condition, as described below in S.I. units (19).From this, it was possible to rewrite the system in state-space notation (18).Thus, the control project was designed and optimized.The analytical simulation of the longitudinal dynamics of the aircraft when stimulated by unitary step showed a difference in the percentage of overshoot to the different amplitudes, according to Table IV.Whereas in X-Plane simulation the overshoot tends to decrease with the increase in amplitudes variation.The time until steady-state for both methods are relatively equal.Fig. 11 illustrates the comparison of the simulations described in Table IV, where the blue line represents the analytical response and the red line represents the X-Plane response.Note that the analytical method has smaller overshoots before stabilizing when compared with X-Plane method, which besides the overshoot it has also a small undershoot before stabilizing.The difference between the simulations can be justified by the different algorithms used by the platforms, being the MATLAB a purely numerical simulation, whereas X-Plane, being a flight simulator, that simulates the dynamics of the model in a more realistic way; as well as the difficulties in achieving perfect cruise flight at a constant speed in flight simulations.

CONCLUSION AND FUTURE WORK
Both platforms used for this project are great tools for simulation of early aircraft models to obtain flight data in different conditions, facilitating a prediction of its behavior and performance during the flight before manufacturing a prototype.The flight simulator X-Plane along with MATLAB/Simulink have shown high confidence level and reliability in modeling and simulating, providing strong expandability for flight data creation, collection and processing, and wide application in aircraft project development.
The mathematical model and its analytical simulations have validated the digital model, showing it is consistent and reliable.The model created in Plane-Maker opens up numerous possibilities for applications, enabling in depth studies of Flying Wings Aircraft design, also the testing of several techniques for control and navigation algorithms.Additionally, this simulation platform is a great tool for data generation for embedded systems, software data processing, and storage and simulation of flight recorders.
Developing both a simulation and an analytical model is a powerful method of getting answers to different sets of questions most effectively through one approach vs. the other.
The next development step, which will be tackled in future work, is the Hardware In The Loop (HIL) simulation and other control laws, which in turn, would receive the state variables generated from the simulator and calculate the control signals injected into the simulated plant at different flight conditions.The HIL simulator system simulates the aircraft characteristics, sensor and actuator modeling while communicating with the autopilot hardware.
The acquisition of data from the modeling of an aircraft, and its flight simulation as well as its data processing, could lead to a disruptive approach in aircraft design, potentially reducing time and costs necessary to manufacture a final prototype.

TABLE III COMPARISON
OF FORCES AND AERODYNAMIC COEFFICIENTS FROM BOTH

TABLE IV ANALYSIS
OF STEP RESPONSE OF DIFFERENT AMPLITUDES SIMULATING PITCH ANGLE VARIATION.RESULTS OF ANALYTICAL AND X-PLANE SIMULATIONS.