diff --git a/classes/Bay.m b/classes/Bay.m index 0ddb41a8133d1248f6e9fcf87c2f891b290546a8..9e35314776a008f3ff0a205a600d58a4eaefb9b3 100644 --- a/classes/Bay.m +++ b/classes/Bay.m @@ -7,6 +7,7 @@ classdef Bay < Component length % [m] Total bay length diameter % [m] Diameter of the bay mass % [kg] Total bay mass + xCg % [m] Cg relative to bay upper side inertia % [kg*m^2] Total bay inertia (Body reference) end end diff --git a/classes/Component.m b/classes/Component.m index 6db8d02ab9ee68609be916bb4ad33ea516834905..9412cf273a13aa97a352af18ba0cdd5db2dcc1f7 100644 --- a/classes/Component.m +++ b/classes/Component.m @@ -36,16 +36,22 @@ classdef Component < Config end end - methods(Access = ?Rocket) - function setMission(obj, mission) - obj.mission = mission; - end - end + % methods(Access = ?Rocket) + % function setMission(obj, mission) + % obj.mission = mission; + % end + % end methods(Access = protected) function loadConfig(obj, varargin) - % This method loads desired configs by running the corresponding script. - % The script name is specified as the "configName" for each subclass of "Config" + % This method loads desired configs into calling component. + % The component can chose between: + % - Only specifying the configName (name of the config file): + % The loader will look for a variable named like the + % config file. + % - Specifying both the configName and the variableName: + % Useful for when you want to group multiple small + % objects into a larger config file % % Syntax: % obj.loadConfig() - To load from a config file diff --git a/classes/Rocket.m b/classes/Rocket.m index 11e79075d69066fd633853ee8aeb74600e59fbea..755026dc4594b021ae540f34b19dfd6ae35c1b1c 100644 --- a/classes/Rocket.m +++ b/classes/Rocket.m @@ -13,12 +13,24 @@ classdef Rocket < Bay fins Fins = Fins() pitot Pitot = Pitot() - + end + + properties(Dependent) length diameter mass - massNoMotor + massNoMotor % [kg] Mass of rocket with empty motr vane (includes motor fuselage weight) inertia + xCg + end + + properties(Access = private, Hidden) % Overrides + length_ + diameter_ + mass_ + massNoMotor_ + inertia_ + xCg_ end properties(Access = protected) @@ -27,11 +39,62 @@ classdef Rocket < Bay mission Mission end + methods % Getters / Setters + function out = get.length(obj) + if ~isempty(obj.length_), out = obj.length_; return; end + out = obj.nose.length + obj.payload.length + obj.recovery.length + ... + obj.electronics.length + obj.airbrakes.length + obj.motor.length + ... + obj.boat.length; + end + function out = get.diameter(obj) + if ~isempty(obj.diameter_), out = obj.diameter_; return; end + out = obj.payload.diameter; + end + function out = get.mass(obj) + if ~isempty(obj.mass_), out = obj.mass_; return; end + out = obj.nose.mass + obj.payload.mass + obj.recovery.mass + ... + obj.electronics.mass + obj.airbrakes.mass + obj.motor.mass + ... + obj.boat.mass + obj.fins.mass; + end + function out = get.massNoMotor(obj) + if ~isempty(obj.massNoMotor_), out = obj.massNoMotor_; return; end + out = obj.nose.mass + obj.payload.mass + obj.recovery.mass + ... + obj.electronics.mass + obj.airbrakes.mass + obj.motor.fuselageMass + ... + obj.boat.mass + obj.fins.mass; + end + function out = get.inertia(obj) % WIP + if ~isempty(obj.inertia_), out = obj.inertia_; return; end + xCgRelative = [obj.nose.xCg, obj.payload.xCg, obj.recovery.xCg, ... + obj.electronics.xCg, obj.airbrakes.xCg, obj.motor.xCg, ... + obj.boat.xCg, obj.fins.xCg]; + lengths = [obj.nose.length, obj.payload.length, obj.recovery.length, ... + obj.electronics.length, obj.airbrakes.length, obj.motor.length, ... + obj.boat.length]; + lengthsAbsolute = zeros(1, size(lengths, 2)); + for i = 1:size(lengths, 2), lengthsAbsolute(i) = sum(lengths(1:i)); end + xCgAbsolute = xCgRelative + lengthsAbsolute; + + end + function out = get.xCg(obj) + if ~isempty(obj.xCg_), out = obj.xCg_; return; end + %out = + end + + function set.length(obj, value), obj.length_ = value; end + function set.diameter(obj, value), obj.diameter_ = value; end + function set.mass(obj, value), obj.mass_ = value; end + function set.massNoMotor(obj, value), obj.massNoMotor_ = value; end + function set.inertia(obj, value), obj.inertia_ = value; end + function set.xCg(obj, value), obj.xCg_ = value; end + end + methods - function obj = Rocket(mission) + function obj = Rocket(mission, varIn) arguments mission Mission = Mission() + varIn = [] end + obj@Bay(mission, varIn); obj.mission = mission; %% Loading data @@ -46,6 +109,8 @@ classdef Rocket < Bay obj.boat = Boat(mission, vars); obj.fins = Fins(mission, vars); obj.pitot = Pitot(mission, vars); + + %obj.getAvailableProperties() end end end diff --git a/classes/bays/Airbrakes.m b/classes/bays/Airbrakes.m index d7e5e7f4ec0e05e157d0a60ae75652566b096a2f..6974f62180db5f37ea1203e4c69383b92a262d8d 100644 --- a/classes/bays/Airbrakes.m +++ b/classes/bays/Airbrakes.m @@ -18,6 +18,7 @@ classdef Airbrakes < Bay diameter % [m] Diameter of the bay mass % [kg] Total bay mass inertia % [kg*m^2] Total bay inertia (Body reference) + xCg % [m] Cg relative to bay upper side end properties(Access = protected) diff --git a/classes/bays/Boat.m b/classes/bays/Boat.m index 4747c7ad131e778dda8b39c068010158684fbf6b..20d282ce6b9bc41c8433dbdb61865da6b945e2da 100644 --- a/classes/bays/Boat.m +++ b/classes/bays/Boat.m @@ -6,6 +6,7 @@ classdef Boat < Bay diameter % [m] Diameter of the bay mass % [kg] Total bay mass inertia % [kg*m^2] Total bay inertia (Body reference) + xCg % [m] Cg relative to bay upper side end properties(Access = protected) diff --git a/classes/bays/Electronics.m b/classes/bays/Electronics.m index 30add52a8a51543b85cd22e2cafa34cd5e4d3326..a0e1a7a5b2e589a3d19365831bef5116e78d3295 100644 --- a/classes/bays/Electronics.m +++ b/classes/bays/Electronics.m @@ -7,6 +7,7 @@ classdef Electronics < Bay diameter % [m] Diameter of the bay mass % [kg] Total bay mass inertia % [kg*m^2] Total bay inertia (Body reference) + xCg % [m] Cg relative to bay upper side end properties(Access = protected) diff --git a/classes/bays/Motor.m b/classes/bays/Motor.m index 72267804e965c0b0a3410ab8a324eca2b0817d63..8d3fa3704ccbf8e7027afd5e7b9e6aec3bf3bc75 100644 --- a/classes/bays/Motor.m +++ b/classes/bays/Motor.m @@ -16,7 +16,7 @@ classdef Motor < Bay oxidizerMass double % [kg] Oxidizer initial mass structureMass double % [kg] Engine Structural Mass fuselageMass double % [kg] Fuselage of the engine only - xCg double % [m] Engine xcg from tank tip + xCg % [m] Engine xcg from tank tip pe double % [Pa] Eflux pressure ae double % [Pa] Eflux Area end diff --git a/classes/bays/Nose.m b/classes/bays/Nose.m index 297c2246cf8ab0ce9fa9e5c46036706b65ed3d59..0bc382e820d8ab09f457258651305cc9e1fe7cef 100644 --- a/classes/bays/Nose.m +++ b/classes/bays/Nose.m @@ -11,6 +11,7 @@ classdef Nose < Bay diameter % [m] Diameter of the bay mass % [kg] Total bay mass inertia % [kg*m^2] Total bay inertia (Body reference) + xCg % [m] Cg relative to bay upper side end properties(Access = protected) diff --git a/classes/bays/Payload.m b/classes/bays/Payload.m index 9aedec37dfbf1b2e40489de689f6a2f7e9ba4047..0b76fe7076655cf50796589adff5b1db32401547 100644 --- a/classes/bays/Payload.m +++ b/classes/bays/Payload.m @@ -6,6 +6,7 @@ classdef Payload < Bay diameter % [m] Diameter of the bay mass % [kg] Total bay mass inertia % [kg*m^2] Total bay inertia (Body reference) + xCg % [m] Cg relative to bay upper side end properties(Access = protected) diff --git a/classes/bays/Recovery.m b/classes/bays/Recovery.m index 802272bea549696521efb76d325a01a0629b9a8b..09b56aee9fe71efb16aa582bf9687d9715b172c1 100644 --- a/classes/bays/Recovery.m +++ b/classes/bays/Recovery.m @@ -6,6 +6,7 @@ classdef Recovery < Bay diameter % [m] Diameter of the bay mass % [kg] Total bay mass inertia % [kg*m^2] Total bay inertia (Body reference) + xCg % [m] Cg relative to bay upper side end properties(Access = protected) diff --git a/classes/components/Fins.m b/classes/components/Fins.m index bf20b0685bc2086ef5904d0b2be1c65f453e5d8b..c5b214d51619ad3908e80ba14979d72b7a8923bf 100644 --- a/classes/components/Fins.m +++ b/classes/components/Fins.m @@ -3,6 +3,8 @@ classdef Fins < Component % Detailed explanation goes here properties + mass double % [kg] Fins mass + xCg double % [m] Cg from fins root chord tip rootChord double % [m] attached chord length freeChord double % [m] free chord length height double % [m] fin heigth diff --git a/classes/old/Control.m b/classes/old/Control.m deleted file mode 100644 index 1a550e55565360190d3a0ca7f123bb6c47b0946d..0000000000000000000000000000000000000000 --- a/classes/old/Control.m +++ /dev/null @@ -1,33 +0,0 @@ -classdef Control < Config - % CONTROL Summary of this class goes here - % Detailed explanation goes here - - properties - multipleAB logical % If true, multiple and smooth airbrakes opening will be simulated - opening double % aerobrakes, 1-2-3 for 0%, 50% or 100% opened - deltaTime double % aerobrakes, configurations usage time - minTime double % [s] time after which the airbrakes can be used - maxMach double % [-] Maximum Mach at which airbrakes can be used - servoOmega double % [rad/s] Servo-motor angular velocity - height double % [m] Block airbrakes opening coordinate ( First entry must be 0! ) - end - - properties(Access = protected) - configName = 'controlConfig.m' - mission Mission - motor Motor - end - - methods - function obj = Control(mission, motor) - arguments - mission Mission = Mission() - motor Motor = Motor() - end - obj.mission = mission; - obj.motor = motor; - if nargin == 0, return; end - obj.loadConfig(); - end - end -end diff --git a/missions/2024_Lyra_Roccaraso_September/config/rocketConfig.m b/missions/2024_Lyra_Roccaraso_September/config/rocketConfig.m index 5f16058a899b345ed9c8d6d06f6b8047c22257a0..f8c35ee295e17d775c81e8bcdf78e263b48e08da 100644 --- a/missions/2024_Lyra_Roccaraso_September/config/rocketConfig.m +++ b/missions/2024_Lyra_Roccaraso_September/config/rocketConfig.m @@ -3,11 +3,11 @@ %% ROCKET - OVERRIDES BAYS CONFIG rocket = Rocket(); -rocket.length = NaN; % [m] OVERRIDE total length -rocket.diameter = NaN; % [m] OVERRIDE diameter -rocket.mass = NaN; % [kg] OVERRIDE total mass -rocket.massNoMotor = NaN; % [kg] OVERRIDE mass without motor -rocket.inertia = NaN; % [] OVERRIDE total inertia +rocket.length = []; % [m] OVERRIDE total length +rocket.diameter = []; % [m] OVERRIDE diameter +rocket.mass = []; % [kg] OVERRIDE total mass +rocket.massNoMotor = []; % [kg] OVERRIDE mass without motor +rocket.inertia = []; % [] OVERRIDE total inertia %% NOSE nose = Nose(); @@ -86,6 +86,8 @@ boat.inertia = 0; %% FINS fins = Fins(); +fins.mass = 0; +fins.xCg = 0; fins.rootChord = 0.30; % [m] attached chord length fins.freeChord = 0.14; % [m] free chord length fins.height = 0.11; % [m] fin heigth