Page 1 of 2
running ScaletOOL API
Posted: Tue May 08, 2018 3:34 am
by firoozs
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
Re: running ScaletOOL API
Posted: Tue May 08, 2018 9:15 am
by tkuchida
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.
Re: running ScaletOOL API
Posted: Wed May 09, 2018 12:52 am
by firoozs
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
Re: running ScaletOOL API
Posted: Wed May 09, 2018 4:02 pm
by tkuchida
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
Re: running ScaletOOL API
Posted: Fri May 11, 2018 8:04 am
by firoozs
Many Thanks.
I think the code would be useful though Matlab crashes after running it.
Regards
Firooz
Re: running ScaletOOL API
Posted: Fri May 11, 2018 10:50 am
by tkuchida
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);
Re: running ScaletOOL API
Posted: Mon May 14, 2018 6:25 am
by firoozs
Dear Tom,
Thanks.
The Code works fine. I am trying to run the same for MarkerPlacer.
regards
Firooz
Re: running ScaletOOL API
Posted: Mon May 14, 2018 8:15 am
by firoozs
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.)
Re: running ScaletOOL API
Posted: Mon May 14, 2018 11:28 am
by tkuchida
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).
Re: running ScaletOOL API
Posted: Tue May 15, 2018 2:23 am
by firoozs
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?