From a05ea54c4fe294ebc6bf71fdd81700d4a616e11e Mon Sep 17 00:00:00 2001
From: giuliaghirardini <giuliaghirardini2001@gmail.com>
Date: Sat, 2 Mar 2024 18:57:41 +0100
Subject: [PATCH] [refactoring-msa][classes] Implemented bays and implemented
 config for bays

---
 classes/Bay.m                                 | 28 +++++++++++---
 classes/Payload.m                             | 15 ++++++++
 classes/Recovery.m                            | 15 ++++++++
 classes/bays/Airbrakes.m                      | 27 ++++++++++++++
 classes/bays/Boat.m                           | 14 +++++--
 classes/bays/Electronics.m                    | 16 ++++++++
 classes/bays/Motor.m                          | 16 ++------
 classes/bays/Nose.m                           | 20 +++++++---
 classes/bays/Protuberances.m                  | 11 ------
 .../config/airbrakesConfig.m                  | 37 +++++++++++++++++++
 .../config/boatConfig.m                       |  8 ++++
 .../config/controlConfig.m                    | 27 --------------
 .../config/noseConfig.m                       | 12 ++++++
 .../config/payloadConfig.m                    |  8 ++++
 .../config/recoveryConfig.m                   |  8 ++++
 15 files changed, 195 insertions(+), 67 deletions(-)
 create mode 100644 classes/Payload.m
 create mode 100644 classes/Recovery.m
 create mode 100644 classes/bays/Airbrakes.m
 create mode 100644 classes/bays/Electronics.m
 delete mode 100644 classes/bays/Protuberances.m
 create mode 100644 missions/2024_Lyra_Roccaraso_September/config/airbrakesConfig.m
 create mode 100644 missions/2024_Lyra_Roccaraso_September/config/boatConfig.m
 delete mode 100644 missions/2024_Lyra_Roccaraso_September/config/controlConfig.m
 create mode 100644 missions/2024_Lyra_Roccaraso_September/config/noseConfig.m
 create mode 100644 missions/2024_Lyra_Roccaraso_September/config/payloadConfig.m
 create mode 100644 missions/2024_Lyra_Roccaraso_September/config/recoveryConfig.m

diff --git a/classes/Bay.m b/classes/Bay.m
index 6de8215..01cedb5 100644
--- a/classes/Bay.m
+++ b/classes/Bay.m
@@ -1,13 +1,29 @@
-classdef (Abstract) Bay < Component
+classdef Bay < Component
     % 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 ...)
 
-    properties(Abstract)
-        length      
-        diameter
-        mass
-        inertia
+    properties (Abstract)
+        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)
+    end
+
+    methods(Static, Access = protected)
+        function loadData(), end
+    end
+    
+    methods
+        function obj = Bay(mission)
+            arguments (Input)
+                mission Mission = Mission()
+            end
+            obj.mission = mission;
+            if nargin == 0, return;  end
+            obj.loadConfig();
+            obj.loadData();
+        end
     end
 end
 
