opensim-core icon indicating copy to clipboard operation
opensim-core copied to clipboard

Enabled getCoordinatesInMultibodyTreeOrder

Open cvhammond opened this issue 2 years ago • 3 comments

We are trying to step through a .mot file and record information at each time point. Looking at how InverseDynamics achieves model positions, we are modifying the Q vector in state.setQ(newVector). The issue is understanding which coordinate is associated with each position in the Q vector requires model.getCoordinatesInMultibodyTreeOrder(). Would it be possible to implement a version of that function call such that even just an org.opensim.modeling.StringVector is returned?

If not, what is the recommended way to put the model into a specific pose?

cvhammond avatar Jul 12 '22 19:07 cvhammond

You can set positions and velocities using the Coordinate::setValue() and Coordinate::setSpeedValue() methods. Please note the third argument to Coordinate::setValue(). 🦉

tkuchida avatar Jul 13 '22 00:07 tkuchida

How do I get a mutable version of the coordinate of interest? model.getCoordinateSet().get(coordName) returns an immutable reference correct?

Example:

>> model.getCoordinateSet().get(1).setValue(state, 5)
>> model.getCoordinateSet().get(1).getValue(state)

ans =

    1.5708

cvhammond avatar Jul 13 '22 03:07 cvhammond

No need for Coordinate to be non-const as the change of value only changes the state not the coordinate definition. You may want to look into StateTrajectory class for help/usage

aymanhab avatar Jul 13 '22 15:07 aymanhab

Please post additional questions over on the user forum. Thanks!

jenhicks avatar Nov 23 '22 19:11 jenhicks