Turn off text to screen during API calls to Inverse Dynamics

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
William Thompson
Posts: 17
Joined: Mon Jun 25, 2012 7:07 pm

Turn off text to screen during API calls to Inverse Dynamics

Post by William Thompson » Mon Dec 26, 2016 7:53 am

I am trying to suppress all text output to the screen when running ID from the Matlab API. I have tried using the getVerboseLevel/setVerboseLevel methods as in the following code, but it does not work. Can anyone help identify what I might be doing wrong? --Thanks, Bill

%API calls to run ID from Matlab
import org.opensim.modeling.*
idTool = InverseDynamicsTool(IDSetup_File);
IDModel = Model(Model_File);
IDModel.initSystem();

%only process 1 frame of data each iteration for efficiency
idTool.setStartTime(CurrTime);
idTool.setEndTime(CurrTime);

%Suppress output text to screen during ID
vLevel=idTool.getVerboseLevel();
vLevel.swigToEnum(0);
idTool.setVerboseLevel(vLevel);

idTool.run();

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

Re: Turn off text to screen during API calls to Inverse Dynamics

Post by Thomas Uchida » Tue Dec 27, 2016 2:10 am

What version of OpenSim are you using? I don't see anything displayed in the MATLAB Command Window with the Tools in OpenSim 4.0. Regardless, have you tried MATLAB's "evalc()" function?

User avatar
William Thompson
Posts: 17
Joined: Mon Jun 25, 2012 7:07 pm

Re: Turn off text to screen during API calls to Inverse Dynamics

Post by William Thompson » Tue Dec 27, 2016 6:01 am

Thanks, Tom, evalc() works, but I am not seeing much improvement in speed in my optimizer code. So i will look for other ways to speed things up.

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

Re: Turn off text to screen during API calls to Inverse Dynamics

Post by Thomas Uchida » Tue Dec 27, 2016 7:08 pm

evalc() works, but I am not seeing much improvement in speed in my optimizer code.
Printing to the MATLAB Command Window is not likely to be taking much time (unless you're printing a lot of text). Also note that eval() has some overhead (see https://www.mathworks.com/help/matlab/m ... ation.html). If you're trying to improve the speed of your optimization code, you might check things like the following:
- avoid unnecessary calls to initSystem() (if possible, create the underlying System once and pass the State around)
- avoid unnecessarily creating and destroying OpenSim objects (e.g., within the objective function)

You might try using MATLAB's tic/toc functions to track down the most expensive lines of code.

POST REPLY