Page 1 of 1

Setting initial joint coordinates and force parameters from an STO file

Posted: Thu Jun 24, 2021 12:02 pm
by jonperdomo
Hi everyone,

I was wondering if it is possible to use an *.STO file with initial values at time 0 (for joint coordinates and force parameters) to load and set up the initial state for a model in C++? I want to set the initial state of the model before running a simulation.


Sincerely,

Jonathan Perdomo
Drexel University

Re: Setting initial joint coordinates and force parameters from an STO file

Posted: Thu Jun 24, 2021 12:08 pm
by jonperdomo
My current approach is to load the *.STO file as a SimTK::Storage object, and then try to update each of the parameters individually in a for-loop.

Re: Setting initial joint coordinates and force parameters from an STO file

Posted: Thu Jun 24, 2021 12:23 pm
by aymanh
Hi Jonathan,

Many of the items you described are state variables and have a default value stored in the model's osim file (e.g. default value for coordinates or muscle activations). You can set these in the file and you get the initialization for free on call to initSystem(). Generally it could be hard to come up on your own with a consistent set of states, especially if a model contains constraints, but if you list what you want to initialize in your case, it could be easier than the more generic but harder problem.

Hope this helps,
-Ayman

Re: Setting initial joint coordinates and force parameters from an STO file

Posted: Mon Jun 28, 2021 11:58 am
by jonperdomo
Hi Ayman,

OK thank you for the suggestion. I ended up finding a useful utility, the OpenSim::ForwardTool(), to set the initial state and controller files via the input XML.


Sincerely,

Jonathan