diff --git a/classes/Payload.m b/classes/Payload.m
new file mode 100644
index 0000000..3f120f1
--- /dev/null
+++ b/classes/Payload.m
@@ -0,0 +1,15 @@
+classdef Payload < Bay
+    %GEOMETRY Summary of this class goes here
+    %   Detailed explanation goes here
+    properties
+        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)
+    end
+
+    properties(Access = protected)
+        configName = 'payloadConfig.m'
+        mission
+    end
+end
\ No newline at end of file
diff --git a/classes/Recovery.m b/classes/Recovery.m
new file mode 100644
index 0000000..d76416f
--- /dev/null
+++ b/classes/Recovery.m
@@ -0,0 +1,15 @@
+classdef Recovery < Bay
+    %GEOMETRY Summary of this class goes here
+    %   Detailed explanation goes here
+    properties
+        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)
+    end
+
+    properties(Access = protected)
+        configName = 'recoveryConfig.m'
+        mission
+    end
+end
\ No newline at end of file
diff --git a/classes/bays/Airbrakes.m b/classes/bays/Airbrakes.m
new file mode 100644
index 0000000..1a5adea
--- /dev/null
+++ b/classes/bays/Airbrakes.m
@@ -0,0 +1,27 @@
+classdef Airbrakes < Bay
+    %AIRBRAKES Summary of this class goes here
+    %   Detailed explanation goes here
+    
+    properties
+        n           double         % [-] number of brakes
+        brakeLength double         % [m] brakes length (normal)         
+        brakeWidth  double         % [m] brakes width (normal)
+        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! )
+        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)
+    end
+    
+    properties(Access = protected)
+        configName = 'airbrakesConfig.m'
+        mission
+    end    
+end
\ No newline at end of file
diff --git a/classes/bays/Boat.m b/classes/bays/Boat.m
index afb58f0..3869888 100644
--- a/classes/bays/Boat.m
+++ b/classes/bays/Boat.m
@@ -1,9 +1,15 @@
-classdef Boat
+classdef Boat < Bay
     %GEOMETRY Summary of this class goes here
     %   Detailed explanation goes here
-
     properties
-        length      double
-        diameter    double
+        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)
+    end
+
+    properties(Access = protected)
+        configName = 'boatConfig.m'
+        mission
     end
 end
\ No newline at end of file
diff --git a/classes/bays/Electronics.m b/classes/bays/Electronics.m
new file mode 100644
index 0000000..7f12373
--- /dev/null
+++ b/classes/bays/Electronics.m
@@ -0,0 +1,16 @@
+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 ...)
+    properties
+        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)
+    end
+
+    properties(Access = protected)
+        configName = 'electronicsConfig.m'
+        mission
+    end
+end
\ No newline at end of file
diff --git a/classes/bays/Motor.m b/classes/bays/Motor.m
index fdb3464..bfc6728 100644
--- a/classes/bays/Motor.m
+++ b/classes/bays/Motor.m
@@ -5,8 +5,8 @@ classdef Motor < Bay
     properties
         name            {mustBeTextScalar} = '' % [-]  Motor name
         length                                  % [m]  Total length (motor + tank)
-        diameter        
-        inertia         
+        diameter                                % [m]  Diameter of the Motor 
+        inertia                                 % [kg*m^2] Total Motor inertia (Body reference)
         tankLength      double                  % [m]  Tank length
         ignitionTime    double                  % [s]  Ignition transient duration
         cutoffTime      double                  % [s]  Cutoff transient duration
@@ -22,7 +22,7 @@ classdef Motor < Bay
     end
 
     properties(Dependent)
-        mass                                    % [kg] Total motor mass
+        mass                                    % [kg] Total Motor mass
         propellantMass  double                  % [Kg] Propellant Mass (in time)
         fuselageXCg     double                  % [m]  xcg of the engine fuselage only from tank tip
     end
@@ -33,16 +33,6 @@ classdef Motor < Bay
     end
 
     methods
-        function obj = Motor(mission)
-            arguments (Input)
-                mission Mission = Mission()
-            end
-            obj.mission = mission;
-            if nargin == 0, return;  end
-            obj.loadConfig();
-            obj.loadData();
-        end
-
         function set.name(obj, name)
             obj.name = name;
             obj.loadData();
diff --git a/classes/bays/Nose.m b/classes/bays/Nose.m
index 3820eac..6085b1b 100644
--- a/classes/bays/Nose.m
+++ b/classes/bays/Nose.m
@@ -1,12 +1,20 @@
-classdef Nose
+classdef Nose < Bay
     %NOSE Summary of this class goes here
     %   Detailed explanation goes here
 
     properties
-        length      double                               % [m] Nosecone Length
-        ogiveType   {mustBeTextScalar} = ''              % [-] Nosecone shape
-        power       double                          % [-] Nosecone power type parameter
-        p           double                  % [-] P coefficient for modified nosecone shapes
-        c           double                  % [-] C coefficient for modified nosecone shapes
+        ogiveType   {mustBeTextScalar} = ''     % [-] Nosecone shape
+        power       double                      % [-] Nosecone power type parameter
+        p           double                      % [-] P coefficient for modified nosecone shapes
+        c           double                      % [-] C coefficient for modified nosecone shapes
+        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)
+    end
+
+    properties(Access = protected)
+        configName = 'noseConfig.m'
+        mission
     end
 end
