In the MATLAB editor, I'm attempting to set the controls.sto file for a forward dynamics simulation. I have gotten other forward dynamics object methods to override the forward dynamics object's setup .xml file (for example, FDobj.setResultsDir(String directory)). However, using the forward dynamics object's method FDobj.setControlsFileName(String filename), the simulation is run with the controls filename set in the setup file, instead of with the controls filename set with setControlsFilename(String filename), which is written below the statement loading the setup file. I know that the setup file is still being used because (test1:) if I set some controls .sto file (badfile.sto) in the setup file, then attempt to setControlsFileName() in MATLAB to a goodfile.sto, simulate, and plot the simulation's output in OpenSim, the output is the same as output for the badfile.sto set in the setup file. That output is also different from output (test2:) if I set the goodfile.sto in the .xml and simulate in MATLAB without using setControlsFileName(). Files are attached.
In other words, the MATLAB command FDobj.setControlsFileName(String filename) doesn't seem to be working.
Because the forum website didn't allow me to upload my MATLAB script, saying the .m was an invalid file extension, here is the MATLAB script:
Code: Select all
clearvars
import org.opensim.modeling.*
testN = 1;
model = Model('OSmodel.osim');
ft = ForwardTool('MATLABforwardDynamics.xml');
ft.setModel(model);
if testN ==1
ft.setControlsFileName('\goodfile.sto'); % doesn't override .xml
end
% ft.setResultsDir('anotherDir\'); % successfully overrides .xml file
ft.run();
Stephanie