Editing the XML file using Matlab
- Sheeba Davis
- Posts: 56
- Joined: Sat Mar 23, 2019 5:19 am
Editing the XML file using Matlab
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
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
Tags:
- Ayman Habib
- Posts: 2238
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Editing the XML file using Matlab
Hello,
MarkerPair has a method 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
MarkerPair has a method
Code: Select all
setMarkerName(int i, String aName)
https://simtk.org/api_docs/opensim/api_ ... rPair.html
Hope this helps,
-Ayman
- Sheeba Davis
- Posts: 56
- Joined: Sat Mar 23, 2019 5:19 am
Re: Editing the XML file using Matlab
Hi Ayman
Thanks for the clarification. I am getting to understand much better now.
Regards
Sheeba
Thanks for the clarification. I am getting to understand much better now.
Regards
Sheeba
- Sheeba Davis
- Posts: 56
- Joined: Sat Mar 23, 2019 5:19 am
Re: Editing the XML file using Matlab
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:
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
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');
Can you please tell me why this happens?
Regards
Sheeba
- Thomas Uchida
- Posts: 1789
- Joined: Wed May 16, 2012 11:40 am
Re: Editing the XML file using Matlab
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();).
- Sheeba Davis
- Posts: 56
- Joined: Sat Mar 23, 2019 5:19 am
Re: Editing the XML file using Matlab
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
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
- Sheeba Davis
- Posts: 56
- Joined: Sat Mar 23, 2019 5:19 am
Re: Editing the XML file using Matlab
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.
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.
- Thomas Uchida
- Posts: 1789
- Joined: Wed May 16, 2012 11:40 am
Re: Editing the XML file using Matlab
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.
- Sheeba Davis
- Posts: 56
- Joined: Sat Mar 23, 2019 5:19 am
Re: Editing the XML file using Matlab
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:
Thanks
Sheeba
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:
Code: Select all
>> methodsview IKCoordinateTask
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);
It must be some small change i need to incorporate, but unable to figure it out.and i got
<IKCoordinateTask name="mtp_angle_l">
<apply>true</apply>
<weight>1000</weight>
<value_type>default_value</value_type>
<value>0</value>
</IKCoordinateTask>
Thanks
Sheeba