Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MSA Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aerodynamics and Flight Dynamics
Mission Analysis
MSA Toolkit
Commits
b7047296
Commit
b7047296
authored
7 months ago
by
Gabriele Ghia
Committed by
Marco Luigi Gaibotti
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
[unit-test][unitTestClasses] fixed TestSimulator, and added dynamic(optional)parameters
parent
28b32adf
No related branches found
No related tags found
1 merge request
!12
Unit test
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
unitTests/unitTestClasses/TestSimulator.m
+61
-50
61 additions, 50 deletions
unitTests/unitTestClasses/TestSimulator.m
with
61 additions
and
50 deletions
unitTests/unitTestClasses/TestSimulator.m
+
61
−
50
View file @
b7047296
...
@@ -5,56 +5,51 @@ classdef TestSimulator < UnitTest
...
@@ -5,56 +5,51 @@ classdef TestSimulator < UnitTest
end
end
properties
(
TestParameter
)
properties
(
TestParameter
)
verifiable
=
{
'multipleAB'
,
'descent6DOF'
,
'ballistic'
,
'engineCut'
,
'solid'
,
'HRE1'
,
'HRE2'
,
'HRE3'
}
generalParams
=
{
'multipleAB'
,
'descent6DOF'
,
'ballistic'
,
'engineCut'
,
'solid'
,
'HRE1'
,
'HRE2'
,
'HRE3'
}
end
end
methods
methods
function
createTest
(
testCase
,
verifiable
)
currentPath
=
fileparts
(
mfilename
(
'fullpath'
));
addpath
(
currentPath
);
function
values
=
setVerifiable
(
externalValues
)
% Function to allow user to change, if wanted, the parameters with
% which the test is run, so as to allow test running for certain
% conditions only
if
strcmp
(
verifiable
,
'solid'
)
if
isempty
(
externalValues
)
testCase
.
mission
=
Mission
(
pyxis
);
%marco help
values
=
testCase
.
generalParams
;
testCase
.
rocket
=
Rocket
(
mission
);
fprintf
(
'\t testing with general params\n'
);
testCase
.
environment
=
Environment
(
mission
);
else
if
strcmp
(
verifiable
,
'HRE1'
)
testCase
.
rocket
.
airbrakes
.
extension
=
0
;
testCase
.
rocket
.
updateAll
else
if
strcmp
(
verifiable
,
'HRE2'
)
testCase
.
rocket
.
airbrakes
.
extension
=
0.5
;
testCase
.
rocket
.
updateAll
else
if
strcmp
(
verifiable
,
'HRE3'
)
testCase
.
rocket
.
airbrakes
.
extension
=
1
;
testCase
.
rocket
.
updateAll
else
else
if
strcmp
(
verifiable
,
'engineCut'
)
values
=
externalValues
;
settings
.
timeEngineCut
=
(
0.75
)
*
settings
.
tb
;
% [s] Moment in time in wich the engine will be cut off
settings
=
settingsEngineCut
(
settings
);
%%HELP MAUCO
end
end
end
end
end
end
end
end
[
~
,
~
,
testCase
.
simulator
]
=
mainSimulator
(
testCase
.
rocket
,
testCase
.
wind
,
testCase
.
environment
);
methods
(
Test
)
function
createTest
(
testCase
,
verifiable
)
currentPath
=
fileparts
(
mfilename
(
'fullpath'
));
addpath
(
currentPath
);
fileName
=
sprintf
(
"referenceState_%s.mat"
,
verifiable
);
filePath
=
fullfile
(
'data'
,
'testSimulator'
,
verifiable
,
fileName
);
% Construct the file path dynamically based on the test parameter
filePath
=
sprintf
(
"data\\testSimulator\\%s\\referenceState_%s.mat"
,
verifiable
,
verifiable
);
% Load the reference file
% Load the reference file
ref
=
load
(
filePath
);
testCase
.
rocket
=
load
(
filePath
,
'rocket'
);
testCase
.
motor
=
load
(
filePath
,
'motor'
);
testCase
.
environment
=
load
(
filePath
,
'environment'
);
testCase
.
wind
=
load
(
filePath
,
'wind'
);
% fieldName = ['referenceState_' verifiable];
testCase
.
refSimulator
=
load
(
filePath
,
'stateA'
,
'stateF'
);
testCase
.
simulatorSettings
=
load
(
filePath
,
'simulatorSettings'
);
% Construct the file path dynamically based on the test parameter
fieldName
=
[
'referenceState_'
verifiable
];
testCase
.
refSimulator
=
ref
.
(
fieldName
);
end
end
...
@@ -62,34 +57,50 @@ classdef TestSimulator < UnitTest
...
@@ -62,34 +57,50 @@ classdef TestSimulator < UnitTest
function
saveTest
(
testCase
,
verifiable
)
function
saveTest
(
testCase
,
verifiable
)
verifiable
=
testCase
.
setVerifiable
(
verifiable
);
Time
=
tic
;
Time
=
tic
;
mission
=
Mission
(
true
);
rocket
=
Rocket
(
Mission
);
motor
=
Motor
(
mission
);
environment
=
Environment
(
mission
,
motor
);
wind
=
Wind
(
mission
);
% simulator
% simulator
[
ascent
,
descent
,
~
]
=
mainSimulator
(
testCase
.
simulator
);
[
ascent
,
descent
,
simulatorSettings
]
=
mainSimulator
(
rocket
,
motor
,
environment
,
wind
);
stateA
=
ascent
(
end
,
:);
% state at end of ascent
stateA
=
ascent
(
end
,
:);
% state at end of ascent
stateF
=
descent
(
end
,
:);
% final state, at touchdown
stateF
=
descent
(
end
,
:);
% final state, at touchdown
stateF
=
[
stateF
zeros
(
1
,
7
)];
% to avoid problems in checkErrorSimulator
stateF
=
[
stateF
zeros
(
1
,
7
)];
% to avoid problems in checkErrorSimulator
% saving final state
% saving final state
filePath
=
sprintf
(
"data\\testSimulator\\%s\\referenceState_%s.mat"
,
verifiable
,
verifiable
);
fileName
=
sprintf
(
"referenceState_%s.mat"
,
verifiable
);
save
(
filePath
,
'stateA'
,
'stateF'
);
filePath
=
fullfile
(
'data'
,
'testSimulator'
,
verifiable
,
fileName
);
save
(
filePath
,
'stateA'
,
'stateF'
,
'simulatorSettings'
,
...
'mission'
,
'rocket'
,
...
'environment'
,
'wind'
,
'motor'
);
Time
=
toc
(
Time
);
Time
=
toc
(
Time
);
fprintf
(
'\t %s test created in: %2.2f seconds\n'
,
verifiable
,
Time
)
fprintf
(
'\t %s test created in: %2.2f seconds\n'
,
verifiable
,
Time
)
end
end
end
methods
(
Test
)
function
mainSimulator
(
testCase
)
addpath
(
genpath
(
'../../simulator'
))
function
mainSimulator
(
testCase
,
verifiable
)
[
postp
.
ascent
,
postp
.
descent
,
~
]
=
mainSimulator
(
testCase
.
simulator
);
verifiable
=
testCase
.
setVerifiable
(
verifiable
);
testCase
.
createTest
(
verifiable
);
mainSimPath
=
fullfile
(
'..'
,
'simulator'
);
addpath
(
mainSimPath
);
[
postp
.
ascent
,
postp
.
descent
,
~
]
=
mainSimulator
(
testCase
.
simulatorSettings
);
testCase
.
postp
=
postp
;
testCase
.
postp
=
postp
;
testCase
.
verifyEqual
(
testCase
.
postp
,
testCase
.
refSimulator
,
'AbsTol'
,
testCase
.
absToll
,
...
testCase
.
verifyEqual
(
testCase
.
postp
,
testCase
.
refSimulator
,
'AbsTol'
,
testCase
.
absToll
,
...
'RelTol'
,
testCase
.
relToll
)
'RelTol'
,
testCase
.
relToll
)
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment