Page 1 of 1

Question about scripting in the GUI

Posted: Sun Dec 27, 2015 8:50 am
by jolthoff
I want to look at the effect of activating different pairs of muscles on the movement of the limbs. I am having a problem with automating this, however. I can get the simulation to run and save a .mot file, but I can't get it to set the activations and actually work (they stay at the default instead of the desired setting here of 0.5). I'm sure this is a straightforward problem with either syntax or order. Any help to straighten this out would be greatly appreciated. The code is below:

import os
import org.opensim.utils as utils
import org.opensim

modelFile = "C:/Users/John/Desktop/Scripting/rat_model.osim"

loadModel(modelFile);
model = getCurrentModel();

myBodySet = model.getBodySet();
myMuscles = model.getMuscles();
nMuscles = myMuscles.getSize();

myState = model.initSystem()
myMuscles.get(0).setActivation(myState,.5)
myMuscles.get(1).setActivation(myState,.5)

tool = modeling.ForwardTool()
tool.setModel(model);
tool.setStartTime(0);
tool.setFinalTime(.1);
tool.setSolveForEquilibrium(1);

tool.setName('Rat');

tool.run();

Re: Question about scripting in the GUI

Posted: Sun Dec 27, 2015 5:24 pm
by jolthoff
I answered my own question, well, at least I got around the problem by creating a controller.

But for future reference: are the default_activation variable and setActivation() method not accessible/available from the gui scripting?

Thanks!