forked from GliderWinchCommons/ps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
State_Parachute.m
56 lines (44 loc) · 1.14 KB
/
State_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
function z = State_Parachute(vec)
global state
% if isempty(state)
% state = 0;
% end
ydotdot = vec(1);
xdotdot = vec(2);
ydot = vec(7);
xdot = vec(5);
vsq = xdot^2 + ydot^2;
v = sqrt(vsq);
vdot = (xdot * xdotdot + ydot * ydotdot) / v;
y = vec(6);
switch state
case 0 % Safe proxy, wait for state message in main program
% state = 1;
case 1 % Ground roll through liftoff
if ydot > 0
state = 3;
end
case 3 % Liftoff has occured
if vdot < 0
state = 5;
end
if y < 0
state = 8;
end
case 5 % Airpseed has peaked, damping engaged
if ydot + 1.5 * vdot <= 0 % clugey criteria for transition to recovery
state = 7;
end
if y < 0
state = 8;
end
case 7 % Altitude has peaked, glider released
if y < 0
state = 8;
end
case 8
% Launch should terminate soon
otherwise
error('Invalid State')
end
z = state;