Page 1 of 1
Editing the XML file using Matlab
Posted: Tue Mar 09, 2021 1:41 am
by sheebadavis
Hi
I have some doubts w.r.t editing my scale setup file.
I have added the first "Marker pair" to my "Marker pair set" and then to the "Measurement-torso". Similarly, "Body scale" to "Body scale set" to "Measurement-torso". With this, i have created my first "Measurement-torso". Next when i want create second "Measurement-pelvis" , i could change the marker names in the already existing "Marker Pair". But when i use "cloneAnd Append", the new "Marker pair" gets appended to the old "Marker pair" in the "Measurement" instead of replacing it.
What command do i need to use to replace the "Marker pair" in the "Measurement"?
Thanks in advance.
Sheeba
Re: Editing the XML file using Matlab
Posted: Thu Mar 11, 2021 10:18 am
by aymanh
Hello,
MarkerPair has a method
Code: Select all
setMarkerName(int i, String aName)
which is used to set the names. In general you should consult the doxygen documentation to see what methods are available for each object, for example here:
https://simtk.org/api_docs/opensim/api_ ... rPair.html
Hope this helps,
-Ayman
Re: Editing the XML file using Matlab
Posted: Fri Mar 12, 2021 9:03 pm
by sheebadavis
Hi Ayman
Thanks for the clarification. I am getting to understand much better now.
Regards
Sheeba
Re: Editing the XML file using Matlab
Posted: Mon Mar 15, 2021 11:02 pm
by sheebadavis
Hi
In continuation with the process of editing "myScale" (Scale Setup file), i have created a "MeasurementSet" and appended it to "myScale". Next time when i wanted to append "ScaleSet" to "myScale" (on some other day), i just did:
Code: Select all
import org.opensim.modeling.*
myScale = ScaleTool();
myScale.getModelScaler().getScaleSet().setName('gait2354_Scale');
myScale.print('myScale.xml');
But what happens is, the whole file of "myScale" becomes blank (empty file, that means whatever i had done previously is gone) and only the ScaleSet name has been set <ScaleSet name="gait2354_Scale">
Can you please tell me why this happens?
Regards
Sheeba
Re: Editing the XML file using Matlab
Posted: Tue Mar 16, 2021 7:38 am
by tkuchida
In your code, you are creating a new ScaleTool object, setting a string, and then saving to file---presumably overwriting the file you had saved eariler. If you want to modify an existing file, you need to read that file in as the starting point (something like myScale = ScaleTool('myScale.xml'); rather than myScale = ScaleTool();).
Re: Editing the XML file using Matlab
Posted: Tue Mar 16, 2021 8:08 am
by sheebadavis
Hi Thomas
Thanks for your response. It was indeed a great help. Now it works fine. I did'nt know that we could do that way.
Regards
Sheeba
Re: Editing the XML file using Matlab
Posted: Fri Mar 19, 2021 2:50 am
by sheebadavis
Hi
In continuation with the process of editing an xml file, i would like to know the matlab command for setting the value type in the IK coordinate task. In case of default value, there was no issue, but if i have to set value type to "ManualValue", i am unsure of its argument. i do not know whether i should use StringToValueType for converting to the required value type.
Thanks in advance
Sheeba.
Re: Editing the XML file using Matlab
Posted: Fri Mar 19, 2021 6:15 am
by tkuchida
Please refer to the API documentation for the ScaleTool class (
https://simtk.org/api_docs/opensim/api_ ... eTool.html). Also, as described on the "Scripting with Matlab" page in the documentation (
https://simtk-confluence.stanford.edu/d ... ith+Matlab), you can use the "methodsview()" function in Matlab to display all the methods available for an OpenSim object.
Re: Editing the XML file using Matlab
Posted: Sun Mar 21, 2021 10:35 pm
by sheebadavis
Hi Thomas
Thanks for your reply. I have gone through API documentation, scripting with matlab and also used methodsview(). I am actually trying to recreate the the scale setup file for gait2354 model provided in the OpenSim 4.1 distribution in matlab. The 'ValueType' in the IKCoordinateTask for 'lumbar extension' is to be set to 'manual_value'. I used:
The 'setValueType' has an argument 'org.opensim.modeling.IKCoordinateTask$ValueType'. For ex, in case of a 'default_value', i dint have to do 'setValueType':
Code: Select all
>> MtpAngleLIKCoordinateTask=IKCoordinateTask ();
MtpAngleLIKCoordinateTask.setName('mtp_angle_l');
MtpAngleLIKCoordinateTask.setApply(true);
MtpAngleLIKCoordinateTask.setWeight(1000.00000000);
myScale.getMarkerPlacer().getIKTaskSet().cloneAndAppend(MtpAngleLIKCoordinateTask);
and i got
<IKCoordinateTask name="mtp_angle_l">
<apply>true</apply>
<weight>1000</weight>
<value_type>default_value</value_type>
<value>0</value>
</IKCoordinateTask>
It must be some small change i need to incorporate, but unable to figure it out.
Thanks
Sheeba