0% found this document useful (0 votes)
121 views6 pages

Real-Time Simulation System For UAV Based On Matlab/Simulink

Uploaded by

Engr Jawad Zakir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views6 pages

Real-Time Simulation System For UAV Based On Matlab/Simulink

Uploaded by

Engr Jawad Zakir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Real-time Simulation System for UAV Based on Matlab/Simulink

Peng Lu Qingbo Geng


School of Automation School of Automation
Beijing Institute of Technology Beijing Institute of Technology
Beijing, China Beijing, China
E-mail: [email protected] E-mail: [email protected]

Abstract—Aiming at finding an effective way to design and test out real flight tests. For complex missions, UAVs need to
the control law for the UAV flight system, a real-time flight integrate both hardware and software in a seamless manner.
simulation system of Hardware-in-loop (HIL) is constructed. An autopilot can only be certificated by extensive flight test
With the principles of hierarchy and modularity, the UAV to debug both the hardware and the software successfully
nonlinear model, which is built based on the UAV
mathematical model, has been established under the
before deploying the UAV in field. In particular, hardware-
Matlab/Simulink environment. The whole HIL simulation in-the-loop (HIL) simulation testing should be adopted
system is completed with xPC Target system, and is configured whenever possible to validate together both the hardware
with the data of the UAV. Compared with flight test, the result and the software under realistic conditions.
of the simulation validates the rationality and validity of the With the reasons above, the design ideas about aircraft
modeling theories and method. This simulation system plays an model and HIL system based on Simulink was raised, it’s
importance role in designing and testing the control law, and useful to improve the controlling accuracy. Based on the
has made good effect on validating the control law of the UAV. necessity, with research purposes in developing the
autopilot control system, this paper has given an overview
Keywords- unmanned aerial vehicle (UAV); flight simulation;
Hardware-in-loop(HIL)simulation ;Matlab/Simulink
of flight dynamic modeling platform. After representing the
mathematical model using ordinary differential equations, it
discussed an integrative flight dynamics modeling and HIL
I. INTRODUCTION test system. Finally, simulations results are validated to be
In recent years, unmanned aerial vehicles (UAVs) have reliable, and the implementation method was proposed.
received considerable attention in both civilian and military
applications. The increasingly demand of complex missions II. MATHEMATICAL MODEL OF UAV
have brought UAVs more complicated software and The aircraft mathematical model is the basis of the semi-
hardware structure so that the probability of unexpected physical platform for control research. Generally, the
problems is increasing. At present, any successful aircraft implementation of flight dynamics model is a full nonlinear
flight must be credited to their advanced flight dynamics six-degree of freedom rigid-body flight dynamic model
models [1, 2]. In many cases, testing newly developed under the certain coordinate system. Nevertheless, the flight
autopilot systems in a virtual environment is the only way to dynamics models are based on the mathematics model
guarantee absolute safety. Additionally the model would derived from the Newton’s second law [4, 5]. Hence the
allow better repeatability in testing, with controlled flying motion of the aircraft in its six-degree of freedom can be
environments. Hence, in order to control the UAV safely described by a system of ordinary differential equations.
and precisely, ensure the flight reliable and effectively, the Therefore, the mathematical modeling has become the most
flight dynamics model is required. important part in the flight control system.
The control of UAV is usually achieved by controlling
Researchers tend to build the flight models in
the aileron, rudder, elevator and engine throttle, which are
Matlab/Simulink because Matlab/Simulink is a visual
presented as G a ǃ G r ǃ G e and G f . The parameters of the
programming tool, and its modular design makes it used
commonly in the dynamic systems of simulation [3]. UAV such as airspeed V , angle of attack D , sideslip angle E ,
Building models in the environment of Simulink has roll rate p , pitch rate q , yaw rate r , roll angle M , pitch
varieties of advantages, it has good visualization, high angle T , yaw angle \ and three position parameters xe , ye ,
simulation accuracy, and especially the feature of automatic H are considered as state variables. The controlled variable
code generation can ease the work. and the state variables of the UAV mathematical model can
Though the real flight tests are necessary, the be expressed as:
simulation-based testing also plays an important role for the
u [G a G r G e G f ]T
reason that it can save more time and effort than carrying
___________________________________
978-1-4244-9600-6/11/$26.00 ©2011 IEEE

Supported by Deep Exploration Technology and Experimentation Project


(201011080)


