diff --git a/classes/@Rocket/Rocket.m b/classes/@Rocket/Rocket.m index 0e4be4a76d84243943f964c2f76f3efea786e24d..8da0e3c0bbaafc4d47a86fbf3cecd820b2ac5003 100644 --- a/classes/@Rocket/Rocket.m +++ b/classes/@Rocket/Rocket.m @@ -177,11 +177,19 @@ classdef Rocket < Config function obj = set.parafoil(obj, value), obj = obj.updateBay('PARAFOIL', value); end function obj = set.recovery(obj, value), obj = obj.updateBay('RECOVERY', value); end function obj = set.electronics(obj, value), obj = obj.updateBay('ELECTRONICS', value); end - function obj = set.airbrakes(obj, value), obj = obj.updateBay('AIRBRAKES', value); end + function obj = set.airbrakes(obj, value) + obj = obj.updateBay('AIRBRAKES', value); + if ~isempty(obj.motor) + obj.AIRBRAKES.minTime = obj.motor.cutoffTime; + end + end function obj = set.motor(obj, value) obj = obj.updateBay('MOTOR', value); obj.time = value.time; obj.cutoffTime = value.cutoffTime; + if ~isempty(obj.airbrakes) + obj.AIRBRAKES.minTime = obj.motor.cutoffTime; + end end function obj = set.rear(obj, value), obj = obj.updateBay('REAR', value); end diff --git a/classes/bays/Airbrakes.m b/classes/bays/Airbrakes.m index 73495d58137e2a369b6d84114c164aca63367222..b0e98234a54a6c3c27b8b35ac08c5b94b4231766 100644 --- a/classes/bays/Airbrakes.m +++ b/classes/bays/Airbrakes.m @@ -39,7 +39,7 @@ classdef Airbrakes < Bay end properties(SetAccess = ?Rocket, GetAccess = private) - minTime % [s] Minimum time since engine fire at which airbrakes can open + minTime = 0 % [s] Minimum time since engine fire at which airbrakes can open end properties(SetAccess = private) @@ -63,7 +63,7 @@ classdef Airbrakes < Bay end function obj = updateTime(obj) - if isempty(obj.deltaTime) || isempty(obj.minTime), return; end + if isempty(obj.deltaTime), return; end obj.time = cumsum(obj.deltaTime) + obj.minTime; end end diff --git a/classes/misc/WindCustom.m b/classes/misc/Wind.m similarity index 90% rename from classes/misc/WindCustom.m rename to classes/misc/Wind.m index 9c927d0a05b28226822366644de7a0f304b121e6..109e646c5deddd970be91fa46814081375be1fea 100644 --- a/classes/misc/WindCustom.m +++ b/classes/misc/Wind.m @@ -1,8 +1,8 @@ -classdef WindCustom < Component -% WindCustom: Represents Skyward's custom wind model. +classdef Wind < Config +% Wind: Represents Skyward's custom wind model. % % Constructor: -% - WindCustom: Creates an instance of the WindCustom class. +% - Wind: Creates an instance of the Wind class. % Loaded config: windConfig.m > windCustom % Loaded data: - % Arguments: @@ -29,25 +29,23 @@ classdef WindCustom < Component magnitude end - properties(Access = protected) + properties(Constant, Access = protected) configName = 'windConfig.m' variableName = 'windCustom' - mission Mission end methods - function obj = WindCustom(mission, varIn) + function obj = Wind(mission, varIn) arguments(Input) mission Mission = Mission() varIn = [] end - obj@Component(mission, varIn); - obj.updateAll(); + obj@Config(mission, varIn); + obj = obj.updateAll(); end function [uw, vw, ww] = getVels(obj, z) - s = length(obj.altitudes); % reference vectors length - if s==1 + if isscalar(obj.altitudes) uw = round( - obj.magnitude * cos(obj.azimuth) * cos(obj.elevation), 6); vw = round( - obj.magnitude * sin(obj.azimuth) * cos(obj.elevation), 6); ww = round( - obj.magnitude * (-sin(obj.elevation)), 6); @@ -62,7 +60,7 @@ classdef WindCustom < Component end end - function updateAll(obj) + function obj = updateAll(obj) obj = obj.checkElevation(); s = length(obj.altitudes); diff --git a/classes/misc/WindMatlab.m b/classes/misc/WindMatlab.m deleted file mode 100644 index 393a034e469d240381d3667bd440eec0936ecde6..0000000000000000000000000000000000000000 --- a/classes/misc/WindMatlab.m +++ /dev/null @@ -1,62 +0,0 @@ -classdef WindMatlab < Config -% WindMatlab: Represents matlab wind variables. -% -% Constructor: -% - WindMatlab: Creates an instance of the WindMatlab class. -% Loaded config: windConfig.m > windMatlab -% Loaded data: - -% Arguments: -% - mission: Mission, mission object -% - environment: Environment, used to get launch coordinates -% - varIn: (optional) config source. Alternative to config.m -% file - - properties - DayMin % [d] Minimum Day of the launch - DayMax % [d] Maximum Day of the launch - HourMin % [h] Minimum Hour of the day - HourMax % [h] Maximum Hour of the day - ww % [m/s] Vertical wind speed - end - - properties(Access = protected) - configName = 'windConfig.m' - variableName = 'windMatlab' - mission Mission - environment Environment - end - - methods - function obj = WindMatlab(mission, environment, varIn) - arguments(Input) - mission Mission = Mission() - environment Environment = Environment() - varIn = [] - end - if nargin > 0 && nargin < 2, error('MATLAB:narginchk:notEnoughInputs', ... - 'Not enough input arguments.'); end - obj@Component(mission, varIn); - obj.environment = environment; - end - - function [uw, vw, ww] = getVels(obj, z, t, Hour, Day) - h = z + obj.environment.z0; - if h < 0 - h = 0; - end - - if nargin == 3 - if obj.HourMin == obj.HourMax - Day = obj.DayMin; - Hour = obj.HourMin; - end - end - - Seconds = Hour*3600; - % horizontal wind - [uw,vw] = atmoshwm(obj.environment.lat0, obj.environment.lon0,h,'day',Day,... - 'seconds',Seconds+t,'model','quiet','version','14'); % NED reference - ww = obj.ww; - end - end -end diff --git a/functions/miscellaneous/singleGArun.m b/functions/miscellaneous/singleGArun.m index f30e47870d40ad1e29053308c91b9b52d0171350..e2ca5044abfdd3a1811fe13b9841e9cd98fcedc0 100644 --- a/functions/miscellaneous/singleGArun.m +++ b/functions/miscellaneous/singleGArun.m @@ -6,7 +6,7 @@ arguments data_opt struct rocket Rocket environment Environment - wind WindCustom + wind Wind settings Settings wrapper DataWrapper end diff --git a/functions/odeFunctions/ballistic.m b/functions/odeFunctions/ballistic.m index cce9648500d2f9f604739ca224ab90c4ca4a88c3..0e16abd4f74355055c66f1839180c1d248e7e8fb 100644 --- a/functions/odeFunctions/ballistic.m +++ b/functions/odeFunctions/ballistic.m @@ -4,7 +4,7 @@ arguments Y rocket Rocket environment Environment - wind % WindCustom {mustBeA(wind, {'WindCustom', 'WindMatlab'})} + wind Wind control struct = [] t0 double = 0 wrapper = [] %DataWrapper = DataWrapper.empty @@ -72,13 +72,7 @@ Q = [qw qx qy qz]; Q = Q/norm(Q); %% ADDING WIND (supposed to be added in NED axes); -switch class(wind) - case 'WindMatlab' - [uw, vw, ww] = wind.getVels(altitude, theta); - case 'WindCustom' - [uw, vw, ww] = wind.getVels(altitude); -end - +[uw, vw, ww] = wind.getVels(altitude); dcm = quatToDcm(Q); windVels = dcm*[uw; vw; ww]; diff --git a/functions/odeFunctions/descentParachute.m b/functions/odeFunctions/descentParachute.m index 6e3e77d4bbd4be50f691c853ab626f926bac6614..bbca96a724686eee8529a72ff6163447a23bea1c 100644 --- a/functions/odeFunctions/descentParachute.m +++ b/functions/odeFunctions/descentParachute.m @@ -4,7 +4,7 @@ arguments Y rocket Rocket environment Environment - wind % WindCustom {mustBeA(wind, {'WindCustom', 'WindMatlab'})} + wind % Wind {mustBeA(wind, {'Wind', 'WindMatlab'})} descentData struct wrapper = [] %DataWrapper = DataWrapper.empty Q = [1 0 0 0] @@ -61,7 +61,7 @@ local = [environment.z0, environment.temperature, ... % vector containing inpu switch class(wind) case 'WindMatlab' [uw, vw, ww] = wind.getVels(altitude, theta); - case 'WindCustom' + case 'Wind' [uw, vw, ww] = wind.getVels(altitude); end diff --git a/functions/odeFunctions/descentParafoil.m b/functions/odeFunctions/descentParafoil.m index 9deb592eaf5383fcbccc6f99dbdd4365f2cdfed0..ec73f328509b77df5b25b3c5dae785e0eedfe77a 100644 --- a/functions/odeFunctions/descentParafoil.m +++ b/functions/odeFunctions/descentParafoil.m @@ -4,7 +4,7 @@ arguments Y rocket Rocket environment Environment - wind % WindCustom {mustBeA(wind, {'WindCustom', 'WindMatlab'})} + wind % Wind {mustBeA(wind, {'Wind', 'WindMatlab'})} descentData struct control struct = [] t0 double = 0 diff --git a/functions/simulations/quickApogeeOnly.m b/functions/simulations/quickApogeeOnly.m index 7978ed8322cab610e4e6788b5e680b68106fb550..f1bd16703413f6260ae11dd079aea3acdc92d183 100644 --- a/functions/simulations/quickApogeeOnly.m +++ b/functions/simulations/quickApogeeOnly.m @@ -2,7 +2,7 @@ function [apogee, maxAccel] = quickApogeeOnly(rocket, environment, wind, setting arguments rocket Rocket environment Environment - wind WindCustom + wind Wind settings Settings wrapper = []; % DataWrapper (empty by default) end diff --git a/functions/simulations/stdAscent.m b/functions/simulations/stdAscent.m index cd89849d8125ce4551725c95d4f1c67893c02d34..f0ef8d5130612b979bae233f9e4d58f79a44ea01 100644 --- a/functions/simulations/stdAscent.m +++ b/functions/simulations/stdAscent.m @@ -2,7 +2,7 @@ function [solution, ascent] = stdAscent(rocket, env, wind, settings, wrapper) arguments rocket Rocket env Environment - wind WindCustom {mustBeA(wind, {'WindCustom', 'WindMatlab'})} + wind Wind {mustBeA(wind, {'Wind', 'WindMatlab'})} settings Settings wrapper DataWrapper end diff --git a/functions/simulations/stdStability.m b/functions/simulations/stdStability.m index 7898fa5b09ecdc498d8839b735d45ee377fff9e1..bf03c018c5aa1c9f47ba86dbeda9bd930a9451b3 100644 --- a/functions/simulations/stdStability.m +++ b/functions/simulations/stdStability.m @@ -2,7 +2,7 @@ function stabilityOut = stdStability(rocket, env, wind, settings, wrapper) arguments rocket Rocket env Environment - wind WindCustom {mustBeA(wind, {'WindCustom', 'WindMatlab'})} + wind Wind {mustBeA(wind, {'Wind', 'WindMatlab'})} settings Settings wrapper DataWrapper end diff --git a/missions/2021_Lynx_Portugal_October/config/windConfig.m b/missions/2021_Lynx_Portugal_October/config/windConfig.m index bba16a9731f7f0c525dddd433e9f54aaba975d08..a2b384c02d9b14289fe2babb51e12b9d2f81e109 100644 --- a/missions/2021_Lynx_Portugal_October/config/windConfig.m +++ b/missions/2021_Lynx_Portugal_October/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 200 2000]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["u", "u", "u"]; % [-] Distribution type: "u" - uniform, "g" - gaussian diff --git a/missions/2021_Lynx_Roccaraso_September/config/windConfig.m b/missions/2021_Lynx_Roccaraso_September/config/windConfig.m index bba16a9731f7f0c525dddd433e9f54aaba975d08..a2b384c02d9b14289fe2babb51e12b9d2f81e109 100644 --- a/missions/2021_Lynx_Roccaraso_September/config/windConfig.m +++ b/missions/2021_Lynx_Roccaraso_September/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 200 2000]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["u", "u", "u"]; % [-] Distribution type: "u" - uniform, "g" - gaussian diff --git a/missions/2022_Pyxis_Portugal_October/config/windConfig.m b/missions/2022_Pyxis_Portugal_October/config/windConfig.m index bba16a9731f7f0c525dddd433e9f54aaba975d08..a2b384c02d9b14289fe2babb51e12b9d2f81e109 100644 --- a/missions/2022_Pyxis_Portugal_October/config/windConfig.m +++ b/missions/2022_Pyxis_Portugal_October/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 200 2000]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["u", "u", "u"]; % [-] Distribution type: "u" - uniform, "g" - gaussian diff --git a/missions/2022_Pyxis_Roccaraso_September/config/windConfig.m b/missions/2022_Pyxis_Roccaraso_September/config/windConfig.m index bba16a9731f7f0c525dddd433e9f54aaba975d08..a2b384c02d9b14289fe2babb51e12b9d2f81e109 100644 --- a/missions/2022_Pyxis_Roccaraso_September/config/windConfig.m +++ b/missions/2022_Pyxis_Roccaraso_September/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 200 2000]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["u", "u", "u"]; % [-] Distribution type: "u" - uniform, "g" - gaussian diff --git a/missions/2023_Gemini_Portugal_October/config/windConfig.m b/missions/2023_Gemini_Portugal_October/config/windConfig.m index bba16a9731f7f0c525dddd433e9f54aaba975d08..a2b384c02d9b14289fe2babb51e12b9d2f81e109 100644 --- a/missions/2023_Gemini_Portugal_October/config/windConfig.m +++ b/missions/2023_Gemini_Portugal_October/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 200 2000]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["u", "u", "u"]; % [-] Distribution type: "u" - uniform, "g" - gaussian diff --git a/missions/2023_Gemini_Roccaraso_September/config/windConfig.m b/missions/2023_Gemini_Roccaraso_September/config/windConfig.m index bba16a9731f7f0c525dddd433e9f54aaba975d08..a2b384c02d9b14289fe2babb51e12b9d2f81e109 100644 --- a/missions/2023_Gemini_Roccaraso_September/config/windConfig.m +++ b/missions/2023_Gemini_Roccaraso_September/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 200 2000]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["u", "u", "u"]; % [-] Distribution type: "u" - uniform, "g" - gaussian diff --git a/missions/2024_Lyra_Portugal_October/config/windConfig.m b/missions/2024_Lyra_Portugal_October/config/windConfig.m index 48fd0bed4a67d4bcf7b871a4b433c9ab2bc2934b..28c80775f18f797b195bc435ae760dc4a04d3258 100644 --- a/missions/2024_Lyra_Portugal_October/config/windConfig.m +++ b/missions/2024_Lyra_Portugal_October/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 10 150 500 1000 1500 2000 2500 3000 3500 4000]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["u","g", "g", "g", "g", "g", "g", "g", "g", "g", "g"]; % [-] Distribution type: "u" - uniform, "g" - gaussian diff --git a/missions/2024_Lyra_Roccaraso_September/config/windConfig.m b/missions/2024_Lyra_Roccaraso_September/config/windConfig.m index 0f889ba42f50d7ea8134e1757981a8f1be64faa7..5e91be331e50f40283fd8815ef0826be3d36c561 100644 --- a/missions/2024_Lyra_Roccaraso_September/config/windConfig.m +++ b/missions/2024_Lyra_Roccaraso_September/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 10 500 900 1200]; windCustom.magnitudeDistribution = ["u", "g", "g", "g", "g"]; % [-] Distribution type: "u" - uniform, "g" - gaussian diff --git a/missions/2025_Orion_Portugal_October/config/windConfig.m b/missions/2025_Orion_Portugal_October/config/windConfig.m index 32bd11ee5e83b92402b84277be0e5e943e2dca34..ec6df23d6ffe40cb8088bfb8f891fd3f73f8b8f3 100644 --- a/missions/2025_Orion_Portugal_October/config/windConfig.m +++ b/missions/2025_Orion_Portugal_October/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 140 500 1000 1500 2000 2500 3000 3500 4000]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["u", "g", "g", "g", "g", "g", "g", "g", "g", "g"]; % [-] Distribution type: "u" - uniform, "g" - gaussian @@ -26,10 +26,10 @@ windCustom.azimuthParameters = [270 270 270 280 270 260 260 240 240 240; % windCustom.azimuthParameters = [0 0; 359 359]; %% MATLAB WIND MODEL -windMatlab = WindMatlab(); - -windMatlab.DayMin = 105; % [d] Minimum Day of the launch -windMatlab.DayMax = 105; % [d] Maximum Day of the launch -windMatlab.HourMin = 4; % [h] Minimum Hour of the day -windMatlab.HourMax = 4; % [h] Maximum Hour of the day -windMatlab.ww = 0; % [m/s] Vertical wind speed \ No newline at end of file +% windMatlab = WindMatlab(); +% +% windMatlab.DayMin = 105; % [d] Minimum Day of the launch +% windMatlab.DayMax = 105; % [d] Maximum Day of the launch +% windMatlab.HourMin = 4; % [h] Minimum Hour of the day +% windMatlab.HourMax = 4; % [h] Maximum Hour of the day +% windMatlab.ww = 0; % [m/s] Vertical wind speed \ No newline at end of file diff --git a/missions/2025_Orion_Roccaraso_September/config/windConfig.m b/missions/2025_Orion_Roccaraso_September/config/windConfig.m index cd274dacf5d5590e4e3c49b00f0b63d47a2edf5d..31748d97d738997d37d0b012452fa023b8c8c8c5 100644 --- a/missions/2025_Orion_Roccaraso_September/config/windConfig.m +++ b/missions/2025_Orion_Roccaraso_September/config/windConfig.m @@ -9,7 +9,7 @@ %% CUSTOM WIND MODEL -windCustom = WindCustom(); +windCustom = Wind(); windCustom.altitudes = [0 500 900 1200]; % [m] Altitudes at which a distribution change occurs windCustom.magnitudeDistribution = ["g", "g", "g", "g"]; % [-] Distribution type: "u" - uniform, "g" - gaussian