From 16db4910290d985de6d1c674fe2e7127c35b17bf Mon Sep 17 00:00:00 2001
From: MatteoGotti <matteo.gotti@skywarder.eu>
Date: Tue, 23 Jul 2024 18:10:41 +0200
Subject: [PATCH] [fins-dimensioning][missions][functions] fixed motors and
 updated functions

---
 functions/miscellaneous/exitVelocity.m        | 17 +++++++---------
 functions/simulations/quickApogeeOnly.m       | 20 ++++++-------------
 .../data/motors.mat                           |  4 ++--
 3 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/functions/miscellaneous/exitVelocity.m b/functions/miscellaneous/exitVelocity.m
index 4cdc367..5709f67 100644
--- a/functions/miscellaneous/exitVelocity.m
+++ b/functions/miscellaneous/exitVelocity.m
@@ -1,4 +1,4 @@
-function velExit = exitVelocity(settings)
+function velExit = exitVelocity(rocket, environment, settings)
 
 %{  
 exitVelocity - This function calculates the launchpad exit velocity.
@@ -27,15 +27,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
 % Initial State
 X0pad = [0; 0; 0; 0];
 % Attitude
-Q0 = angleToQuat(settings.PHI, settings.OMEGA, 0*pi/180)';
-
-
-    nAlpha = size(settings.Coeffs, 2);
-    nBeta = size(settings.Coeffs, 4);
-    meanCA = settings.Coeffs(1, ceil(nAlpha/2), 1, ceil(nBeta/2), 1, 1, 1);   % CA at alpha = 0 | beta = 0 | Mach = 0.05 | ARB = closed | Xcg = full     
-
-[~, Ypad] = ode113(@launchPadFreeDyn, [0, 10], X0pad, settings.ode.optionspad,...
-    settings, Q0, meanCA);
+Q0 = angleToQuat(environment.phi, environment.omega, 180*pi/180)';
+    nAlpha = size(rocket.coefficients.total, 2);
+    nBeta = size(rocket.coefficients.total, 4);
+    meanCA = rocket.coefficients.total(1, ceil(nAlpha/2), 1, ceil(nBeta/2), 1, 1, 1);   % CA at alpha = 0 | beta = 0 | Mach = 0.05 | ARB = closed | Xcg = full     
+[~, Ypad] = ode113(@launchPadFreeDyn, [0, 10], X0pad, settings.ode.optLaunchpad,...
+    rocket, environment, Q0, meanCA);
 
 velExit = Ypad(end, 4);
                 
\ No newline at end of file
diff --git a/functions/simulations/quickApogeeOnly.m b/functions/simulations/quickApogeeOnly.m
index a8595a1..1f34971 100644
--- a/functions/simulations/quickApogeeOnly.m
+++ b/functions/simulations/quickApogeeOnly.m
@@ -4,7 +4,7 @@ arguments
     environment Environment
     wind        WindCustom
     settings    Settings
-    wrapper     DataWrapper
+    wrapper     = []; % DataWrapper (empty by default)
 end
 %{
 quickApogeeOnly - This function tests the fins simulating the ascent
@@ -41,20 +41,16 @@ if not(rocket.airbrakes.enabled) && length(rocket.airbrakes.extension) > 1
     error('To simulate different airbrakes opening, please set to true settings.multipleAB in config.m');
 end
 
-% if rocket.airbrakes.enabled && length(rocket.airbrakes.extension) < 2
-%     error('In airbrakes smooth opening simulations, airbrakes configuration must be always greater than 2 (from launch), check config.m')
-% end
-
 if rocket.airbrakes.enabled && length(rocket.airbrakes.extension) > 1 && length(rocket.airbrakes.deltaTime) < length(rocket.airbrakes.extension) - 2
     error('In airbrakes smooth opening simulations, AB configuration usage time vector must be at least of length length(pCOntrol)-2, check config.m')
 end
 
-% if settings.wind.variable
-%     error('Wind variable model available just in stoch simulations'); 
-% end
-
 %% DATA PREPARATION
-options = odeset(settings.ode.optAscent, 'OutputFcn', @storeData);
+if isempty(wrapper)
+    options = odeset(settings.ode.optAscent);
+else
+    options = odeset(settings.ode.optAscent, 'OutputFcn', @storeData);
+end
 tf = settings.ode.finalTime;
 
 %% INITIAL CONDITIONS
@@ -68,10 +64,6 @@ W0 = [0; 0; 0];
 
 Y0a = [X0; V0; W0; Q0; 0];
 
-%% WIND GENERATION
-% [uw, vw, ww, ~] = windConstGenerator(settings.wind);
-% settings.constWind = [uw, vw, ww];
-
 %% ASCENT
 t0 = 0;
 [Ta, Ya] = ode113(@ballistic, [t0, tf], Y0a, options, ...
diff --git a/missions/2024_Lyra_Portugal_October/data/motors.mat b/missions/2024_Lyra_Portugal_October/data/motors.mat
index 33a052f..fbad2d9 100644
--- a/missions/2024_Lyra_Portugal_October/data/motors.mat
+++ b/missions/2024_Lyra_Portugal_October/data/motors.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:dff4610133e4db71aadd2d83e2b0513655581b4b0a4c404973735814963af198
-size 5465773
+oid sha256:b6b54a264d9ae4628a203d7bcca2a4db3e6853835d5d1a403d4f8d999d2a0d08
+size 5458716
-- 
GitLab