x [V D E p q r M T \ xe ye H ]T Fz are force(including gravity, thrust of the engine,
.
aerodynamic force) in x-, y-, and z-axis respectively. L, M,
The UAV mathematical model can be described as the
N present the rolling moment, yawing moment, and pitching
following differential equation, where y presents the output
variables and t presents the time. moment separately. I x , I y , I z are moment of inertia
around the body coordinate axis, and I xz is the product of
­ x f (t , x ,u )
 ®    inertia [6].
¯ y g (t , x ,u ) According to the transformational relation of the aircraft
attitude angle between the inertial and the body coordinate,
As the UAV has six degrees of freedom, the body the Differential equations for the Euler angles has been
coordinate and the earth inertial coordinate are adopted to established as follow:
modeling. The UAV mathematical model is described under
the following assumptions: ­
x Assume the aircraft has a rigid body, omit the elastic °M p  q sin M ˜tan T  r cos M ˜tan T
°
influence on aircraft, and the mass of the aircraft is a  ®T q cos M  r sin M   
constant. ° sin M cos M
x Take the earth as an inertial system; ignore the °\ q r
¯ cos T cos T
impact of the Earth's rotation, that is, regard the earth
to be immobile. Where , ,  are rolling, pitching, and yawing angles in
x Ignore the curvature of the Earth, take the Earth as a earth-fixed reference respectively. And differential
plane. equations for the aircraft coordinates are:
x Assume the acceleration of gravity does not change
with the altitude.
­ xe {u cos T  ( v sin M  w cos M ) sin T }cos\ ( v cos M  w sin M )sin\
x Assume the geometry of the plane is symmetrical,
and the internal mass is well-distributed.  °® ye {u cosT ( v sin M  w cos M )sin T }sin\  ( v cos M  w sin M ) cos\   
° z u sin T ( v sin M  w cos M ) cos T
The controlled variable u is usually combined with ¯ e
aerodynamic and engine data to calculate the present force
and moment of the aircraft. The aerodynamic and engine Equation (2) ~ (5) have described the mathematical
coefficient data are obtained from wind tunnel tests or model of an aircraft. Since force and moment are derived
analytical method. These coefficient data are reasonable from aerodynamic coefficients, the sum force and moment
important for accuracy of modeling. With the calculated are not specified, because for different aircraft, the
aerodynamic/engine force and moment, the solving process coefficient is different. However, the 12 differential
of motion equations can be continued. equations have formed the generic aircraft motion
According to the flight dynamics to analysis the force of simulation process. Therefore, the modularity model can be
the UAV, six equations of motion has been established under constructed by using the Matlab/Simunlink with the
the body coordinate as follow: obtained mathematical model.

­ Fx III. FLIGHT DYNAMIC MODEL IN MATLAB/SIMULINK


°u m
 qw rv
° For the reason that an aircraft’s movement has six-
° Fy degrees of freedom in space, the establishment work would
 ®v  pw ru   
° m face a large system which has a complex structure and a
° Fz great number of aerodynamic data, it's not easy to establish a
° w  pv  qu
whole nonlinear six-degree of freedom UAV model.
¯ m
However, the Matlab has the advantages of doing matrix
calculation, data analysis and model building [7, 8]. In order
to make the model reusable and less complicated, the
­
° p 1 2 2 modular modeling method is adopted. The UAV model was
[ I L  I xz N  ( I x  I y  I z ) I xz pq ( I y I z  I z  I xz ) qr ]
° I I I 2 z developed in Matlab/Simulink, using Aerospace Blockset.
° x z xz
° The relationship between the modules of the UAV model is
 ®q 1 [ M  I xz ( p 2 r 2 ) ( I x  I z ) pr ]    shown in Fig.1.
° Iy
° The initial data of the aircraft model includes: surface
°r 1
[ I xz L  I x N  ( I x2  I x I y  I xz
2 ) pq ( I  I  I ) qr ]
x y z position, throttle data mass of the UAV, center-of-gravity
° I I I 2
¯ x z xz position (C.G), moment of inertia, aerodynamic coefficient,
engine thrust coefficient and so on.
Where u, v, w are three components of airspeed V about
body coordinate x-, y-, and z-axis respectively. Fx , Fy ,


The pitching, rolling, and yawing moment coefficient are
calculated as follows:

