I'm confused about the states' order when I use State::getY() or similar methods.
I found Y=Q+U+Z, but the states' orders inside Q,U,Z are hard to know. Is there a method to output states' name with the same sequence order of Y?
I tried Component::getStateVariableNames. It can output same states as in Opensim model, but obviously different from getY().
Thanks for reading.
states order in State::getY()
- Thomas Uchida
- Posts: 1800
- Joined: Wed May 16, 2012 11:40 am
Re: states order in State::getY()
It is generally advisable to get the values of state variables through the OpenSim API. For example, you can ask a Muscle for its fiber length using getFiberLength() (https://simtk.org/api_docs/opensim/api_ ... 61455143e8). It would be helpful to know what you are trying to do.
Re: states order in State::getY()
Thanks for replying. I was actually trying to get state derivatives, but they were different from what I expected. So I checked states setting, and found they were also different as I expected. The differences were mainly states' order.tkuchida wrote: ↑Thu Nov 21, 2019 3:07 amIt is generally advisable to get the values of state variables through the OpenSim API. For example, you can ask a Muscle for its fiber length using getFiberLength() (https://simtk.org/api_docs/opensim/api_ ... 61455143e8). It would be helpful to know what you are trying to do.
- Thomas Uchida
- Posts: 1800
- Joined: Wed May 16, 2012 11:40 am
Re: states order in State::getY()
Still not sure what you're trying to do, but there are some methods in OpenSim's Component interface that might be helpful:
- getStateIndex(), https://simtk.org/api_docs/opensim/api_ ... e65c5a1b5a
- getStateVariableSystemIndex(), https://simtk.org/api_docs/opensim/api_ ... 7d5938284d
- getDiscreteVariableIndex(), https://simtk.org/api_docs/opensim/api_ ... 1bc698cd88
- etc.
You could also interpret Y by changing states using OpenSim methods and seeing which entries in Y change, but there's no guarantee that the order/indices of state variables will remain the same between software releases. Some additional information can be found in the Simbody documentation, https://github.com/simbody/simbody/tree ... imbody/doc.
- getStateIndex(), https://simtk.org/api_docs/opensim/api_ ... e65c5a1b5a
- getStateVariableSystemIndex(), https://simtk.org/api_docs/opensim/api_ ... 7d5938284d
- getDiscreteVariableIndex(), https://simtk.org/api_docs/opensim/api_ ... 1bc698cd88
- etc.
You could also interpret Y by changing states using OpenSim methods and seeing which entries in Y change, but there's no guarantee that the order/indices of state variables will remain the same between software releases. Some additional information can be found in the Simbody documentation, https://github.com/simbody/simbody/tree ... imbody/doc.