From b4b2a321806c9756da16a72d21341318667c9ad6 Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Wed, 3 Apr 2024 18:19:38 +0200 Subject: [PATCH] [msa-refactoring][classes] Applying merge request directives - Removed unnecessary files - Added headers --- classes/Bay.m | 5 ++-- classes/Component.m | 6 ++-- classes/Config.m | 6 ++-- classes/Mission.m | 13 ++++----- classes/Rocket.m | 16 +++++++---- classes/Settings.m | 13 ++++++++- classes/bays/Airbrakes.m | 46 +++++++++++++++++------------- classes/bays/Boat.m | 29 ------------------- classes/bays/Electronics.m | 13 +++++++-- classes/bays/Fincan.m | 38 ------------------------- classes/bays/Motor.m | 15 +++++++--- classes/bays/Nose.m | 12 ++++++-- classes/bays/Payload.m | 13 +++++++-- classes/bays/Rear.m | 14 +++++++-- classes/bays/Recovery.m | 13 +++++++-- classes/old/Environment.asv | 54 ----------------------------------- classes/old/Geometries.m | 57 ------------------------------------- classes/old/Masses.m | 52 --------------------------------- tests/argValidation.m | 11 ------- tests/speedBenchmark.asv | 22 -------------- tests/speedBenchmark.m | 32 --------------------- 21 files changed, 128 insertions(+), 352 deletions(-) delete mode 100644 classes/bays/Boat.m delete mode 100644 classes/bays/Fincan.m delete mode 100644 classes/old/Environment.asv delete mode 100644 classes/old/Geometries.m delete mode 100644 classes/old/Masses.m delete mode 100644 tests/argValidation.m delete mode 100644 tests/speedBenchmark.asv delete mode 100644 tests/speedBenchmark.m diff --git a/classes/Bay.m b/classes/Bay.m index a364fa0..180b279 100644 --- a/classes/Bay.m +++ b/classes/Bay.m @@ -1,7 +1,6 @@ classdef Bay < Component & matlab.mixin.Heterogeneous - % An abstraction class that enables a standardized management of data - % Properties and methods implemented in the Component class will - % impact every physical component of the rocket (e.g. motor, elc ...) +% Bay: Represents an abstraction layer for all bays +% Arrays of bay subclasses will be represented as [mxn Bay] arrays properties(Abstract) position % [m] Absolute position, relative to previous component diff --git a/classes/Component.m b/classes/Component.m index ea0b56b..6bb0510 100644 --- a/classes/Component.m +++ b/classes/Component.m @@ -1,7 +1,7 @@ classdef Component < Config - %COMPONENT Summary of this class goes here - % Detailed explanation goes here - +% Component: Represents an abstraction layer for all components +% Components standardize object construction, config and data loading + properties(Abstract, Access = protected) % Insert dependencies here mission Mission diff --git a/classes/Config.m b/classes/Config.m index 0042af3..7995125 100644 --- a/classes/Config.m +++ b/classes/Config.m @@ -1,7 +1,7 @@ classdef(Abstract) Config < handle - % An abstraction class that enables a standardized management of data - % Properties and methods implemented in the Config class will impact - % every data class in the framework (e.g. Component and its subclasses) +% Config: Represents an abstraction layer for all config-dependent Classes +% Config standardizes property management and declares fundemental +% properties (see doc for more info) properties(Abstract, Access = protected) configName {mustBeTextScalar} diff --git a/classes/Mission.m b/classes/Mission.m index c18fd9f..d3b2508 100644 --- a/classes/Mission.m +++ b/classes/Mission.m @@ -1,11 +1,10 @@ classdef Mission < Config - % Class containing names and paths to access mission files - % This should be the first class to be created, - % when running a tool. - % - % To get an empty Mission, run "Mission()", or "Mission(false)" - % To get an initialized Mission, run "Mission(true)" - % Where the argument specifies whether to read config files or not +% Config: Contains names and paths needed to access mission-dependent config files +% +% To get an empty Mission, run "Mission()", or "Mission(false)" +% To get an initialized Mission, run "Mission(true)" +% Where the argument specifies whether to read config files or not + properties name % Mission name, used to access <mission> folder diff --git a/classes/Rocket.m b/classes/Rocket.m index 99affd7..b56e56e 100644 --- a/classes/Rocket.m +++ b/classes/Rocket.m @@ -1,7 +1,15 @@ classdef Rocket < Component - %ROCKET Summary of this class goes here - % Detailed explanation goes here - +% Rocket: Contains and manages all bays +% +% Constructor: +% - Rocket: Creates an instance of the Rocket class. +% Loaded config: rocketConfig.m > rocket (for overrides) +% Loaded data: - +% Arguments: +% - mission: Mission, mission object +% - varIn: (optional) config source. Alternative to config.m +% file + properties nose Nose = Nose() payload Payload = Payload() @@ -10,8 +18,6 @@ classdef Rocket < Component airbrakes Airbrakes = Airbrakes() motor Motor = Motor() rear Rear = Rear() - % fincan Fincan = Fincan() - % boat Boat = Boat() pitot Pitot = Pitot() diff --git a/classes/Settings.m b/classes/Settings.m index 7255fa5..e7a9e8d 100644 --- a/classes/Settings.m +++ b/classes/Settings.m @@ -1,5 +1,16 @@ classdef Settings < Config & dynamicprops - +% Settings: Provides standardized way of loading config files +% Looks for files in missions > settings for global settings +% Looks for files in caller's folder otherwise +% +% Constructor: +% - Settings: Creates an instance of the Settings class. +% Loaded config: - +% Loaded data: - +% Arguments: +% - configNames: config file names. Accepts shortened version +% e.g: ode -> odeConfig.m + properties(Access = protected) configPath = '' configName = '' diff --git a/classes/bays/Airbrakes.m b/classes/bays/Airbrakes.m index c4d67b5..34a5405 100644 --- a/classes/bays/Airbrakes.m +++ b/classes/bays/Airbrakes.m @@ -1,25 +1,33 @@ classdef Airbrakes < Bay - %AIRBRAKES Summary of this class goes here - % Detailed explanation goes here +% Airbrakes: Represents airbrakes configuration for a rocket. +% +% Constructor: +% - Airbrakes: Creates an instance of the Airbrakes class. +% Loaded config: rocketConfig.m > airbrakes +% Loaded data: - +% Arguments: +% - mission: Mission, mission object +% - varIn: (optional) config source. Alternative to config.m +% file properties - n double % [-] number of brakes - thickness double % [m] brakes thickness - width double % [m] brakes width - xDistance double % [m] axial position from nosecone base - multipleAB {islogical} % 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! ) - position % [m] Offset with respect to other bays (negative -> shift forward) - length % [m] Total bay length - 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 + n double % [-] number of brakes + thickness double % [m] brakes thickness + width double % [m] brakes width + xDistance double % [m] axial position from nosecone base + multipleAB {islogical} % 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! ) + position % [m] Offset with respect to other bays (negative -> shift forward) + length % [m] Total bay length + 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 deleted file mode 100644 index 068eff1..0000000 --- a/classes/bays/Boat.m +++ /dev/null @@ -1,29 +0,0 @@ -classdef Boat < Bay - %GEOMETRY Summary of this class goes here - % Detailed explanation goes here - properties - type {mustBeMember(type, {'', 'CONE', 'OGIVE'})} = '' % [] Boat type - position % [m] Absolute position, relative to nose base - length % [m] Total bay length - diameter % [m] Final 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) - configName = 'rocketConfig.m' - variableName = 'boat' - mission Mission = Mission() - end - - methods - function obj = Boat(mission, varIn) - arguments(Input) - mission Mission = Mission() - varIn = [] - end - obj@Bay(mission, varIn); - end - end -end \ No newline at end of file diff --git a/classes/bays/Electronics.m b/classes/bays/Electronics.m index 3da5111..c7b419e 100644 --- a/classes/bays/Electronics.m +++ b/classes/bays/Electronics.m @@ -1,7 +1,14 @@ classdef Electronics < Bay - % An abstraction class that enables a standardized management of data - % Properties and methods implemented in the Component class will - % impact every physical component of the rocket (e.g. motor, elc ...) +% Electronics: Represents electronics configuration for a rocket. +% +% Constructor: +% - Electronics: Creates an instance of the Electronics class. +% Loaded config: rocketConfig.m > electronics +% Loaded data: - +% Arguments: +% - mission: Mission, mission object +% - varIn: (optional) config source. Alternative to config.m +% file properties offset = 0 position % [m] Absolute position, relative to nose base diff --git a/classes/bays/Fincan.m b/classes/bays/Fincan.m deleted file mode 100644 index fba4ea2..0000000 --- a/classes/bays/Fincan.m +++ /dev/null @@ -1,38 +0,0 @@ -classdef Fincan < Bay - %FINS Summary of this class goes here - % Detailed explanation goes here - - properties - mass % [kg] Fins mass - position % [m] Absolute position, relative to nose base - length - diameter - inertia - xCg % [m] Cg from fins root chord tip - rootChord double % [m] attached chord length - freeChord double % [m] free chord length - height double % [m] fin heigth - deltaXFreeChord double % [m] start of Chord 2 measured from start of Chord 1 - nPanel double % [m] number of fins - leadingEdgeRadius double % [deg] Leading edge radius at each span station - axialDistance double % [m] distance between end of root chord and end of center body - semiThickness double % [m] fin semi-thickness - maxThicknessPosition double % [m] Fraction of chord from leading edge to max thickness - end - - properties(Access = protected) - configName = 'rocketConfig.m' - variableName = 'fincan' - mission Mission = Mission() - end - - methods - function obj = Fincan(mission, varIn) - arguments(Input) - mission Mission = Mission() - varIn = [] - end - obj@Bay(mission, varIn); - end - end -end \ No newline at end of file diff --git a/classes/bays/Motor.m b/classes/bays/Motor.m index 41dfde0..d58b4e1 100644 --- a/classes/bays/Motor.m +++ b/classes/bays/Motor.m @@ -1,7 +1,14 @@ classdef Motor < Bay - %MOTOR Summary of this class goes here - % Detailed explanation goes here - +% Motor: Represents the motor configuration for a rocket. +% +% Constructor: +% - Motor: Creates an instance of the Motor class. +% Loaded config: rocketConfig.m > motor +% Loaded data: motors.mat +% Arguments: +% - mission: Mission, mission object +% - varIn: (optional) config source. Alternative to config.m file + properties name {mustBeTextScalar} = '' % [-] Motor name position % [m] Absolute position, relative to nose base @@ -51,7 +58,7 @@ classdef Motor < Bay function mass = get.mass(obj) mass = obj.propellantMass + ... - obj.structureMass; %+ obj.fuselageMass; + obj.structureMass + obj.fuselageMass; end function fuselageXCg = get.fuselageXCg(obj) diff --git a/classes/bays/Nose.m b/classes/bays/Nose.m index 8906d68..1bdc032 100644 --- a/classes/bays/Nose.m +++ b/classes/bays/Nose.m @@ -1,6 +1,14 @@ classdef Nose < Bay - %NOSE Summary of this class goes here - % Detailed explanation goes here +% Nose: Represents nose configuration for a rocket. +% +% Constructor: +% - Nose: Creates an instance of the Nose class. +% Loaded config: rocketConfig.m > nose +% Loaded data: - +% Arguments: +% - mission: Mission, mission object +% - varIn: (optional) config source. Alternative to config.m +% file properties ogiveType {mustBeMember(ogiveType, {'', 'CONE', 'OGIVE', ... diff --git a/classes/bays/Payload.m b/classes/bays/Payload.m index 3db6c22..1c94ad7 100644 --- a/classes/bays/Payload.m +++ b/classes/bays/Payload.m @@ -1,6 +1,15 @@ classdef Payload < Bay - %GEOMETRY Summary of this class goes here - % Detailed explanation goes here +% Payload: Represents payload configuration for a rocket. +% +% Constructor: +% - Payload: Creates an instance of the Payload class. +% Loaded config: rocketConfig.m > payload +% Loaded data: - +% Arguments: +% - mission: Mission, mission object +% - varIn: (optional) config source. Alternative to config.m +% file + properties position % [m] Absolute position, relative to nose base length % [m] Total bay length diff --git a/classes/bays/Rear.m b/classes/bays/Rear.m index cd0b66d..33f1b9e 100644 --- a/classes/bays/Rear.m +++ b/classes/bays/Rear.m @@ -1,7 +1,15 @@ classdef Rear < Bay - %REAR Summary of this class goes here - % Detailed explanation goes here - +% Rear: Represents fincan + boat configuration for a rocket. +% +% Constructor: +% - Rear: Creates an instance of the Rear class. +% Loaded config: rocketConfig.m > rear +% Loaded data: - +% Arguments: +% - mission: Mission, mission object +% - varIn: (optional) config source. Alternative to config.m +% file + properties position % [m] Absolute position, relative to nose base length % [m] Total bay length diff --git a/classes/bays/Recovery.m b/classes/bays/Recovery.m index 2c34c58..1947b29 100644 --- a/classes/bays/Recovery.m +++ b/classes/bays/Recovery.m @@ -1,6 +1,15 @@ classdef Recovery < Bay - %GEOMETRY Summary of this class goes here - % Detailed explanation goes here +% Recovery: Represents recovery configuration for a rocket. +% +% Constructor: +% - Recovery: Creates an instance of the Recovery class. +% Loaded config: rocketConfig.m > recovery +% Loaded data: - +% Arguments: +% - mission: Mission, mission object +% - varIn: (optional) config source. Alternative to config.m +% file + properties position % [m] Absolute position, relative to nose base length % [m] Total bay length diff --git a/classes/old/Environment.asv b/classes/old/Environment.asv deleted file mode 100644 index 32e6431..0000000 --- a/classes/old/Environment.asv +++ /dev/null @@ -1,54 +0,0 @@ -classdef Environment < Config - %ENVIRONMENT Summary of this class goes here - % Detailed explanation goes here - - properties - lat0 double % [deg] Launchpad latitude - lon0 double % [deg] Launchpad longitude - z0 double % [m] Launchpad Altitude - pin1Length double % [m] Distance from the upper pin to the upper tank cap - pin2Length double % [m] Distance from the lower pin to the lower tank cap - rampLength double % [m] Total launchpad length - temperature double % [deg] Ground temperature - pressure double % [Pa] Ground pressure - rho double % [Kg/m^3] Gorund air density - end - - properties(Dependent) - g0 double % [-] Gravity costant at launch latitude and altitude - pinDistance double % [m] Distance of the upper pin from the rail base (upper pin-boat + boat-rail base) - effectiveRampLength double % [m] Total launchpad length - end - - properties(Access = protected) - configName = 'environmentConfig.m' - mission Mission - motor Motor - end - - methods - function obj = Environment(mission, motor) - arguments - mission Mission = Mission() - motor Motor = Mission() - end - obj.mission = mission; - obj.motor = motor; - if nargin == 0, return; end - obj.loadConfig(); - end - - function g0 = get.g0(obj) - g0 = gravitywgs84(obj.z0, obj.lat0); - end - - function pinDistance = get.pinDistance(obj) - pinDistance = obj.pin1Length + obj.pin2Length ... - + obj.motor.tankLength; - end - - function effectiveRampLength = get.effectiveRampLength(obj) - effectiveRampLength = gravitywgs84(obj.z0, obj.lat0); - end - end -end \ No newline at end of file diff --git a/classes/old/Geometries.m b/classes/old/Geometries.m deleted file mode 100644 index 1f2706d..0000000 --- a/classes/old/Geometries.m +++ /dev/null @@ -1,57 +0,0 @@ -classdef(InferiorClasses = {?Boat, ?Center, ?Nose, ?Pitot, ?Fins, ?Protuberances}) ... - Geometries < Config - %GEOMETRY Summary of this class goes here - % Detailed explanation goes here - - properties - boat Boat = Boat() - center Center = Center() % Center (Excluding motor) - nose Nose = Nose() - pitot Pitot = Pitot() - fins Fins = Fins() - protuberances Protuberances = Protuberances() - nXCg {mustBePositive, mustBeInteger} - xCgNoMotor double - end - - properties(Dependent) % Center + motor length - length double - xCg (1,:) double - end - - properties(Access = protected) - configName = 'geometryConfig.m' - mission Mission - motor Motor - mass Masses - end - - methods - function obj = Geometries(mission, motor, mass) - %GEOMETRY Construct an instance of this class - % Detailed explanation goes here - %obj; - arguments (Input) - mission Mission = Mission() - motor Motor = Motor() - mass Masses = Masses() - end - obj.mission = mission; - obj.motor = motor; - obj.mass = mass; - if nargin == 0, return; end - if nargin ~= 3, error('Wrong input arguments count: only specify 2 arguments'); end - obj.loadConfig(); - end - - function xCg = get.xCg(obj) - xCg = (obj.motor.totalMass.*(obj.center.length + obj.motor.xCg) + ... - obj.mass.noMotor*obj.xCgNoMotor)./(obj.motor.totalMass + obj.mass.noMotor); - end - - function length = get.length(obj) - length = obj.center.length + ... - obj.motor.totalLength; - end - end -end \ No newline at end of file diff --git a/classes/old/Masses.m b/classes/old/Masses.m deleted file mode 100644 index 5114576..0000000 --- a/classes/old/Masses.m +++ /dev/null @@ -1,52 +0,0 @@ -classdef Masses < Config - %MASS Summary of this class goes here - % Detailed explanation goes here - - properties - boat % [kg] BoatTail Mass - center % [kg] Center Mass (no motor) - nose % [kg] Nosecone Mass - fins % [kg] Finset Mass - end - - properties(Dependent) - noMotor % [kg] Total mass (no motor) - structure % [kg] Total structural Mass - total % [kg] Total mass (in time) - end - - properties(Access = protected) - configName = 'massConfig.m' - mission Mission - motor Motor - end - - methods - function obj = Masses(mission, motor) - arguments (Input) - mission Mission = Mission() - motor Motor = Motor() - end - obj.mission = mission; - obj.motor = motor; - if nargin == 0, return; end - if nargin ~= 2, error('Wrong input arguments count: only specify 2 arguments'); end - obj.loadConfig(); - end - - function noMotor = get.noMotor(obj) - noMotor = obj.boat + obj.center + ... - obj.nose + obj.fins; - end - - function structure = get.structure(obj) - structure = obj.noMotor + ... - obj.motor.structureMass; - end - - function total = get.total(obj) - total = obj.noMotor + ... - obj.motor.totalMass; - end - end -end \ No newline at end of file diff --git a/tests/argValidation.m b/tests/argValidation.m deleted file mode 100644 index 96633f8..0000000 --- a/tests/argValidation.m +++ /dev/null @@ -1,11 +0,0 @@ -function test(in) - arguments(Input) - in Config {mustBeConfig} - end - disp(in.a); -end - -function mustBeConfig(obj) - if ~isa(obj, 'Config'), error('suca'); - end -end \ No newline at end of file diff --git a/tests/speedBenchmark.asv b/tests/speedBenchmark.asv deleted file mode 100644 index 1388be0..0000000 --- a/tests/speedBenchmark.asv +++ /dev/null @@ -1,22 +0,0 @@ -ms = Mission(true); - -cl = Motor(ms); -st = struct(cl); - -len = length(st.xCg); -a = zeros(1, len); -b = zeros(1, len); - -tic - for i = 1:len - a(i) = cl.xCg(i); - end -classTime = toc; - -tic - for i = 1:len - b(i) = st.xCg(i); - end -structTime = toc; - -disp(strcat('classTime: ', classTime)); \ No newline at end of file diff --git a/tests/speedBenchmark.m b/tests/speedBenchmark.m deleted file mode 100644 index 5c2c39e..0000000 --- a/tests/speedBenchmark.m +++ /dev/null @@ -1,32 +0,0 @@ -clear; clc; close all; - -ms = Mission(true); - -cl = Motor(ms); -st = struct(cl); - -len = length(st.xCg); -a = zeros(1, len); -b = zeros(1, len); -c = zeros(1, len); -d = zeros(1, len); - -tic -a = cl.xCg; -fprintf('stdAssignment, class: %f s\n', toc); - -tic -c = st.xCg; -fprintf('stdAssignment, struct: %f s\n', toc); - -tic -for i = 1:len - b(i) = cl.xCg(i); -end -fprintf('elementWiseAssignment, class: %f s\n', toc); - -tic -for i = 1:len - d(i) = st.xCg(i); -end -fprintf('elementWiseAssignment, struct: %f s\n', toc); \ No newline at end of file -- GitLab