pb rb
Cl Cl  Cl  Cl  Cl  Cl G a  Cl G r  Cl G D
0 E p 2V r 2V Ga Gr GaD a
qc rb
Cm Cm0 CmD D CmD 2 D 2 Cmq
V
CmG Ge CmE 2 E 2 Cmr
e 2V
CmG G f
f    
pb rb qc
Cn Cn  Cn E  Cn  Cn  Cn G a  Cn G r  Cn G r  Cn
0 E p 2V r 2V Ga Gr Gr q V

The pitching moment, rolling moment, yawing moment


Figure 1. Structure of the UAV simulation model. are calculated as:
According to the navigation task, the autopilot gives out
the control surface via the control law. The aerodynamic 1 2
L C ˜ UV S
l 2
force/moment module calculates the aerodynamic
1
force/moment via the control data, and then the flight  M Cm ˜ UV 2 S   
dynamics module solves the equations and gives out the 2
state variables. These variables are sent back to the 1 2
N C ˜ UV S
aerodynamic module, the moment module and other n 2
subsystems of the simulation system.
Where q presents the dynamic pressure, U presents the
A. Aerodynamic Module air density, V presents the airspeed of the UAV, S is the
The aerodynamic module includes the aerodynamic area of the wing, b is the length of the wing, and c is the
force and moment module. The aerodynamic force and mean aerodynamic chord. The structure of aerodynamic
moment of the aircraft is the most important part of the net module built in Matlab/Simulink is shown in Fig.2.
force and moment. So a reasonable model of aerodynamic
force and moment is crucial to the UAV simulation model.
The aerodynamic force is divided into side force, drag
and lift while the moment is divided into rolling moment,
pitching moment and yawing moment. This need to use the
feedback data from the simulation system, such as airspeed,
altitude, angle of attack, sideslip angle, center of gravity,
angular velocity, and position of the surfaces. This module
combines these parameters with the aerodynamic coefficient
to calculate and output the results to the flight dynamics
module.
This module is based on certain mathematical model of
aerodynamic calculation. And the lift coefficient, drag
coefficient, side force coefficient are calculated as follows.
3 qc 2
CL CL  CL D  C 3 D  CL C G E  CL G f  CL DG f
0 D LD q V LGeE 2 e Gf DG f

qc
CD CD0 CDD D CDD 2 D 2 CDD3 D3 CDq CDG Gr CDG f G f CDDG DG f (6)
V r f
pb rb
CY CY  CY E  CY  CY  CY G a  CY G r  CY D G r D
0 E p 2V r 2V Ga Gr Gr
The pitching moment, rolling moment, and yawing
moment are calculated as:
Figure 2. Aerodynamic module.
1 2
L C ˜ UV S
L 2
1 B. Atmospheric Environment Module
 D CD ˜ UV 2 S   
2 The performance of the UAV is closely related to the
1 2 temperature, pressure and the density of the atmosphere.
Y C ˜ UV S However, these parameters vary with the time, location,
Y 2
altitude, weather conditions, and different meteorological
condition. Thus the aerodynamics and flight performance of


