Page 1 of 1

Forward Dynamics in Matlab

Posted: Tue Sep 29, 2020 4:29 am
by mariacristina
Hi,

I'm trying to execute the Forward Dynamics Tool in Matlab, but the results obtained are wrong. I use the MoBL-ARMS model and I give a .xml file in input at FD Tool. This file contains a constant activation of Brachioradialis muscle(the other muscles of the model have a null activation).

I implement this section of script:
file = [path '\BRD.xml']; % excitation file of Brachioradialis
file = [file{:}];
FDinamicsTool = ForwardTool(file, true, false);
FDinamicsTool.setModel(myModel);
FDinamicsTool.setResultsDir(muscleDir);
FDinamicsTool.setStartTime(time(1));
FDinamicsTool.setFinalTime(time(end));
FDinamicsTool.run();

In the output directory, I obtain: 2 .sto file and 1 .mot file. All files are wrong, because Brachioradialis muscle isn't activated, and it should be instead.
If I execute this tool in OpenSim with the same file the results are correct.

How could I implement Forward Dynamics Tool in Matlab?
Thanks in advance.

Maria Cristina Panettieri

Re: Forward Dynamics in Matlab

Posted: Wed Sep 30, 2020 4:45 pm
by ongcf
Thanks for a nice concise code snippet. Looks close to me. A couple of possible issues below:

1.

Code: Select all

FDinamicsTool = ForwardTool(file, true, false);
The ForwardTool() constructor in this line is expecting a setup file (like the one you would get if you save out a setup file from the GUI) instead of the controls file. You could either pass in a setup file, or use a constructor that doesn't take in a file.

2. You can look at the ForwardTool documentation (https://simtk.org/api_docs/opensim/api_ ... dTool.html) which may be helpful for setting the controls file. If you click under functions that it inherits from parent classes, one function that might work is setControlsFileName() (https://simtk.org/api_docs/opensim/api_ ... a70711d8ce)

Re: Forward Dynamics in Matlab

Posted: Fri Oct 02, 2020 1:26 am
by mariacristina
Using setup file created in Matlab, the FD Tool works correctly.

Thank you very much!

Maria Cristina Panettieri