I am running the static optimization through matlab. I encounter troubles loading the force set file into the analyze tool. I am using the following code and after running the force setfile is not included in the xml setup file of the analyze tool. Is there anyone that knows what I'm doing wrong? Neither is it working when I run the tool with an existing xml setup file including the force set file in the setup file. (using this code line:analysis=AnalyzeTool(XMLTemplate,0) )
Code: Select all
for trial= 1%:ntrials
% external loads Xml file preparation
external_loads = ExternalLoads(extLoadsXml,1);
external_loads.setDataFileName(fullfile(Folder_N(1).folder,char(name1(trial)))) ;
external_loads.setLowpassCutoffFrequencyForLoadKinematics(6);
external_loads.print(fullfile(EL_folder, strcat('ELSetup_', regexprep(char(name(trial)),'_ik.mot','.xml'))));
% construct static optimization
static_optimization = StaticOptimization();
static_optimization.setStartTime(sTime);
static_optimization.setEndTime(fTime);
static_optimization.setUseModelForceSet(true);
static_optimization.setUseMusclePhysiology(true);
static_optimization.setActivationExponent(2);
static_optimization.setConvergenceCriterion(0.0001);
static_optimization.setMaxIterations(100);
scaled_model.addAnalysis(static_optimization);
analysis = AnalyzeTool(scaled_model);
analysis.setName(strcat(regexprep(char(name(trial)),'_ik.mot','')));
analysis.setModel(scaled_model);
analysis.setForceSetFiles(ArrayStr(fullfile(AT_res(1).folder, 'gait2392_RRA_Actuators.xml')));
analysis.setInitialTime(sTime);
analysis.setFinalTime(fTime);
analysis.setLowpassCutoffFrequency(6);
analysis.setCoordinatesFileName(MotionFile);
analysis.setExternalLoadsFileName(fullfile(EL_folder, strcat('ELSetup_', regexprep(char(name(trial)),'_ik.mot','.xml'))));
analysis.setLoadModelAndInput(true)
analysis.setResultsDir(AT_res(1).folder);
outfile = ['Setup_Analyze_' regexprep(char(name(trial)),'_ik.mot','.xml')];
analysis.print(fullfile(AT_results, outfile));
analysis.run()
end