Differences between forward tool and manager

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Shelby Walford
Posts: 7
Joined: Tue Sep 04, 2018 12:05 pm

Differences between forward tool and manager

Post by Shelby Walford » Wed Oct 14, 2020 12:19 pm

Hi All,

I am running forward dynamics simulations from Matlab, and then with the same controls, trying to run the Forward Dynamics tool from the GUI (or in Matlab, both have the issue), mostly for previewing purposes and to save the motion file if needed. However, running the forward tool doesn't work. Specifically, the model just disappears halfway through running - it doesn't "fail" but does not complete. Are there differences between these integration methods (using manager vs. forward tool) that would cause this? Here are the codes that I am running. This one runs no problem:

Code: Select all

import org.opensim.modeling.*; 
osimModel=Model('MoBL_SLW_PrescribeTrunk.osim'); 
controlsfile = 'bestControls_SLW.sto'; 
    
model=osimModel.clone();
pc = PrescribedController(controlsfile);
model.addController(pc);
    
model.setUseVisualizer(true);

initState = model.initSystem();
initState.setTime(0);
model.equilibrateMuscles(initState);
    
manager = Manager(model);
manager.initialize(initState);
    
state = manager.integrate(1.35);
Whereas this one only runs through ~0.9 s:

Code: Select all

import org.opensim.modeling.*
    
osimModel=Model('MoBL_SLW_PrescribeTrunk.osim'); 
model=osimModel.clone();
model.setUseVisualizer(true);
model.initSystem();
tool = ForwardTool(); 

tool.setControlsFileName('bestControls_SLW.sto');
tool.setModel(model);
    
tool.setStartTime(0);
tool.setFinalTime(1.35);
tool.setSolveForEquilibrium(true);
    
tool.setName('visualizeBest');
    
tool.run();
And again, running the Forward Tool from the GUI instead of from Matlab stops at the same point (~0.9 s).

Thank you in advance!

Shelby

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

Re: Differences between forward tool and manager

Post by Thomas Uchida » Wed Oct 14, 2020 2:56 pm

In one case you're adding the controller to the model, in the other case you're adding it to the tool. For a controlled experiment (no pun intended), you might want to try adding the controller the same way in both cases. One thing you could test is running each for 0.8 seconds and compare the trajectories of the two models: are they the same up to 0.8 seconds? If not, a catastrophic failure may be occurring at 0.9 seconds due to the model configuration.

POST REPLY