Page 1 of 1

MATLAB command FDobj.setControlsFileName(String filename) Doesn't Work

Posted: Sat Jun 23, 2018 9:25 am
by gy89
Hello all,

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();
I appreciate any help! Thank you!

Stephanie

Re: MATLAB command FDobj.setControlsFileName(String filename) Doesn't Work

Posted: Sat Jun 23, 2018 11:09 pm
by tkuchida
This is a known issue, also reported in Forum Topic 7998 (viewtopicPhpbb.php?f=91&t=7998). Workarounds are described in that Topic and in GitHub Issue #1832 (https://github.com/opensim-org/opensim-core/issues/1832). It looks like the simplest solution in your case might be calling setControlsFileName() before setModel().

Re: MATLAB command FDobj.setControlsFileName(String filename) Doesn't Work

Posted: Sun Jun 24, 2018 7:55 am
by gy89
Hello Mr. Uchida,

You're right, it works. I should've looked harder online.

Thank you for your help!

Stephanie