Problem with Inverse Dynamics in Matlab (OpenSim 4.2)

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Sheeba Davis
Posts: 56
Joined: Sat Mar 23, 2019 5:19 am

Problem with Inverse Dynamics in Matlab (OpenSim 4.2)

Post by Sheeba Davis » Mon Apr 05, 2021 3:30 am

Hi

I encountered 2 issues with Inverse Dynamics in Matlab.

1. Following is the code

Code: Select all

myID = InverseDynamicsTool();
myID.setName('my_subject01_walk1');
myID.set_results_directory('my_ResultsInverseDynamics');
myModel=Model('my_subject01_simbody.osim');
myID.setModel(myModel);
myID.setModelFileName('my_subject01_simbody.osim');  
myID.setStartTime(0.40000000); 
myID.setEndTime(1.6000000);
myID.setExcludedForces(ArrayStr('Muscles'));
myID.setExternalLoadsFileName('subject01_walk1_grf.xml');
myID.setCoordinatesFileName('my_subject01_walk1__ik.mot');
myID.setLowpassCutoffFrequency(6.00000000);
myID.setOutputGenForceFileName('my_inverse_dynamics.sto');
myID.print('myID.xml');
But when i run it: myID.run();, it displays:
Java exception occurred:
java.io.IOException: InverseDynamicsTool Failed, please see messages window for details...

at org.opensim.modeling.opensimActuatorsAnalysesToolsJNI.InverseDynamicsTool_run(Native Method)

at org.opensim.modeling.InverseDynamicsTool.run(InverseDynamicsTool.java:117)
2. The command
myID.setExcludedForces(ArrayStr('Muscles'));
does the work, however it is not reflected in the xml file:
<forces_to_exclude />
I have already checked with API documentation and also used methodsview InverseKinematicsTool()

Thanks in advance,
Sheeba

Tags:

User avatar
Carmichael Ong
Posts: 401
Joined: Fri Feb 24, 2012 11:50 am

Re: Problem with Inverse Dynamics in Matlab (OpenSim 4.2)

Post by Carmichael Ong » Mon Apr 12, 2021 3:46 pm

It looks like you tried to call this constructor for ArrayStr: https://simtk.org/api_docs/opensim/api_ ... e1f44c9dd3

However, the second input (aSize) has a default value of 0, so since you didn't give a value for this, it has created an ArrayStr of 0 strings. A couple ways to deal with this:

1. Create an empty ArrayStr, and append the string to it:

Code: Select all

excludedForces = ArrayStr();
excludedForces.append('muscles');
myID.setExcludedForces(excludedForces);
2. Get the constructor of ArrayStr() to make an array with 1 string:

Code: Select all

ArrayStr('muscles', 1)

POST REPLY