forked from GliderWinchCommons/ps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FMA_Parachute.m
64 lines (43 loc) · 1.37 KB
/
FMA_Parachute.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function z = FMA_Parachute(fG, u, lambda, delta, Kd, MgoMp, deltp)
persistent vdotold
if isempty(vdotold)
vdotold = 0;
end
y = u(3);
x = u(1);
ydot = u(4);
xdot = u(2);
state = u(5);
vsq = xdot^2 + ydot^2;
v = sqrt(vsq);
rsq = x^2 + y^2;
r = sqrt(rsq);
G = 9.81;
fxG = fG * -x / r;
fyG = fG * -y / r;
switch state
case 0
ydotdot = 0;
xdotdot = 0;
case 1 % Groundroll
xdotdot = fxG - v * delta * xdot;
ydotdot = max(fyG + v * (-lambda * xdot - delta * ydot) - G, 0);
case 3 % Liftoff has occured
xdotdot = fxG + v * (lambda * ydot - delta * xdot);
ydotdot = fyG + v * (-lambda * xdot - delta * ydot) - G;
case 5 % Airspeed has peaked, damping engaged
gain = 1 + Kd * vdotold;
xdotdot = fxG + v * gain * (lambda * ydot - delta * xdot);
ydotdot = fyG + v * gain * (-lambda * xdot - delta * ydot) - G;
case 7 % Recovery has commenced
xdotdot = fxG * MgoMp - v * deltp * xdot;
ydotdot = fyG * MgoMp - v * deltp * ydot - G;
case 8 % Should stop soon
xdotdot = 0;
ydotdot = 0;
otherwise
disp('Invalid State');
display(state);
end
vdotold = (xdot * xdotdot + ydot * ydotdot) / v;
z = [ydotdot xdotdot];