running ScaletOOL API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Firooz Salami
Posts: 29
Joined: Sat Jun 20, 2015 1:02 am

running ScaletOOL API

Post by Firooz Salami » Tue May 08, 2018 3:34 am

Hello,

I am trying to run ScaleTool through MATLAB R2014a but I couldn't find run command for ScaleTool in API docs and when I run ScaleTool.run() I get error messages from MATLAB fileparts as below

myscale = ScaleTool(myScaleSetup);
myscale.run()

Error using fileparts (line 32)
Input must be a row vector of characters.

Would you please help me to generate my scaled model in MATLAB?

Regards
Firooz

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

Re: running ScaletOOL API

Post by Thomas Uchida » Tue May 08, 2018 9:15 am

There are some relevant examples on Confluence (https://simtk-confluence.stanford.edu/d ... +Tutorials, e.g., Tutorial 3) and additional links here: viewtopicPhpbb.php?f=91&t=8425.

User avatar
Firooz Salami
Posts: 29
Joined: Sat Jun 20, 2015 1:02 am

Re: running ScaletOOL API

Post by Firooz Salami » Wed May 09, 2018 12:52 am

Dear Tom,

Thanks for the reply but this is not what I meant. I know how to work with ScaleTool in OpenSim GUI.
I can run IKtool, IDtool and Analysis tool on matlab directly (without using OpenSim GUI) for gait model 2392 but I cannot run Scale tool in matlab directly and I don't know which function or command will perform the scale tool running in matlab ( I couldn't find it in API docs).

regards
Firooz

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

Re: running ScaletOOL API

Post by Thomas Uchida » Wed May 09, 2018 4:02 pm

The ScaleTool contains a ModelScaler (https://simtk.org/api_docs/opensim/api_ ... caler.html) and a MarkerPlacer (https://simtk.org/api_docs/opensim/api_ ... lacer.html), as you see in the GUI. You will need to do something like

Code: Select all

status = myScaleTool.getModelScaler().processModel(state, model);
https://simtk.org/api_docs/opensim/api_ ... 1b85ed4ff2

User avatar
Firooz Salami
Posts: 29
Joined: Sat Jun 20, 2015 1:02 am

Re: running ScaletOOL API

Post by Firooz Salami » Fri May 11, 2018 8:04 am

Many Thanks.
I think the code would be useful though Matlab crashes after running it.

Regards
Firooz

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

Re: running ScaletOOL API

Post by Thomas Uchida » Fri May 11, 2018 10:50 am

I have attached example files that you can find in your OpenSim installation directory (under Models\Gait2354_Simbody). Here's the MATLAB code:

Code: Select all

import org.opensim.modeling.*
tool  = ScaleTool('subject01_Setup_Scale.xml');
model = Model('gait2354_simbody.osim');
state = model.initSystem();
tool.getModelScaler().processModel(state, model);
Attachments
scaleToolFiles.zip
Example files for running Scale Tool
(195.75 KiB) Downloaded 35 times

User avatar
Firooz Salami
Posts: 29
Joined: Sat Jun 20, 2015 1:02 am

Re: running ScaletOOL API

Post by Firooz Salami » Mon May 14, 2018 6:25 am

Dear Tom,

Thanks.

The Code works fine. I am trying to run the same for MarkerPlacer.

regards
Firooz

User avatar
Firooz Salami
Posts: 29
Joined: Sat Jun 20, 2015 1:02 am

Re: running ScaletOOL API

Post by Firooz Salami » Mon May 14, 2018 8:15 am

tool.getMarkerPlacer().processModel(state,model)
Java exception occurred:
java.lang.RuntimeException: AssemblySolver::assemble() Failed: SimTK Exception thrown at Assembler.cpp:227:
Error detected by Simbody method AssemblerSystem::objectiveFunc(): calcGoal() method of assembly condition Markers returned a negative or non-finite value -1.#IND.
(Required condition 'goalValue >= 0' was not met.)

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

Re: running ScaletOOL API

Post by Thomas Uchida » Mon May 14, 2018 11:28 am

The exception is thrown from the Assembler::objectiveFunc() method (https://github.com/simbody/simbody/blob ... #L206-L234) because there are no markers attached to the model. Try using a model file whose MarkerSet is non-empty (e.g., [your OpenSim installation directory]\Models\Gait2354_Simbody\OutputReference\subject01_simbody.osim).

User avatar
Firooz Salami
Posts: 29
Joined: Sat Jun 20, 2015 1:02 am

Re: running ScaletOOL API

Post by Firooz Salami » Tue May 15, 2018 2:23 am

Well, I am not sure if it is the reason because 1 ) I ran the code for gait2392_simbody.osim or Gait2354_Simbody\OutputReference\subject01_simbody.osim with their static.trc and markerset file ( or mine) I get following error
ava exception occurred:
java.lang.RuntimeException: InverseKinematicsSolver: Model has no markers!

at org.opensim.modeling.opensimModelJNI.MarkerPlacer_processModel__SWIG_1(Native Method)

at org.opensim.modeling.MarkerPlacer.processModel(MarkerPlacer.java:77)

but as soon as I use Hamner full body model ( which has marker set) the problem is solved.
but when I use my own static.trc and markerset file with hamner model I get the error
Java exception occurred:
java.lang.RuntimeException: AssemblySolver::assemble() Failed: SimTK Exception thrown at Assembler.cpp:227:
Error detected by Simbody method AssemblerSystem::objectiveFunc(): calcGoal() method of assembly condition Markers returned a negative or non-finite value -1.#IND.
(Required condition 'goalValue >= 0' was not met.)


at org.opensim.modeling.opensimModelJNI.MarkerPlacer_processModel__SWIG_1(Native Method)

at org.opensim.modeling.MarkerPlacer.processModel(MarkerPlacer.java:77)


I compared the marker sets and trc files and find no differences but the time and also I can scale using GUI. is it possible that I use different marker names?

POST REPLY