MATLAB SCRIPTING, SCALE MODEL

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Alessandra Scarton
Posts: 3
Joined: Mon Feb 18, 2013 5:11 am

MATLAB SCRIPTING, SCALE MODEL

Post by Alessandra Scarton » Tue Feb 17, 2015 10:30 am

Hello,
I am trying to write a Matlab script to control the scale tool. I have already succesfully run IK, ID, RRA and SO in this way but I have never tryed to write a code for the scale tool because I needed to check the position of the markers and this was easier to do manually. Now I am working on a different kind of simulations for which I don't have markers and I am scaling the model just using "Manual scale" measures which can be perfectly done using a script. I though that it would have been the same as I have done for the other OpenSim processes but I encountered a problem. I only need to put the measure in Manual Scale but everytime that I try to change the .xml file, Matlab does not change only the numbers but also the tag <Scale> in <item> so that this:

<!--Scale factors to be used for manual scaling.-->
<ScaleSet>
<objects>
<Scale>
<scales> 1.3 1.3 1.3</scales>
<segment>pelvis</segment>
<apply>true</apply>
</Scale>

becomes this:

<ScaleSet>
<objects>
<item>
<scales> 1.3 1.3 1.3</scales>
<segment>pelvis</segment>
<apply>true</apply>
</item>

And OpenSim does not read the measures.
I tryed to fix the xmlwrite code but if I change the tag <item> in <Scale> then I get a double tag <Scale> and again OpenSim doesn't read the measures.

<ScaleSet>
<objects>
<Scale>
<Scale>
<scales> 1.3 1.3 1.3</scales>
<segment>pelvis</segment>
<apply>true</apply>
</Scale>

Has anyone experienced this problem? Any suggestions about how to fix the code?

Thank you for the help!

Alessandra

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: MATLAB SCRIPTING, SCALE MODEL

Post by jimmy d » Mon Feb 23, 2015 2:34 pm

Hi Alessandra,

Looks like a problem with the xmlreader/xmlwrite function you are using. Instead of using xml reading and writing, perhaps try using interacting with the API directly through matlab.

http://simtk-confluence.stanford.edu:80 ... Background
http://simtk-confluence.stanford.edu:80 ... ith+Matlab

An example scaling script can be found at OpenSim 3.2/Scripts/GUI_Scripting/runScaling.py. This is written in python but is very similiar to how you would do it in Matlab.

cheers,
-James

User avatar
Dharmesh Harsha
Posts: 1
Joined: Thu Jun 13, 2019 11:32 pm

Re: MATLAB SCRIPTING, SCALE MODEL

Post by Dharmesh Harsha » Sat Jul 13, 2019 4:44 am

@Alessandra Scarton

Can you please tell, how you have written the Matlab codes to control IK, ID, and tools from Matlab.

Thanks in advance

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: MATLAB SCRIPTING, SCALE MODEL

Post by jimmy d » Sat Jul 13, 2019 8:41 am

You can read the Scripting and API Guide to get an idea of how using the OpenSim API works through Matlab. There is example in your OpenSim distribution, runTutorialThree.py ,that performs the actions of Tutorial 3 (Scale, IK, and ID). You could refactor the script from python to Matlab.

POST REPLY