Aircraft Flight Dynamics, Control and Simulation: Using MATLAB and SIMULINK: Cases and Algorithm Approach
Aircraft Flight Dynamics, Control and Simulation: Using MATLAB and SIMULINK: Cases and Algorithm Approach
P REFACE
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Contents 2
C ONTENTS
Preface.............................................................................................................. 1
Contents ........................................................................................................... 2
1.1 Matlab and Simulink Tools for Flight Dynamics Simulation ........................... 30
2 Flight Control............................................................................................ 31
2.1 Attitude and Altitude Control using Root Locus Anlysis ................................. 32
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Contents 3
2.3.4 Results................................................................................................... 69
2.4 Adaptive Control for Yaw Damper and Coordinated Turn ............................. 71
2.4.5 Results................................................................................................... 72
Appendix A ..................................................................................................... 90
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Contents 4
Appendix B ..................................................................................................... 93
References ...................................................................................................... 99
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
List Of Figures 5
L IST O F F IGURES
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
List Of Figures 6
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
List of Tables 7
L IST OF T ABLES
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
List of Tables 8
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 9
Kinematics
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 10
Kinematics
Body-coordinate system
Wind-coordinate system
Ze
xh
yh
zh
Ye
Xe
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 11
Kinematics
xb
center of gravity
yb zb
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 12
Kinematics
Local Vertical
xb
xh
Local Horizon
z
yh
yb b
zh
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 13
Kinematics
xb
V
xw
yw
yb
zw zb
F IGURE 1-4 WIND -AXES SYSTEM AND ITS RELATION TO B ODY AXES
Wind axes system can be transformed to the body axes system using
the following matrix of transformation,
This equation is useful for transforming the aerodynamic lift and drag
forces to body axes system. As can be seen in Figure 1-4, the
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 14
Kinematics
xb
D
V
xw
yw
yb
zw zb
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 15
Kinematics
Equation (1-4) will be used for transforming aerodynamic lift and drag
coefficients to body axes aerodynamic coefficients C X , CY , and CZ .
W
arctan
U
V
arcsin
(1-6)
VT
Equation (2-10) will also be used in the simulation for calculating angle
of attack and sideslip angle from body axes velocity.
1 sin tan cos tan P
0 cos sin Q
sin cos R
(1-8)
0
cos cos
Equations (2-2) and (2-3) are used to obtained the Euler angles
from the angular velocity P , Q , and R . But the above equations have
disadvantage, i.e. can be singular for = ± 90 degrees. It motivates to
use another way that can avoid the singularity. This can be done using
quaternion which will be discussed in the next section.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 17
Kinematics
r1 r2
i arccos
r1 r2
(1-9)
i h i b i h jb i h z b
DCM jh i b jh jb jh z b
z h i b z h jb z h z b
c c c s s
(1-10)
s s c c s s s s c c s c
c s c s s c s s s c c c
where symbol s sin and c cos are used for
abbreviation. Equation (1-10) is identical to Equation (1-1). Therefore
the term DCM will be used together with the transformation matrix
Cbh in the simulation.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 18
Kinematics
q 1 q0 i q1 j q2 k q3 q0 q3
T
q1 q2 (1-11)
i 2 1 , j2 1 , k 2 1
ij k ji k
jk i kj i
(1-12)
ki j ik j
q K q
0 R Q P q0 q0
R 0
P Q q1
1 q1
K
2 Q P 0 R q2 q2
q3
P Q R 0 q3
q3 q2 q1 q0
(1-13)
q P q
1 2 q3 q0 1
Q K
2 q1 q0 q3 q2
R
q0 q1 q2 q3
Q b K q
where 1 q02 q12 q22 q32 is an error coefficient.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 19
Kinematics
q t q 0 q dt
t
t0
(1-14)
Cbh DCM
q02 q12 q22 q32 2 q1q2 q0 q3 2 q1q3 q0 q2
2 q1q2 q0 q3 q02 q22 q12 q32 2 q2 q3 q0 q1 (1-15)
2 q1q3 q0 q2 2 q2 q3 q0 q1 q02 q32 q12 q22
2 q2 q3 q0 q1
arctan 2
q0 q3 q1 q2
2 2 2
arcsin 2 q1q3 q0 q2
2 q1q2 q0 q3
(1-16)
arctan 2
q0 q1 q2 q3
2 2 2
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 20
Kinematics
q0 cos cos cos sin sin sin
2 2 2 2 2 2
q1 sin cos cos cos sin sin
2 2 2 2 2 2
(1-17)
q2 cos sin cos sin cos sin
2 2 2 2 2 2
q3 cos cos sin sin sin cos
2 2 2 2 2 2
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 21
Kinematics
d mVI
F
dV
m b Vb m Vb
dt
b (1-18)
dt
P Q R denotes angular
T
at the body axes frame and b
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 22
Kinematics
FX m U QW RV mU
FY m V RU PW mV
FZ m W PV QU mW
(1-19)
F mU
U X QW RV
F mV
m
V Y RU PW
(1-20)
F mW
m
W Z PV QU
m
= ax a y az = FX mu m FY mv
m FZ mw m .
b
T T
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 23
Kinematics
1.2.2 A N G ULAR M OT I ON
Angular motion of the aircraft is also derived based on the second law
of Newton. The net moment acting on the airplane can be found by
adding up the moments acting on the all parts of the airplane as:
M Ib I I
dH I
b b b (1-22)
dt
I xx J yx J zx
I J xy J zy
J xz I zz
I yy (1-23)
J yz
b I 1 M b I b I b (1-24)
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 24
Kinematics
k11 k31
1
k32
k21
I k12
1
k22 (1-25)
k13 k23 k33
where
k11 I yy I zz J yz2 k12 k21 J yz J xz J xy I zz
I I J xz2 k13 k31 J xy J yz J xz I yy
I k23 k32 J xy J xz J yz I xx
k22 zz xx (1-26)
k33 I J xy2
xx yy
and
I xx I yy I zz I yy J xz2 (1-28)
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 25
Kinematics
M I M Z J xz J xz I xx I yy I zz PQ I zz I zz I yy J xz QR
P X zz
2
I I PR J xz P R
Q Y zz xx
M
2
2
M X J xz M Z I xx I xx I xx I yy J xz PQ J xz I xx I yy I zz QR
I yy I yy I yy (1-29)
R
2
M X M AX M C X M PX
M Y M AY M CY M PY (1-30)
M Z M AZ M CZ M PZ
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 26
Kinematics
or can be written as
FGX 0 0
h
FGY Cb 0 DCM 0
mg mg
(1-32)
FGZ
FAX C X , , H , M , a , e , r ,U ,V ,W , P, Q, R 12 VT2 S
FAY CY , , H , M , a , e , r ,U ,V ,W , P, Q, R 12 VT2 S
FAZ CZ , , H , M , a , e , r ,U ,V ,W , P, Q, R 12 VT2 S
M AX Cl , , H , M , a , e , r ,U ,V ,W , P, Q, R 12 VT2 Sb
(1-33)
M AY Cm , , H , M , a , e , r ,U ,V ,W , P, Q, R 12 VT2 Sc
M AZ Cn , , H , M , a , e , r ,U ,V ,W , P, Q, R 12 VT2 Sb
V S
Symmetric equations:
FAX C X , H C X q q 2Vc R C X e
C V S
1 2
, H CZ q 2Vc
2 T
C Z
e
C V Sc
1 2
FAZ (1-34)
, H Cm q 2Vc
Z q e 2 T
Cm
R e
1 2
M AY m q R e 2 T
e
altitude ( H ).
Asymmetric equations:
FAY CYo CY CYp p 2VbR CYr r 2VbR CY a CY r VT2 S
C
1
2
C
1
M AX lo 2 (1-35)
Cn Cn p p 2VbR Cnr r 2VbR Cn a Cn r VT2 Sb
a r
1
M AZ no 2
a r
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 28
Kinematics
I yy Q I xx I zz PR J xz P 2 R 2 M aY M pY M cY
I zz R I yy I xx PQ J xz P J xzQR M aZ M pZ M cZ
motion become,
m PV
o o QoU o mg cos o cos o FAZ FPZ FCZ
o o o
(1-37)
I I yy Qo Ro J xz PoQo M AX M PX M C X
o o o
I xx I zz Po Ro J xz Po M
zz
Ro M PY M CY
o o o
I I xx PoQo J xz Qo Ro M AZ M PZ M CZ
2 2
AYo o o
(1-38)
yy o o o
U Uo u o d P Po p
V Vo v o d Q Qo q
o d
(1-39)
W Wo w R Ro r
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 29
Kinematics
During trim condition, external force and moment can be written as:
etc
M aX M aX dM aX M pX M pX dM pX
o
(1-40)
M cX M cX dM cX
o o
etc
o
I xx p J xz r dM AX dM PX dM CX (1-44)
I yy q dM AY dM PY dM CY (1-45)
I zz r J xz p dM AZ dM PZ dM CZ (1-46)
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Aircraft Dynamics and 30
Kinematics
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 31
2 F LIGHT C ONTROL
This chapter deals with control design and analysis using classical and
modern techniques. The explanation will be given in examples. First
we will give example of classical control applying for longitudinal and
lateral control (first example), then continuing by modern control
(second to fourth examples).
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 32
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 33
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 34
Dry weight 97 lb
Instrumented 150 lb
x t Ax t Bu t (2-1)
Where
x u v w p q r a b w r rfb c d
T
(2-2)
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 35
The parameter values of matrix A and B for hover and cruise flight
condition presented in Table 2 and Table 3 below.
Xu -0.0505 -0.122
X , Xa -32.2 -32.2
Xr 0 -11
Yv -0.154 -0.155
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 36
Y , Yb 32.2 32.2
Yr 0 -49.2
Lu -0.144 0
Lv 0.143 0
Lw 0 -0.213
Lb 166 213
Mu -0.0561 0
Mv -0.0585 0
Mw 0 0.0728
Ma 82.6 108
Ba 0.368 0.419
Bd 0.71 0.664
Ab -0.189 -0.176
Ac 0.644 0.577
Zb -131 0
Za -9.75 0
Zw -0.614 -1.01
Zr 0.93 0
Zp 0 11
Zq 0 49.2
Np -3.53 0
Nv 0.0301 0.401
Nw 0.0857 0
Nr -4.13 -3.9
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 37
Kr 2.16 2.18
M col 0 6.98
N col -3.33 0
Yped 0 11.23
p 0.0991 0.0589
f 0.046 0.0346
s 0.342 0.259
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 38
x u v w p q r rfb a b c d
T
(2-4)
Using this new state vector, we have new model with the matrices A
and B are as follows (Eqs. 28 and 29),
Xu 0 g 0
0 0
0 0 0 0 0 0 0 Xa 0 0
Yv 0 0 0 0 g 0 0 0 0 Yb 0
0 0
0 Zw 0 0 Zr 0 0 0 0 Za Zb 0
Lu 0
M u 0
Lv Lw 0 0 0 0 0 0 0 0 Lb 0
Mv Mw 0 0 0 0 0 0 0 Ma 0 0
0 0
0 0
Nv Nw Np 0 Nr 0 0 0 N rfb 0 0 0
A =
0 0 1 0 0 0 0 0 0 0 0 0
0 0
0 0
0 0 0 1 0 0 0 0 0 0 0 0 (2-5)
0 0 0 0 1 0 0 0 0 0 0 0
0 0
0 0 0 0 Kr 0 0 0 K rfb 0 0 0
0 1/ f Ab / f Ac / f 0
0 Bd / f
0 0 0 0 0 0 0 0 0
1 0 Ba / f 1/ f
0 0 0 0 0 0 0 0
0 1/ s 0
0 1 / s
0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0
0 0
0 0
0 0
0 Y ped
0 Z col
0 0
0 0
0 M col
0 0
0 0
0 N col
0 0
0 N ped
B
0 0
0 0
(2-6)
0 0
0 0
0 0
0 0
0 0
Alat / f Alon / f 0
Blat / f 0
0
Blon / f
0
0 Clon / f 0
D / 0
0
lat s 0 0
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 39
2.2.3 P ATH G EN ER AT OR
The path generator was developed by a simple idea, i.e. setting the
trajectory/path in the inertial reference and then finding its velocity
profile. This method can be expressed in the following relation:
x x t x t Vx t
y y t and y t Vy t
z z t z t Vz t
(2-7)
X E 1 0 0 X I
YE 0 1 0 YI
Z 0 0 1 Z
(2-9)
E I
or inversely:
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 40
X I 1 0 0 X E
YI 0 1 0 YE
Z 0 0 1 Z
(2-10)
I E
Trajectory
200
150
100
Altitude [ft]
50
-50
-100
500
400
300
300
200
200 100
100 0
-100
0
-200
-100 -300
North [ft]
East [ft]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 41
Velocity Profile
60
40
20
Vx [ft/s]
0
-20
-40
-60
0 2 4 6 8 10 12 14 16 18 20
Time [s]
Velocity Profile
60
40
20
Vy [ft/s]
0
-20
-40
-60
0 2 4 6 8 10 12 14 16 18 20
Time [s]
Velocity Profile
60
40
20
Vz [ft/s]
0
-20
-40
-60
0 2 4 6 8 10 12 14 16 18 20
Time [s]
Trajectory
200
150
100
Altitude [ft]
50
-50
-100
800
600
800
700
400 600
500
400
200 300
200
0 100
0
-100
-200 -200
North [ft]
East [ft]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 42
Velocity Profile
60
40
20
Vx [ft/s]
0
-20
-40
-60
0 10 20 30 40 50 60
Time [s]
Velocity Profile
60
40
20
Vy [ft/s]
0
-20
-40
-60
0 10 20 30 40 50 60
Time [s]
Velocity Profile
60
40
20
Vz [ft/s]
0
-20
-40
-60
0 10 20 30 40 50 60
Time [s]
Trajectory
200
150
100
Altitude [ft]
50
-50
-100
500
400
300
300
200
200 100
100 0
-100
0
-200
-100 -300
North [ft]
East [ft]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 43
Velocity Profile
60
40
20
Vx [ft/s]
0
-20
-40
-60
0 5 10 15 20 25 30 35 40
Time [s]
Velocity Profile
60
40
20
Vy [ft/s]
0
-20
-40
-60
0 5 10 15 20 25 30 35 40
Time [s]
Velocity Profile
60
40
20
Vz [ft/s]
0
-20
-40
-60
0 5 10 15 20 25 30 35 40
Time [s]
J x t f Hx t f xT t Q t x t uT t R t u t dt
1 T 1 tf
(2-11)
2 2 t0
x t A t x t B t u t (2-12)
The solution of this LQR problem can be seen in [6], in the form of
optimal gain matrix K and the optimal control law. The optimal gain
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 44
u * t R 1 t BT t K t x t
K opt t x t
(2-14)
if we set xref t constant then the time derivative of Eqs. (39) can be
simplified to be
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 45
xerror t xref t x t
xerror t yerror t yref t y t
zerror t zref t z t
(2-19)
where xerror , yerror , zerror are error in x, y, and z position in body axis
frame. Applying equation (41) to equation (42) yields
xerror t 1 x t
x error t yerror t 2 y t
zerror t 3 z t
(2-20)
1u t
x error t 2 v t
3 w t
(2-21)
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 46
where
xaug xerror x
T
yerror zerror (2-23)
0 0.1 I 3 0311
A aug 33
0143 A
(2-24)
0
B aug 34
B
(2-25)
t0
(2-26)
with
Q 0.01 I17
R 0.01 I 4
(2-27)
%==================================================%
% Simulation Yamaha R-50 Helicopter %
% Author : Singgih S. Wibowo %
% NIM : 23604003 %
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 47
%==================================================%
% Physical Parameter of The Yamaha R-50 %
%==================================================%
% Rotor speed 850 rpm %
% Tip speed 449 ft/s %
% Dry weight 97 lb %
% Instrumented 150 lb %
% Engine Single cylinder, 2-stroke %
% Flight autonomy 30 minutes %
%==================================================%
clear;
%===================================%
% A matrix [Hover mode; Cruise mode]%
%===================================%
Xu = [ -0.0505; -0.122 ];
Xth = [ -32.2 ; -32.2 ];
Xa = [ -32.2 ; -32.2 ];
Xr = [ 0 ; -11 ];
Yv = [ -0.154 ; -0.155 ];
Yph = [ 32.2 ; 32.2 ];
Yb = [ 32.2 ; 32.2 ];
Yr = [ 0 ; -49.2 ];
Lu = [ -0.144 ; 0 ];
Lv = [ 0.143 ; 0 ];
Lw = [ 0 ; -0.213 ];
Lb = [ 166 ; 213 ];
Mu = [ -0.0561; 0 ];
Mv = [ -0.0585; 0 ];
Mw = [ 0 ; 0.0728];
Ma = [ 82.6 ; 108 ];
Ba = [ 0.368 ; 0.419 ];
Bd = [ 0.71 ; 0.664 ];
Ab = [ -0.189 ; -0.176 ];
Ac = [ 0.644 ; 0.577 ];
Zb = [-131 ; 0 ];
Za = [ -9.75 ; 0 ];
Zw = [ -0.614 ; -1.01 ];
Zr = [ 0.93 ; 0 ];
Zp = [ 0 ; 11 ];
Zq = [ 0 ; 49.2 ];
Np = [ -3.53 ; 0 ];
Nv = [ 0.0301; 0.401 ];
Nw = [ 0.0857; 0 ];
Nr = [ -4.13 ; -3.9 ];
Nrfb = [ -33.1 ; -26.4 ];
Kr = [ 2.16 ; 2.18 ];
Krfb = [ -8.26 ; -7.79 ];
g = 32.2; %gravity constant = 32.2 ft/s^2
%===================================%
% B matrix [Hover mode; Cruise mode]%
%===================================%
Blat = [ 0.14 ; 0.124 ];
Blon = [ 0.0138; 0.02 ];
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 48
%===================================%
% Choose fly mode
% 1 = Hover
% 2 = Cruise
%===================================%
Mode = 2;
if Mode == 1
Mtext = '[Hover Mode]';
elseif Mode == 2
Mtext = '[Cruise Mode]';
end
A = [Xu(Mode) 0 0 0 0 0 0 -g 0 0 ...
Xa(Mode) 0 0 0;
0 Yv(Mode) 0 0 0 0 g 0 0 0 ...
0 Yb(Mode) 0 0;
0 0 Zw(Mode) 0 0 Zr(Mode) 0 0 0 0 ...
Za(Mode) Zb(Mode) 0 0;
Lu(Mode) Lv(Mode) Lw(Mode) 0 0 0 0 0 0 0 ...
0 Lb(Mode) 0 0;
Mu(Mode) Mv(Mode) Mw(Mode) 0 0 0 0 0 0 0 ...
Ma(Mode) 0 0 0;
0 Nv(Mode) Nw(Mode) Np(Mode) 0 Nr(Mode) 0 0 0 Nrfb(Mode) ...
0 0 0 0;
0 0 0 1 0 0 0 0 0 0 ...
0 0 0 0;
0 0 0 0 1 0 0 0 0 0 ...
0 0 0 0;
0 0 0 0 0 1 0 0 0 0 ...
0 0 0 0;
0 0 0 0 0 Kr(Mode) 0 0 0 Krfb(Mode) ...
0 0 0 0;
0 0 0 0 -1 0 0 0 0 0 ...
-1/Tau_f(Mode) Ab(Mode)/Tau_f(Mode) Ac(Mode)/Tau_f(Mode) 0;
0 0 0 -1 0 0 0 0 0 0 ...
Ba(Mode)/Tau_f(Mode) -1/Tau_f(Mode) 0 Bd(Mode)/Tau_f(Mode);
0 0 0 0 -1 0 0 0 0 0 ...
0 0 -1/Tau_s(Mode) 0;
0 0 0 -1 0 0 0 0 0 0 ...
0 0 0 -1/Tau_s(Mode)];
B = [0 0 0 0
0 0 Yped(Mode) 0
0 0 0 Zcol(Mode)
0 0 0 0
0 0 0 Mcol(Mode)
0 0 Nped(Mode) Ncol(Mode)
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
Alat(Mode)/Tau_f(Mode) Alon(Mode)/Tau_f(Mode) 0 0
Blat(Mode)/Tau_f(Mode) Blon(Mode)/Tau_f(Mode) 0 0
0 Clon(Mode)/Tau_s(Mode) 0 0
Dlat(Mode)/Tau_s(Mode) 0 0 0];
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 49
%===========================================================
% X = [u v w p q r phi theta psi rfb a b c d]'
% U = [delta_lat delta_lon delta_ped delta_col]'
%===========================================================
alp = 5;
A_aug = [0 0 0 -alp 0 0 zeros(1,11)
0 0 0 0 -alp 0 zeros(1,11)
0 0 0 0 0 -alp zeros(1,11)
zeros(14,3) A];
B_aug = [zeros(3,4); B];
C = eye(14);
D = B*0;
%===========================================================
% Linear Quadratic Regulator is computed here
% We defined The Performance Cost by
% J = INTEGRAL (X^2 + U^2);
%===========================================================
weight = 1;
Q = weight*eye(17);
R = weight*eye(4);
K = lqr(A_aug,B_aug,Q,R);
%===========================================================
I to E transform
V [f t/s] Vx,Vy ,Vz u,v ,w u,v ,w Vx,Vy ,Vz Inertial Earth Vel_Earth_Axes (f t/s)
u,v ,w error Pos_Earth_Axes (f t)
p,q,r
Pos [f t] ph,th,psi Control Input input Control_Input (rad)
State phi,theta,psi ph,th,psi X,Y ,Z Inertial Earth
Attitude (rad)
Path Generator Inertial to Body
Optimal Controller State I to E transform1 Ref _V_E_Axes (f t/s)
Local Horizon Frame Body to Inertial
Yamaha R50 Dynamics Ref _Pos_E_Axes (f t)
Write to File
cos
Step 50 1
sin V [ft/s]
1
2
Step1 s
Pos [ft]
0
Vz
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 50
2 Eul2DCM
Matrix
ph,th,psi 1
Multiply
1 Earth Inertial u,v,w
Vx,Vy,Vz
E to I transform
1
1
s
error -K* u 1
2 Control Input
LQ Gain Saturation
State
-11
v_ini
49.2
u_ini
1
u,v,w
2
p,q,r
x' = Ax+Bu
1
y = Cx+Du 3
input
phi,theta,psi
State-Space Model
of Yamaha R50
4
State
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 51
u,v,w
1 u,v ,w
Vx,Vy ,Vz 1
T
2 Eul2DCM u DCM Vx,Vy,Vz
ph,th,psi
1
2
s
X,Y,Z
1 -1 1
Inertial Earth
-1
5
Yamaha_R50_OPTCON_vdata
Ref_V_E_Axes (ft/s) 1
Vel_Earth_Axes (ft/s) To File
Yamaha_R50_OPTCON_verrdata
To File5
6
Yamaha_R50_OPTCON_xdata
Ref_Pos_E_Axes (ft) 2
Pos_Earth_Axes (ft) To File2
Yamaha_R50_OPTCON_errdata
To File1
3 -K- Yamaha_R50_OPTCON_condata
Control_Input (rad)
rad2deg To File3
4 -K- Yamaha_R50_OPTCON_atdata
Attitude (rad)
rad2deg To File4
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 52
The following Matlab code will plot figures of the simulation results.
%==================================================%
% This program will plotting simulation results %
% of Path-Tracking Controller for R-50 Helicopter %
%==================================================%
% Loading data From %
% [1] Yamaha_R50_OPTCON_vdata.mat %
% [2] Yamaha_R50_OPTCON_xdata.mat %
% [3] Yamaha_R50_OPTCON_condata; %
% [4] Yamaha_R50_OPTCON_atdata; %
% [5] Yamaha_R50_OPTCON_verrdata; %
% [6] Yamaha_R50_OPTCON_errdata; %
% then plotting them %
%==================================================%
% Author : Singgih S. Wibowo %
% NIM : 23604003 %
% Version 2.1, 18 Des 2004 %
% 1st modification, 21 Feb 2007 %
%==================================================%
load Yamaha_R50_OPTCON_vdata;
load Yamaha_R50_OPTCON_xdata;
load Yamaha_R50_OPTCON_condata;
load Yamaha_R50_OPTCON_atdata;
load Yamaha_R50_OPTCON_verrdata;
load Yamaha_R50_OPTCON_errdata;
Tmax = X(1,end);
%Trajectory History
figure(2);
subplot(311);
plot(X(1,:),X(2,:),'b',X(1,:),X(5,:),'r','LineWidth',2);
xlabel('time [s]'); ylabel('East [ft]'); title('X-position');
legend('X_r_e_f','X_o_u_t');
axis([0 Tmax -200 800]);
%grid on;
subplot(312);
plot(X(1,:),X(3,:),'b',X(1,:),X(6,:),'r','LineWidth',2);
xlabel('time [s]'); ylabel('North [ft]'); title('Y-position');
legend('Y_r_e_f','Y_o_u_t');
axis([0 Tmax -200 800]);
%grid on;
subplot(313);
plot(X(1,:),X(4,:),'b',X(1,:),X(7,:),'r','LineWidth',2);
xlabel('time [s]'); ylabel('Altitude [ft]'); title('Z-position');
legend('Z_r_e_f','Z_o_u_t');
axis([0 Tmax -100 100]);
%grid on;
%Velocity History
figure(3);
subplot(311);
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 53
plot(V(1,:),V(2,:),'b',V(1,:),V(5,:),'r','LineWidth',2);
xlabel('time [s]'); ylabel('V_x [ft/s]'); title('X-Velocity');
legend('V_x _r_e_f','V_x _o_u_t');
axis([0 Tmax -60 60]);
%grid on;
subplot(312);
plot(V(1,:),V(3,:),'b',V(1,:),V(6,:),'r','LineWidth',2);
xlabel('time [s]'); ylabel('V_y [ft/s]'); title('Y-Velocity');
legend('V_y _r_e_f','V_y _o_u_t');
axis([0 Tmax -60 60]);
%grid on;
subplot(313);
plot(V(1,:),V(4,:),'b',V(1,:),V(7,:),'r','LineWidth',2);
xlabel('time [s]'); ylabel('V_z [ft/s]'); title('Z-velocity');
legend('V_z _r_e_f','V_z _o_u_t');
axis([0 Tmax -60 60]);
%grid on;
%Attitude History
figure(5);
subplot(311);
plot(Atd(1,:),Atd(2,:),'b','LineWidth',2);
xlabel('time [s]'); ylabel('\phi [deg]'); title('roll angle');
axis([0 Tmax -60 60]);
%grid on;
subplot(312);
plot(Atd(1,:),Atd(3,:),'b','LineWidth',2);
xlabel('time [s]'); ylabel('\theta [deg]'); title('pitch angle');
axis([0 Tmax -60 60]);
%grid on;
subplot(313);
plot(Atd(1,:),Atd(4,:),'b','LineWidth',2);
xlabel('time [s]'); ylabel('\psi [deg]'); title('yaw angle');
axis([0 Tmax -360 20]);
%grid on;
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 54
xlabel('time [s]');
ylabel('v_e_r_r_o_r [ft/s]');
title('Y Velocity Error');
axis([0 Tmax -100 100]);
%grid on;
subplot(313);
plot(verr(1,:),verr(4,:),'r','LineWidth',2);
xlabel('time [s]');
ylabel('w_e_r_r_o_r [ft/s]');
title('Z Velocity Error');
axis([0 Tmax -100 100]);
%grid on;
2.2.6 N UM ER IC AL R E S ULTS
In this section, we present our numerical experiment result using
MATLAB/Simulink®. The Simulink model as shown in Figure 2-10. We
have carried out three experiments as follow
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 55
Pathref
Pathout
100
80
60
40
20
Altitude [ft]
0
-20
-40
-60
-80
-100
500
400
300
300 200
200 100
100 0
-100
0
-200
-100 -300
North [ft]
East [ft]
X-position
300
Xref
200
Xout
100
East [ft]
0
-100
-200
-300
0 2 4 6 8 10 12 14 16 18 20
time [s]
Y-position
500
Yref
400
Yout
300
North [ft]
200
100
0
-100
0 2 4 6 8 10 12 14 16 18 20
time [s]
Z-position
20
Zref
10 Zout
Altitude [ft]
-10
-20
0 2 4 6 8 10 12 14 16 18 20
time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 56
X-Velocity
60
Vx ref
40
Vx out
20
Vx [ft/s]
0
-20
-40
-60
0 2 4 6 8 10 12 14 16 18 20
time [s]
Y-Velocity
60
Vy ref
40
Vy out
20
Vy [ft/s]
0
-20
-40
-60
0 2 4 6 8 10 12 14 16 18 20
time [s]
Z-velocity
60
Vz ref
40
Vz out
20
Vz [ft/s] 0
-20
-40
-60
0 2 4 6 8 10 12 14 16 18 20
time [s]
20 20
10 10
lon [deg]
[deg]
0 0
lat
-10 -10
-20 -20
-30 -30
0 5 10 15 20 0 5 10 15 20
time [s] time [s]
20 20
10 10
[deg]
col [deg]
0 0
ped
-10 -10
-20 -20
-30 -30
0 5 10 15 20 0 5 10 15 20
time [s] time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 57
roll angle
60
40
20
[deg]
0
-20
-40
-60
0 2 4 6 8 10 12 14 16 18 20
time [s]
pitch angle
60
40
20
[deg]
0
-20
-40
-60
0 2 4 6 8 10 12 14 16 18 20
time [s]
yaw angle
0
-100
[deg]
-200
-300
0 2 4 6 8 10 12 14 16 18 20
time [s]
X Position Error
50
Xerror [ft]
-50
0 2 4 6 8 10 12 14 16 18 20
time [s]
Y Position Error
50
Yerror [ft]
-50
0 2 4 6 8 10 12 14 16 18 20
time [s]
Z Position Error
50
Zerror [ft]
-50
0 2 4 6 8 10 12 14 16 18 20
time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 58
Pathref
Pathout
100
80
60
40
20
Altitude [ft]
0
-20
-40
-60
-80
-100
800
600
800
700
400 600
500
400
200 300
200
0 100
0
-100
-200 -200
North [ft]
East [ft]
X-position
800
Xref
600
Xout
East [ft]
400
200
-200
0 10 20 30 40 50 60
time [s]
Y-position
800
Yref
600
Yout
North [ft]
400
200
-200
0 10 20 30 40 50 60
time [s]
Z-position
100
Zref
50 Zout
Altitude [ft]
-50
-100
0 10 20 30 40 50 60
time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 59
X-Velocity
60
Vx ref
40
Vx out
20
Vx [ft/s]
0
-20
-40
-60
0 10 20 30 40 50 60
time [s]
Y-Velocity
60
Vy ref
40
Vy out
20
Vy [ft/s]
0
-20
-40
-60
0 10 20 30 40 50 60
time [s]
Z-velocity
60
Vz ref
40
Vz out
20
Vz [ft/s]
0
-20
-40
-60
0 10 20 30 40 50 60
time [s]
20 20
10 10
lon [deg]
[deg]
0 0
lat
-10 -10
-20 -20
-30 -30
0 10 20 30 40 50 60 0 10 20 30 40 50 60
time [s] time [s]
20 20
10 10
[deg]
col [deg]
0 0
ped
-10 -10
-20 -20
-30 -30
0 10 20 30 40 50 60 0 10 20 30 40 50 60
time [s] time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 60
roll angle
60
40
20
[deg]
0
-20
-40
-60
0 10 20 30 40 50 60
time [s]
pitch angle
60
40
20
[deg]
0
-20
-40
-60
0 10 20 30 40 50 60
time [s]
yaw angle
0
-100
[deg]
-200
-300
0 10 20 30 40 50 60
time [s]
X Position Error
100
50
Xerror [ft]
-50
-100
0 10 20 30 40 50 60
time [s]
Y Position Error
100
50
Yerror [ft]
-50
-100
0 10 20 30 40 50 60
time [s]
Z Position Error
100
50
Zerror [ft]
-50
-100
0 10 20 30 40 50 60
time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 61
Pathref
Pathout
300
250
200
150
Altitude [ft]
100
50
-50
-100
500
400
300
300 200
200 100
100 0
-100
0
-200
-100 -300
North [ft]
East [ft]
X-position
800
Xref
600
Xout
East [ft]
400
200
-200
0 5 10 15 20 25 30 35 40
time [s]
Y-position
800
Yref
600
Yout
North [ft]
400
200
-200
0 5 10 15 20 25 30 35 40
time [s]
Z-position
300
Zref
200 Zout
Altitude [ft]
100
-100
0 5 10 15 20 25 30 35 40
time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 62
X-Velocity
60
Vx ref
40
Vx out
20
Vx [ft/s]
0
-20
-40
-60
0 5 10 15 20 25 30 35 40
time [s]
Y-Velocity
60
Vy ref
40
Vy out
20
Vy [ft/s]
0
-20
-40
-60
0 5 10 15 20 25 30 35 40
time [s]
Z-velocity
60
Vz ref
40
Vz out
20
Vz [ft/s]
0
-20
-40
-60
0 5 10 15 20 25 30 35 40
time [s]
20 20
10 10
lon [deg]
[deg]
0 0
lat
-10 -10
-20 -20
-30 -30
0 5 10 15 20 25 30 35 40 0 5 10 15 20 25 30 35 40
time [s] time [s]
20 20
10 10
[deg]
col [deg]
0 0
ped
-10 -10
-20 -20
-30 -30
0 5 10 15 20 25 30 35 40 0 5 10 15 20 25 30 35 40
time [s] time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 63
roll angle
60
40
20
[deg]
0
-20
-40
-60
0 5 10 15 20 25 30 35 40
time [s]
pitch angle
60
40
20
[deg]
0
-20
-40
-60
0 5 10 15 20 25 30 35 40
time [s]
yaw angle
0
-200
[deg]
-400
-600
0 5 10 15 20 25 30 35 40
time [s]
X Position Error
50
Xerror [ft]
-50
0 5 10 15 20 25 30 35 40
time [s]
Y Position Error
50
Yerror [ft]
-50
0 5 10 15 20 25 30 35 40
time [s]
Z Position Error
50
Zerror [ft]
-50
0 5 10 15 20 25 30 35 40
time [s]
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 64
can be applied for full states feedback where in the real application
may not applicable since only a part of states can be fed back.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 65
x Ax Bu (2-28)
where
x u v w p q r
T
(2-29)
The variables , , and are the three velocities with respect to the
body frame, which is shown in Figure 2-36 below.
The variables , , and are the roll, pitch, and yaw rates, � and � are
pitch and roll respectively.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 66
%=========================================================================%
% LQG design for 60 degree aircraft turn
% Copyright 1986-2002 The MathWorks, Inc.
% $Revision: 1.5 $ $Date: 2002/04/10 06:40:38 $
%=========================================================================%
% State vector => x = [u,v,w,p,q,r,theta,phi]
% u,v,w: linear velocities
% p,q,r: roll, pitch, yaw rates
% theta: pitch angle
% phi : bank angle
% Control vector => u = [u1,u2,u3,u4]
%=========================================================================%
% Modified by SSW, 21 Feb 2007 for education purpose
%=========================================================================%
% Linear dynamics
A = [-0.0404 0.0618 0.0501 -0.0000 -0.0005 0.0000 0 0
-0.1686 -1.1889 7.6870 0 0.0041 0 0 0
0.1633 -2.6139 -3.8519 0.0000 0.0489 -0.0000 0 0
-0.0000 -0.0000 -0.0000 -0.3386 -0.0474 -6.5405 0 0
-0.0000 0.0000 -0.0000 -1.1288 -0.9149 -0.3679 0 0
-0.0000 -0.0000 -0.0000 0.9931 -0.1763 -1.2047 0 0
0 0 0.9056 0 0 -0.0000 0 0
0 0 -0.0000 0 0.9467 -0.0046 0 0];
%=========================================================================%
% Add integrator state dz/dt = -phi
% Augmanted vector => x_aug = [z,u,v,w,p,q,r,theta,phi]
% Augmanted control => u_aug = [0,u1,u2,u3,u4]
%=========================================================================%
A_aug = [zeros(1,8) -1;
zeros(8,1) A];
B_aug = [zeros(1,4) ; B];
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 67
%=========================================================================%
% LQR gain synthesis
%=========================================================================%
Q = blkdiag(1,0.1*eye(6),1000,1);
R = diag([10,50,1,1]);
K_lqr = lqr(A_aug,B_aug,Q,R);
W rite to File
20 1
s+20 s
x' = Ax+Bu
K*u U U(E)
phi_ref Integrator y = Cx+Du
Linearized
LQR Gain Dynamics
3
Aircraft_Turn_State
States
1 To File
Roll_Ref
U U(E) Aircraft_Turn_Error
To File5
2 Aircraft_Turn_Control
Control
To File1
The following Matlab code will plot figures of the simulation results.
%==================================================%
% This program will plotting simulation results %
% of Turn-Coordinator Controller for Aircraft %
%==================================================%
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 68
load Aircraft_Turn_State;
load Aircraft_Turn_Error;
load Aircraft_Turn_Control;
Tmax = state(1,end);
%==================================================%
%Aircraft Attitude, Pitch and Roll
%==================================================%
figure(1);
set(1,'Name','Attitude History');
subplot(211);
plot(state(1,:),state(8,:)*180/pi,'b','LineWidth',2);
set(gca,'FontSize',14);
xlabel('Time (s)');
ylabel('\theta (deg)');
title('Pitch Attitude History');
grid on;
subplot(212);
plot(state(1,:),state(10,:)*180/pi,'r',...
state(1,:),state(9,:)*180/pi,'b','LineWidth',2);
set(gca,'FontSize',14);
xlabel('Time (s)');
ylabel('\phi (deg)');
title ('Roll Attitude History');
legend ('roll ref','roll actual');
grid on;
%==================================================%
%Aircraft Tracking Error
%==================================================%
figure(2);
set(2,'Name','Tracking Error');
plot(error(1,:),error(2,:)*180/pi,'b','LineWidth',2);
set(gca,'FontSize',14);
xlabel('Time (s)');
ylabel('\phi_r_e_f - \phi (deg)');
title('Roll Tracking-Error History');
grid on;
%==================================================%
%Aircraft Control Input
%==================================================%
figure(3);
set(3,'Name','Control Input');
plot(control(1,:),control(2,:)*180/pi,'b',...
control(1,:),control(3,:)*180/pi,'g',...
control(1,:),control(4,:)*180/pi,'r',...
control(1,:),control(5,:)*180/pi,'m',...
'LineWidth',2);
set(gca,'FontSize',14);
xlabel('Time (s)');
ylabel('Control Input (deg)');
title('Control Input History');
grid on;
legend ('control 1','control 2','control 3','control 4');
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 69
2.3.4 R E S ULT S
This figure shows the response of to the 60° step command. Figure 4-
58: Tracking the Roll Step Command As you can see, the system tracks
the commanded 60° roll in about 60 seconds. Another goal was to
keep , the pitch angle, relatively small. This figure shows how well the
LQG controller did. Figure 4-59: Minimizing the Displacement in the
Pitch Angle, Theta Finally, this figure shows the control inputs. Figure
4-60: The Control Inputs for the LQG Tracking Problem Try adjusting
the Q and R matrices in lqrdes.m and inspecting the control inputs and
the system states, making sure to rerun lqrdes to update the LQG gain
matrix K. Through trial and error, you may improve the response time
of this design. Also, compare the linear and nonlinear designs to see
the effects of the nonlinearities on the system performance.
x 10
-3 Pitch Attitude History
2
(deg)
0
0 10 20 30 40 50 60
Time (s)
Roll Attitude History
100
roll ref
(deg)
roll actual
50
0
0 10 20 30 40 50 60
Time (s)
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 70
50
40
- (deg)
30
20
ref
10
-10
0 10 20 30 40 50 60
Time (s)
-1
0 10 20 30 40 50 60
Time (s)
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 71
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 72
2.4.5 R E S ULT S
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Control 73
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 74
3 F LIGHT S IMULATION
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 75
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 76
3.2.1.1 D E FI NI NG TH E PR OBLE M
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 77
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 78
file. Figure E.2 show the 3D model of virtual lake and hill. The file
name of the model is 3D_lake (.dwg). This name is also preserved for
the 3D studio file.
After running the V-Realm Builder, the next step is opening the 3D
Studio files that have already been created, and then editing the files.
The procedures are as follows:
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 79
(1) Click the open button, or choose the menu: File\Open, or push
the keyboard buttons: Ctrl + O.
(2) The open dialog window will then appear. Choose the file type of
3D Studio and file name: wise8craft.3ds.
(3) The 3D model of WiSE-8 craft will then appear as shown in Figure
E. . ‘e a e Group to Wise y dou le li ki g the ord
Group a d the typi g the e a e Wise .
(6) Add four Tra sfor for Wise y li ki g the Tra sfor utto
(8) Mo e the Wise to the hild of the fourth Tra sfor , see agai
Figure E.7. This action can be carried out by the following step:
utti g the Wise , a ti ate the hildre y poi ti g the
ursor to hildre of the fourth Tra sfor or Wise_Ya a d
then click once, and (3) click the paste button.
F IGURE 3-7 R ENAMING THE FOUR TRANSFORM AND MOVING THE W ISE
Input for the orientation is X axis, Y axis, Z axis, and Rotation (degree).
The X, Y and Z axis define the vector of rotation axes in VR axes
system, while the Rotation defines the rotation angle in degree. The
position parameter defines the position of the observer. Inputs for the
position are X, Y and Z position with respect to VR axes system.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 82
In this example, we will show how to make an observer that will flying
with the WiSE craft, located at [20,0,7] meter from the craft and the
orientation is 73 degrees, see Figure E.12.
To make this observer, set the location as [20,0,7] and orientation as [0,1,0,73]. Then
a e this o ser er as Fro t ‘ight O ser er . The result is sho i Figure E. . Note
that the Tra sfor a d Vie poi t ha e ee re a ed as ‘ightFro t_O ser er .
Using the same procedures, we made other observers and add the lake and hill model.
The result is shown in Figure E.14.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 83
(1) Open Simulink Library Browser. Then create new model. The new
model window will appear. Drag the VR Sink block available in
the Virtual Reality Toolbox into the new model window, see
Figure E.15.
(2) Double click the block. The parameters window will then appear,
see Figure E.16. Then click the Browse button. Select the VR file
we already made, ise raftV‘. rl . The i do ill sho the
VRML tree, see Figure E.17.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 84
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 85
(4) Click the Block Parameter button ( ). This action will show the
parameter window as already shown in Figure E.17. In the VRML
tree, click the translation parameter for Wise_Translation, then
click the rotation for Wise_Roll, Wise_Pitch, and Wise_Yaw, see
Figure E.19. Click also the translation parameter for the
Right_Observer, RightFront_Observer, Front_Observer,
LeftFront_Oberver, Left_Observer, LeftBehind_Oberver,
Behind_Observer, and RightBehind_Observer. Choose rotation
parameter for StaticRight_A_Observer, StaticRight_B_Observer,
and StaticRight_C_Observer. Finally click OK button.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 86
(5) Back to Simulink model window. The VR Sink will show the VR
parameter as shown in Figure E.20. Save this Simulink model as
Tes_VR_World. Now the VR Sink is ready to be connected to
Simulink model of WiSE-8 motion simulation. As already
discussed in the beginning of Appendix E, the motion parameters
needed for visualization are position and attitude angle.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 87
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 88
1 0 0
C 0 0 1
h
(3-1)
0 1 0
VR
LH to VR matrix
[3x3] Matrix
1
Multiply
<signal2> X Y Z [m] (0 1 0)
1 5
200
Motion Bus atan2 Angle A [rad]
<signal3> Xo [m]
25
(1 0 0) Zo [m]
2
roll angle [rad] (0 1 0)
6
600
atan2 Angle B [rad]
Xo [m]1
(0 0 1) 25
3 Zo [m]1
pitch angle [rad]
(0 1 0)
7
[0 -1 0] 1100
4 atan2 Angle C [rad]
Xo [m]2
25
yaw angle [rad]
Zo [m]2
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Flight Simulation 89
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix A Appendix
90 A
A PPENDIX A
Matrix commands
1 2 3
[1 2 3; 4 5 6] create the matrix
4 5 6
zeros(n) creates an nxn matrix whose elements are zero.
zeros(m,n) creates a m-row, n-column matrix of zeros.
ones(n) creates a n x n square matrix whose elements are 1's
ones(m,n) creates a mxn matrix whose elements are 1's.
ones(A) creates an m x n matrix of 1's, where m and n are based on the size of an
existing matrix, A.
zeros(A) creates an mxn matrix of 0's, where m and n are based on the size of the
existing matrix, A.
eye(n) creates the nxn identity matrix with 1's on the diagonal.
A' Transpose of A
Plotting commands
plot(x,y) creates an Cartesian plot of the vectors x & y
plot(y) creates a plot of y vs. the numerical values of the elements in the y-vector
semilogx(x,y) plots log(x) vs y
semilogy(x,y) plots x vs log(y)
loglog(x,y) plots log(x) vs log(y)
grid creates a grid on the graphics plot
title('text') places a title at top of graphics plot
xlabel('text') writes 'text' beneath the x-axis of a plot
ylabel('text') writes 'text' beside the y-axis of a plot
text(x,y,'text') writes 'text' at the location (x,y)
text(x,y,'text','sc') writes 'text' at point x,y assuming lower left corner is (0,0) and upper
right corner is (1,1)
gtext('text') writes text according to placement of mouse hold on maintains the current
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix A 91
Misc. commands
length(x) returns the number elements in a vector
size(x) returns the size m(rows) and n(columns) of matrix x
rand returns a random number between 0 and 1
randn returns a random number selected from a normal distribution with a mean
of 0 and variance of 1
rand(A) returns a matrix of size A of random numbers
fliplr(x) reverses the order of a vector. If x is a matrix, this reverse the order of the
columns in the matrix
flipud(x) reverses the order of a matrix in the sense of exchanging or reversing the
order of the matrix rows. This will not reverse a row vector!
reshape(A,m,n) reshapes the matrix A into an mxn matrix from element (1,1) working
column-wise
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix A 92
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix B 93
A PPENDIX B
Transfer functions are defined in MATLAB by storing the coefficients of the numerator and
the denominator in vectors. Given a continuous-time transfer function
( )
� =
( )
where
= � � + �−1 �−1 + ⋯ + 0 and = � � + �−1 �−1 + ⋯ + 0 written in their
coefficients, A(s) in numerator vectors num = [1 aN-1 ... a0] and B(s) is denominator den =
[bM bM-1 ... b0].
In this text,
the names of the vectors are generally chosen to be num and den, but any other name could
be used.
For example,
2 + 3
�( ) = 3+ 4 2+ 5
is defined by
num = [2 3];
den = [1 4 0 5];
Note that all coefficients must be included in the vector, even zero coefficients.
A transfer function may also be defined in terms of its zeros, poles and gain:
H(s) =
k(s- z )(s- z ) (s-z )
(s- p )(s- p ) (s-p )
12m
12n
K
K
Error! Switch argument not specified.
To find the zeros, poles and gain of a transfer function from the vectors num and den which
contain the coefficients of the numerator and denominator polynomials, type
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix B 94
[z,p,k] = tf2zp(num,den)
The zeros are stored in z, the poles are stored in p, and the gain is stored in k. To find the
numerator and denominator polynomials from z, p, and k, type
11
G(s)
G(s)
H(s)
unity feedback
feedback
-
-
[num,den] = zp2tf(z,p,k)
The overall transfer function of individual systems in parallel, series or feedback can be found
using
MATLAB. Consider block diagram reduction of the different configurations shown in Figure
1.
Store the transfer function G in numG and denG, and the transfer function H in numH and
denH.
To reduce the general feedback system to a single transfer function, Gcl(s) =
G(s)/(1+G(s)H(s)) type
[numcl,dencl] = feedback(numG,denG,numH,denH);
For a unity feedback system, let numH = 1 and denH = 1 before applying the above
algorithm. Alternately, use the command
[numcl,dencl] = cloop(numG,denG,-1);
To reduce the series system to a single transfer function, Gs(s) = G(s)H(s) type
[nums,dens] = series(numG,denG,numH,denH);
To reduce the parallel system to a single transfer function, Gp(s) = G(s) + H(s) type
[nump,denp] = parallel(numG,denG,numH,denH);
(Parallel is not available in the Student Version.)
12
G(s)
G(s)
H(s)
H(s)
series
parallel
B. Time Simulations
Commands covered: residue
step
impulse
lsim
The analytical method to find the time response of a system requires taking the inverse
Laplace
Transform of the output Y(s). MATLAB aides in this process by computing the partial
fraction
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix B 95
expansion of Y(s) using the command residue. Store the numerator and denominator
coefficients of Y(s) in num and den, then type
[r,p,k] = residue(num,den)
The residues are stored in r, the corresponding poles are stored in p, and the gain is stored in
k.
Once the partial fraction expansion is known, an analytical expression for y(t) can be
computed by
hand.
A numerical method to find the response of a system to a particular input is available in
MATLAB.
First store the numerator and denominator of the transfer function in num and den,
respectively.
To plot the step response, type
step(num,den)
13
To plot the impulse response, type
impulse(num,den)
For the response to an arbitrary input, use the command lsim. Create a vector t which
contains
the time values in seconds at which you want MATLAB to calculate the response. Typically,
this is
done by entering
t = a:b:c;
where a is the starting time, b is the time step and c is the end time. For smooth plots,
choose b
so that there are at least 300 elements in t (increase as necessary). Define the input x as a
function of time, for example, a ramp is defined as x = t. Then plot the response by typing
lsim(num,den,x,t);
To customize the commands, the time vector can be defined explicitly and the step response
can be
saved to a vector. Simulating the response for five to six time constants generally is sufficient
to
show the behavior of the system. For a stable system, a time constant is calculated as 1/Re(-p)
where p is the pole that has the largest real part (i.e., is closest to the origin).
For example, consider a transfer function defined by
H(s) =
2
s+ 2
4
The step response y is calculated and plotted from the following commands:
num = 2; den = [1 2];
t = 0:3/300:3; % for a time constant of 1/2
y = step(num,den,t);
plot(t,y)
For the impulse response, simply replace the word step with impulse. For the response to
an
arbitrary input stored in x, type
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix B 96
y = lsim(num,den,x,t);
plot(t,y)
E. Control Design
Commands covered: rlocus
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix B 97
Consider a feedback loop as shown in Figure 1 where G(s)H(s) = KP(s) and K is a gain and
P(s)
contains the poles and zeros of the controller and of the plant. The root locus is a plot of the
roots
of the closed loop transfer function as the gain is varied. Suppose that the numerator and
denominator coefficients of P(s) are stored in the vectors num and den. Then the following
command computes and plots the root locus:
rlocus(num,den)
To customize the plot for a specific range of K, say for K ranging from 0 to 100, then use the
following commands:
K = 0:100;
r = rlocus(num,den,K);
plot(r,’.’)
The graph contains dots at points in the complex plane that are closed loop poles for integer
values
of K ranging from 0 to 100. To get a finer grid of points, use a smaller increment when
defining
K, for example, K = 0:.5:100. The resulting matrix r contains the closed poles for all of
the
gains defined in the vector K. This is particularly useful to calculate the closed loop poles for
one
particular value of K. Note that if the root locus lies entirely on the real axis, then using
plot(r,’.’) gives inaccurate results.
F. State Space Representation
Commands Covered: step
lsim
ss2tf
tf2ss
ss2ss
The standard state space representation is used in MATLAB, i.e.,
&x Ax Bu
y Cx
5
17
where x is nx1 vector, u is mx1, y is px1, A is nxn, B is nxm, and C is pxn. The response of a
system to various inputs can be found using the same commands that are used for transfer
function
representations: step, impulse, and lsim. The argument list contains the A, B, C, and
D
matrices instead of the numerator and denominator vectors. For example, the step response is
obtained by typing:
[y,x,t] = step(A,B,C,D);
The states are stored in x, the outputs in y and the time vector, which is automatically
generated,
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
Appendix B 98
is stored in t. The rows of x and y contain the states and outputs for the time points in t.
Each
column of x represents a state. For example, to plot the second state versus time, type
plot(t,x(:,2))
To find the response of an arbitrary input or to find the response to initial conditions, use
lsim.
Define a time vector t and an input matrix u with the same number of rows as in t and the
number of columns equaling the number of inputs. An optional argument is the initial
condition
vector x0. The command is then given as
[y,x] = lsim(A,B,C,D,u,t,x0);
You can find the transfer function for a single-input/single-output (SISO) system using the
command:
[num,den] = ss2tf(A,B,C,D);
The numerator coefficients are stored in num and the denominator coefficients are stored in
den.
Given a transformation matrix P, the ss2ss function will perform the similarity transform.
Store the state space model in A, B, C and D and the transformation matrix in P.
[Abar,Bbar,Cbar,Dbar]=ss2ss(A,B,C,D,P);
performs the similarity transform z=Px resulting in a state space system that is defined as:
&x Ax Bu
y Cx Du
6
where A= PAP-1, B= PB, C = CP-1, D= D.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
References 99
R EFERENCES
Textbooks
[1] Brian L. Stevens and Frank L. Lewis, Aircraft Control and Simulation, John Wiley and
Sons, Inc, 2003.
[2] Said D. Jenie, Flight Control, Lecture Notes, Department of Aeronautics and
Astronautics, Bandung Institute of Technology, 2006. (in Bahasa Indonesia)
[3] Said D. Jenie and Hari Muhammad, Flight Dynamics, Lecture Notes, Department of
Aeronautics and Astronautics, Bandung Institute of Technology, 2006. (in Bahasa
Indonesia)
[4] John H. Blakelock, Automatic Control of Aircraft and Missiles, John Wiley and Sons, Inc,
1991.
[5] J.A. Mulder, W.H.J.J van Staveren, and J.C. van der Vaart, Flight Dynamics, Lecture
Notes, Faculty of Aerospace Engineering, TU-Delft, 2000.
[6] Donald E. Kirk, Optimal Control Theory an Introduction, Prentice-Hall, Inc, 1970.
Thesis
[7] Singgih S. Wibowo, Virtual Reality of Wing in Surface Effect Craft, Graduate Thesis,
Department of Aeronautics and Astronautics, Bandung Institute of Technology, 2006.
[8] Singgih S. Wibowo, Calculation of Aerodynamic Parameter of RX 250 LAPAN Rocket and
Analysis of its Dynamics, Undergraduate Thesis, Department of Aeronautics and
Astronautics, Bandung Institute of Technology, 2002. (in Bahasa Indonesia)
[9] Ony Arifianto, Adaptive Control Design for Yaw Damper and Turn Coordinator, Case
Study: N-250 PA-2 Aircraft, Undergraduate Thesis, Department of Aeronautics and
Astronautics, Bandung Institute of Technology, 1997. (in Bahasa Indonesia)
Paper
[10] Singgih S. Wibowo, Optimal Path Tracking Control for Autonomous Helicopter using
LQR, Unpublished Paper, Department of Aeronautics and Astronautics, Bandung
Institute of Technology, 2004.
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach
References 100
[11] Singgih S. Wibowo, Effect of Weighing Matrix in Error Tracking for Autonomous
Helicopter, Unpublished Paper, Department of Aeronautics and Astronautics, Bandung
Institute of Technology, 2004.
[12] Singgih S. Wibowo and Hari Muhammad, Real-Time Simulation with Virtual Reality
Visualization, National Conference in Computational Technology-BPPT, 2006.
[13] Singgih S. Wibowo, Hari Muhammad and Said D. Jenie, Simulation with VR
Visualization of WiSE Craft during Takeoff Maneuver, The Sixth Asian Control
Conference-Bali, 2006.
Online Resources
[14] www.control.lth.se/~kursdr/matlab/matlabref.pdf
[15] www.ee.unlv.edu/kevin/index_files/tutorials/matlab_tutorial.pdf
Other Documents
[16] MATLAB 7.0 Help Documentation
Aircraft Flight Dynamics, Control and Using MATLAB and SIMULINK: Cases and Singgih Satrio Wibowo
Simulation Algorithm Approach