Page 1 of 1

creating IK setup file in Matlab

Posted: Wed Mar 31, 2021 3:17 am
by sheebadavis
Hi

I was creating an IK setup file in Matlab and i could'nt find the following objects in the InverseKinematicsTool
setModelFileName()
setAccuracy()
setConstraintWeight()
I actually need them to update my xml file:
<model_file>Unassigned</model_file>
<constraint_weight>Inf</constraint_weight>
<accuracy>1.0000000000000001e-05</accuracy>
Is there another procedure for doing this?

Thanks in advance,
Sheeba

Re: creating IK setup file in Matlab

Posted: Wed Mar 31, 2021 8:20 am
by tkuchida
You should be able to set the model filename using the set_model_file() method (see the API documentation under "Public Member Functions inherited from OpenSim::InverseKinematicsToolBase" here: https://simtk.org/api_docs/opensim/api_ ... sTool.html). In the future, you can use the API documentation or (perhaps easier) use the "methodsview()" function in Matlab. Please see the "Scripting with Matlab" page in the documentation: https://simtk-confluence.stanford.edu/d ... ith+Matlab.

Re: creating IK setup file in Matlab

Posted: Wed Mar 31, 2021 10:18 pm
by sheebadavis
Hi Thomas

Thanks for the response.

I did try set_model_file(), but it dint work:

Code: Select all

>> myIK=InverseKinematicsTool('myIK.xml');
>> myIK.set_model_file('my_subject01_simbody.osim');
Unrecognized function or variable 'set_model_file'.
I have already loaded my model using:

Code: Select all

>>osimModel=Model('my_subject01_simbody.osim');
>>myIK.setModel(osimModel);
It works when i run it (myIK.run()), however the model file name does not reflect in the xml file:

Code: Select all

<model_file>Unassigned</model_file>
The same with set_constraint_weight() and set_accuracy(). I think there must be something else that needs to be done before using set_model_file(), something like upd, am not sure.

Thanks
Sheeba

Re: creating IK setup file in Matlab

Posted: Thu Apr 01, 2021 1:55 am
by masterv
Hi Sheeba

You can get the list of methods in InverseKinematicTool by using methods()

Image

I guess you can use setModel(). Hope this helps.

Best,
Vishal

Re: creating IK setup file in Matlab

Posted: Thu Apr 01, 2021 9:44 pm
by sheebadavis
Hi Vishal

Thanks for your response.

I have used setModel(), as you can see in my previous post. But the model is not reflected in the IK xml file.

Code: Select all

<model_file>Unassigned</model_file>
Moreover, there is no option to set the model file name in the InverseKinematicsTool. I could find set_model_file() in InverseKinematicsToolBase, however it did not work

Code: Select all

>> myIK.set_model_file('my_subject01_simbody.osim');
Unrecognized function or variable 'set_model_file'
I even tried something like:

Code: Select all

>> myIK.upd_model_file().set_model_file('my_subject01_simbody.osim');
Undefined function 'upd_model_file' for input arguments of type 'org.opensim.modeling.InverseKinematicsTool'
Thanks in advance,
Sheeba

Re: creating IK setup file in Matlab

Posted: Fri Apr 02, 2021 2:46 am
by masterv
Hi Sheeba,

I just looked into the API documentation and it looks like you might have to use OpenSim4.2 to do it.

set_model_file() is only available in IMUInverseKinematicsTool for OpenSim4.1

I tested it by installing the opensim4.2 and executing the following:

Code: Select all

import org.opensim.modeling.*;
my_ik = InverseKinematicsTool();
model = Model('subject01_gait2392_scaled.osim');
my_ik.setModel(model);
my_ik.print('test_ik.xml'); % This still doesn't show any model file in XML

% To reflect it in XML, you might have to do as Thomas suggested:
my_ik.set_model_file('subject01_gait2392_scaled.osim');
my_ik.print('test_ik.xml');
Hope this helps.

Best,
Vishal

Re: creating IK setup file in Matlab

Posted: Sat Apr 03, 2021 4:21 am
by sheebadavis
Hi Vishal

Thank you very much for your clarification. As per your suggestion i downloaded 4.2 version and it works fine now. Thanks a lot.


Regards
Sheeba