I am trying to write a plug-in for OpenSim. To start with, I want to store some muscle parameters such as forces, activations, lengths... Using an example template giving positions for bones as a basis, I am able now to store muscle names and time column correctly but the values for muscles' states are all zeros. When trying to find a proper function, I get an error "ArrayPtrs.get: Array index out of bounds."
![Question :?:](./images/smilies/icon_question.gif)
// Do I need to compute equilibrium for the model or to realize it?
_model->getSystem().realize(s,SimTK::Stage::Velocity);
_model->getSystem().realize(s,SimTK::Stage::Acceleration);
_model->computeEquilibriumForAuxiliaryStates(s);
![Question :?:](./images/smilies/icon_question.gif)
Is it right to call muscles using indices for actuators?
I am not an expert in C++ and have difficulties to figure out how to operate with the classes and functions. I will be very glad if you share your experience. I expect it should not be very complicated.
Best,
Natalia
Below are some fragments of my code. I suppose that my problem is in following lines:
//I defined muscle indexes as actuators' attributes:
_muscleIndices[j]=actuatorSet.getIndex(_muscleNames[j]);
labels.append(actuator.getName());
//I tried to use Actuators class:
const OpenSim::Set<Actuator>& actuatorSet = _model->getActuators();
const Actuator& actuator = actuatorSet.get(_muscleIndices);
OutputValues1=actuator.computeActuation(s);
OutputValues2=actuator.getForce(s);
//and also Muscles class:
const Muscle& muscle=_model->getMuscles().get(_muscleIndices);
OutputValues1=muscle.computeActuation(s);
OutputValues2=muscle.getForce(s);