Unfortunately, I fail to see how to link Model, Storage and State instances API-wise. My code can already output the transformation for the initial state, but how do I load a new state from a specific row of the motion file?
I already browsed the API documentation several times, but all I could find was a way to manually set the coordintes as per one of the Python bindings examples:
model.setStateVariableValue(state, 'joint/q/value', 0.25 * math.pi)
Surely, there must be a better and more automatic way, I think. OpenSim's GUI also loads motion files, hence I suppose this logic has already been implemented, but I was only unable to find it.
Code: Select all
import opensim as osim
model = osim.Model("model.osim")
model.buildSystem()
state = model.initializeState()
motion_storage = osim.Storage("ik.mot")
# Acquiring the transformation for a specific body in the bodyset already works
model.getBodySet().get(0).getTransformInGround(state)