\ No newline at end of file
diff --git a/classes/bays/Protuberances.m b/classes/bays/Protuberances.m
deleted file mode 100644
index a27673e..0000000
--- a/classes/bays/Protuberances.m
+++ /dev/null
@@ -1,11 +0,0 @@
-classdef Protuberances
-    %PROTUBERANCES Summary of this class goes here
-    %   Detailed explanation goes here
-
-    properties
-        n           double      % [-] number of brakes
-        length      double      % [m] brakes thickness
-        width       double      % [m] brakes width (normal)
-        xDistance   double      % [m] axial position from nosecone base
-    end
-end
\ No newline at end of file
diff --git a/missions/2024_Lyra_Roccaraso_September/config/airbrakesConfig.m b/missions/2024_Lyra_Roccaraso_September/config/airbrakesConfig.m
new file mode 100644
index 0000000..70b9c42
--- /dev/null
+++ b/missions/2024_Lyra_Roccaraso_September/config/airbrakesConfig.m
@@ -0,0 +1,37 @@
+% CONFIG - This script sets up control parameters
+
+%% AEROBRAKES SETTINGS
+% Multiple air-brakes and smooth opening simulation
+% If FALSE:
+%       - settings.control: only the first value will be computed;
+%       - settings.dtControl: is not read.
+% If TRUE:
+%       - settings.control: define the sequence of air-brakes opening
+%                           configuration. Closed air-brakes are simulated
+%                           untill the conditions settings.tControl and
+%                           settings.machControl are both verified, check
+%                           simulationsData.m;
+%       - settings.dtControl: define the usage time of the i-th
+%                             configuration. Its length must be -1 the
+%                             length of settings.control
+airbrakes = Airbrakes();
+
+airbrakes.multipleAB = false;                   % If true, multiple and smooth airbrakes opening will be simulated
+airbrakes.opening = [1 3];                      % aerobrakes, 1-2-3 for 0%, 50% or 100% opened
+airbrakes.deltaTime = [10];                     % aerobrakes, configurations usage time
+
+airbrakes.n = 3;                                % [-] number of brakes
+airbrakes.brakeWidth = 0.1002754821;            % [m] brakes width (normal)
+airbrakes.brakeLength = 0.008;                  % [m] brakes thickness
+airbrakes.xDistance = 1.517;                    % [m] axial position from nosecone base
+
+airbrakes.length = 000;
+airbrakes.diameter = 000;
+airbrakes.mass = 000;
+airbrakes.inertia = 000;
+
+%% AIRBRAKES CONTROL SETTINGS
+airbrakes.minTime = 0;                          % [s] time after which the airbrakes can be used
+airbrakes.maxMach = 0.8;                        % [-] Maximum Mach at which airbrakes can be used
+airbrakes.servoOmega = 150*pi/180;              % [rad/s] Servo-motor angular velocity
+airbrakes.height = linspace(0, 0.0363, 3);      % [m] Block airbrakes opening coordinate ( First entry must be 0! )
\ No newline at end of file
diff --git a/missions/2024_Lyra_Roccaraso_September/config/boatConfig.m b/missions/2024_Lyra_Roccaraso_September/config/boatConfig.m
new file mode 100644
index 0000000..910977d
--- /dev/null
+++ b/missions/2024_Lyra_Roccaraso_September/config/boatConfig.m
@@ -0,0 +1,8 @@
+% CONFIG - This script sets up control parameters
+
+boat = Boat();
+
+boat.length = 0;
+boat.diameter = 0;
+boat.mass = 0;
+boat.inertia = 0;
diff --git a/missions/2024_Lyra_Roccaraso_September/config/controlConfig.m b/missions/2024_Lyra_Roccaraso_September/config/controlConfig.m
deleted file mode 100644
index 0fe845b..0000000
--- a/missions/2024_Lyra_Roccaraso_September/config/controlConfig.m
+++ /dev/null
@@ -1,27 +0,0 @@
-% CONFIG - This script sets up control parameters
-
-%% AEROBRAKES SETTINGS
-% Multiple air-brakes and smooth opening simulation
-% If FALSE:
-%       - settings.control: only the first value will be computed;
-%       - settings.dtControl: is not read.
-% If TRUE:
-%       - settings.control: define the sequence of air-brakes opening
-%                           configuration. Closed air-brakes are simulated
-%                           untill the conditions settings.tControl and
-%                           settings.machControl are both verified, check
-%                           simulationsData.m;
-%       - settings.dtControl: define the usage time of the i-th
-%                             configuration. Its length must be -1 the
-%                             length of settings.control
-control = Control();
-
-control.multipleAB = false;                                                % If true, multiple and smooth airbrakes opening will be simulated
-control.opening = [1 3];                                                   % aerobrakes, 1-2-3 for 0%, 50% or 100% opened
-control.deltaTime = [10];                                                  % aerobrakes, configurations usage time
-
-%% AIRBRAKES CONTROL SETTINGS
-control.minTime = 0;                              % [s] time after which the airbrakes can be used
-control.maxMach = 0.8;                                   % [-] Maximum Mach at which airbrakes can be used
-control.servoOmega = 150*pi/180;                                 % [rad/s] Servo-motor angular velocity
-control.height = linspace(0, 0.0363, 3);                      % [m] Block airbrakes opening coordinate ( First entry must be 0! )
\ No newline at end of file
diff --git a/missions/2024_Lyra_Roccaraso_September/config/noseConfig.m b/missions/2024_Lyra_Roccaraso_September/config/noseConfig.m
new file mode 100644
index 0000000..a17048f
--- /dev/null
+++ b/missions/2024_Lyra_Roccaraso_September/config/noseConfig.m
@@ -0,0 +1,12 @@
+% CONFIG - This script contains information about Nose
+
+nose = Nose();
+
+nose.length = 000;                                       % [m] Nosecone Length
+nose.diameter = 000;                                     % [m] Nosecone Diameter
+nose.mass = 000;                                         % [m] Nosecone Inertia
+nose.inertia = 000;                                      % [m] Nosecone Mass
+nose.ogiveType = 'MHAACK';                               % [-] Nosecone shape
+nose.power = 000; %3/4;                                  % [-] Nosecone power type parameter
+nose.p = 000; %1.250152e+00;                             % [-] P coefficient for modified nosecone shapes
+nose.c = 000; %1.799127e-01;                             % [-] C coefficient for modified nosecone shapes
\ No newline at end of file
diff --git a/missions/2024_Lyra_Roccaraso_September/config/payloadConfig.m b/missions/2024_Lyra_Roccaraso_September/config/payloadConfig.m
new file mode 100644
index 0000000..4171b03
--- /dev/null
+++ b/missions/2024_Lyra_Roccaraso_September/config/payloadConfig.m
@@ -0,0 +1,8 @@
+% CONFIG - This script sets up control parameters
+
+payload = Payload();
+
+payload.length = 0;
+payload.diameter = 0;
+payload.mass = 0;
+payload.inertia = 0;
\ No newline at end of file
diff --git a/missions/2024_Lyra_Roccaraso_September/config/recoveryConfig.m b/missions/2024_Lyra_Roccaraso_September/config/recoveryConfig.m
new file mode 100644
index 0000000..9777cce
--- /dev/null
+++ b/missions/2024_Lyra_Roccaraso_September/config/recoveryConfig.m
@@ -0,0 +1,8 @@
+% CONFIG - This script sets up control parameters
+
+recovery = Recovery();
+
+recovery.length = 0;
+recovery.diameter = 0;
+recovery.mass = 0;
+recovery.inertia = 0;
\ No newline at end of file
-- 
GitLab