-
Notifications
You must be signed in to change notification settings - Fork 53
/
runPredSim.m
50 lines (44 loc) · 1.33 KB
/
runPredSim.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function [varargout] = runPredSim(S, osim_path)
% --------------------------------------------------------------------------
% runPredSim
% Function to run PredSim.
%
% INPUT:
% - S -
% * setting structure S
%
% - osim_path -
% * path to the OpenSim model file (.osim)
%
%
% OUTPUT:
% - savename (optional) -
% * results of the simulation will be saved in a file with this name
%
% Original author: Lars D'Hondt
% Original date: 14/August/2024
% --------------------------------------------------------------------------
% Make sure casadi path is set up correctly. This needs to happen before
% adding a simulation to the batch
if ~isfield(S.solver,'CasADi_path')
try
S.solver.CasADi_path = casadi.GlobalOptions.getCasadiPath();
catch
error("Please add CasADi to the matlab search path, or pass the path " + ...
"to your CasADi installation (top folder) to S.solver.CasADi_path.")
end
elseif ~isempty(S.solver.CasADi_path) && ~isfolder(S.solver.CasADi_path)
error("Unable to find the path assigned to S.solver.CasADi_path:" + ...
" \n\t%s",S.solver.CasADi_path)
end
if S.solver.run_as_batch_job
% add to batch
[savename] = add_pred_sim_to_batch(S,osim_path);
else
% run
[savename] = run_pred_sim(S,osim_path);
end
if nargout == 1
varargout{1} = savename;
end
end