From 864eae6b255b09e889643ab42e3ce9301e7e1e31 Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Sun, 1 Jun 2025 20:17:32 +0200 Subject: [PATCH 01/24] [unit-test][apogeeAnalysis] Renamed plots to options --- apogeeAnalysis/apogeeAnalysisConfig.m | 11 ++++---- apogeeAnalysis/mainApogeeAnalysis.m | 8 +++--- apogeeAnalysis/src/plotApogeeAnalysis.m | 36 ++++++++++++------------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/apogeeAnalysis/apogeeAnalysisConfig.m b/apogeeAnalysis/apogeeAnalysisConfig.m index 12d8efe9..cf5fae02 100644 --- a/apogeeAnalysis/apogeeAnalysisConfig.m +++ b/apogeeAnalysis/apogeeAnalysisConfig.m @@ -26,17 +26,18 @@ selection.motorName = {'HRE_ARM_EuRoC_2024'}; selection.transient = 1; %% PLOTS OPTIONS -plots.targetApogee = 3000; % [m] target apogee -plots.maxAcceleration = 15; % [g] imposed limit acceleration -plots.minVexit = 20; % [m/s] imposed limit on launchpad exit velocity +options.unitTest = false; % [-] true to disable prints and plots +options.targetApogee = 3000; % [m] target apogee +options.maxAcceleration = 15; % [g] imposed limit acceleration +options.minVexit = 20; % [m/s] imposed limit on launchpad exit velocity % Acceleration plot % set to false if you don't want the acceleration plot -plots.accelerationPlot = true; +options.accelerationPlot = true; % Launchpad exit velocity % set to false if you don't want the launchpad exit velocity plot -plots.launchpadVelPlot = true; +options.launchpadVelPlot = true; %% UNCERTAINTIES % Total impulse uncertaintie diff --git a/apogeeAnalysis/mainApogeeAnalysis.m b/apogeeAnalysis/mainApogeeAnalysis.m index 8fba1605..c24cdb02 100644 --- a/apogeeAnalysis/mainApogeeAnalysis.m +++ b/apogeeAnalysis/mainApogeeAnalysis.m @@ -1,12 +1,12 @@ -function [standardResults, engineCutResults] = mainApogeeAnalysis(rocket, settings, analysis, plots) +function [standardResults, engineCutResults] = mainApogeeAnalysis(rocket, settings, analysis, options) arguments rocket = [] % Rocket = Rocket.empty settings Settings = Settings.empty analysis.isStandard = [] analysis.isEngineCut = [] - plots.accelerationPlot = [] - plots.launchpadVelPlot = [] + options.accelerationPlot = [] + options.launchpadVelPlot = [] end % % @@ -38,7 +38,7 @@ if isempty(rocket), rocket = Rocket(mission); end if isempty(settings), settings = Settings('ode', 'apogeeAnalysis'); end Settings.read(settings, analysis, 'analysis'); -Settings.read(settings, plots, 'plots'); +Settings.read(settings, options, 'options'); if ~settings.analysis.isStandard && ~settings.analysis.isEngineCut error('Select at least one between standardAnalysis and engineCutAnalysis'); diff --git a/apogeeAnalysis/src/plotApogeeAnalysis.m b/apogeeAnalysis/src/plotApogeeAnalysis.m index be61a386..b65b405a 100644 --- a/apogeeAnalysis/src/plotApogeeAnalysis.m +++ b/apogeeAnalysis/src/plotApogeeAnalysis.m @@ -28,13 +28,13 @@ if isStdAnalysis xGrid = result.deltaStructuralMass; xLegend = 'Variation in structural mass ($kg$)'; figTitles = ["HIGHEST APOGEE CASE", "LOWEST APOGEE CASE"]; - nSubPlots = 2 + settings.plots.accelerationPlot + settings.plots.launchpadVelPlot; + nSubPlots = 2 + settings.options.accelerationPlot + settings.options.launchpadVelPlot; - if settings.plots.launchpadVelPlot + if settings.options.launchpadVelPlot maxAcc = result.maxAcc; end - if settings.plots.accelerationPlot + if settings.options.accelerationPlot vExit = result.vExit; end margin = 0.25; @@ -57,13 +57,13 @@ colorMap = turbo(nMotors+1); % plot highest/lowest apogee case for i = 1:2 - if i == 1 && min(min(apogee(:,:,i))) > settings.plots.targetApogee %% UPWIND - string = strcat("In the case the apogee is maximized, for each motor the final apogee is over ", num2str(settings.plots.targetApogee), "m."); + if i == 1 && min(min(apogee(:,:,i))) > settings.options.targetApogee %% UPWIND + string = strcat("In the case the apogee is maximized, for each motor the final apogee is over ", num2str(settings.options.targetApogee), "m."); string = strcat(string, " Decrease the minimum Itot in configApogee"); warning(string); end - if i == 2 && max(max(apogee(:,:,i))) < settings.plots.targetApogee %% DOWNWIND - string = strcat("In the case the apogee is minimized, for each motor the final apogee is above ", num2str(settings.plots.targetApogee), "m."); + if i == 2 && max(max(apogee(:,:,i))) < settings.options.targetApogee %% DOWNWIND + string = strcat("In the case the apogee is minimized, for each motor the final apogee is above ", num2str(settings.options.targetApogee), "m."); string = strcat(string, " Increase the maximum Itot in configApogee"); warning(string); end @@ -75,12 +75,12 @@ for i = 1:2 % ref plot quantities minApo = min(min(apogee(:,:,i))); maxApo = max(max(apogee(:,:,i))); - delta = [settings.plots.targetApogee - minApo; maxApo - settings.plots.targetApogee]; + delta = [settings.options.targetApogee - minApo; maxApo - settings.options.targetApogee]; delta(2) = delta(2)*(delta(2) > 0) + 100*(delta(2) <= 0); - yMax = settings.plots.targetApogee + delta(2) + 10; + yMax = settings.options.targetApogee + delta(2) + 10; yMin = minApo - 10; - if isStdAnalysis && (settings.plots.accelerationPlot || settings.plots.launchpadVelPlot) + if isStdAnalysis && (settings.options.accelerationPlot || settings.options.launchpadVelPlot) plotApogee = subplot(1, nSubPlots, 1:2); else plotApogee = fig.CurrentAxes; @@ -98,7 +98,7 @@ for i = 1:2 end leg = legend(labels, 'Interpreter', 'latex', 'Location', 'Best'); - yline(settings.plots.targetApogee,':', 'Color', [0.85 0 0], 'Linewidth', 2.5, ... + yline(settings.options.targetApogee,':', 'Color', [0.85 0 0], 'Linewidth', 2.5, ... 'Label', {'Target', 'Apogee'}, 'LabelHorizontalAlignment','left',... 'LabelVerticalAlignment', 'middle', 'Interpreter', 'latex'); % target apogee line @@ -124,7 +124,7 @@ for i = 1:2 end else % green rectangle over the target line - rectangle('Position', [xGridMin settings.plots.targetApogee (xGridMax-xGridMin) delta(2)], ... + rectangle('Position', [xGridMin settings.options.targetApogee (xGridMax-xGridMin) delta(2)], ... 'FaceColor', [0 1 0 0.1], 'Linestyle', 'none', 'FaceAlpha', 0.3); end @@ -144,7 +144,7 @@ for i = 1:2 if isStdAnalysis % Max acceleration plot - if settings.plots.accelerationPlot + if settings.options.accelerationPlot spA = subplot(1, nSubPlots, 3); hold on, grid on; @@ -163,7 +163,7 @@ for i = 1:2 spA.YLabel.String = '$max~|a|$ ($g$)'; spA.TickLabelInterpreter = 'latex'; % legend(labels, 'Interpreter', 'latex', 'Location', 'Best') - yline(settings.plots.maxAcceleration,':', 'Color', [0.85 0 0], 'Linewidth', 2.5, ... + yline(settings.options.maxAcceleration,':', 'Color', [0.85 0 0], 'Linewidth', 2.5, ... 'Label', {'Limit $max|a|$'}, 'LabelHorizontalAlignment','left',... 'LabelVerticalAlignment', 'bottom', 'Interpreter', 'latex'); % target apogee line xline(0,':', 'Interpreter', 'latex', ... @@ -172,8 +172,8 @@ for i = 1:2 end % Launchpad exit velocity plot - if settings.plots.launchpadVelPlot - spV = subplot(1, nSubPlots, 3 + settings.plots.accelerationPlot); + if settings.options.launchpadVelPlot + spV = subplot(1, nSubPlots, 3 + settings.options.accelerationPlot); hold on, grid on; % sorting for a better plot visualization @@ -184,7 +184,7 @@ for i = 1:2 plot(xGrid,vExit(:,k,i),'o-','color',colorMap(iCol(k),:),'LineWidth',1) end - yline(settings.plots.minVexit,':', 'Color', [0.85 0 0], 'Linewidth', 2.5, ... + yline(settings.options.minVexit,':', 'Color', [0.85 0 0], 'Linewidth', 2.5, ... 'Label', {'Minimum', 'Exit Velocity'}, 'LabelHorizontalAlignment','left',... 'LabelVerticalAlignment', 'top', 'Interpreter', 'latex'); % target apogee line xline(0,':', 'Interpreter', 'latex', ... @@ -192,7 +192,7 @@ for i = 1:2 'Color', [0.1 0.1 0.1], 'LineWidth', 2.5); % reference mass line spV.XLabel.String = xLegend; spV.YLabel.String = 'Launchpad exit velocity ($m/s$)'; - spV.YLim(1) = min(settings.plots.minVexit, min(vExit, [], 'all')) - 2; + spV.YLim(1) = min(settings.options.minVexit, min(vExit, [], 'all')) - 2; spV.TickLabelInterpreter = 'latex'; end % sorting for a better plot visualization -- GitLab From 21c75d9b860d8b937cbf266a67e2d430bcddd20e Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Sun, 1 Jun 2025 20:34:42 +0200 Subject: [PATCH 02/24] [unit-test-updates][apogeeAnalysis] Added option to disable plots and prints --- apogeeAnalysis/mainApogeeAnalysis.m | 27 +++++++++++++++++++++------ apogeeAnalysis/src/engineCutApogee.m | 4 ++-- apogeeAnalysis/src/standardApogee.m | 4 ++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/apogeeAnalysis/mainApogeeAnalysis.m b/apogeeAnalysis/mainApogeeAnalysis.m index c24cdb02..3227df28 100644 --- a/apogeeAnalysis/mainApogeeAnalysis.m +++ b/apogeeAnalysis/mainApogeeAnalysis.m @@ -7,6 +7,7 @@ arguments analysis.isEngineCut = [] options.accelerationPlot = [] options.launchpadVelPlot = [] + options.unitTest = [] end % % @@ -131,28 +132,42 @@ standardResults = []; engineCutResults = []; if settings.analysis.isStandard - fprintf('Standard apogee analysis started:\n'); + if ~settings.options.unitTest + fprintf('Standard apogee analysis started:\n'); + end + standardResults = standardApogee(settings, rocket, mission, selectedMotors, environments, winds, airbrakes); - fprintf('Elapsed time for standard apogee analysis: %4.2f [s]\n', standardResults.compTime); + + if ~settings.options.unitTest + fprintf('Elapsed time for standard apogee analysis: %4.2f [s]\n', standardResults.compTime); + end end if settings.analysis.isEngineCut - fprintf('Engine cut apogee analysis started:\n'); + if ~settings.options.unitTest + fprintf('Engine cut apogee analysis started:\n'); + end + if settings.uncert.percEngineCut < settings.uncert.percDeltaTime error('The selected cut-off time is smaller than deltaTime') end + if settings.uncert.percEngineCut + settings.uncert.percDeltaTime > 1 error('The sum of percEngineCut and percDeltaTime mus be <= 1') end + engineCutResults = engineCutApogee(settings, rocket, mission, selectedMotors, environments, winds, airbrakes); - fprintf('Elapsed time for engine cut apogee analysis: %4.2f [s]\n', engineCutResults.compTime); + + if ~settings.options.unitTest + fprintf('Elapsed time for engine cut apogee analysis: %4.2f [s]\n', engineCutResults.compTime); + end end %% PLOTS -if settings.analysis.isStandard +if settings.analysis.isStandard && ~settings.options.unitTest plotApogeeAnalysis(true, settings, selectedMotors, standardResults); end -if settings.analysis.isEngineCut +if settings.analysis.isEngineCut && ~settings.options.unitTest plotApogeeAnalysis(false, settings, selectedMotors, engineCutResults); end \ No newline at end of file diff --git a/apogeeAnalysis/src/engineCutApogee.m b/apogeeAnalysis/src/engineCutApogee.m index 5efb982e..0c0ad49b 100644 --- a/apogeeAnalysis/src/engineCutApogee.m +++ b/apogeeAnalysis/src/engineCutApogee.m @@ -71,9 +71,9 @@ for i = 1:2 % highest and lowest apogee cases nIT = nIT + 1; % if not(isfield(settings, 'unitTest')) || settings.unitTest == false - fprintf(repmat('\b',1,numel(msg))); + if ~settings.options.unitTest, fprintf(repmat('\b',1,numel(msg))); end msg = strcat('Simulation progress:',num2str(floor(nIT/iTOT*100)),'%%'); - fprintf(strcat(msg, '\n')); + if ~settings.options.unitTest, fprintf(strcat(msg, '\n')); end % end end end diff --git a/apogeeAnalysis/src/standardApogee.m b/apogeeAnalysis/src/standardApogee.m index 3ff5b551..14264cf1 100644 --- a/apogeeAnalysis/src/standardApogee.m +++ b/apogeeAnalysis/src/standardApogee.m @@ -69,9 +69,9 @@ for i = 1:2 % highest and lowest apogee cases end nIT = nIT + 1; % if not(isfield(settings, 'unitTest')) || settings.unitTest == false - fprintf(repmat('\b',1,numel(msg))); + if ~settings.options.unitTest, fprintf(repmat('\b',1,numel(msg))); end msg = strcat('Simulation progress:',num2str(floor(nIT/iTOT*100)),'%%'); - fprintf(strcat(msg, '\n')); + if ~settings.options.unitTest, fprintf(strcat(msg, '\n')); end % end end end -- GitLab From 0a92f93c608cbd9cef5a045da348826e396b39d7 Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Sun, 1 Jun 2025 20:43:45 +0200 Subject: [PATCH 03/24] [unit-test-updates][simulator] Added option to disable plots and prints --- simulator/mainSimulator.m | 22 +++++++++++++++++++--- simulator/simulatorConfig.m | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/simulator/mainSimulator.m b/simulator/mainSimulator.m index 5a14012e..fec14574 100644 --- a/simulator/mainSimulator.m +++ b/simulator/mainSimulator.m @@ -13,6 +13,7 @@ arguments options.landingMap logical = []; % True to run geoplots options.satellite3D logical = []; % True to plot trajectory on 3D map options.SMonly logical = []; % True to plot only SM, useful during design + options.unitTest logical = []; % True to disable all plots and prints end % MAIN SIMULATOR - Runs the simulation that has been chosen in config files % @@ -62,6 +63,12 @@ end % Needed for compatibility with sensitivity settings.simulator.parachute = ~settings.simulator.ballistic; +if settings.simulator.unitTest + settings.simulator.prints = false; + settings.simulator.plots = false; + settings.simulator.SMonly = false; +end + %% DATA PREPARATION % Pre-allocating wrapper Y0 = zeros(1, 14); Y0(10) = 1; @@ -74,15 +81,24 @@ wrapper = DataWrapper(dataDummy, 1000, 1); tStart = tic; -fprintf('- Standard Ascent Simulation Started...\n'); +if ~settings.simulator.unitTest + fprintf('- Standard Ascent Simulation Started...\n'); +end + [solution, ascent] = stdAscent(rocket, environment, wind, settings, wrapper); wrapper.reset(); if settings.simulator.ballistic - fprintf('- Standard Ballistic Descent Started...\n\n'); + if ~settings.simulator.unitTest + fprintf('- Standard Ballistic Descent Started...\n\n'); + end + descent = stdDescentBal(solution, settings); else - fprintf('- Standard Descent Started...\n\n'); + if ~settings.simulator.unitTest + fprintf('- Standard Descent Started...\n\n'); + end + descent = stdDescent(solution, settings); end diff --git a/simulator/simulatorConfig.m b/simulator/simulatorConfig.m index bd5af2b6..66d00f6f 100644 --- a/simulator/simulatorConfig.m +++ b/simulator/simulatorConfig.m @@ -16,6 +16,8 @@ simulator.ballistic = false; % True to run a ballistic (without parachut % NOTE: airbrakes flag is set in rocketConfig %% PLOTS +simulator.unitTest = false; % True to disable all plots and prints + simulator.prints = false; % True to print data after simulation simulator.plots = false; % True to plot data after simulation simulator.landingMap = true; % True to run geoplots -- GitLab From a0ed4dcd229518cbd4324f705fbbc7b30b8b7258 Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Sun, 1 Jun 2025 20:59:30 +0200 Subject: [PATCH 04/24] [unit-test-updates][stability] Added option to disable plots and prints --- stabilityAnalysis/mainStabilityAnalysis.m | 16 +- stabilityAnalysis/src/computeStability.m | 10 +- stabilityAnalysis/src/stabilityPlots.m | 188 ++++++++++---------- stabilityAnalysis/stabilityAnalysisConfig.m | 2 + 4 files changed, 116 insertions(+), 100 deletions(-) diff --git a/stabilityAnalysis/mainStabilityAnalysis.m b/stabilityAnalysis/mainStabilityAnalysis.m index b4ae30af..b63fc8c8 100644 --- a/stabilityAnalysis/mainStabilityAnalysis.m +++ b/stabilityAnalysis/mainStabilityAnalysis.m @@ -14,6 +14,7 @@ arguments options.plotXCPlonATOT = []; options.plotQINDEX = []; options.plotCoeffs = []; + options.unitTest = []; end % mainStabilityAnalysis - Main script to compute the rocket stability at % launchpad exit given a set of wind intensity and @@ -47,11 +48,18 @@ if isempty(environment), environment = Environment(mission, rocket.motor); end if isempty(wind), wind = Wind(mission); end if isempty(settings), settings = Settings('stabilityAnalysis', 'ode'); end -% Settings.read(settings, options, 'stability'); +Settings.read(settings, options, 'stability'); settings.stability.dissile.alt = environment.z0; settings.stability.dissile.xcg = rocket.xcg(1); +%% FLAGS + +if options.unitTest + settings.stability.plots = false; + settings.stability.prints = false; +end + %% LAUNCHPAD DYNAMICS % states to compute the exit pad velocity T = (288.15 - 0.0065*environment.z0); % temperature @@ -94,7 +102,7 @@ stabilityData.XCPmat(indexNan) = nan; XCPlonATOT = squeeze(stabilityData.XCPmat(5, :, :)); % XCPlatATOT = squeeze(stabilityData.XCPmat(6, :, :)); -%% +flag = false; if settings.stability.prints || settings.stability.plots flag = true; if isscalar(settings.stability.windMag) @@ -125,7 +133,9 @@ if flag stabilityPrints(settings.stability, stabilityData, const, nameConst, refVec, nameVec, computeStabilityTime, vExit, a) end %% PLOTS -stabilityPlots(flag, settings.stability, stabilityData, const, nameConst, refVec, nameVec) +if settings.stability.plots + stabilityPlots(flag, settings.stability, stabilityData, const, nameConst, refVec, nameVec) +end %% SAVING if settings.stability.saveRes diff --git a/stabilityAnalysis/src/computeStability.m b/stabilityAnalysis/src/computeStability.m index 976090cd..c452a896 100644 --- a/stabilityAnalysis/src/computeStability.m +++ b/stabilityAnalysis/src/computeStability.m @@ -102,7 +102,10 @@ windMesh = [row1; row2]; %% computation nCall = ceil(meshCol/nFC); -barStab = PoolWaitbar(nCall, strcat('Calculating...')); + +if ~stability.unitTest + barStab = PoolWaitbar(nCall, strcat('Calculating...')); +end for i = 1:nCall if i~=nCall @@ -185,7 +188,10 @@ for i = 1:nCall [XCPmat(:, index), qIndexMat(:, index), stabilityCoeffs(:, index)] = getXCP(coeff, iAlpha, iBeta, dissileInput, stability); end - increment(barStab) + + if ~stability.unitTest + increment(barStab) + end end %% reshape to increase readibility diff --git a/stabilityAnalysis/src/stabilityPlots.m b/stabilityAnalysis/src/stabilityPlots.m index 2b3be312..05f4a1d7 100644 --- a/stabilityAnalysis/src/stabilityPlots.m +++ b/stabilityAnalysis/src/stabilityPlots.m @@ -16,119 +16,117 @@ function [] = stabilityPlots(flag, settings, stabilityData, const, nameConst, re XCPlonATOT = squeeze(stabilityData.XCPmat(5, :, :)); %% PLOTS -if settings.plots - if flag - figure('Name','Stability margin'); - hold on; - % if (settings.vars.plotXCPlon), plot(refVec, XCPlon, '-o', 'DisplayName','XCPlon'); end - % if (settings.vars.plotXCPlat), plot(refVec, XCPlat, '-o', 'DisplayName','XCPlat'); end - % if (settings.vars.plotXCPtotSTD), plot(refVec, XCPtotSTD, '-o', 'DisplayName', 'XCPtot - STD'); end - % if (settings.vars.plotXCPtotMOD), plot(refVec, XCPtotMOD, '-o', 'DisplayName', 'XCPtot - MOD'); end - if (settings.plotXCPlonATOT), plot(refVec, XCPlonATOT, '-o', 'DisplayName', 'XCPlon - ATOT'); end - % if (settings.vars.plotXCPlatATOT), plot(refVec, XCPlatATOT, '-o', 'DisplayName', 'XCPlat - ATOT'); end +if flag + figure('Name','Stability margin'); + hold on; + % if (settings.vars.plotXCPlon), plot(refVec, XCPlon, '-o', 'DisplayName','XCPlon'); end + % if (settings.vars.plotXCPlat), plot(refVec, XCPlat, '-o', 'DisplayName','XCPlat'); end + % if (settings.vars.plotXCPtotSTD), plot(refVec, XCPtotSTD, '-o', 'DisplayName', 'XCPtot - STD'); end + % if (settings.vars.plotXCPtotMOD), plot(refVec, XCPtotMOD, '-o', 'DisplayName', 'XCPtot - MOD'); end + if (settings.plotXCPlonATOT), plot(refVec, XCPlonATOT, '-o', 'DisplayName', 'XCPlon - ATOT'); end + % if (settings.vars.plotXCPlatATOT), plot(refVec, XCPlatATOT, '-o', 'DisplayName', 'XCPlat - ATOT'); end + + grid on; + xlabel(strcat(nameVec{1},{' '}, nameVec{2})); + ylabel('SM (-)'); + title('STABILITY MARGIN'); + subtitle(strcat(nameConst{1},':',{' '},num2str(const), {' '}, nameConst{2})); + legend; + if settings.plotQINDEX + figure('Name','Quality indices (angular)') + names = {'Angle between Faero and Maero', 'Angle between Fyz and Myz', 'Angle between Fyz and vRyz'}; + hold on; + for i = 1:3 + plot(refVec, stabilityData.qIndexMat(i, :).*180/pi,'-o','DisplayName',names{i}); + end grid on; xlabel(strcat(nameVec{1},{' '}, nameVec{2})); - ylabel('SM (-)'); - title('STABILITY MARGIN'); + ylabel('Angle (deg)'); + title('Angular indices'); subtitle(strcat(nameConst{1},':',{' '},num2str(const), {' '}, nameConst{2})); legend; - if settings.plotQINDEX - figure('Name','Quality indices (angular)') - names = {'Angle between Faero and Maero', 'Angle between Fyz and Myz', 'Angle between Fyz and vRyz'}; - hold on; - for i = 1:3 - plot(refVec, stabilityData.qIndexMat(i, :).*180/pi,'-o','DisplayName',names{i}); - end - grid on; - xlabel(strcat(nameVec{1},{' '}, nameVec{2})); - ylabel('Angle (deg)'); - title('Angular indices'); - subtitle(strcat(nameConst{1},':',{' '},num2str(const), {' '}, nameConst{2})); - legend; - - figure('Name','Tindex') - plot(refVec, stabilityData.qIndexMat(4, :),'-o', 'DisplayName','T - index'); - grid on; - xlabel(strcat(nameVec{1},{' '}, nameVec{2})); - ylabel('(-)'); - title('T - index') - subtitle(strcat(nameConst{1},':',{' '},num2str(const), {' '}, nameConst{2})); - legend; + figure('Name','Tindex') + plot(refVec, stabilityData.qIndexMat(4, :),'-o', 'DisplayName','T - index'); + grid on; + xlabel(strcat(nameVec{1},{' '}, nameVec{2})); + ylabel('(-)'); + title('T - index') + subtitle(strcat(nameConst{1},':',{' '},num2str(const), {' '}, nameConst{2})); + legend; - figure('Name','Quality index (force)') - plot(refVec, stabilityData.qIndexMat(5, :),'-o', 'DisplayName','Norm of Fpar'); - grid on; - xlabel(strcat(nameVec{1},{' '}, nameVec{2})); - ylabel('(-)'); - title('Force index'); - end + figure('Name','Quality index (force)') + plot(refVec, stabilityData.qIndexMat(5, :),'-o', 'DisplayName','Norm of Fpar'); + grid on; + xlabel(strcat(nameVec{1},{' '}, nameVec{2})); + ylabel('(-)'); + title('Force index'); + end - if settings.plotCoeffs - names = {'Cl', 'Cm', 'Cn', 'CA', 'CY', 'CN'}; - ind = [9 3 7 10 8 4]; + if settings.plotCoeffs + names = {'Cl', 'Cm', 'Cn', 'CA', 'CY', 'CN'}; + ind = [9 3 7 10 8 4]; - figure('Name','Coefficients'); - hold on; - for j = 1:6 - coeff = stabilityData.stabilityCoeffs(ind(j), :); - coeff = coeff./max(abs(coeff)); - if j <=3 - mk = '-o'; - else - mk = '-^'; - end - plot(refVec, coeff, mk , 'DisplayName', names{j}); + figure('Name','Coefficients'); + hold on; + for j = 1:6 + coeff = stabilityData.stabilityCoeffs(ind(j), :); + coeff = coeff./max(abs(coeff)); + if j <=3 + mk = '-o'; + else + mk = '-^'; end - - grid on - legend - ylabel('(-)'); - xlabel(strcat(nameVec{1},{' '}, nameVec{2})); - title('Normalized Coefficients'); + plot(refVec, coeff, mk , 'DisplayName', names{j}); end + + grid on + legend + ylabel('(-)'); + xlabel(strcat(nameVec{1},{' '}, nameVec{2})); + title('Normalized Coefficients'); + end +else + if settings.plotXCPlonATOT + tit = strcat('Stability margin (XCPlonATOT)'); + figure('Name',tit); + SM = XCPlonATOT; + surf(settings.windMag, settings.windAz*180/pi,SM','FaceColor','Interp', 'EdgeColor','none'); + colormap jet; + cb = colorbar; + cb.Label.String = 'SM (-)'; + xlabel('Wind Magnitude (m/s)'); + ylabel('Wind Azimuth (deg)'); + zlabel('SM (-)'); + title('XCP tot'); else - if settings.plotXCPlonATOT - tit = strcat('Stability margin (XCPlonATOT)'); + warning('plotXCPlonATOT set to false') + end + + if settings.plotQINDEX + names = {'Angle between Faero and Maero', 'Angle between Fyz and Myz', 'Angle between Fyz and vRyz', 'T - index', 'Norm of Fpar'}; + for i = 1:5 + tit = strcat('Quality index num:', num2str(i)); figure('Name',tit); - SM = XCPlonATOT; - surf(settings.windMag, settings.windAz*180/pi,SM','FaceColor','Interp', 'EdgeColor','none'); + qInd = squeeze(stabilityData.qIndexMat(i, :, :)); + if i <= 3 + qInd = qInd.*180/pi; + end + surf(settings.windMag, settings.windAz*180/pi, qInd', 'FaceColor', 'Interp'); colormap jet; cb = colorbar; - cb.Label.String = 'SM (-)'; xlabel('Wind Magnitude (m/s)'); ylabel('Wind Azimuth (deg)'); - zlabel('SM (-)'); - title('XCP tot'); - else - warning('plotXCPlonATOT set to false') - end - - if settings.plotQINDEX - names = {'Angle between Faero and Maero', 'Angle between Fyz and Myz', 'Angle between Fyz and vRyz', 'T - index', 'Norm of Fpar'}; - for i = 1:5 - tit = strcat('Quality index num:', num2str(i)); - figure('Name',tit); - qInd = squeeze(stabilityData.qIndexMat(i, :, :)); - if i <= 3 - qInd = qInd.*180/pi; - end - surf(settings.windMag, settings.windAz*180/pi, qInd', 'FaceColor', 'Interp'); - colormap jet; - cb = colorbar; - xlabel('Wind Magnitude (m/s)'); - ylabel('Wind Azimuth (deg)'); - - if i <= 4 - cb.Label.String = 'qIndex (deg)'; - zlabel('qIndex (deg)'); - else - cb.Label.String = 'qIndex (-)'; - zlabel('qIndex (-)'); - end - title(names{i}) + + if i <= 4 + cb.Label.String = 'qIndex (deg)'; + zlabel('qIndex (deg)'); + else + cb.Label.String = 'qIndex (-)'; + zlabel('qIndex (-)'); end + title(names{i}) end end end diff --git a/stabilityAnalysis/stabilityAnalysisConfig.m b/stabilityAnalysis/stabilityAnalysisConfig.m index 8eb9c276..9e192e7c 100644 --- a/stabilityAnalysis/stabilityAnalysisConfig.m +++ b/stabilityAnalysis/stabilityAnalysisConfig.m @@ -10,6 +10,8 @@ % % SPDX-License-Identifier: GPL-3.0-or-later +stability.unitTest = false; + %% SIMULATION SETUP stability.windAz = (0:359)*pi/180; stability.windMag = 9; -- GitLab From ffa5c821d281409b14340bd60b626f051048343e Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Tue, 3 Jun 2025 15:28:24 +0200 Subject: [PATCH 05/24] [unit-test-updates][sensitivity] Added option to disable plots and prints --- sensitivityAnalysis/mainSensitivity.m | 15 +++++++++++++-- sensitivityAnalysis/sensitivityConfig.m | 1 + .../src/postprocess/postprocessAscent.m | 10 ++++++++-- .../src/postprocess/postprocessDescentBall.m | 10 ++++++++-- .../src/postprocess/postprocessDescentPara.m | 11 +++++++++-- .../src/postprocess/postprocessLaunchMode.m | 15 ++++++++++----- .../src/postprocess/postprocessStability.m | 10 ++++++++-- sensitivityAnalysis/src/sensitivityStochRun.m | 12 ++++++++++-- 8 files changed, 67 insertions(+), 17 deletions(-) diff --git a/sensitivityAnalysis/mainSensitivity.m b/sensitivityAnalysis/mainSensitivity.m index 56ac7b8a..2d91b129 100644 --- a/sensitivityAnalysis/mainSensitivity.m +++ b/sensitivityAnalysis/mainSensitivity.m @@ -1,5 +1,5 @@ function [postProcess, parameters] = ... - mainSensitivity(rocket, wind, environment, settings, plots) + mainSensitivity(rocket, wind, environment, settings, plots, options) arguments rocket = [] % Rocket = Rocket.empty wind = [] % Wind = Wind.empty @@ -13,6 +13,9 @@ arguments plots.offlineMap = []; + options.n = []; + options.type = []; + options.unitTest = []; end % mainSensitivity - main script for the sensitivity analysis. % @@ -51,6 +54,7 @@ if isempty(wind), wind = Wind(mission); end if isempty(settings), settings = Settings('ode', 'sensitivity'); end Settings.read(settings, plots, 'sensitivity', 'plots'); +Settings.read(settings, options, 'sensitivity'); parameters = initParameter(settings.sensitivity.parameters, rocket, environment, settings); gcp('nocreate'); % If pool exists, do not create new one. @@ -80,6 +84,11 @@ settings.simulator.parafoil = settings.sensitivity.parafoil; settings.simulator.stability = false; settings.simulator.launchMode = false; +if settings.sensitivity.unitTest + settings.sensitivity.plots.enabled = false; + settings.simulator.launchMode = false; +end + switch settings.sensitivity.type case 2 settings.simulator.ballistic = true; @@ -141,7 +150,9 @@ end postTime = toc; -fprintf('----COMPUTATION COMPLETE------\nComputational effort: %5.3f [s]\nPostprocess effort: %5.3f [s]\n', compTime, postTime); +if ~settings.sensitivity.unitTest + fprintf('----COMPUTATION COMPLETE------\nComputational effort: %5.3f [s]\nPostprocess effort: %5.3f [s]\n', compTime, postTime); +end postProcess = struct(); postProcess.ascent = postpAsc; diff --git a/sensitivityAnalysis/sensitivityConfig.m b/sensitivityAnalysis/sensitivityConfig.m index 7653b39f..f3a559a0 100644 --- a/sensitivityAnalysis/sensitivityConfig.m +++ b/sensitivityAnalysis/sensitivityConfig.m @@ -13,6 +13,7 @@ % SPDX-License-Identifier: GPL-3.0-or-later %% SIMULATION PARAMETERS +sensitivity.unitTest = false; sensitivity.n = 100; % Number of cases sensitivity.type = 4; % Simulation type: diff --git a/sensitivityAnalysis/src/postprocess/postprocessAscent.m b/sensitivityAnalysis/src/postprocess/postprocessAscent.m index 53eade5f..b059d9dd 100644 --- a/sensitivityAnalysis/src/postprocess/postprocessAscent.m +++ b/sensitivityAnalysis/src/postprocess/postprocessAscent.m @@ -155,7 +155,11 @@ else end %% postprocessing the simulations -pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' ASCENT simulations...')); +barEnabled = ~settings.sensitivity.unitTest; + +if barEnabled + pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' ASCENT simulations...')); +end for i = 1:N sim = ascent(i); @@ -269,7 +273,9 @@ for i = 1:N end end - pwPost.increment(); + if barEnabled + pwPost.increment(); + end end %% Saving data diff --git a/sensitivityAnalysis/src/postprocess/postprocessDescentBall.m b/sensitivityAnalysis/src/postprocess/postprocessDescentBall.m index fb5a4900..92725b7e 100644 --- a/sensitivityAnalysis/src/postprocess/postprocessDescentBall.m +++ b/sensitivityAnalysis/src/postprocess/postprocessDescentBall.m @@ -78,7 +78,11 @@ velFun = @(dat) [dat(4); dat(5); -dat(6); sqrt(dat(4)^2 + dat(5)^2) + dat(6)^2]; descVelZFun = @(dat) [min(dat); max(dat); mean(dat)]; %% postprocessing the simulations -pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' BALLISTIC simulations...')); +barEnabled = ~settings.sensitivity.unitTest; + +if barEnabled + pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' BALLISTIC simulations...')); +end for i = 1:N sim = descent(i); @@ -111,7 +115,9 @@ for i = 1:N varPar(:, i) = aux; end - pwPost.increment(); + if barEnabled + pwPost.increment(); + end end %% Saving data diff --git a/sensitivityAnalysis/src/postprocess/postprocessDescentPara.m b/sensitivityAnalysis/src/postprocess/postprocessDescentPara.m index b9d1b17a..385a7177 100644 --- a/sensitivityAnalysis/src/postprocess/postprocessDescentPara.m +++ b/sensitivityAnalysis/src/postprocess/postprocessDescentPara.m @@ -187,7 +187,11 @@ else end %% postprocessing the simulations -pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' PARA simulations...')); +barEnabled = ~settings.sensitivity.unitTest; + +if barEnabled + pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' PARA simulations...')); +end for i = 1:N desc = descent(:, :, i); @@ -274,7 +278,10 @@ for i = 1:N bendingTorqueMainOpening(j, i)=forceMainOpening(3); end end - pwPost.increment(); + + if barEnabled + pwPost.increment(); + end end %% Saving data diff --git a/sensitivityAnalysis/src/postprocess/postprocessLaunchMode.m b/sensitivityAnalysis/src/postprocess/postprocessLaunchMode.m index 1806e776..91479616 100644 --- a/sensitivityAnalysis/src/postprocess/postprocessLaunchMode.m +++ b/sensitivityAnalysis/src/postprocess/postprocessLaunchMode.m @@ -10,9 +10,12 @@ function postp = postprocessLaunchMode(ascent, descentPara, descentBall, setting pointFun = @(dat) [dat(1); dat(2); -dat(3); sqrt(dat(1)^2 + dat(2)^2)]; - %% postprocessing the simulations - pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' PARA simulations...')); - + %% postprocessing the simulationsbarEnabled = ~settings.sensitivity.unitTest; + + if barEnabled + pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' PARA simulations...')); + end + for i = 1:N desc = descentPara(:, :, i); ball = descentBall(i); @@ -25,8 +28,10 @@ function postp = postprocessLaunchMode(ascent, descentPara, descentBall, setting mainLandingPoint(:, i) = pointFun(main.state.Y(1:3, end)); ballLandingPoint(:, i) = pointFun(ball.state.Y(1:3, end)); apogee(i) = -asc.state.Y(3, end); - - increment(pwPost); + + if barEnabled + increment(pwPost); + end end %% Saving data diff --git a/sensitivityAnalysis/src/postprocess/postprocessStability.m b/sensitivityAnalysis/src/postprocess/postprocessStability.m index a6122238..34187d8a 100644 --- a/sensitivityAnalysis/src/postprocess/postprocessStability.m +++ b/sensitivityAnalysis/src/postprocess/postprocessStability.m @@ -62,7 +62,11 @@ windAz = zeros(1, N); alphaTot = zeros(1, N); %% postprocessing the simulations -pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' STABILITY simulations...')); +barEnabled = ~settings.sensitivity.unitTest; + +if barEnabled + pwPost = PoolWaitbar(N, strcat('Postprocessing', {' '}, num2str(N), ' STABILITY simulations...')); +end for i = 1:N sim = stability(i); @@ -90,7 +94,9 @@ for i = 1:N varPar(:, i) = aux; end - pwPost.increment(); + if barEnabled + pwPost.increment(); + end end %% Saving data diff --git a/sensitivityAnalysis/src/sensitivityStochRun.m b/sensitivityAnalysis/src/sensitivityStochRun.m index b8921df0..c24b63c3 100644 --- a/sensitivityAnalysis/src/sensitivityStochRun.m +++ b/sensitivityAnalysis/src/sensitivityStochRun.m @@ -78,7 +78,13 @@ descentBall = struct.empty(); stability = struct.empty(); %% EXECUTING SIMULATIONS -waitBar = PoolWaitbar(n, strcat('Computing', {' '}, num2str(n), ' simulations...')); +barEnabled = ~settings.sensitivity.unitTest; + +if barEnabled + waitBar = PoolWaitbar(n, strcat('Computing', {' '}, num2str(n), ' simulations...')); +else + waitBar = PoolWaitbar.empty(); +end if ascentFlag ascent = wrapper.dummy; @@ -143,6 +149,8 @@ parfor i = 1:n end end - waitBar.increment(); %#ok<PFBNS> + if barEnabled + waitBar.increment(); %#ok<PFBNS> + end end end \ No newline at end of file -- GitLab From 342d02ade1b9824f39f28c67ea24a2e3f7a36a41 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Sat, 7 Jun 2025 01:18:08 +0200 Subject: [PATCH 06/24] [unit-test-updates] Added simulator.unitTest to reference settings --- common | 2 +- unitTests/configUnitTest.m | 4 ++-- unitTests/data/testSimulator/HRE/referenceState_HRE.mat | 4 ++-- .../data/testSimulator/ballistic/referenceState_ballistic.mat | 4 ++-- .../data/testSimulator/engineCut/referenceState_engineCut.mat | 4 ++-- .../testSimulator/multipleAB/referenceState_multipleAB.mat | 4 ++-- unitTests/data/testSimulator/solid/referenceState_solid.mat | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/common b/common index 615eeea4..344104d2 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 615eeea4668b5936cde62ab86c88809a8913fad2 +Subproject commit 344104d20daae4d3e7889eef268e45f4e477119d diff --git a/unitTests/configUnitTest.m b/unitTests/configUnitTest.m index 4303d2db..7df49312 100644 --- a/unitTests/configUnitTest.m +++ b/unitTests/configUnitTest.m @@ -7,7 +7,7 @@ mission = Mission(true); % choose which folders to test opt.testSimulator = true; % opt.testCommonFunction = true; -opt.testApogeeAnalysis = true; +opt.testApogeeAnalysis = false; opt.testOptimization = false; opt.testSensitivity = false; @@ -16,6 +16,6 @@ opt.testSensitivity = false; % choose which folders to create data for opt.createTestSimulator = true; % opt.createTestCommonFunction = true; -opt.createTestApogeeAnalysis = true; +opt.createTestApogeeAnalysis = false; opt.createTestOptimization = false; opt.createTestSensitivity = false; diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat index de39f3f0..36d4c956 100644 --- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat +++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94213b354af235446bfe76f6d7914d2c8905f3d6cec4bfb2f543322d4b5736e1 -size 81189519 +oid sha256:45e5372d29592a2fe1b0f4d3cd2f608b80bea68d364deabe14a53dca409fa977 +size 80927786 diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat index 2ec9624f..c8d9d52c 100644 --- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat +++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa6a60fb79d87e78807a383d3f631ae33962d3aac96d79b324f9141f1651d093 -size 80572522 +oid sha256:981130b51a6a1269b6359b42de9207e5b223151b354e60db07fb2986d881cc9b +size 80281353 diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat index fbc21a9e..d3eacdbb 100644 --- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat +++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b26f24f1967c13154953c43e1b703af995f113eb2c5f294a2a4129073b03b831 -size 81203214 +oid sha256:b218807eabfe8fc307c2afcb78ecf2c52f3da93d1b095b2a04e7719d15ad0d71 +size 80952834 diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat index 742bc0e3..af67f43c 100644 --- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat +++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2d6010f5e911e3bd2a99a941dce7daa7373d7856596c9b6e5dea203489865bd3 -size 81167424 +oid sha256:22ef703251e1a66550c8fe36c10af4e3e8ec63e205334f515291e312b157f822 +size 80940019 diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat index d01fcc82..308aec3a 100644 --- a/unitTests/data/testSimulator/solid/referenceState_solid.mat +++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e9752252923f523ca283d55092109d99a3ca7ce9bde96335988c49fd7c3d496a -size 81192294 +oid sha256:4504a5538c66571b16d03ded9468a82653815d27162c39604395e9646e05a6bc +size 80965569 -- GitLab From 683efb841092a67494080303dc5808d18871d586 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Sat, 7 Jun 2025 10:56:17 +0200 Subject: [PATCH 07/24] [unit-test-updates] Set rocket.airbrakes.enabled = 1 in multipleAB settings --- unitTests/data/testSimulator/HRE/referenceState_HRE.mat | 4 ++-- unitTests/data/testSimulator/HRE/referenceState_solid.mat | 3 +++ .../data/testSimulator/ballistic/referenceState_ballistic.mat | 4 ++-- .../data/testSimulator/engineCut/referenceState_engineCut.mat | 4 ++-- .../testSimulator/multipleAB/referenceState_multipleAB.mat | 4 ++-- unitTests/data/testSimulator/solid/referenceState_HRE.mat | 3 +++ unitTests/data/testSimulator/solid/referenceState_solid.mat | 4 ++-- unitTests/tests/TestSimulator.m | 4 ++++ 8 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 unitTests/data/testSimulator/HRE/referenceState_solid.mat create mode 100644 unitTests/data/testSimulator/solid/referenceState_HRE.mat diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat index 36d4c956..3331f314 100644 --- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat +++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:45e5372d29592a2fe1b0f4d3cd2f608b80bea68d364deabe14a53dca409fa977 -size 80927786 +oid sha256:831092047758e774e5ef76b35b38e69da3d6bcb25860251f4ff66f410b1a8db6 +size 80954262 diff --git a/unitTests/data/testSimulator/HRE/referenceState_solid.mat b/unitTests/data/testSimulator/HRE/referenceState_solid.mat new file mode 100644 index 00000000..308aec3a --- /dev/null +++ b/unitTests/data/testSimulator/HRE/referenceState_solid.mat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4504a5538c66571b16d03ded9468a82653815d27162c39604395e9646e05a6bc +size 80965569 diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat index c8d9d52c..43b6deed 100644 --- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat +++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:981130b51a6a1269b6359b42de9207e5b223151b354e60db07fb2986d881cc9b -size 80281353 +oid sha256:867d5140122460820a941efaddb3485ecfd4aae7731210e72e5c30d95a382aa9 +size 80216228 diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat index d3eacdbb..b0126fd0 100644 --- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat +++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b218807eabfe8fc307c2afcb78ecf2c52f3da93d1b095b2a04e7719d15ad0d71 -size 80952834 +oid sha256:bd1b284dcf129621db80ddec20afe9970cfc571d0ed84e0debb410545bc6d1af +size 80990432 diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat index af67f43c..ddcd7da8 100644 --- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat +++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22ef703251e1a66550c8fe36c10af4e3e8ec63e205334f515291e312b157f822 -size 80940019 +oid sha256:669e170138f6ed0041481355b962cd9826fe85cfc50ed8065fb72e96978978ae +size 80876361 diff --git a/unitTests/data/testSimulator/solid/referenceState_HRE.mat b/unitTests/data/testSimulator/solid/referenceState_HRE.mat new file mode 100644 index 00000000..36d4c956 --- /dev/null +++ b/unitTests/data/testSimulator/solid/referenceState_HRE.mat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:45e5372d29592a2fe1b0f4d3cd2f608b80bea68d364deabe14a53dca409fa977 +size 80927786 diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat index 308aec3a..ae85f128 100644 --- a/unitTests/data/testSimulator/solid/referenceState_solid.mat +++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4504a5538c66571b16d03ded9468a82653815d27162c39604395e9646e05a6bc -size 80965569 +oid sha256:b1265227aac6c42eaaa8b9deeb64a90e421966c7e46c3df54f713538d4dd8ed3 +size 80958071 diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index d630437d..bb7bc61f 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -50,6 +50,10 @@ classdef TestSimulator < UnitTest rocket = Rocket(mission); environment = Environment(mission, rocket.motor); wind = Wind(mission); + + if verifiable == "multipleAB" + rocket.airbrakes.enabled = 1; + end simulatorSettings = Settings(mainSimPath, mainOdePath); simulatorSettings.simulator.SMonly = 0; -- GitLab From 28c767a151c42ef16ca0129c74b66af3be78fa84 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettonte <lorenzo.bettonte@skywarder.edu> Date: Sun, 8 Jun 2025 19:38:59 +0200 Subject: [PATCH 08/24] transformed mainUnitTest from a script to a function with the ability to set input options --- .../{configUnitTest.m => UnitTestConfig.m} | 2 +- unitTests/mainUnitTest.m | 36 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) rename unitTests/{configUnitTest.m => UnitTestConfig.m} (94%) diff --git a/unitTests/configUnitTest.m b/unitTests/UnitTestConfig.m similarity index 94% rename from unitTests/configUnitTest.m rename to unitTests/UnitTestConfig.m index 7df49312..fc571fa7 100644 --- a/unitTests/configUnitTest.m +++ b/unitTests/UnitTestConfig.m @@ -5,7 +5,7 @@ mission = Mission(true); %% UNIT TESTS TO RUN % choose which folders to test -opt.testSimulator = true; +opt.testSimulator = false; % opt.testCommonFunction = true; opt.testApogeeAnalysis = false; opt.testOptimization = false; diff --git a/unitTests/mainUnitTest.m b/unitTests/mainUnitTest.m index d8cbd73c..9e85c331 100644 --- a/unitTests/mainUnitTest.m +++ b/unitTests/mainUnitTest.m @@ -1,9 +1,24 @@ +function [apoResults, optResults,sensResults,simResults] = mainUnitTest(absToll,relToll,options) +arguments + absToll = []; + relToll = []; + options.testApogeeAnalysis logical = []; + options.testOptimization logical = []; + options.testSensitivity logical = []; + options.testSimulator logical = []; + + + +end +%% PATH % main unit-test currentPath = fileparts(mfilename('fullpath')); addpath(genpath(fullfile(currentPath, '..'))); +%% LOAD OPTIONS -configUnitTest; +settings = Settings('UnitTest'); +if ~isempty(options), Settings.read(settings, options, 'opt'); end %% TESTS beginTest = tic; @@ -14,28 +29,35 @@ beginTest = tic; % disp(testcmnfnctResults); % end -if opt.testApogeeAnalysis +if settings.opt.testApogeeAnalysis test = TestApogeeAnalysis(); + apoResults = run(test); disp(apoResults); end -if opt.testOptimization +if settings.opt.testOptimization test = TestOptimization(); optResults = run(test); disp(optResults); end -if opt.testSensitivity +if settings.opt.testSensitivity test = TestSensitivity(); sensResults = run(test); disp(sensResults); end -if opt.testSimulator +if settings.opt.testSimulator test = TestSimulator(); + + if ~isempty(absToll), test.absToll = absToll; end + if ~isempty(relToll), test.relToll = relToll; end + simResults = run(test); - disp(simResults); + disp(simResults); end -toc(beginTest) \ No newline at end of file +toc(beginTest) + +end \ No newline at end of file -- GitLab From 117e185b7dbffba4e1e4c76a38225f7a4b6158d4 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Tue, 10 Jun 2025 18:39:54 +0200 Subject: [PATCH 09/24] [unit-test-updates] partially fixed the way to save Settings and fixed AB test --- simulator/mainSimulator.m | 2 +- unitTests/UnitTestConfig.m | 2 +- .../testSimulator/HRE/referenceState_HRE.mat | 4 +- .../HRE/referenceState_solid.mat | 3 - .../ballistic/referenceState_ballistic.mat | 4 +- .../engineCut/referenceState_engineCut.mat | 4 +- .../multipleAB/referenceState_multipleAB.mat | 4 +- .../solid/referenceState_HRE.mat | 3 - .../solid/referenceState_solid.mat | 4 +- unitTests/mainUnitTest.m | 7 +- unitTests/saveTests.m | 8 +- unitTests/tests/TestSimulator.m | 88 +++++++++++-------- 12 files changed, 68 insertions(+), 65 deletions(-) delete mode 100644 unitTests/data/testSimulator/HRE/referenceState_solid.mat delete mode 100644 unitTests/data/testSimulator/solid/referenceState_HRE.mat diff --git a/simulator/mainSimulator.m b/simulator/mainSimulator.m index fec14574..9ec8e265 100644 --- a/simulator/mainSimulator.m +++ b/simulator/mainSimulator.m @@ -1,4 +1,4 @@ -function [ascent, descent] = mainSimulator(rocket, wind, environment, settings, options) +function [ascent, descent, settings] = mainSimulator(rocket, wind, environment, settings, options) arguments rocket = [] % Rocket = Rocket.empty wind = [] % Wind = Wind.empty diff --git a/unitTests/UnitTestConfig.m b/unitTests/UnitTestConfig.m index fc571fa7..7df49312 100644 --- a/unitTests/UnitTestConfig.m +++ b/unitTests/UnitTestConfig.m @@ -5,7 +5,7 @@ mission = Mission(true); %% UNIT TESTS TO RUN % choose which folders to test -opt.testSimulator = false; +opt.testSimulator = true; % opt.testCommonFunction = true; opt.testApogeeAnalysis = false; opt.testOptimization = false; diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat index 3331f314..2322be59 100644 --- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat +++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:831092047758e774e5ef76b35b38e69da3d6bcb25860251f4ff66f410b1a8db6 -size 80954262 +oid sha256:b59a1ce9094c77e8b49372d2b7506618553c36ab066f54016de7bd1d427c58a5 +size 81007984 diff --git a/unitTests/data/testSimulator/HRE/referenceState_solid.mat b/unitTests/data/testSimulator/HRE/referenceState_solid.mat deleted file mode 100644 index 308aec3a..00000000 --- a/unitTests/data/testSimulator/HRE/referenceState_solid.mat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4504a5538c66571b16d03ded9468a82653815d27162c39604395e9646e05a6bc -size 80965569 diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat index 43b6deed..a16d4002 100644 --- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat +++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:867d5140122460820a941efaddb3485ecfd4aae7731210e72e5c30d95a382aa9 -size 80216228 +oid sha256:da148d37baf11593053b5c4de858b92b2418caa024b77796a43dbb449b9c695e +size 80282383 diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat index b0126fd0..082b671a 100644 --- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat +++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd1b284dcf129621db80ddec20afe9970cfc571d0ed84e0debb410545bc6d1af -size 80990432 +oid sha256:d73735a073e896c78191d5f45798181d28fbb8b51e6b9d79def178803ac2bb0e +size 80930900 diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat index ddcd7da8..b8a3fa07 100644 --- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat +++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:669e170138f6ed0041481355b962cd9826fe85cfc50ed8065fb72e96978978ae -size 80876361 +oid sha256:338e3960adae4e04ef9eee7a56b399674b27f23115dd1bcd914ac33c76a3f7b1 +size 80876038 diff --git a/unitTests/data/testSimulator/solid/referenceState_HRE.mat b/unitTests/data/testSimulator/solid/referenceState_HRE.mat deleted file mode 100644 index 36d4c956..00000000 --- a/unitTests/data/testSimulator/solid/referenceState_HRE.mat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:45e5372d29592a2fe1b0f4d3cd2f608b80bea68d364deabe14a53dca409fa977 -size 80927786 diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat index ae85f128..984ec936 100644 --- a/unitTests/data/testSimulator/solid/referenceState_solid.mat +++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b1265227aac6c42eaaa8b9deeb64a90e421966c7e46c3df54f713538d4dd8ed3 -size 80958071 +oid sha256:69a49aeddfad717fb4849a369866d1a3b782472568cfdbdf850d45a23df70ad7 +size 80976751 diff --git a/unitTests/mainUnitTest.m b/unitTests/mainUnitTest.m index 9e85c331..13bd31f4 100644 --- a/unitTests/mainUnitTest.m +++ b/unitTests/mainUnitTest.m @@ -6,9 +6,6 @@ arguments options.testOptimization logical = []; options.testSensitivity logical = []; options.testSimulator logical = []; - - - end %% PATH % main unit-test @@ -17,7 +14,7 @@ currentPath = fileparts(mfilename('fullpath')); addpath(genpath(fullfile(currentPath, '..'))); %% LOAD OPTIONS -settings = Settings('UnitTest'); +settings = Settings('unitTest'); if ~isempty(options), Settings.read(settings, options, 'opt'); end %% TESTS @@ -60,4 +57,6 @@ end toc(beginTest) +clear all + end \ No newline at end of file diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m index c14e556f..0e5cb83c 100644 --- a/unitTests/saveTests.m +++ b/unitTests/saveTests.m @@ -3,15 +3,13 @@ currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); -configUnitTest; - -mission = Mission(true); +unitTestConfig; totTime = tic; %% CREATING SIMULATOR TESTS if opt.createTestSimulator - verifiable = {'HRE', 'solid', 'multipleAB', 'engineCut', 'ballistic'}; + verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; for k = 1:length(verifiable) TestSimulator.saveTest(verifiable{k}, mission); end @@ -53,3 +51,5 @@ end totTimeF = toc(totTime); fprintf('\n\n All unit tests created in: %2.2f seconds\n\n', totTimeF) +% clear all +% clc diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index bb7bc61f..5b80c568 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -34,7 +34,29 @@ classdef TestSimulator < UnitTest end end + methods (Test) + function mainSimulatorTest(testCase, verifiable) + + testCase.createTest(verifiable); + + verifiable %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + mainSimPath = fullfile('..', '..', 'simulator'); + addpath(genpath(mainSimPath)); + + testCase.rocket.airbrakes.enabled %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % Run main simulator + [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.simulatorSettings); + + max(abs(postp.stateA.state.Y(3,:))) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % Verify results + testCase.verifyEqual(postp, testCase.refSimulator, 'AbsTol', testCase.absToll, 'RelTol', testCase.relToll); + clear all, close all + end + end methods (Static) function saveTest(verifiable, mission) @@ -44,8 +66,28 @@ classdef TestSimulator < UnitTest currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); - mainSimPath = fullfile(currentPath, '..', '..', 'simulator', 'simulatorConfig.m'); - mainOdePath = fullfile(currentPath, '..', '..', 'common', 'settings', 'odeConfig.m'); + % simPath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'simulator', 'simulatorConfig.m'); + % odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings', 'odeConfig.m'); + % simulatorSettings = Settings(simPath, odePath); + + simulatorSettings = Settings('ode'); + + simConfigPath = fullfile(currentPath, '..', '..', 'simulator', 'simulatorConfig.m'); + + run(simConfigPath); + + if strcmp(verifiable, 'ballistic') + simulator.ballistic = 1; + simulator.parafoil = 0; + end + simulator.SMonly = 0; + simulator.prints = 0; + simulator.plots = 0; + simulator.landingMap = 0; + simulator.satellite3D = 0; + + simulatorSettings.addprop('simulator'); + simulatorSettings.simulator = simulator; rocket = Rocket(mission); environment = Environment(mission, rocket.motor); @@ -54,59 +96,27 @@ classdef TestSimulator < UnitTest if verifiable == "multipleAB" rocket.airbrakes.enabled = 1; end - - simulatorSettings = Settings(mainSimPath, mainOdePath); - simulatorSettings.simulator.SMonly = 0; - if strcmp(verifiable, 'ballistic') - simulatorSettings.simulator.ballistic = 1; - simulatorSettings.simulator.parafoil = 0; - end % simulator - [stateA, stateF] = mainSimulator(rocket, wind, environment, simulatorSettings); - - % mainSimPath = fullfile('..', '..', 'simulator', 'simulatorConfig.m'); - % mainOdePath = fullfile('..', '..', 'common', 'settings', 'odeConfig.m'); - % simulatorSettings = Settings(mainSimPath, mainOdePath); - % simulatorSettings.simulator.SMonly = 0; - % if strcmp(verifiable, 'ballistic') - % simulatorSettings.simulator.ballistic = 1; - % simulatorSettings.simulator.parafoil = 0; - % end + [stateA, stateF, simulatorSettings] = mainSimulator(rocket, wind, environment, simulatorSettings); % Save final state fileName = sprintf("referenceState_%s.mat", verifiable); - folderPath = fullfile(currentPath,'..', 'data', 'testSimulator', verifiable); + folderPath = fullfile(currentPath, '..', 'data', 'testSimulator', verifiable); filePath = fullfile(folderPath, fileName); if ~exist(folderPath, "dir") mkdir(folderPath) end + save(filePath,'stateA','stateF', 'simulatorSettings',... 'mission', 'rocket', 'environment', 'wind'); - - close all; Time = toc(Time); fprintf('\t %s test created in: %2.2f seconds\n',verifiable, Time) + + clear all, close all end end - methods (Test) - function mainSimulatorTest(testCase, verifiable) - - testCase.createTest(verifiable); - - mainSimPath = fullfile('..', '..', 'simulator'); - addpath(genpath(mainSimPath)); - - % Run main simulator - [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.simulatorSettings); - - close all; - - % Verify results - testCase.verifyEqual(postp, testCase.refSimulator, 'AbsTol', testCase.absToll, 'RelTol', testCase.relToll); - end - end end -- GitLab From e2ca7c402140b0f2b9aacec47ee45eddd80a339d Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Wed, 11 Jun 2025 11:39:32 +0200 Subject: [PATCH 10/24] [unit-test-updates] Added Setup and Teardown methods and fixed HRE test --- .../testSimulator/HRE/referenceState_HRE.mat | 4 +- .../ballistic/referenceState_ballistic.mat | 4 +- .../engineCut/referenceState_engineCut.mat | 4 +- .../multipleAB/referenceState_multipleAB.mat | 4 +- .../solid/referenceState_solid.mat | 4 +- unitTests/tests/TestSimulator.m | 74 ++++++++++--------- 6 files changed, 50 insertions(+), 44 deletions(-) diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat index 2322be59..3ff707f4 100644 --- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat +++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b59a1ce9094c77e8b49372d2b7506618553c36ab066f54016de7bd1d427c58a5 -size 81007984 +oid sha256:0467b74a556ebf31ae1175c70f3544aa2445c7d96036e06e91503651fa69312b +size 80937255 diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat index a16d4002..6a7447b5 100644 --- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat +++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da148d37baf11593053b5c4de858b92b2418caa024b77796a43dbb449b9c695e -size 80282383 +oid sha256:8f9ed6b470f14e519542f06adaeae08a698c3d05db66ca22c28ebe2b37f9a79c +size 80258344 diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat index 082b671a..b65d4ff5 100644 --- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat +++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d73735a073e896c78191d5f45798181d28fbb8b51e6b9d79def178803ac2bb0e -size 80930900 +oid sha256:7121f30f477becacda5bcc92e9e9868ad3f1c9a02fdad5fcc1f2c8ca0466e608 +size 80973706 diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat index b8a3fa07..126547f9 100644 --- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat +++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:338e3960adae4e04ef9eee7a56b399674b27f23115dd1bcd914ac33c76a3f7b1 -size 80876038 +oid sha256:35fe398dc348a018eeb1d15d489d935aa7f4387dd31a8d933bff85c2f0af3820 +size 80900181 diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat index 984ec936..e70ea65c 100644 --- a/unitTests/data/testSimulator/solid/referenceState_solid.mat +++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69a49aeddfad717fb4849a369866d1a3b782472568cfdbdf850d45a23df70ad7 -size 80976751 +oid sha256:eb8af06e30dbe69ad92b0fa84a186ea73605f6cb52939a34e612bdcfd83d5594 +size 80978018 diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index 5b80c568..f4ad54ad 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -7,12 +7,16 @@ classdef TestSimulator < UnitTest refSimulator end - properties (TestParameter) + properties (MethodSetupParameter) verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; end - methods - function createTest(testCase, verifiable) + % properties (TestParameter) + % verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; + % end + + methods (TestMethodSetup) + function setup(testCase, verifiable) currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); @@ -34,27 +38,25 @@ classdef TestSimulator < UnitTest end end + methods (TestMethodTeardown) + function teardown(testCase) + close all + end + end + methods (Test) function mainSimulatorTest(testCase, verifiable) - testCase.createTest(verifiable); + % testCase.createTest(verifiable); - verifiable %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - mainSimPath = fullfile('..', '..', 'simulator'); addpath(genpath(mainSimPath)); - testCase.rocket.airbrakes.enabled %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % Run main simulator [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.simulatorSettings); - max(abs(postp.stateA.state.Y(3,:))) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % Verify results - testCase.verifyEqual(postp, testCase.refSimulator, 'AbsTol', testCase.absToll, 'RelTol', testCase.relToll); - - clear all, close all + testCase.verifyEqual(postp, testCase.refSimulator); end end @@ -66,36 +68,43 @@ classdef TestSimulator < UnitTest currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); - % simPath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'simulator', 'simulatorConfig.m'); - % odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings', 'odeConfig.m'); - % simulatorSettings = Settings(simPath, odePath); + simPath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'simulator', 'simulatorConfig.m'); + odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings', 'odeConfig.m'); + simulatorSettings = Settings(simPath, odePath); - simulatorSettings = Settings('ode'); - - simConfigPath = fullfile(currentPath, '..', '..', 'simulator', 'simulatorConfig.m'); - - run(simConfigPath); + % simulatorSettings = Settings('ode'); + % simConfigPath = fullfile(currentPath, '..', '..', 'simulator', 'simulatorConfig.m'); + % run(simConfigPath); if strcmp(verifiable, 'ballistic') - simulator.ballistic = 1; - simulator.parafoil = 0; + simulatorSettings.simulator.ballistic = 1; + simulatorSettings.simulator.parafoil = 0; end - simulator.SMonly = 0; - simulator.prints = 0; - simulator.plots = 0; - simulator.landingMap = 0; - simulator.satellite3D = 0; + + simulatorSettings.simulator.unitTest = 1; - simulatorSettings.addprop('simulator'); - simulatorSettings.simulator = simulator; + % simulatorSettings.addprop('simulator'); + % simulatorSettings.simulator = simulator; rocket = Rocket(mission); environment = Environment(mission, rocket.motor); wind = Wind(mission); - + + if verifiable == "HRE" + mission = Mission("2024_Lyra_Portugal_October"); + end + + % if verifiable == "solid" + % mission = Mission("2023_Pyxis_Portugal_October"); + % end + if verifiable == "multipleAB" rocket.airbrakes.enabled = 1; end + + % if verifiable == "engineCut" + % rocket.motor.cutOffTime = ; + % end % simulator [stateA, stateF, simulatorSettings] = mainSimulator(rocket, wind, environment, simulatorSettings); @@ -114,9 +123,6 @@ classdef TestSimulator < UnitTest Time = toc(Time); fprintf('\t %s test created in: %2.2f seconds\n',verifiable, Time) - - clear all, close all end end - end -- GitLab From 2cef8b44bc8c360c686b88471d8ad6e3748b82f7 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettonte <lorenzo.bettonte@skywarder.edu> Date: Wed, 11 Jun 2025 14:37:27 +0200 Subject: [PATCH 11/24] [unit-test-updates] transformed saveTests from a script to a function with te abitlity to set input settings and options --- unitTests/UnitTestConfig.m | 9 ++-- .../testSimulator/HRE/referenceState_HRE.mat | 4 +- .../ballistic/referenceState_ballistic.mat | 4 +- .../engineCut/referenceState_engineCut.mat | 4 +- .../multipleAB/referenceState_multipleAB.mat | 4 +- .../solid/referenceState_solid.mat | 4 +- unitTests/mainUnitTest.m | 3 +- unitTests/saveTests.m | 40 ++++++++++++--- unitTests/tests/TestSimulator.m | 50 ++++++------------- 9 files changed, 64 insertions(+), 58 deletions(-) diff --git a/unitTests/UnitTestConfig.m b/unitTests/UnitTestConfig.m index 7df49312..0a2f0208 100644 --- a/unitTests/UnitTestConfig.m +++ b/unitTests/UnitTestConfig.m @@ -14,8 +14,9 @@ opt.testSensitivity = false; %% UNIT TEST TO CREATE % choose which folders to create data for -opt.createTestSimulator = true; +opt.saveTestSimulator = true; % opt.createTestCommonFunction = true; -opt.createTestApogeeAnalysis = false; -opt.createTestOptimization = false; -opt.createTestSensitivity = false; +opt.saveTestApogeeAnalysis = false; +opt.saveTestOptimization = false; +opt.saveTestSensitivity = false; + diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat index 3ff707f4..481f5873 100644 --- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat +++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0467b74a556ebf31ae1175c70f3544aa2445c7d96036e06e91503651fa69312b -size 80937255 +oid sha256:7b93d349359893dc6b10a2959cb2b70f71ff1a4902280a50e795dde74db36285 +size 80208047 diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat index 6a7447b5..1327f8c0 100644 --- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat +++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8f9ed6b470f14e519542f06adaeae08a698c3d05db66ca22c28ebe2b37f9a79c -size 80258344 +oid sha256:db69488a839d1cbf7b6d1db8e05af0016098cc3910eb9c3fc95a076e126d48cd +size 80208047 diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat index b65d4ff5..0a01760d 100644 --- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat +++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7121f30f477becacda5bcc92e9e9868ad3f1c9a02fdad5fcc1f2c8ca0466e608 -size 80973706 +oid sha256:47a3834687056548eff3dd4e27da6a749687a78d052b85a3a589d46876d0e8e8 +size 80208047 diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat index 126547f9..1cc02991 100644 --- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat +++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:35fe398dc348a018eeb1d15d489d935aa7f4387dd31a8d933bff85c2f0af3820 -size 80900181 +oid sha256:dac6eb6f3c456a77a3e4241643983218cad47f1dee15fc17317514dfbd581a2f +size 80895844 diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat index e70ea65c..e3e14a40 100644 --- a/unitTests/data/testSimulator/solid/referenceState_solid.mat +++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eb8af06e30dbe69ad92b0fa84a186ea73605f6cb52939a34e612bdcfd83d5594 -size 80978018 +oid sha256:d53b91bbb63edf70664108f16f383fd1f45289191bb675ac3713089da1a68b4e +size 80208047 diff --git a/unitTests/mainUnitTest.m b/unitTests/mainUnitTest.m index 13bd31f4..e59cd511 100644 --- a/unitTests/mainUnitTest.m +++ b/unitTests/mainUnitTest.m @@ -15,8 +15,7 @@ addpath(genpath(fullfile(currentPath, '..'))); %% LOAD OPTIONS settings = Settings('unitTest'); -if ~isempty(options), Settings.read(settings, options, 'opt'); end - +Settings.read(settings, options, 'opt'); %% TESTS beginTest = tic; diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m index 0e5cb83c..fd096d82 100644 --- a/unitTests/saveTests.m +++ b/unitTests/saveTests.m @@ -1,17 +1,41 @@ -% save tests - +function saveTests(rocket, wind, environment, settings , options) +arguments + rocket = [] % Rocket = Rocket.empty + wind = [] % Wind = Wind.empty + environment = [] % Environment = Environment.empty + settings = [] % Settings = Settings.empty + options.saveTestApogeeAnalysis logical = []; + options.saveTestOptimization logical = []; + options.saveTestSensitivity logical = []; + options.saveTestSimulator logical = []; +end +%% PATH currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); -unitTestConfig; totTime = tic; +%% LOAD DATA / SETTINGS +mission = Mission(true); +if isempty(rocket), rocket = Rocket(mission); end +if isempty(environment), environment = Environment(mission, rocket.motor); end +if isempty(wind), wind = Wind(mission); end +if isempty(settings) + simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m'); + %odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings ', 'odeConfig.m'); + settings = Settings(simPath, 'ode','unitTest'); + +end +Settings.read(settings, options, 'opt'); + + + %% CREATING SIMULATOR TESTS -if opt.createTestSimulator +if settings.opt.saveTestSimulator verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; for k = 1:length(verifiable) - TestSimulator.saveTest(verifiable{k}, mission); + TestSimulator.saveTest(verifiable{k}, mission,rocket, wind, environment, settings ); end end @@ -33,7 +57,7 @@ end % end %% TEST APOGEE ANALYSIS -if opt.createTestApogeeAnalysis +if settings.opt.saveTestApogeeAnalysis TestApogeeAnalysis.saveTest(mission); end @@ -43,13 +67,13 @@ end % end %% OPTIMIZATION -if opt.createTestOptimization +if settings.opt.saveTestOptimization TestOptimization.saveTest(mission); end totTimeF = toc(totTime); fprintf('\n\n All unit tests created in: %2.2f seconds\n\n', totTimeF) - +end % clear all % clc diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index f4ad54ad..c6fde689 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -3,7 +3,7 @@ classdef TestSimulator < UnitTest % TEST FUNZIONANTE, DA RISOLVERE PATH PER simulatorConfig.m in saveTest properties - simulatorSettings + settings refSimulator end @@ -32,7 +32,7 @@ classdef TestSimulator < UnitTest testCase.refSimulator.stateA = load(filePath).stateA; testCase.refSimulator.stateF = load(filePath).stateF; - testCase.simulatorSettings = load(filePath).simulatorSettings; + testCase.settings = load(filePath).settings; % Construct the file path dynamically based on the test parameter end @@ -53,51 +53,31 @@ classdef TestSimulator < UnitTest addpath(genpath(mainSimPath)); % Run main simulator - [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.simulatorSettings); + [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.settings); + max(abs(postp.stateA.state.Y(3,:))) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % Verify results testCase.verifyEqual(postp, testCase.refSimulator); end end methods (Static) - function saveTest(verifiable, mission) + function saveTest(verifiable,mission,rocket, wind, environment, settings) Time = tic; - - disp('Started saving simulator tests') - currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); - simPath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'simulator', 'simulatorConfig.m'); - odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings', 'odeConfig.m'); - simulatorSettings = Settings(simPath, odePath); - - % simulatorSettings = Settings('ode'); - % simConfigPath = fullfile(currentPath, '..', '..', 'simulator', 'simulatorConfig.m'); - % run(simConfigPath); - if strcmp(verifiable, 'ballistic') - simulatorSettings.simulator.ballistic = 1; - simulatorSettings.simulator.parafoil = 0; - end - simulatorSettings.simulator.unitTest = 1; - - % simulatorSettings.addprop('simulator'); - % simulatorSettings.simulator = simulator; + disp('Started saving simulator tests') - rocket = Rocket(mission); - environment = Environment(mission, rocket.motor); - wind = Wind(mission); - if verifiable == "HRE" - mission = Mission("2024_Lyra_Portugal_October"); + if strcmp(verifiable, 'ballistic') + settings.simulator.ballistic = 1; + settings.simulator.parafoil = 0; end - % if verifiable == "solid" - % mission = Mission("2023_Pyxis_Portugal_October"); - % end - + if verifiable == "multipleAB" rocket.airbrakes.enabled = 1; end @@ -107,7 +87,7 @@ classdef TestSimulator < UnitTest % end % simulator - [stateA, stateF, simulatorSettings] = mainSimulator(rocket, wind, environment, simulatorSettings); + [stateA, stateF, settings] = mainSimulator(rocket, wind, environment, settings,'unitTest',true); % Save final state fileName = sprintf("referenceState_%s.mat", verifiable); @@ -117,12 +97,14 @@ classdef TestSimulator < UnitTest if ~exist(folderPath, "dir") mkdir(folderPath) end - - save(filePath,'stateA','stateF', 'simulatorSettings',... + + save(filePath,'stateA','stateF', 'settings',... 'mission', 'rocket', 'environment', 'wind'); Time = toc(Time); fprintf('\t %s test created in: %2.2f seconds\n',verifiable, Time) + + end end end -- GitLab From 5a44d8d4d638efb9f61ef94ae080f8a8e0f0b990 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Wed, 11 Jun 2025 15:39:53 +0200 Subject: [PATCH 12/24] [unit-test-updates] Moved simulator test type selection from saveTests to unitTestConfig --- unitTests/UnitTestConfig.m | 4 +--- .../testSimulator/HRE/referenceState_HRE.mat | 4 ++-- .../ballistic/referenceState_ballistic.mat | 4 ++-- .../engineCut/referenceState_engineCut.mat | 4 ++-- .../multipleAB/referenceState_multipleAB.mat | 4 ++-- .../solid/referenceState_solid.mat | 4 ++-- unitTests/saveTests.m | 15 ++++++--------- unitTests/tests/TestSimulator.m | 19 +++---------------- 8 files changed, 20 insertions(+), 38 deletions(-) diff --git a/unitTests/UnitTestConfig.m b/unitTests/UnitTestConfig.m index 0a2f0208..b37ab83b 100644 --- a/unitTests/UnitTestConfig.m +++ b/unitTests/UnitTestConfig.m @@ -11,12 +11,10 @@ opt.testApogeeAnalysis = false; opt.testOptimization = false; opt.testSensitivity = false; - %% UNIT TEST TO CREATE % choose which folders to create data for -opt.saveTestSimulator = true; +opt.saveTestSimulator = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; % Select the simulator tests to perform % opt.createTestCommonFunction = true; opt.saveTestApogeeAnalysis = false; opt.saveTestOptimization = false; opt.saveTestSensitivity = false; - diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat index 481f5873..d1f3b29a 100644 --- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat +++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7b93d349359893dc6b10a2959cb2b70f71ff1a4902280a50e795dde74db36285 -size 80208047 +oid sha256:8d44e6c60b057002f63ce0429a9c087f1bed08ab0aa14274f4dc2c1abf9700df +size 80254417 diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat index 1327f8c0..4b1b43c2 100644 --- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat +++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db69488a839d1cbf7b6d1db8e05af0016098cc3910eb9c3fc95a076e126d48cd -size 80208047 +oid sha256:c28b587fa822511881f0cca4502b512f6616c89bcb4587a263d264a5324c41cf +size 80254417 diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat index 0a01760d..61ed5521 100644 --- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat +++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47a3834687056548eff3dd4e27da6a749687a78d052b85a3a589d46876d0e8e8 -size 80208047 +oid sha256:b248789765f30a8a556cde4222e5fd529e799d8f5718ea68d58746b1f5343aaf +size 80254417 diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat index 1cc02991..026b1ae5 100644 --- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat +++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dac6eb6f3c456a77a3e4241643983218cad47f1dee15fc17317514dfbd581a2f -size 80895844 +oid sha256:fbf1a2a08c2e412f580bb6080c03252451b950bcfdea85b10d8bc8b9b004167b +size 80909350 diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat index e3e14a40..3f6dc484 100644 --- a/unitTests/data/testSimulator/solid/referenceState_solid.mat +++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d53b91bbb63edf70664108f16f383fd1f45289191bb675ac3713089da1a68b4e -size 80208047 +oid sha256:3e87e622e0ac53cb9739316eaa723168f7a3496496b41e70989e80593d2d79b4 +size 80254417 diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m index fd096d82..763640b3 100644 --- a/unitTests/saveTests.m +++ b/unitTests/saveTests.m @@ -21,10 +21,9 @@ if isempty(rocket), rocket = Rocket(mission); end if isempty(environment), environment = Environment(mission, rocket.motor); end if isempty(wind), wind = Wind(mission); end if isempty(settings) - simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m'); - %odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings ', 'odeConfig.m'); - settings = Settings(simPath, 'ode','unitTest'); - + simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m'); + %odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings ', 'odeConfig.m'); + settings = Settings(simPath, 'ode','unitTest'); end Settings.read(settings, options, 'opt'); @@ -32,14 +31,12 @@ Settings.read(settings, options, 'opt'); %% CREATING SIMULATOR TESTS -if settings.opt.saveTestSimulator - verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; - for k = 1:length(verifiable) - TestSimulator.saveTest(verifiable{k}, mission,rocket, wind, environment, settings ); +if ~isempty(settings.opt.saveTestSimulator) + for k = 1:length(settings.opt.saveTestSimulator) + TestSimulator.saveTest(settings.opt.saveTestSimulator{k}, mission, rocket, wind, environment, settings ); end end - % %% TEST COMMONFUNCTIONS % if opt.createTestCommonFunction % vars.mach = 0.05:0.05:1; diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index c6fde689..061a3b4c 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -1,7 +1,5 @@ classdef TestSimulator < UnitTest - % TEST FUNZIONANTE, DA RISOLVERE PATH PER simulatorConfig.m in saveTest - properties settings refSimulator @@ -11,10 +9,7 @@ classdef TestSimulator < UnitTest verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; end - % properties (TestParameter) - % verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; - % end - + methods (TestMethodSetup) function setup(testCase, verifiable) currentPath = fileparts(mfilename('fullpath')); @@ -45,18 +40,13 @@ classdef TestSimulator < UnitTest end methods (Test) - function mainSimulatorTest(testCase, verifiable) - - % testCase.createTest(verifiable); - + function mainSimulatorTest(testCase) mainSimPath = fullfile('..', '..', 'simulator'); addpath(genpath(mainSimPath)); % Run main simulator [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.settings); - max(abs(postp.stateA.state.Y(3,:))) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % Verify results testCase.verifyEqual(postp, testCase.refSimulator); end @@ -68,15 +58,12 @@ classdef TestSimulator < UnitTest currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); - disp('Started saving simulator tests') - if strcmp(verifiable, 'ballistic') settings.simulator.ballistic = 1; settings.simulator.parafoil = 0; end - if verifiable == "multipleAB" rocket.airbrakes.enabled = 1; @@ -87,7 +74,7 @@ classdef TestSimulator < UnitTest % end % simulator - [stateA, stateF, settings] = mainSimulator(rocket, wind, environment, settings,'unitTest',true); + [stateA, stateF, settings] = mainSimulator(rocket, wind, environment, settings, 'unitTest', true); % Save final state fileName = sprintf("referenceState_%s.mat", verifiable); -- GitLab From 050283e4c63c49b91f70481c8545e152754d9d04 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettonte <lorenzo.bettonte@skywarder.edu> Date: Wed, 11 Jun 2025 16:22:26 +0200 Subject: [PATCH 13/24] [unit-test-updates] fixed inizialization of simulator test type selection in saveTest arguments --- unitTests/mainUnitTest.m | 2 +- unitTests/saveTests.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unitTests/mainUnitTest.m b/unitTests/mainUnitTest.m index e59cd511..0018eaed 100644 --- a/unitTests/mainUnitTest.m +++ b/unitTests/mainUnitTest.m @@ -56,6 +56,6 @@ end toc(beginTest) -clear all + end \ No newline at end of file diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m index 763640b3..127d9291 100644 --- a/unitTests/saveTests.m +++ b/unitTests/saveTests.m @@ -7,7 +7,7 @@ arguments options.saveTestApogeeAnalysis logical = []; options.saveTestOptimization logical = []; options.saveTestSensitivity logical = []; - options.saveTestSimulator logical = []; + options.saveTestSimulator cell = {}; end %% PATH currentPath = fileparts(mfilename('fullpath')); -- GitLab From 73094b3a3b1b83b6d012742ec8e4cfaa7f087f11 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Wed, 11 Jun 2025 18:09:21 +0200 Subject: [PATCH 14/24] [unit-test-updates] Updated, renamed unitTestConfig and removed tolls --- unitTests/UnitTestConfig.m | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 unitTests/UnitTestConfig.m diff --git a/unitTests/UnitTestConfig.m b/unitTests/UnitTestConfig.m deleted file mode 100644 index b37ab83b..00000000 --- a/unitTests/UnitTestConfig.m +++ /dev/null @@ -1,20 +0,0 @@ -% config unit-test - -% choose the mission -mission = Mission(true); - -%% UNIT TESTS TO RUN -% choose which folders to test -opt.testSimulator = true; -% opt.testCommonFunction = true; -opt.testApogeeAnalysis = false; -opt.testOptimization = false; -opt.testSensitivity = false; - -%% UNIT TEST TO CREATE -% choose which folders to create data for -opt.saveTestSimulator = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; % Select the simulator tests to perform -% opt.createTestCommonFunction = true; -opt.saveTestApogeeAnalysis = false; -opt.saveTestOptimization = false; -opt.saveTestSensitivity = false; -- GitLab From a5331d71fa2a94b7d25c312703526a72bce69c8a Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Wed, 11 Jun 2025 18:11:10 +0200 Subject: [PATCH 15/24] [unit-test-updates] Update, renamed unitTestConfig and removed tolls --- .../multipleAB/referenceState_multipleAB.mat | 4 +- .../solid/referenceState_solid.mat | 4 +- unitTests/mainUnitTest.m | 42 +++++------------ unitTests/saveTests.m | 47 +++++-------------- unitTests/unitTestConfig.m | 15 ++++++ 5 files changed, 45 insertions(+), 67 deletions(-) create mode 100644 unitTests/unitTestConfig.m diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat index 026b1ae5..b5f9c256 100644 --- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat +++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fbf1a2a08c2e412f580bb6080c03252451b950bcfdea85b10d8bc8b9b004167b -size 80909350 +oid sha256:ab850cb272aeccddb4e1ff04f2b631d5edc512dcb2c1a23c71867ea6d1e0cc64 +size 80906846 diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat index 3f6dc484..d0cca106 100644 --- a/unitTests/data/testSimulator/solid/referenceState_solid.mat +++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e87e622e0ac53cb9739316eaa723168f7a3496496b41e70989e80593d2d79b4 -size 80254417 +oid sha256:2f4fd7a5e5d2744080472a3a4be8445eff5b5018599c132bf3ee026848783502 +size 80311103 diff --git a/unitTests/mainUnitTest.m b/unitTests/mainUnitTest.m index 0018eaed..c3d2ea49 100644 --- a/unitTests/mainUnitTest.m +++ b/unitTests/mainUnitTest.m @@ -1,61 +1,45 @@ -function [apoResults, optResults,sensResults,simResults] = mainUnitTest(absToll,relToll,options) +function [apoResults, optResults,sensResults,simResults] = mainUnitTest(options) arguments - absToll = []; - relToll = []; options.testApogeeAnalysis logical = []; options.testOptimization logical = []; options.testSensitivity logical = []; options.testSimulator logical = []; end %% PATH -% main unit-test - currentPath = fileparts(mfilename('fullpath')); addpath(genpath(fullfile(currentPath, '..'))); -%% LOAD OPTIONS +%% LOAD OPTIONS settings = Settings('unitTest'); -Settings.read(settings, options, 'opt'); +Settings.read(settings, options, 'unitTest'); + %% TESTS beginTest = tic; -% if opt.testCommonFunction -% test = TestCommonFunctions(); -% testcmnfnctResults = run(test); -% disp(testcmnfnctResults); -% end - -if settings.opt.testApogeeAnalysis +if settings.unitTest.testApogeeAnalysis test = TestApogeeAnalysis(); - apoResults = run(test); disp(apoResults); end -if settings.opt.testOptimization - test = TestOptimization(); - optResults = run(test); - disp(optResults); -end +% if settings.unitTest.testOptimization +% test = TestOptimization(); +% optResults = run(test); +% disp(optResults); +% end -if settings.opt.testSensitivity +if settings.unitTest.testSensitivity test = TestSensitivity(); sensResults = run(test); disp(sensResults); end -if settings.opt.testSimulator - test = TestSimulator(); - - if ~isempty(absToll), test.absToll = absToll; end - if ~isempty(relToll), test.relToll = relToll; end - +if settings.unitTest.testSimulator + test = TestSimulator(); simResults = run(test); disp(simResults); end toc(beginTest) - - end \ No newline at end of file diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m index 127d9291..7d2e3bec 100644 --- a/unitTests/saveTests.m +++ b/unitTests/saveTests.m @@ -12,9 +12,8 @@ end %% PATH currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); - - totTime = tic; + %% LOAD DATA / SETTINGS mission = Mission(true); if isempty(rocket), rocket = Rocket(mission); end @@ -25,49 +24,29 @@ if isempty(settings) %odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings ', 'odeConfig.m'); settings = Settings(simPath, 'ode','unitTest'); end -Settings.read(settings, options, 'opt'); - - - +Settings.read(settings, options, 'unitTest'); %% CREATING SIMULATOR TESTS -if ~isempty(settings.opt.saveTestSimulator) - for k = 1:length(settings.opt.saveTestSimulator) - TestSimulator.saveTest(settings.opt.saveTestSimulator{k}, mission, rocket, wind, environment, settings ); +if ~isempty(settings.unitTest.saveTestSimulator) + for k = 1:length(settings.unitTest.saveTestSimulator) + TestSimulator.saveTest(settings.unitTest.saveTestSimulator{k}, mission, rocket, wind, environment, settings ); end end -% %% TEST COMMONFUNCTIONS -% if opt.createTestCommonFunction -% vars.mach = 0.05:0.05:1; -% vars.alpha = [-10 -7.5 -5 -2.5 -1 -0.5 -0.1 0 0.1 0.5 1 2.5 5 7.5 10]; -% vars.beta = [-2.5 -0.1 0 0.1 2.5]; -% vars.alt = (0:400:4000); -% vars.hprot = []; -% t = 1.3; -% alpha = 5; -% mach = 0.4; -% beta = 2; -% alt = 1145; -% c = 2; -% TestCommonFunctions.saveTest(mission, vars, t, alpha, mach, beta, alt, c); -% end - %% TEST APOGEE ANALYSIS -if settings.opt.saveTestApogeeAnalysis +if settings.unitTest.saveTestApogeeAnalysis TestApogeeAnalysis.saveTest(mission); end -% %% SENSITIVITY ANALYSIS -% if opt.createTestSensitivity -% TestSensitivity.saveTest(mission); -% end - -%% OPTIMIZATION -if settings.opt.saveTestOptimization - TestOptimization.saveTest(mission); +%% SENSITIVITY ANALYSIS +if settings.unitTest.saveTestSensitivity + TestSensitivity.saveTest(mission); end +% %% OPTIMIZATION +% if settings.unitTest.saveTestOptimization +% TestOptimization.saveTest(mission); +% end totTimeF = toc(totTime); fprintf('\n\n All unit tests created in: %2.2f seconds\n\n', totTimeF) diff --git a/unitTests/unitTestConfig.m b/unitTests/unitTestConfig.m new file mode 100644 index 00000000..31da7208 --- /dev/null +++ b/unitTests/unitTestConfig.m @@ -0,0 +1,15 @@ +% CONFIG - This script sets up rocket's parameters + +%% UNIT TESTS TO RUN +% choose which folders to test +unitTest.testSimulator = true; +unitTest.testApogeeAnalysis = false; +% unitTest.testOptimization = false; +unitTest.testSensitivity = false; + +%% UNIT TEST TO CREATE +% choose which folders to create data for +unitTest.saveTestSimulator = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; % Select the simulator tests to perform +unitTest.saveTestApogeeAnalysis = false; +% unitTest.saveTestOptimization = false; +unitTest.saveTestSensitivity = false; \ No newline at end of file -- GitLab From e92706de8af03f1cba33429302b8fd644d28a3f8 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Wed, 11 Jun 2025 18:14:07 +0200 Subject: [PATCH 16/24] [unit-test-update] Removed UnitTest parent class --- unitTests/tests/UnitTest.m | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 unitTests/tests/UnitTest.m diff --git a/unitTests/tests/UnitTest.m b/unitTests/tests/UnitTest.m deleted file mode 100644 index ec4039be..00000000 --- a/unitTests/tests/UnitTest.m +++ /dev/null @@ -1,22 +0,0 @@ -classdef (Abstract) UnitTest < matlab.unittest.TestCase - properties - mission Mission % [-] mission object - rocket Rocket % [-] rocket object - environment Environment % [-] environment component - wind Wind % [-] wind component - absToll % [-] absolute tolerance - relToll % [-] relative tolerance - end - - methods - function obj = UnitTest() - obj.mission = Mission(true); - obj.rocket = Rocket(obj.mission); - obj.environment = Environment(obj.mission, obj.rocket.motor); - obj.wind = Wind(obj.mission); - obj.absToll = 0.001; - obj.relToll = 0.001; - end - - end -end \ No newline at end of file -- GitLab From b01da53e7eccd502ff8b3b065e3a9ced8d95ab7a Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Wed, 11 Jun 2025 18:15:17 +0200 Subject: [PATCH 17/24] [unit-test-updates] Fixed test classes --- unitTests/tests/TestApogeeAnalysis.m | 2 +- unitTests/tests/TestCommonFunctions.m | 2 +- unitTests/tests/TestSensitivity.m | 2 +- unitTests/tests/TestSimulator.m | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unitTests/tests/TestApogeeAnalysis.m b/unitTests/tests/TestApogeeAnalysis.m index 3c7a9b97..cc30caa3 100644 --- a/unitTests/tests/TestApogeeAnalysis.m +++ b/unitTests/tests/TestApogeeAnalysis.m @@ -1,4 +1,4 @@ -classdef TestApogeeAnalysis < UnitTest +classdef TestApogeeAnalysis < matlab.unittest.TestCase properties refStandardResults diff --git a/unitTests/tests/TestCommonFunctions.m b/unitTests/tests/TestCommonFunctions.m index 86cff731..a259a354 100644 --- a/unitTests/tests/TestCommonFunctions.m +++ b/unitTests/tests/TestCommonFunctions.m @@ -1,4 +1,4 @@ -classdef TestCommonFunctions < UnitTest +classdef TestCommonFunctions < matlab.unittest.TestCase % This class contains the common functions unit-test. % To run the test you have to create the istance of this class in the % mainUnitTests script. diff --git a/unitTests/tests/TestSensitivity.m b/unitTests/tests/TestSensitivity.m index 71d03dc7..c6cd08f2 100644 --- a/unitTests/tests/TestSensitivity.m +++ b/unitTests/tests/TestSensitivity.m @@ -1,4 +1,4 @@ -classdef TestSensitivity < UnitTest +classdef TestSensitivity < matlab.unittest.TestCase % NON FUNZIONANTE, testCase.sensitivitySettings must be of type Settings or be convertible to Settings. diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index 061a3b4c..34603fbc 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -1,4 +1,4 @@ -classdef TestSimulator < UnitTest +classdef TestSimulator < matlab.unittest.TestCase properties settings -- GitLab From 36eb5845d43e7ca033afe4d3d44811f1fbe0b63f Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Wed, 11 Jun 2025 19:14:29 +0200 Subject: [PATCH 18/24] [unit-test-updates] split settings in saveTests and removed addpath --- unitTests/mainUnitTest.m | 2 +- unitTests/saveTests.m | 14 +++++++------- unitTests/tests/TestSimulator.m | 15 +++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/unitTests/mainUnitTest.m b/unitTests/mainUnitTest.m index c3d2ea49..d546408c 100644 --- a/unitTests/mainUnitTest.m +++ b/unitTests/mainUnitTest.m @@ -1,4 +1,4 @@ -function [apoResults, optResults,sensResults,simResults] = mainUnitTest(options) +function [apoResults, optResults, sensResults, simResults] = mainUnitTest(options) arguments options.testApogeeAnalysis logical = []; options.testOptimization logical = []; diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m index 7d2e3bec..1da82a0c 100644 --- a/unitTests/saveTests.m +++ b/unitTests/saveTests.m @@ -3,7 +3,7 @@ arguments rocket = [] % Rocket = Rocket.empty wind = [] % Wind = Wind.empty environment = [] % Environment = Environment.empty - settings = [] % Settings = Settings.empty + settings = [] % Settings = Settings.empty options.saveTestApogeeAnalysis logical = []; options.saveTestOptimization logical = []; options.saveTestSensitivity logical = []; @@ -19,22 +19,22 @@ mission = Mission(true); if isempty(rocket), rocket = Rocket(mission); end if isempty(environment), environment = Environment(mission, rocket.motor); end if isempty(wind), wind = Wind(mission); end -if isempty(settings) - simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m'); - %odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings ', 'odeConfig.m'); - settings = Settings(simPath, 'ode','unitTest'); -end +if isempty(settings), settings = Settings('unitTest'); end Settings.read(settings, options, 'unitTest'); %% CREATING SIMULATOR TESTS if ~isempty(settings.unitTest.saveTestSimulator) + simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m'); + simSettings = Settings('ode', simPath); for k = 1:length(settings.unitTest.saveTestSimulator) - TestSimulator.saveTest(settings.unitTest.saveTestSimulator{k}, mission, rocket, wind, environment, settings ); + TestSimulator.saveTest(settings.unitTest.saveTestSimulator{k}, rocket, wind, environment, simSettings ); end end %% TEST APOGEE ANALYSIS if settings.unitTest.saveTestApogeeAnalysis + apoPath = fullfile(fileparts(mfilename('fullpath')),'..', 'apogeeAnalysis', 'apogeeAnalysisConfig.m'); + apoSettings = Settings('ode', apoPath); TestApogeeAnalysis.saveTest(mission); end diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index 34603fbc..0072ee26 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -3,17 +3,18 @@ classdef TestSimulator < matlab.unittest.TestCase properties settings refSimulator + rocket + wind + environment end properties (MethodSetupParameter) verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; end - methods (TestMethodSetup) function setup(testCase, verifiable) currentPath = fileparts(mfilename('fullpath')); - addpath(genpath(currentPath)); fileName = sprintf("referenceState_%s.mat", verifiable); filePath = fullfile(currentPath, '..', 'data', 'testSimulator', verifiable, fileName); @@ -35,7 +36,8 @@ classdef TestSimulator < matlab.unittest.TestCase methods (TestMethodTeardown) function teardown(testCase) - close all + mainSimPath = fullfile('..', '..', 'simulator'); + rmpath(genpath(mainSimPath)); end end @@ -53,10 +55,9 @@ classdef TestSimulator < matlab.unittest.TestCase end methods (Static) - function saveTest(verifiable,mission,rocket, wind, environment, settings) + function saveTest(verifiable, rocket, wind, environment, settings) Time = tic; currentPath = fileparts(mfilename('fullpath')); - addpath(genpath(currentPath)); disp('Started saving simulator tests') @@ -86,12 +87,10 @@ classdef TestSimulator < matlab.unittest.TestCase end save(filePath,'stateA','stateF', 'settings',... - 'mission', 'rocket', 'environment', 'wind'); + 'rocket', 'environment', 'wind'); Time = toc(Time); fprintf('\t %s test created in: %2.2f seconds\n',verifiable, Time) - - end end end -- GitLab From a782678a918801ef5030b51aa44ca8b106a0a9c5 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Wed, 11 Jun 2025 19:27:21 +0200 Subject: [PATCH 19/24] [unit-test-updates] Removed settings as output of mainSimulator --- simulator/mainSimulator.m | 2 +- unitTests/saveTests.m | 6 +----- unitTests/tests/TestSimulator.m | 13 +++++++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/simulator/mainSimulator.m b/simulator/mainSimulator.m index 9ec8e265..fec14574 100644 --- a/simulator/mainSimulator.m +++ b/simulator/mainSimulator.m @@ -1,4 +1,4 @@ -function [ascent, descent, settings] = mainSimulator(rocket, wind, environment, settings, options) +function [ascent, descent] = mainSimulator(rocket, wind, environment, settings, options) arguments rocket = [] % Rocket = Rocket.empty wind = [] % Wind = Wind.empty diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m index 1da82a0c..2b6aede1 100644 --- a/unitTests/saveTests.m +++ b/unitTests/saveTests.m @@ -24,17 +24,13 @@ Settings.read(settings, options, 'unitTest'); %% CREATING SIMULATOR TESTS if ~isempty(settings.unitTest.saveTestSimulator) - simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m'); - simSettings = Settings('ode', simPath); for k = 1:length(settings.unitTest.saveTestSimulator) - TestSimulator.saveTest(settings.unitTest.saveTestSimulator{k}, rocket, wind, environment, simSettings ); + TestSimulator.saveTest(settings.unitTest.saveTestSimulator{k}, rocket, wind, environment); end end %% TEST APOGEE ANALYSIS if settings.unitTest.saveTestApogeeAnalysis - apoPath = fullfile(fileparts(mfilename('fullpath')),'..', 'apogeeAnalysis', 'apogeeAnalysisConfig.m'); - apoSettings = Settings('ode', apoPath); TestApogeeAnalysis.saveTest(mission); end diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index 0072ee26..aa4044a0 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -55,12 +55,15 @@ classdef TestSimulator < matlab.unittest.TestCase end methods (Static) - function saveTest(verifiable, rocket, wind, environment, settings) + function saveTest(verifiable, rocket, wind, environment) Time = tic; currentPath = fileparts(mfilename('fullpath')); disp('Started saving simulator tests') + simPath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'simulator', 'simulatorConfig.m'); + settings = Settings('ode', simPath); + if strcmp(verifiable, 'ballistic') settings.simulator.ballistic = 1; settings.simulator.parafoil = 0; @@ -75,17 +78,15 @@ classdef TestSimulator < matlab.unittest.TestCase % end % simulator - [stateA, stateF, settings] = mainSimulator(rocket, wind, environment, settings, 'unitTest', true); + [stateA, stateF] = mainSimulator(rocket, wind, environment, settings, 'unitTest', true); % Save final state fileName = sprintf("referenceState_%s.mat", verifiable); folderPath = fullfile(currentPath, '..', 'data', 'testSimulator', verifiable); filePath = fullfile(folderPath, fileName); - if ~exist(folderPath, "dir") - mkdir(folderPath) - end - + if ~exist(folderPath, "dir"), mkdir(folderPath); end + save(filePath,'stateA','stateF', 'settings',... 'rocket', 'environment', 'wind'); -- GitLab From f654a30d3fdd9bdae571267433c5767f8671a6c0 Mon Sep 17 00:00:00 2001 From: Lorenzo Amici <lorenzo.amici@skywarder.eu> Date: Sat, 14 Jun 2025 07:54:43 +0000 Subject: [PATCH 20/24] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 102 +++++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 04a87756..c4ff065b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,75 +1,85 @@ -# # # Copyright (c) 2023 Skyward Experimental Rocketry -# # # Authors: Alberto Nidasio -# # # -# # # Permission is hereby granted, free of charge, to any person obtaining a copy -# # # of this software and associated documentation files (the "Software"), to deal -# # # in the Software without restriction, including without limitation the rights -# # # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# # # copies of the Software, and to permit persons to whom the Software is -# # # furnished to do so, subject to the following conditions: -# # # -# # # The above copyright notice and this permission notice shall be included in -# # # all copies or substantial portions of the Software. -# # # -# # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# # # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# # # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# # # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# # # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# # # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# # # THE SOFTWARE. +# Copyright (c) 2023 Skyward Experimental Rocketry +# Authors: Alberto Nidasio +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. -# variables: -# GIT_DEPTH: 1 +variables: + GIT_DEPTH: 1 -# stages: -# - test +stages: + - test -# # Stage test +# Stage test -# simulator: -# stage: test -# tags: -# - matlab -# script: -# - cd . -# # - if (Test-Path ..\dissilematcom) { Remove-Item -Path ..\dissilematcom -Recurse -Force } -# # - git clone git@git.skywarder.eu:afd/msa/dissilematcom.git ../dissilematcom -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('simulatorUnitTests'))" +simulator: + stage: test + tags: + - matlab + script: + - cd . + - if (Test-Path ..\dissilematcom) { Remove-Item -Path ..\dissilematcom -Recurse -Force } + - git clone git@git.skywarder.eu:afd/msa/dissilematcom.git ../dissilematcom + - cd unitTests/tests + - matlab -batch "assertSuccess(runtests('TestSimulator'))" # apogeeAnalysis: # stage: test # tags: # - matlab # script: -# - cd . -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('apogeeUnitTests'))" +# - cd . +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('TestApogeeAnalysis'))" # commonFuncitons: # stage: test # tags: # - matlab # script: -# - cd . -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('cmnFnctnUnitTests'))" +# - cd . +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('TestCommonFunctions'))" # optimizator: # stage: test # tags: # - matlab # script: -# - cd . -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('optUnitTests'))" +# - cd . +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('optUnitTests'))" # sensitivity: # stage: test # tags: # - matlab # script: +# - cd . +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('TestSensitivity'))" + +# allTests: +# stage: test +# tags: +# - matlab +# script: # - cd . -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('sensitivityUnitTests'))" +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('unitTests/tests'))" + -- GitLab From bf99131a5c168d6dab38e65edd78f46d52b5191c Mon Sep 17 00:00:00 2001 From: Lorenzo Amici <lorenzo.amici@skywarder.eu> Date: Sat, 14 Jun 2025 08:11:32 +0000 Subject: [PATCH 21/24] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 101 ++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 56 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4ff065b..02b54f6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,85 +1,74 @@ -# Copyright (c) 2023 Skyward Experimental Rocketry -# Authors: Alberto Nidasio -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# # # Authors: Alberto Nidasio +# # # +# # # Permission is hereby granted, free of charge, to any person obtaining a copy +# # # of this software and associated documentation files (the "Software"), to deal +# # # in the Software without restriction, including without limitation the rights +# # # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# # # copies of the Software, and to permit persons to whom the Software is +# # # furnished to do so, subject to the following conditions: +# # # +# # # The above copyright notice and this permission notice shall be included in +# # # all copies or substantial portions of the Software. +# # # +# # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# # # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# # # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# # # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# # # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# # # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# # # THE SOFTWARE. -variables: - GIT_DEPTH: 1 +# variables: +# GIT_DEPTH: 1 -stages: - - test +# stages: +# - test -# Stage test +# # Stage test -simulator: - stage: test - tags: - - matlab - script: - - cd . - - if (Test-Path ..\dissilematcom) { Remove-Item -Path ..\dissilematcom -Recurse -Force } - - git clone git@git.skywarder.eu:afd/msa/dissilematcom.git ../dissilematcom - - cd unitTests/tests - - matlab -batch "assertSuccess(runtests('TestSimulator'))" +# simulator: +# stage: test +# tags: +# - matlab +# script: +# - cd . +# # - if (Test-Path ..\dissilematcom) { Remove-Item -Path ..\dissilematcom -Recurse -Force } +# # - git clone git@git.skywarder.eu:afd/msa/dissilematcom.git ../dissilematcom +# # - cd unitTests/tests +# # - matlab -batch "assertSuccess(runtests('simulatorUnitTests'))" # apogeeAnalysis: # stage: test # tags: # - matlab # script: -# - cd . -# - cd unitTests/tests -# - matlab -batch "assertSuccess(runtests('TestApogeeAnalysis'))" +# - cd . +# # - cd unitTests/tests +# # - matlab -batch "assertSuccess(runtests('apogeeUnitTests'))" # commonFuncitons: # stage: test # tags: # - matlab # script: -# - cd . -# - cd unitTests/tests -# - matlab -batch "assertSuccess(runtests('TestCommonFunctions'))" +# - cd . +# # - cd unitTests/tests +# # - matlab -batch "assertSuccess(runtests('cmnFnctnUnitTests'))" # optimizator: # stage: test # tags: # - matlab # script: -# - cd . -# - cd unitTests/tests -# - matlab -batch "assertSuccess(runtests('optUnitTests'))" +# - cd . +# # - cd unitTests/tests +# # - matlab -batch "assertSuccess(runtests('optUnitTests'))" # sensitivity: # stage: test # tags: # - matlab # script: -# - cd . -# - cd unitTests/tests -# - matlab -batch "assertSuccess(runtests('TestSensitivity'))" - -# allTests: -# stage: test -# tags: -# - matlab -# script: # - cd . -# - cd unitTests/tests -# - matlab -batch "assertSuccess(runtests('unitTests/tests'))" - +# # - cd unitTests/tests +# # - matlab -batch "assertSuccess(runtests('sensitivityUnitTests'))" \ No newline at end of file -- GitLab From f1e14970098ba6f4677b5a883e5d7f7592781c55 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Sat, 14 Jun 2025 10:22:36 +0200 Subject: [PATCH 22/24] [unit-test-updates] Fixed engineCut test and commented solid and HRE tests --- unitTests/tests/TestSimulator.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index aa4044a0..af33c4ab 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -64,18 +64,18 @@ classdef TestSimulator < matlab.unittest.TestCase simPath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'simulator', 'simulatorConfig.m'); settings = Settings('ode', simPath); - if strcmp(verifiable, 'ballistic') + if verifiable == "ballistic" settings.simulator.ballistic = 1; settings.simulator.parafoil = 0; - end - - if verifiable == "multipleAB" + elseif verifiable == "multipleAB" rocket.airbrakes.enabled = 1; + elseif verifiable == "engineCut" + rocket.motor.cutoffTime = 3; + % elseif verifiable == "HRE" + % rocket.motor = Motor(Mission("2024_Lyra_Portugal_October")); + % elseif verifiable == "solid" + % rocket.motor = Motor(Mission("2022_Pyxis_Portugal_October")); end - - % if verifiable == "engineCut" - % rocket.motor.cutOffTime = ; - % end % simulator [stateA, stateF] = mainSimulator(rocket, wind, environment, settings, 'unitTest', true); @@ -86,7 +86,7 @@ classdef TestSimulator < matlab.unittest.TestCase filePath = fullfile(folderPath, fileName); if ~exist(folderPath, "dir"), mkdir(folderPath); end - + save(filePath,'stateA','stateF', 'settings',... 'rocket', 'environment', 'wind'); -- GitLab From b1e277c3e05191fc03fc88070377402456720da5 Mon Sep 17 00:00:00 2001 From: Lorenzo Amici <lorenzo.amici@skywarder.eu> Date: Sat, 14 Jun 2025 10:12:55 +0000 Subject: [PATCH 23/24] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 52 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 02b54f6f..6a0d0188 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,49 +26,59 @@ # # Stage test -# simulator: -# stage: test -# tags: -# - matlab -# script: -# - cd . -# # - if (Test-Path ..\dissilematcom) { Remove-Item -Path ..\dissilematcom -Recurse -Force } -# # - git clone git@git.skywarder.eu:afd/msa/dissilematcom.git ../dissilematcom -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('simulatorUnitTests'))" +simulator: + stage: test + tags: + - matlab + script: + - cd . + - if (Test-Path ..\dissilematcom) { Remove-Item -Path ..\dissilematcom -Recurse -Force } + - git clone git@git.skywarder.eu:afd/msa/dissilematcom.git ../dissilematcom + - cd unitTests/tests + - matlab -batch "assertSuccess(runtests('TestSimulator'))" + # apogeeAnalysis: # stage: test # tags: # - matlab # script: -# - cd . -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('apogeeUnitTests'))" +# - cd . +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('apogeeUnitTests'))" # commonFuncitons: # stage: test # tags: # - matlab # script: -# - cd . -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('cmnFnctnUnitTests'))" +# - cd . +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('cmnFnctnUnitTests'))" # optimizator: # stage: test # tags: # - matlab # script: -# - cd . -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('optUnitTests'))" +# - cd . +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('optUnitTests'))" # sensitivity: # stage: test # tags: # - matlab # script: +# - cd . +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests('sensitivityUnitTests'))" + +# allTests: +# stage: test +# tags: +# - matlab +# script: # - cd . -# # - cd unitTests/tests -# # - matlab -batch "assertSuccess(runtests('sensitivityUnitTests'))" \ No newline at end of file +# - cd unitTests/tests +# - matlab -batch "assertSuccess(runtests)" \ No newline at end of file -- GitLab From 388cdfa0750c024a591fa2293b5bd30284d48934 Mon Sep 17 00:00:00 2001 From: LolloBici <lorenzo.amici@skywarder.eu> Date: Fri, 20 Jun 2025 12:30:03 +0200 Subject: [PATCH 24/24] [unit-test-updates] Added HRE test --- common | 2 +- unitTests/data/testSimulator/HRE/referenceState_HRE.mat | 4 ++-- .../data/testSimulator/ballistic/referenceState_ballistic.mat | 4 ++-- .../data/testSimulator/engineCut/referenceState_engineCut.mat | 4 ++-- .../testSimulator/multipleAB/referenceState_multipleAB.mat | 4 ++-- unitTests/data/testSimulator/solid/referenceState_solid.mat | 4 ++-- unitTests/tests/TestSimulator.m | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/common b/common index 344104d2..52e9a50b 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 344104d20daae4d3e7889eef268e45f4e477119d +Subproject commit 52e9a50b3b7a6c88a0681fb5d38636ccd5f1d0f9 diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat index d1f3b29a..df6749b4 100644 --- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat +++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d44e6c60b057002f63ce0429a9c087f1bed08ab0aa14274f4dc2c1abf9700df -size 80254417 +oid sha256:9ff07ce27d01bf23c29c98a7dd1c758b21bf3bc65a62dae0004cee6e382bee55 +size 80968214 diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat index 4b1b43c2..eeab8cc5 100644 --- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat +++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c28b587fa822511881f0cca4502b512f6616c89bcb4587a263d264a5324c41cf -size 80254417 +oid sha256:3e0cb11e661873efb0afedd3f0a1a9b4db1e6a2b231cac731e7dc0c4858d329f +size 80257863 diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat index 61ed5521..79548f48 100644 --- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat +++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b248789765f30a8a556cde4222e5fd529e799d8f5718ea68d58746b1f5343aaf -size 80254417 +oid sha256:7351319f1601e60ed22da5672aa76cfa44705c5f61791110c0b96e3cb42dd029 +size 80821062 diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat index b5f9c256..109f8c24 100644 --- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat +++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ab850cb272aeccddb4e1ff04f2b631d5edc512dcb2c1a23c71867ea6d1e0cc64 -size 80906846 +oid sha256:d70bf97397bd031aaca2318234955e01df09c79b5810217d88f8234138aea97e +size 80909109 diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat index d0cca106..d6125031 100644 --- a/unitTests/data/testSimulator/solid/referenceState_solid.mat +++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2f4fd7a5e5d2744080472a3a4be8445eff5b5018599c132bf3ee026848783502 -size 80311103 +oid sha256:2b0c9958bc51b0a045785bc572f3948a7d79285979d520cc0916d5139b2552ed +size 80968216 diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m index af33c4ab..3216246c 100644 --- a/unitTests/tests/TestSimulator.m +++ b/unitTests/tests/TestSimulator.m @@ -71,8 +71,8 @@ classdef TestSimulator < matlab.unittest.TestCase rocket.airbrakes.enabled = 1; elseif verifiable == "engineCut" rocket.motor.cutoffTime = 3; - % elseif verifiable == "HRE" - % rocket.motor = Motor(Mission("2024_Lyra_Portugal_October")); + elseif verifiable == "HRE" + rocket.motor = Motor(Mission("2024_Lyra_Portugal_October")); % elseif verifiable == "solid" % rocket.motor = Motor(Mission("2022_Pyxis_Portugal_October")); end -- GitLab