opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
783 stars 316 forks source link

Inconsistency between orders of `model.getStateVariableNames()` and `State` #3660

Open mrrezaie opened 9 months ago

mrrezaie commented 9 months ago

Hi, model.getStateVariableNames and model.getStateVariableValues return coordinates names and values in CoordinateSet order whereas state.getQ/U/UDot returns coordinates values in multibody tree order. It might make more sense if both of them followed a same order.

Thank you.

RealZiangLiu commented 5 months ago

Hi, as a quick follow up, is there any way to find out the ordering of the state variables returned from state.getQ? Thanks.

mrrezaie commented 5 months ago

Hi, Model::getCoordinateNamesInMultibodyTreeOrder may help:

import opensim as osim 

model = osim.Model(model_file_name)
model.initSystem()
coordNames = model.getCoordinateNamesInMultibodyTreeOrder()
[coordNames.getElt(i) for i in range(coordNames.size())]