I am trying to assign Activation,maxIsometricForce, optimalFiberLength, tendonSlackLength and pennationAngle for each muscles of arm26.osim within Matlab. Below are my codes:
Code: Select all
import org.opensim.modeling.*;
%Call the model
model = Model('arm26.osim');
%Get initial state of the model
state = model.initSystem;
%Get the muscles, get the size of the muscle arrays
muscles= model.getMuscles();
nMuscles = muscles.getSize();
% Set muscle parameters
Activation = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05];
maxIsometricForce = [798.52, 624.3, 624.3, 624.3, 435.56, 987.26];
optimalFiberLength = [0.134, 0.1134, 0.1138, 0.1157, 0.1321, 0.0858];
tendonSlackLength = [0.134, 0.098, 0.0908, 0.2723, 0.1923, 0.0535];
pennationAngle = [0.20943951, 0.15707963, 0.15707963, 0, 0, 0];
%Creating for loop to assign above values to each muscle in the model
for i = 1:nMuscles
muscles.get(i).setActivation(state, Activation(i));
muscles.get(i).setMaxIsometricForce(state, maxIsometricForce(i));
muscles.get(i).setOptimalFiberLength(state, optimalFiberLength(i));
muscles.get(i).setTendonSlackLength(state, tendonSlackLength(i));
muscles.get(i).setPennationAngleAtOptimalFiberLength(state, pennationAngle(i));
end
I think the problem is due to 'state' input but I couldn't figure that out. I spent the whole two days but it still does not work.
Any help is appreciated.
RoZi