model "snap shot" of a single state via API
Posted: Sun Feb 27, 2011 10:37 pm
Hello everyone. For anyone who has read my threads before you may have noticed I typically use opensim via the API for what may be considered "unintended uses". Because of this I often have off topic questions, and I apologize because here is another one
I wish to take a single "snap shot" of a model's parameters in a defined state. I wish to set the generalized coordinate angles, velocities, muscle activations, and maybe (not essential) joint accelerations.
Once put into this state, I then wish to calculate...
* musculotendon lengths and velocities
* muscle fibre lengths and velocities
* musculotendon tensions
* muscle moment arms
* Kinematic Jacobian
* Mass matrix
To date I have been pretty successful, but I keep finding small inconsistencies in the results which makes me think the method I am using the API is not correct.
A typical example is when I set the joint angles/velocities to set values, and slowly increase the muscle activations while viewing the corresponding muscle tensions. I would expect the tensions to increase linearly with activation, however at some activations the tensions drop to zero. I also find that this behaviour changes when I ramp the activations slower or faster, or start from a different value.
I suspect this is because the way I am doing it makes a new state instance every time, and the new state depends on the previous to some extent? Here are my basic steps:
1 - create model and initialize the system/state
2 - I set coordinate values using OpenSim::Coordinate::setValue();
3 - I set coordinate speeds using OpenSim::Coordinate::setSpeedValue();
4 - I set muscle activation using OpenSim::Muscle:setActivation();
5 - I run osimModel.getSimbodyEngine().projectConfigurationToSatisfyConstraints(si,0.01);
6 - I run osimModel.getSystem().realize(si,SimTK::Stage::Velocity);
7 - I run osimModel.computeEquilibriumForAuxiliaryStates(si);
I then go ahead and get the information I need, for example I use getLength() to get musculotendon length. Is there a step I am missing or performing in the wrong order which could mess up the calculation?
Could it be the function I am using for muscle tension? I am happy to assume muscle equilibrium (fibre velocity = musculotendon velocity) so I was using computeIsokineticForceAssumingInfinitelyStiffTendon(), but if I use getForce() the inconsistent results go away (but I am unsure if it is in equilibrium). Maybe I need to manually equilibriate the muscle before hand?
Sorry again for the novel I just posed Any help is greatly appreciated.
Also, on a side note would it be a good idea to start a new forum section on API related questions only? I am sure the majority of OpenSim users operate via the GUI only and are not interested in reading these long winded API questions
Cheers
Marc
I wish to take a single "snap shot" of a model's parameters in a defined state. I wish to set the generalized coordinate angles, velocities, muscle activations, and maybe (not essential) joint accelerations.
Once put into this state, I then wish to calculate...
* musculotendon lengths and velocities
* muscle fibre lengths and velocities
* musculotendon tensions
* muscle moment arms
* Kinematic Jacobian
* Mass matrix
To date I have been pretty successful, but I keep finding small inconsistencies in the results which makes me think the method I am using the API is not correct.
A typical example is when I set the joint angles/velocities to set values, and slowly increase the muscle activations while viewing the corresponding muscle tensions. I would expect the tensions to increase linearly with activation, however at some activations the tensions drop to zero. I also find that this behaviour changes when I ramp the activations slower or faster, or start from a different value.
I suspect this is because the way I am doing it makes a new state instance every time, and the new state depends on the previous to some extent? Here are my basic steps:
1 - create model and initialize the system/state
2 - I set coordinate values using OpenSim::Coordinate::setValue();
3 - I set coordinate speeds using OpenSim::Coordinate::setSpeedValue();
4 - I set muscle activation using OpenSim::Muscle:setActivation();
5 - I run osimModel.getSimbodyEngine().projectConfigurationToSatisfyConstraints(si,0.01);
6 - I run osimModel.getSystem().realize(si,SimTK::Stage::Velocity);
7 - I run osimModel.computeEquilibriumForAuxiliaryStates(si);
I then go ahead and get the information I need, for example I use getLength() to get musculotendon length. Is there a step I am missing or performing in the wrong order which could mess up the calculation?
Could it be the function I am using for muscle tension? I am happy to assume muscle equilibrium (fibre velocity = musculotendon velocity) so I was using computeIsokineticForceAssumingInfinitelyStiffTendon(), but if I use getForce() the inconsistent results go away (but I am unsure if it is in equilibrium). Maybe I need to manually equilibriate the muscle before hand?
Sorry again for the novel I just posed Any help is greatly appreciated.
Also, on a side note would it be a good idea to start a new forum section on API related questions only? I am sure the majority of OpenSim users operate via the GUI only and are not interested in reading these long winded API questions
Cheers
Marc