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
MATLAB SCRIPTING, SCALE MODEL
Re: MATLAB SCRIPTING, SCALE MODEL
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
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
- Dharmesh Harsha
- Posts: 1
- Joined: Thu Jun 13, 2019 11:32 pm
Re: MATLAB SCRIPTING, SCALE MODEL
@Alessandra Scarton
Can you please tell, how you have written the Matlab codes to control IK, ID, and tools from Matlab.
Thanks in advance
Can you please tell, how you have written the Matlab codes to control IK, ID, and tools from Matlab.
Thanks in advance
Re: MATLAB SCRIPTING, SCALE MODEL
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.