Thanks for your help! I solved the issue, it hadn't anything to do with coordinates orders: storage values where in degrees. . I modified the state looping for the unordered state nevertheless. Thank you very much for your assistance!
Code: Select all
from math import radians
def computeLen(mot,mod):
storage = opensim.Storage(mot)
model = opensim.Model(mod)
model.setUseVisualizer(False)
state = model.initSystem()
semiten_l = model.getMuscles().get('semiten_l')
lengths_array = []
if storage.isInDegrees():
r = radians
else:
r = lambda x: x
for t in range(storage.getSize()):
for i in range(model.getNumCoordinates()):
n = model.getCoordinateSet().get(i).getName()
j = storage.getStateIndex(n)
v = storage.getStateVector(t).getData().get(j)
model.updCoordinateSet().get(i).setValue(state,r(v))
# Here should go model.realizePosition(state), which I lack.
model.computeStateVariableDerivatives(state)
lengths_array.append(semiten_l.getLength(state))
return lengths_array