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.
torqueActuator
- Shreeshan Jena
- Posts: 2
- Joined: Mon Sep 04, 2017 4:04 am
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: torqueActuator
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.
- Shreeshan Jena
- Posts: 2
- Joined: Mon Sep 04, 2017 4:04 am
Re: torqueActuator
Thank you. It works now.