the UAV will be changed with the state of the atmosphere. risk of the real test [9, 10, 11]. In this hard-ware-in-the loop
In order to test the performance of the UAV, there must be a (HIL) simulation system.
unified atmosphere standard to measure.
A. Hardware System
The atmosphere module provides standard and non-
standard atmospheric temperature, pressure, air density, The hardware system is consists of simulation computer,
sound velocity and other parameters to simulate the target computer, autopilot (including the controller, sensor
atmospheric environment. This module also calculates three and I/O device), and the ground station. Fig.7 has shown the
disturbance velocities with the environmental wind and structure of this simulation system. The simulation
altitude. computer output the reaction of the flight, gives the visible
result, and deal with the simulation data. The target
C. Thrust Module computer is used to download the model, then read the
The input of the propulsion module includes the present control surface data from the I/O interface and solve the
air pressure, temperature, density, wind speed and the equations so that the model can react to the input data. The
controlled variables from the system output. Take use of the autopilot collets the simulated sensor data and gives out the
engine speed and the engine thrust coefficient by using the control data according to the requirement of the flight task
linear interpolation look-up table to obtain the thrust which is set from the ground station.
vector F prop . The output of the module is the thrust force
B. Software System
and moment vectors. The software is the RTW system of Matlab. RTW is one
D. Earth Data Module of the most important parts of Matlab, and it's embedded
This module gives out the standard semidiameter and into the Matlab perfectly. RTW provides the UAV
gravitational acceleration of the present UAV location simulation model a good environment to do the real-time
(longitude, latitude, altitude) by using the WGS-84 earth simulation test and makes the test more convenience. The
model and takes them as the input of the navigation module. xPC system is the additional production of the RTW. This
The magnetic heading angle of UAV can be obtained system takes the use of two computers. The
through the WMM-2000 magnetic model, and it can be used Matlab/Simulink is running on the host computer while the
in navigation of the UAV control system. generated code of the UAV model is running on the target
computer. The host and target computers are linked by the
E. Flight Dynamics Module internet or the serial port to communicate.
This model represents the flight dynamics equations of
motion built under the body coordinate. The task of this
module is to solve the twelve ordinary differential equations
and output the flight parameters. Hence, it is consists of
several submodules. The main force of the UAV are the
aerodynamic force Faero , thrust force F prop and the
gravity G , and the total force can be divide into three
components under the body coordinate: Fx , Fy , Fz . Under
certain assumptions, with the known force, moment,
acceleration, and rotational inertia, the equations of motion
module can be established from the mathematical model
which has been described above into a Simulink block.
IV. HARDWARE-IN-THE LOOP SIMULATION
DEVELOPMENT
Figure 3. Sructure of the HIL simulation system.
This section described the details of a semi-physical
simulation system based on Matlab/Simulink. The complete In the HIL environment, the autopilot functions
6-DOF aircraft model built above is used to simulate identically as in a real flight test, computing control
realistic dynamic behavior of the aircraft. The aircraft model commands to each control actuator and drive the actuator
would run on the xPC Target, and certain actual autopilot model of the control surface. Therefore, a simulation loop
hardware is placed inside the simulation loop in order to test between the simulator and the autopilot is formed. The
and validate both the hardware and the control software. workflow of the simulation system is: the simulation
Meanwhile, the xPC Target has the advantage of real-time computer controls the process of the simulation to start,
simulation, making the flight more similar to the real task, when the initial value of parameters are given, the
solving the flight testing problems and reducing the cost and simulation can be started. Then the target computer solves
the equations of motion of the UAV model, after the


equations are solved out, the related results will be sent to Then chang the set value of the airspeed while it’s flying
the autopilot and the flight attitude display interface. The steady, with the control of the autpliot, the respone of the
host computer receives the flight attitude signal and throttle curve can be obtained in Fig.5. And the response to
reproduces the visible UAV to show the movement of the the throttle is proved to be as correct as the real UAV.
aircraft. Meanwhile, the autopilot calculated the control
value of the surface according to the flight attitude data
from the target computer. Finally, the surface control signals
are sent to the target computer to complete the control loop
of the UAV model simulation.
The state variables from the simulation platform are
used to emulate real sensors. After the data transmitted into
the acceptable form, they are sent to the autopilot via a
serial communication. In the same way, the autopilot also
sends the control data via the serial communication.
In order to visualize the simulation, we adopted the
animation block in the Aerospace blockset. Animation is a
flight simulator framework, which has been widely used in Figure 5. Airspeed response
aircraft simulation research environments. We used
animation block as a visualization tool combining with the
developed 6-DOF simulator. By doing this, animation block
receives the simulated states generated by the xPC Target
computer to view the flight attitude. The closed loop control
performance can be verified and demonstrated by
conducting virtual experiments in advance to a real flight
test.
V. SIMULATION
In order to confirm the function of this simulation
system, the UAV flight control simulation tests were carried
out by using Matlab. The simulation tests are carried out
with the aerodynamic coefficient which is obtained from the
wind tunnel test, the thrust coefficient, the mass of the UAV,
the rotational inertia and etc. And the system should connect
with the autopilot which gives out the navigation and
control law to ensure the tests can be carried out [12]. The Figure 6. Roll, pitch and yaw angular response
following curves are given by taking one kind of UAV as
example.

Figure 4. Altitude response

On condition that the UAV is in a steady state and flying


forward, chang the set value of the altitude, then the
autopilot controls the elevator to chang the altitude. Thus
the respone of the elevator curve is obtained in Fig.4. And Figure 7. Keep-on-line flight
the response to the elevator is proved to correct.


