Skip to content

Commit afefd5d

Browse files
committed
LVD: Added termination conditions for the rest of the steering angles and throttle setting.
1 parent a88eede commit afefd5d

14 files changed

Lines changed: 745 additions & 7 deletions

File tree

helper_methods/ksptot_ma/launch_vehicle_designer/classes/Events/termConditions/@TerminationConditionEnum/TerminationConditionEnum.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
AngleOfAttack('Angle of Attack','AngleOfAttackTermCondition');
88
BankAngle('Bank Angle','BankAngleTermCondition');
99
EventDuration('Event Duration','EventDurationTermCondition');
10+
PitchAngle('Pitch Angle','PitchTermCondition');
11+
RollAngle('Roll Angle','RollTermCondition');
12+
SideSlipAngle('Side Slip Angle','SideSlipAngleTermCondition');
1013
TankMass('Tank Mass','TankMassTermCondition');
14+
ThrottleSetting('Throttle Setting','ThrottleTermCondition');
1115
TrueAnomaly('True Anomaly','TrueAnomalyTermCondition');
12-
13-
16+
YawAngle('Yaw Angle','YawTermCondition');
1417
end
1518

1619
properties
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
classdef ThrottleTermCondition < AbstractEventTerminationCondition
2+
%ThrottleTermCondition Summary of this class goes here
3+
% Detailed explanation goes here
4+
5+
properties
6+
throttleModel(1,1) AbstractThrottleModel = ThrottlePolyModel.getDefaultThrottleModel();
7+
targetThrottle(1,1) double = 0;
8+
end
9+
10+
methods
11+
function obj = ThrottleTermCondition(targetThrottle)
12+
obj.targetThrottle = targetThrottle;
13+
end
14+
15+
function evtTermCondFcnHndl = getEventTermCondFuncHandle(obj)
16+
evtTermCondFcnHndl = @(t,y) obj.eventTermCond(t,y, obj.targetThrottle, obj.throttleModel);
17+
end
18+
19+
function initTermCondition(obj, initialStateLogEntry)
20+
obj.throttleModel = initialStateLogEntry.throttleModel;
21+
end
22+
23+
function name = getName(obj)
24+
name = sprintf('Throttle Setting (%.3f %%)', 100*obj.targetThrottle);
25+
end
26+
27+
function params = getTermCondUiStruct(obj)
28+
params = struct();
29+
30+
params.paramName = 'Target Throttle Setting';
31+
params.paramUnit = '%';
32+
params.useParam = 'on';
33+
params.useStages = 'off';
34+
params.useTanks = 'off';
35+
params.useEngines = 'off';
36+
37+
params.value = 100*obj.targetThrottle;
38+
params.refStage = LaunchVehicleStage.empty(1,0);
39+
params.refTank = LaunchVehicleEngine.empty(1,0);
40+
params.refEngine = LaunchVehicleEngine.empty(1,0);
41+
end
42+
43+
function optVar = getNewOptVar(obj)
44+
optVar = ThrottleTermCondOptimVar(obj);
45+
end
46+
47+
function optVar = getExistingOptVar(obj)
48+
optVar = obj.optVar;
49+
end
50+
51+
function tf = usesStage(obj, stage)
52+
tf = false;
53+
end
54+
55+
function tf = usesEngine(obj, engine)
56+
tf = false;
57+
end
58+
59+
function tf = usesTank(obj, tank)
60+
tf = false;
61+
end
62+
63+
function tf = usesEngineToTankConn(obj, engineToTank)
64+
tf = false;
65+
end
66+
end
67+
68+
methods(Static)
69+
function termCond = getTermCondForParams(paramValue, stage, tank, engine)
70+
termCond = ThrottleTermCondition(paramValue);
71+
end
72+
end
73+
74+
methods(Static, Access=private)
75+
function [value,isterminal,direction] = eventTermCond(t,y, targetThrottle, throttleModel)
76+
ut = t;
77+
78+
throttle = throttleModel.getThrottleAtTime(ut);
79+
80+
value = throttle - targetThrottle;
81+
isterminal = 1;
82+
direction = 0;
83+
end
84+
end
85+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
classdef PitchTermCondition < AbstractEventTerminationCondition
2+
%BankAngleTermCondition Summary of this class goes here
3+
% Detailed explanation goes here
4+
5+
properties
6+
steeringModel(1,1) AbstractSteeringModel = RollPitchYawPolySteeringModel.getDefaultSteeringModel();
7+
targetPitchAngle(1,1) double = 0;
8+
bodyInfo KSPTOT_BodyInfo
9+
end
10+
11+
methods
12+
function obj = PitchTermCondition(targetPitchAngle)
13+
obj.targetPitchAngle = targetPitchAngle;
14+
end
15+
16+
function evtTermCondFcnHndl = getEventTermCondFuncHandle(obj)
17+
evtTermCondFcnHndl = @(t,y) obj.eventTermCond(t,y, obj.targetPitchAngle, obj.steeringModel, obj.bodyInfo);
18+
end
19+
20+
function initTermCondition(obj, initialStateLogEntry)
21+
obj.steeringModel = initialStateLogEntry.steeringModel;
22+
obj.bodyInfo = initialStateLogEntry.centralBody;
23+
end
24+
25+
function name = getName(obj)
26+
name = sprintf('Pitch Angle (%.3f deg)', rad2deg(obj.targetPitchAngle));
27+
end
28+
29+
function params = getTermCondUiStruct(obj)
30+
params = struct();
31+
32+
params.paramName = 'Target Pitch Angle';
33+
params.paramUnit = 'deg';
34+
params.useParam = 'on';
35+
params.useStages = 'off';
36+
params.useTanks = 'off';
37+
params.useEngines = 'off';
38+
39+
params.value = rad2deg(obj.targetPitchAngle);
40+
params.refStage = LaunchVehicleStage.empty(1,0);
41+
params.refTank = LaunchVehicleEngine.empty(1,0);
42+
params.refEngine = LaunchVehicleEngine.empty(1,0);
43+
end
44+
45+
function optVar = getNewOptVar(obj)
46+
optVar = PitchAngleTermCondOptimVar(obj);
47+
end
48+
49+
function optVar = getExistingOptVar(obj)
50+
optVar = obj.optVar;
51+
end
52+
53+
function tf = usesStage(obj, stage)
54+
tf = false;
55+
end
56+
57+
function tf = usesEngine(obj, engine)
58+
tf = false;
59+
end
60+
61+
function tf = usesTank(obj, tank)
62+
tf = false;
63+
end
64+
65+
function tf = usesEngineToTankConn(obj, engineToTank)
66+
tf = false;
67+
end
68+
end
69+
70+
methods(Static)
71+
function termCond = getTermCondForParams(paramValue, stage, tank, engine)
72+
termCond = PitchTermCondition((paramValue));
73+
end
74+
end
75+
76+
methods(Static, Access=private)
77+
function [value,isterminal,direction] = eventTermCond(t,y, targetPitchAngle, steeringModel, bodyInfo)
78+
ut = t;
79+
rVect = y(1:3);
80+
vVect = y(4:6);
81+
82+
dcm = steeringModel.getBody2InertialDcmAtTime(ut, rVect, vVect, bodyInfo);
83+
[~,pitchAngle,~] = computeEulerAnglesFromInertialBodyAxes(ut, rVect, vVect, bodyInfo, dcm(:,1), dcm(:,2), dcm(:,3));
84+
85+
value = pitchAngle - targetPitchAngle;
86+
isterminal = 1;
87+
direction = 0;
88+
end
89+
end
90+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
classdef RollTermCondition < AbstractEventTerminationCondition
2+
%BankAngleTermCondition Summary of this class goes here
3+
% Detailed explanation goes here
4+
5+
properties
6+
steeringModel(1,1) AbstractSteeringModel = RollPitchYawPolySteeringModel.getDefaultSteeringModel();
7+
targetRollAngle(1,1) double = 0;
8+
bodyInfo KSPTOT_BodyInfo
9+
end
10+
11+
methods
12+
function obj = RollTermCondition(targetRollAngle)
13+
obj.targetRollAngle = targetRollAngle;
14+
end
15+
16+
function evtTermCondFcnHndl = getEventTermCondFuncHandle(obj)
17+
evtTermCondFcnHndl = @(t,y) obj.eventTermCond(t,y, obj.targetRollAngle, obj.steeringModel, obj.bodyInfo);
18+
end
19+
20+
function initTermCondition(obj, initialStateLogEntry)
21+
obj.steeringModel = initialStateLogEntry.steeringModel;
22+
obj.bodyInfo = initialStateLogEntry.centralBody;
23+
end
24+
25+
function name = getName(obj)
26+
name = sprintf('Roll Angle (%.3f deg)', rad2deg(obj.targetRollAngle));
27+
end
28+
29+
function params = getTermCondUiStruct(obj)
30+
params = struct();
31+
32+
params.paramName = 'Target Roll Angle';
33+
params.paramUnit = 'deg';
34+
params.useParam = 'on';
35+
params.useStages = 'off';
36+
params.useTanks = 'off';
37+
params.useEngines = 'off';
38+
39+
params.value = rad2deg(obj.targetRollAngle);
40+
params.refStage = LaunchVehicleStage.empty(1,0);
41+
params.refTank = LaunchVehicleEngine.empty(1,0);
42+
params.refEngine = LaunchVehicleEngine.empty(1,0);
43+
end
44+
45+
function optVar = getNewOptVar(obj)
46+
optVar = RollAngleTermCondOptimizationVariable(obj);
47+
end
48+
49+
function optVar = getExistingOptVar(obj)
50+
optVar = obj.optVar;
51+
end
52+
53+
function tf = usesStage(obj, stage)
54+
tf = false;
55+
end
56+
57+
function tf = usesEngine(obj, engine)
58+
tf = false;
59+
end
60+
61+
function tf = usesTank(obj, tank)
62+
tf = false;
63+
end
64+
65+
function tf = usesEngineToTankConn(obj, engineToTank)
66+
tf = false;
67+
end
68+
end
69+
70+
methods(Static)
71+
function termCond = getTermCondForParams(paramValue, stage, tank, engine)
72+
termCond = RollTermCondition((paramValue));
73+
end
74+
end
75+
76+
methods(Static, Access=private)
77+
function [value,isterminal,direction] = eventTermCond(t,y, targetRollAngle, steeringModel, bodyInfo)
78+
ut = t;
79+
rVect = y(1:3);
80+
vVect = y(4:6);
81+
82+
dcm = steeringModel.getBody2InertialDcmAtTime(ut, rVect, vVect, bodyInfo);
83+
[rollAngle,~,~] = computeEulerAnglesFromInertialBodyAxes(ut, rVect, vVect, bodyInfo, dcm(:,1), dcm(:,2), dcm(:,3));
84+
85+
value = rollAngle - targetRollAngle;
86+
isterminal = 1;
87+
direction = 0;
88+
end
89+
end
90+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
classdef SideSlipAngleTermCondition < AbstractEventTerminationCondition
2+
%SideSlipAngleTermCondition Summary of this class goes here
3+
% Detailed explanation goes here
4+
5+
properties
6+
steeringModel(1,1) AbstractSteeringModel = RollPitchYawPolySteeringModel.getDefaultSteeringModel();
7+
targetSlipAngle(1,1) double = 0;
8+
bodyInfo KSPTOT_BodyInfo
9+
end
10+
11+
methods
12+
function obj = SideSlipAngleTermCondition(targetSlipAngle)
13+
obj.targetSlipAngle = targetSlipAngle;
14+
end
15+
16+
function evtTermCondFcnHndl = getEventTermCondFuncHandle(obj)
17+
evtTermCondFcnHndl = @(t,y) obj.eventTermCond(t,y, obj.targetSlipAngle, obj.steeringModel, obj.bodyInfo);
18+
end
19+
20+
function initTermCondition(obj, initialStateLogEntry)
21+
obj.steeringModel = initialStateLogEntry.steeringModel;
22+
obj.bodyInfo = initialStateLogEntry.centralBody;
23+
end
24+
25+
function name = getName(obj)
26+
name = sprintf('Side Slip Angle (%.3f deg)', rad2deg(obj.targetSlipAngle));
27+
end
28+
29+
function params = getTermCondUiStruct(obj)
30+
params = struct();
31+
32+
params.paramName = 'Target Side Slip Angle';
33+
params.paramUnit = 'deg';
34+
params.useParam = 'on';
35+
params.useStages = 'off';
36+
params.useTanks = 'off';
37+
params.useEngines = 'off';
38+
39+
params.value = rad2deg(obj.targetSlipAngle);
40+
params.refStage = LaunchVehicleStage.empty(1,0);
41+
params.refTank = LaunchVehicleEngine.empty(1,0);
42+
params.refEngine = LaunchVehicleEngine.empty(1,0);
43+
end
44+
45+
function optVar = getNewOptVar(obj)
46+
optVar = SideSlipAngleTermCondOptimVar(obj);
47+
end
48+
49+
function optVar = getExistingOptVar(obj)
50+
optVar = obj.optVar;
51+
end
52+
53+
function tf = usesStage(obj, stage)
54+
tf = false;
55+
end
56+
57+
function tf = usesEngine(obj, engine)
58+
tf = false;
59+
end
60+
61+
function tf = usesTank(obj, tank)
62+
tf = false;
63+
end
64+
65+
function tf = usesEngineToTankConn(obj, engineToTank)
66+
tf = false;
67+
end
68+
end
69+
70+
methods(Static)
71+
function termCond = getTermCondForParams(paramValue, stage, tank, engine)
72+
termCond = SideSlipAngleTermCondition((paramValue));
73+
end
74+
end
75+
76+
methods(Static, Access=private)
77+
function [value,isterminal,direction] = eventTermCond(t,y, targetSlipAngle, steeringModel, bodyInfo)
78+
ut = t;
79+
rVect = y(1:3);
80+
vVect = y(4:6);
81+
82+
dcm = steeringModel.getBody2InertialDcmAtTime(ut, rVect, vVect, bodyInfo);
83+
[~,~,angOfSideslip] = computeAeroAnglesFromBodyAxes(rVect, vVect, dcm(:,1), dcm(:,2), dcm(:,3));
84+
85+
value = angOfSideslip - targetSlipAngle;
86+
isterminal = 1;
87+
direction = 0;
88+
end
89+
end
90+
end

0 commit comments

Comments
 (0)