Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Sina Porsa
- Posts: 99
- Joined: Thu Feb 03, 2011 7:21 pm
Post
by Sina Porsa » Mon May 27, 2013 10:02 pm
Hi All
I want to set the initial states (joint angles and velocities) to specific values and use forward dynamics to integrate the equations of motion forward in time.
I am using MatLab API. here is my script:
Code: Select all
system = osimModel.initSystem();
modelCoordinateSet = osimModel.updCoordinateSet();
modelCoordinateSet.get(aCoor).setValue(system,aValue);
tool = ForwardTool();
tool.setModel(osimModel);
tool.setStartTime(0);
tool.setFinalTime(finalTime);
tool.run();
When I look at the results, all of the joint angles and velocities have an initial value of zero. Any idea how can I solve this problem?
Thanks,
Sina
-
Ayman Habib
- Posts: 2244
- Joined: Fri Apr 01, 2005 12:24 pm
Post
by Ayman Habib » Tue May 28, 2013 2:13 pm
Hi Sina,
The method
ends up calling initSystem again, to add Forces to the model in case these were specified in the setup file, and that wipes out your initial states. You can work around this by calling
Code: Select all
model.setPropertiesFromState(goodInitialState)
and pass in the state you initialized before calling tool.setModel.
It would generally be helpful (though not needed) if you name the variable returned by the call to initSystem "state" instead of "system" because that's closer to the the actual type of object.
Hope this helps,
-Ayman