Fig.6 has shown the chang of the attitude angle when the REFERENCES
UAV is processing the keep-on-line flight with a fixed [1] Lucio R.Ribeiro, Neusa Maria F.Oliveira,"UAV Autopilot
initial altittude and speed. From the curve of the roll angle, Controllers Test Platform Using Matlab/Simulink and X-Plane",
we can see that the UAV is getting steady after a short Proceedings of the 40th ASEE/IEEE Frontiers in Education
Conference, Washington, DC, Oct. 23-30,2010, pp. S2H-1 - S2H-6,
vibration, and the yaw angle(heading angle) is getting doi: 10.1109/FIE.2010.5673378.
steady. Meawhile, with the turing processing, the lift could [2] Qing Qu, Xiao-qi Chen, "Integrated Flight Dynamics Modelling for
not afford the gravity so that the UAV may fall down hence Unmanned Aerial Vehicles", International Conference of Mechtronic
the autopilot incresed the elevator and pull up the head of and Embedded Systems and Aplications, Oct. 2008,pp. 570-575,
doi:10.1109/MESA.2008.4735660.
UAV to increase the pich angle. The model gives out the
same response as the real UAV during thiskeep-on-line [3] Chang-qing Chen, Yong Ji, "Modular Aircraft Simulation Platform
Based on Simulink", Int. Conf. Mechantronics and Automation,Xi'an,
flight test. Aug. 4-7, pp. 1451-1459, doi: 10.1109/ICMA.2010.5589162.
Fig.7 is the interface of the gorund station. It has shown [4] Armando A.Rodriguez, Oguzhan Cifdaloz, Mariano Phielipp, and
the result of keep-on-line flight test by using this flight Jeff Dickeson, "Description of a Modeling, Simulation, Animation,
simulation system. The management and control law of and Real-Time Control(MoSART) Environment for a Class of 6-DOF
Dynamical Systems", Proc. Conf. American Control, New York,July
UAV can be tested in this virtual environtment. These 2007, pp. 2515-2520, doi: 10.1109/ACC.2007.4283129.
curves has proved the correction of the UAV simulation [5] Liang Qin , Ma Jiezhong , Zhai Zhengjun, "General-aviation Fight
model and the similarity to the real UAV. Simulation Based on MATLAB", Computer Measurement & Control,
vol. 16, Aug. 2008, pp. 1141-1144.
VI. CONCLUSION [6] He Xiang-zhi, Wang Rong-chun, and Zhou Wei, "Simulation and
A real-time HIL rapid prototyping simulation method Research of UAV Based on MATLAB", Mechanical
Engineering&Automation, vol. 4, Aug. 2010, pp. 32-34.
based on Matlab/Simulink is proposed. First, establish the
[7] M.O.Rauw, A Simulink Environment for Flight Dynamics and Contol
mathematical UAV model under the Matlab/Simulink Analysis-application to the DHC-2'Beaver',Delft Unifersity of
environment according to the characteristic of the UAV. Technology,1993.
Then take use of the Matlab/RTW to translate the UAV [8] Tang Bin, Huang Yi-min, "Matlab-based Simulation for the Entire
simulation model into simulation code accepted by the xPC Flight of UnmannedAerial Vehicles", Journal of Shenyang Institute of
Aeronautical Engineering, vol. 24(1), Feb. 2007, pp. 13-16.
Target, and combine the target computer with the autopilot
[9] Li Ming, Ji Yong, Jia Hong-guang, and Xu Zhi-jun, "Hardware-in-
hardware to form a HIL simulation system. With the work closed-loop Simulation System for Aircraft Based on Rapid
done above, the UAV HIL simulation test has been Simulation Prototype", Optics and Precision Engineering, vol.16, Oct.
accomplished to check the correction of the control law. 2008, pp.1949-1955.
Finally, the result of the UAV HIL simulation test shows [10] Zhang Jian-feng, Wang Xin-min, and Qu Yao-hong, "The Realiation
that: this HIL simulation system could simulate precisely of a Test System of Automatic Pilot Based on MATLAB", CACIS,
vol.24, 2004, pp. 32-38.
aiming at different simulation background and requirement,
[11] Yang Feng, Yuan Xiu-gan, "Matlab-based Dynamic Simulation of
and provided a good system to the flight performance Aircraft Environmental Control System", Journal of System
verification work. Not only has the control and navigation Simulation, vol. 4 No.6,June 2002,pp.782-795.
law been proved to be proper in this simulation system, but [12] Zheng Tao, Gao Zheng-hong, and Kong Xiang-jun, "Unmanned
also has the cost and risk of the flight test been reduced. The Aerial Vehicle System", Flight Dynamics, vol. 20, No. 3,Sep. 2002,
pp. 25-28.
relative deviation between the system and real flight is small
and accurate enough for the control law design requirement.



You might also like