Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Maria Isabel Orselli
- Posts: 39
- Joined: Wed Mar 17, 2010 5:30 pm
Post
by Maria Isabel Orselli » Wed Dec 04, 2013 12:23 pm
Hi all,
I'm trying to edit a xml file using a matlab script and I would like to know how to set the IKTaskSet file within the "Marker Set Placer"
In the xml file it is:
Code: Select all
<MarkerPlacer>
<apply>true</apply>
<IKTaskSet file="C:\Users\Documents\Scale_Tasks.xml" />
<marker_file>marker.trc</marker_file>
<time_range> 0 0.5 </time_range>
<output_model_file> .\Scale_Results\scaled.osim</output_model_file>
<output_marker_file> .\Scale_Results\MarkerSet.xml </output_marker_file>
<max_marker_movement>-1</max_marker_movement>
</MarkerPlacer>
I could change the output file with the following script
Code: Select all
analyzeTool = ScaleTool(genericSetupFile);
analyzeTool.getMarkerPlacer().setOutputModelFileName(outputmodelfile_final)
but I could not understand the instructions in the Doxygen for changing the
<IKTaskSet file="C:\Users\Documents\Scale_Tasks.xml" />
Can anyone help ?
Thanks
Bel
-
jimmy d
- Posts: 1375
- Joined: Thu Oct 04, 2007 11:51 pm
Post
by jimmy d » Mon Jan 06, 2014 10:20 am
Hi Bel,
If you are trying to set the ikTaskSet using the api interface in matlab you will have to create a ikTaskSet object and then attach it.
ikTaskObject = IKTaskSet('C:\OpenSim 3.1\Models\Gait2354_Simbody\gait2354_IK_Tasks.xml') ;
theIKTaskSetRef = scaleTool.getMarkerPlacer().getIKTaskSet()
theIKTaskSetRef = ikTaskObject
I havent had a chance to test that so just see how it goes.
Otherwise you can edit each weight manually using a for loop;
scaleTool.getMarkerPlacer().getIKTaskSet().clearAndDestroy() % empty the set
for i = 1:nMkrs
scaleTool.getMarkerPlacer().getIKTaskSet().cloneAndAppend(ikTaskObject.get(i))
end
hope that helps,
-james
-
Maria Isabel Orselli
- Posts: 39
- Joined: Wed Mar 17, 2010 5:30 pm
Post
by Maria Isabel Orselli » Thu Jan 23, 2014 10:22 am
Hi James,
My idea is not to use the loop, so I'll try your first suggestion and let you know if it works
thanks
Bel
-
Maria Isabel Orselli
- Posts: 39
- Joined: Wed Mar 17, 2010 5:30 pm
Post
by Maria Isabel Orselli » Fri Jan 24, 2014 12:27 pm
Hi James,
It didn't work the way I was thinking. Doing the way you suggested, I could copy the IK tasks from one IKTask file to the other, but I could not modify the path name, nor even copy ( set ) the tasks, in the new Scale Setting file.
It seems that I'm missing a 'set' command.
Do you have any other suggestions?
thanks
Bel
-
Maria Fox
- Posts: 14
- Joined: Tue Oct 29, 2013 8:11 am
Post
by Maria Fox » Thu Jun 15, 2017 9:49 am
Hello,
I'm having a similar issue trying to define the IKTaskSet and MeasurementSet files in MATLAB for batch processing. I tried using the suggested method and it did not work. Are there any new ideas about how to fix this? My IKTaskSet and MeasurementSet files get lost during batch processing even if I have them in the generic XML file, so it would be great to find a way to add them in the batch processing code.
Thank you!
-
jimmy d
- Posts: 1375
- Joined: Thu Oct 04, 2007 11:51 pm
Post
by jimmy d » Thu Jun 15, 2017 12:11 pm
Hi, Maria-
My IKTaskSet and MeasurementSet files get lost during batch processing even if I have them in the generic XML file
What do you mean by lost? They don't go anywhere
Anyway, below is some code that may help show you how to write a measurement set or IK task set file. If you are doing this for scaling, you don't need separate files (you can store everything in the ScaleTool)
Code: Select all
import org.opensim.modeling.*
% instantiate a scale tool
scale = ScaleTool()
%% get a reference o the model scalar
% get the model scaler
scaler = scale.getModelScaler()
%% define a measurement
% instantiate and measurement object
m = Measurement()
% get a reference to the marker pair set
mps = m.getMarkerPairSet()
% instantiate a markerpair object; inputing a pair of markers
mp = MarkerPair('RHJC','RKJC')
% add the MarkerPair to the marker pair set
mps.adoptAndAppend(mp)
%% add the measurement to the ModelScaler Measuerement Set
sms = scaler.getMeasurementSet()
% add the measurement to the measurement set
sms.adoptAndAppend(m)
% print the measurement to file (if you want)
sms.print(''measurementset.xml')
%% get a reference to the marker placer
placer = Scale.getMarkerPlacer()
ik = placer.getIKTaskSet()
%% define a task and apend it to the ik task set
% instantiate an IK marker task
t = IKMarkerTask()
% set the name and the weight for the task
t.setName('LASI')
t.setWeight(10)
% append the ik marker task to the the IK task set
ik.adoptAndAppend(t)
% print the ik task set to file (if you want)
ik.print('iktaskset.xml')
-
Maria Fox
- Posts: 14
- Joined: Tue Oct 29, 2013 8:11 am
Post
by Maria Fox » Thu Jun 15, 2017 12:19 pm
James,
Thanks, this is helpful! I wanted to call the IKTastSet and MeasurementSet files because I have generic ones defined that I wanted to use for batch processing:
Code: Select all
<MeasurementSet file=".\Scale_MeasurementSet.xml"/>
This is where the file generated during batch processing "loses" the file I defined in the generic XML. Is there any way to include the files in MATLAB? I tried the code included below that was suggested in another post, but it doesn't seem to work:
Code: Select all
% setup marker placer
markerPlace = scaleTool.getMarkerPlacer();
ikTasks = IKTaskSet('.\Scale_Tasks.xml');
ikTaskSet = markerPlace.getIKTaskSet();
ikTaskSet = ikTasks;
Thank you!
-
jimmy d
- Posts: 1375
- Joined: Thu Oct 04, 2007 11:51 pm
Post
by jimmy d » Thu Jun 15, 2017 1:10 pm
Code: Select all
% get the marker placer
placer = scale.getMarkerPlacer()
% get the marker placer's IKTaskSet
placer_TaskSet = placer.getIKTaskSet()
% Instantiate a (separate) task set from file
taskSetFromFile = IKTaskSet('KTaskSet_File.xml')
% Take each (individual) task from the file generated task set and
% append them to the marker placer's task set.
for i = 0 : taskSetFromFile.getSize() - 1
placer_TaskSet.adoptAndAppend(taskSetFromFile.get(i));
end
if taskSetFromFile.getSize() ~= placer_TaskSet.getSize()
error('Number of ik tasks from file do not match number in object')
end