I'm trying to reproduce the SquatToStand example with a load.
In the example, the osim model used consider only the right leg.
I'd like to use a model with both legs (ex : gait2353 or gait2392 simbody).
I'm trying to integrate the the symmetry like this (from the example2Dwalking) :
Code: Select all
% % Symmetry
symmetryGoal = MocoPeriodicityGoal('symmetryGoal');
problem.addGoal(symmetryGoal);
model = modelProcessor.process();
model.initSystem();
% Symmetric coordinate values (except for pelvis_tx) and speeds
for i = 1:model.getNumStateVariables()
currentStateName = string(model.getStateVariableNames().getitem(i-1));
if startsWith(currentStateName , '/jointset')
if contains(currentStateName,'_r')
pair = MocoPeriodicityGoalPair(currentStateName, ...
regexprep(currentStateName,'_r','_l') );
symmetryGoal.addStatePair(pair);
end
if contains(currentStateName,'_l')
pair = MocoPeriodicityGoalPair(currentStateName, ...
regexprep(currentStateName,'_l','_r'));
symmetryGoal.addStatePair(pair);
end
if (~contains(currentStateName,'_r') && ...
~contains(currentStateName,'_l') && ...
~contains(currentStateName,'pelvis_tx/value') && ...
~contains(currentStateName,'/activation'))
symmetryGoal.addStatePair(MocoPeriodicityGoalPair(currentStateName));
end
end
end
% Symmetric muscle activations
for i = 1:model.getNumStateVariables()
currentStateName = string(model.getStateVariableNames().getitem(i-1));
if endsWith(currentStateName,'/activation')
if contains(currentStateName,'_r')
pair = MocoPeriodicityGoalPair(currentStateName, ...
regexprep(currentStateName,'_r','_l'));
symmetryGoal.addStatePair(pair);
end
if contains(currentStateName,'_l')
pair = MocoPeriodicityGoalPair(currentStateName, ...
regexprep(currentStateName,'_l','_r'));
symmetryGoal.addStatePair(pair);
end
end
end
% Symmetric coordinate actuator controls
symmetryGoal.addControlPair(MocoPeriodicityGoalPair('/lumbarAct'));
Code: Select all
% Position bounds: the model should start in a squat and finish
% standing up.
problem.setStateInfo('/jointset/ground_pelvis/pelvis_tilt/value', [-20*pi/180, -10*pi/180]);
problem.setStateInfo('/jointset/ground_pelvis/pelvis_tx/value', [0, 1]);
problem.setStateInfo('/jointset/ground_pelvis/pelvis_ty/value', [0.75, 1.25]);
problem.setStateInfo('/jointset/hip_r/hip_flexion_r/value', ...
[-2, 0.5], -2, 0);
problem.setStateInfo('/jointset/hip_l/hip_flexion_l/value', ...
[-2, 0.5], -2, 0);
problem.setStateInfo('/jointset/knee_r/knee_angle_r/value', ...
[-2, 0], -2, 0);
problem.setStateInfo('/jointset/knee_l/knee_angle_l/value', ...
[-2, 0], -2, 0);
problem.setStateInfo('/jointset/ankle_r/ankle_angle_r/value', ...
[-0.5, 0.7], -0.5, 0);
problem.setStateInfo('/jointset/ankle_l/ankle_angle_l/value', ...
[-0.5, 0.7], -0.5, 0);
Code: Select all
Error using exampleRugbyLift (line 122)
Java exception occurred:
java.lang.RuntimeException: Could not find state '/jointset/ground_pelvis/pelvis_rist/value'.
Thrown at MocoPeriodicityGoal.cpp:71 in initializeOnModelImpl().
at org.opensim.modeling.opensimMocoJNI.MocoStudy_initCasADiSolver(Native Method)
at org.opensim.modeling.MocoStudy.initCasADiSolver(MocoStudy.java:113)
How should I correct it/or proceed to symmetry in the Squat to Stand case ?
Thank you