Page 1 of 1

torqueActuator

Posted: Sun Feb 16, 2020 10:35 pm
by shreeshan24
Hi,

I am trying to use the torqueActuator at the elbow joint for actuation. The code I am using is pasted below. It throws the following error upon executing
"Component has no underlying System.
You must call initSystem() on the top-level Component (i.e. Model) first."


import org.opensim.modeling.*

model = Model('arm26.osim');

path='C:\OpenSim 4.0\Geometry';
ModelVisualizer.addDirToGeometrySearchPaths(path);


model.setUseVisualizer(true);

state = model.initSystem();

Humerus_r = model.getBodySet().get('r_humerus');
Rad_ulna_r = model.getBodySet().get('r_ulna_radius_hand');
torqueActuator = TorqueActuator();
torqueActuator.setName('torqueActuator');
torqueActuator.setBodyA(Rad_ulna_r);
torqueActuator.setBodyB(Humerus_r);
torqueActuator.setAxis(Vec3(0,0,1));
torqueActuator.setOptimalForce(1000);
model.addComponent(torqueActuator);

brain = PrescribedController();
brain.addActuator(torqueActuator);
model.addController(brain);
brain.prescribeControlForActuator('torqueActuator',StepFunction(0, 1, 10, 20));

viz = model.updVisualizer().updSimbodyVisualizer();
viz.setBackgroundColor(Vec3(0)); % white
viz.setGroundHeight(-2);

manager = Manager(model); %Start manager for the model
state.setTime(0);
manager.initialize(state);
model.realizeAcceleration(state);
state = manager.integrate(5);


Thanks in advance.

Re: torqueActuator

Posted: Sun Feb 16, 2020 11:36 pm
by tkuchida
You're trying to initialize the Manager with a State that was created before you modified the Model. You should call "state = model.initSystem();" after the model has been modified.

Re: torqueActuator

Posted: Mon Feb 17, 2020 2:38 am
by shreeshan24
Thank you. It works now.