From 14f32aa62b0eb7fa2ab0eb040243d4b7199a3638 Mon Sep 17 00:00:00 2001
From: Mauco03 <marco.gaibotti@skywarder.eu>
Date: Tue, 25 Feb 2025 21:23:18 +0100
Subject: [PATCH] [handle-value-conversion][classes] Data coherence check with
 old rocket class

---
 classes/@Rocket/update.m                                  | 5 +++--
 classes/@Rocket/updateBay.m                               | 3 ++-
 classes/bays/Parafoil.m                                   | 5 +++++
 .../config/environmentConfig.m                            | 8 ++++----
 .../2025_Orion_Portugal_October/config/rocketConfig.m     | 3 ++-
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/classes/@Rocket/update.m b/classes/@Rocket/update.m
index ae246b7..2685b08 100644
--- a/classes/@Rocket/update.m
+++ b/classes/@Rocket/update.m
@@ -27,8 +27,9 @@ if ~override('INERTIA')
     % [3xN] Ix, Iy, Iz
     % Assumption: xCgs are close to rocket axis
     motorInertia = obj.motor.inertia(2:3, :) + ...
-        (obj.xcg - (obj.motor.position + obj.motor.xcg)).^2 .* obj.motor.mass;
-    baysInertia = obj.inertiaNoMotor(2:3, :);
+                (obj.xcg - (obj.motor.position + obj.motor.xcg)).^2 .* obj.motor.mass;
+    baysInertia = obj.inertiaNoMotor(2:3, :) + ...
+                (obj.xcg - obj.xcgNoMotor).^2 .* obj.massNoMotor;
     
     obj.inertia = [obj.motor.inertia(1, :) + obj.inertiaNoMotor(1, :);
         motorInertia + baysInertia];
diff --git a/classes/@Rocket/updateBay.m b/classes/@Rocket/updateBay.m
index 4fb11c5..e5355e9 100644
--- a/classes/@Rocket/updateBay.m
+++ b/classes/@Rocket/updateBay.m
@@ -6,7 +6,8 @@ if ~all(values(obj.bayStatus)), return; end
 bays = obj.bays;
 
 %% Update positions
-obj.(bays(1)).position = 0;
+% The only contribution is the offset
+obj.(bays(1)).position = obj.(bays(1)).offset;
 for i = 2:length(bays)
     bay = bays(i);
     prevBay = bays(i-1);
diff --git a/classes/bays/Parafoil.m b/classes/bays/Parafoil.m
index f87d709..b6d7f59 100644
--- a/classes/bays/Parafoil.m
+++ b/classes/bays/Parafoil.m
@@ -45,6 +45,11 @@ classdef Parafoil < Bay
             end
             obj@Bay(mission, varIn);
         end
+
+        function obj = set.noseLength(obj, value)
+            obj.noseLength = value;
+            obj.offset = -value;
+        end
     end
     
     % methods
diff --git a/missions/2025_Orion_Portugal_October/config/environmentConfig.m b/missions/2025_Orion_Portugal_October/config/environmentConfig.m
index 78a48f9..fa1d51f 100644
--- a/missions/2025_Orion_Portugal_October/config/environmentConfig.m
+++ b/missions/2025_Orion_Portugal_October/config/environmentConfig.m
@@ -13,7 +13,7 @@ environment.pin1Length = 0.5603;        % [m] Distance from the upper pin to the
 environment.pin2Length = 0.2055;        % [m] Distance from the lower pin to the lower tank cap  
 environment.rampLength = 12;            % [m] Total launchpad length 
 
-environment.temperature = [];           % [K] Ground temperature correction
-environment.pressure = [];              % [Pa] Ground pressure correction
-environment.rho = [];                   % [Kg/m^3] Gorund air density correction
-environment.gamma = 1.4;                % [-] Gas constant
\ No newline at end of file
+% environment.temperature = [];           % [K] Ground temperature correction
+% environment.pressure = [];              % [Pa] Ground pressure correction
+% environment.rho = [];                   % [Kg/m^3] Gorund air density correction
+% environment.gamma = 1.4;                % [-] Gas constant
\ No newline at end of file
diff --git a/missions/2025_Orion_Portugal_October/config/rocketConfig.m b/missions/2025_Orion_Portugal_October/config/rocketConfig.m
index 543b878..c879160 100644
--- a/missions/2025_Orion_Portugal_October/config/rocketConfig.m
+++ b/missions/2025_Orion_Portugal_October/config/rocketConfig.m
@@ -78,7 +78,8 @@ motor.cutoffTransient = 0.3;                                         % [s] Cut-o
 %% REAR - Includes Fincan + Boat
 rear = Rear();
 
-rear.length = 477 * 1e-3;                                         % [m] Total bay length
+rear.offset = -0.6936;                                               % [m] offset from
+rear.length = 477 * 1e-3;                                            % [m] Total bay length
 rear.mass = 1736.32 *1e-3;                                           % [kg] Total bay mass
 rear.inertia = 1e-9*[13662070; 47529495; 47528846];                  % [kg*m^2] Total bay inertia (Body reference)
 rear.xcg = 236.82 * 1e-3;                                                                                               % [m] Cg relative to bay upper side
-- 
GitLab