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

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Stephanie Hachem
Posts: 34
Joined: Wed Oct 26, 2016 12:40 pm

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

Post by Stephanie Hachem » Sat Jun 23, 2018 9:25 am

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
Attachments
OSmodel.osim
(546.56 KiB) Downloaded 21 times
test2output.PNG
test2output.PNG (14.42 KiB) Viewed 259 times
test1output.PNG
test1output.PNG (13.47 KiB) Viewed 259 times
MATLABforwardDynamics.xml
(3.8 KiB) Downloaded 28 times
badoutput.PNG
badoutput.PNG (13.55 KiB) Viewed 259 times

Tags:

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

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

Post by Thomas Uchida » Sat Jun 23, 2018 11:09 pm

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().

User avatar
Stephanie Hachem
Posts: 34
Joined: Wed Oct 26, 2016 12:40 pm

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

Post by Stephanie Hachem » Sun Jun 24, 2018 7:55 am

Hello Mr. Uchida,

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

Thank you for your help!

Stephanie

POST REPLY