torqueActuator

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Shreeshan Jena
Posts: 2
Joined: Mon Sep 04, 2017 4:04 am

torqueActuator

Post by Shreeshan Jena » Sun Feb 16, 2020 10:35 pm

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.
Attachments
torqueActuator error.JPG
torqueActuator error.JPG (47.23 KiB) Viewed 204 times

Tags:

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: torqueActuator

Post by Thomas Uchida » Sun Feb 16, 2020 11:36 pm

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.

User avatar
Shreeshan Jena
Posts: 2
Joined: Mon Sep 04, 2017 4:04 am

Re: torqueActuator

Post by Shreeshan Jena » Mon Feb 17, 2020 2:38 am

Thank you. It works now.

POST REPLY