creating IK setup file in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Sheeba Davis
Posts: 56
Joined: Sat Mar 23, 2019 5:19 am

creating IK setup file in Matlab

Post by Sheeba Davis » Wed Mar 31, 2021 3:17 am

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

Tags:

User avatar
Thomas Uchida
Posts: 1776
Joined: Wed May 16, 2012 11:40 am

Re: creating IK setup file in Matlab

Post by Thomas Uchida » Wed Mar 31, 2021 8:20 am

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.

User avatar
Sheeba Davis
Posts: 56
Joined: Sat Mar 23, 2019 5:19 am

Re: creating IK setup file in Matlab

Post by Sheeba Davis » Wed Mar 31, 2021 10:18 pm

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

User avatar
Vishal R
Posts: 47
Joined: Wed Oct 29, 2014 4:20 pm

Re: creating IK setup file in Matlab

Post by Vishal R » Thu Apr 01, 2021 1:55 am

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

User avatar
Sheeba Davis
Posts: 56
Joined: Sat Mar 23, 2019 5:19 am

Re: creating IK setup file in Matlab

Post by Sheeba Davis » Thu Apr 01, 2021 9:44 pm

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

User avatar
Vishal R
Posts: 47
Joined: Wed Oct 29, 2014 4:20 pm

Re: creating IK setup file in Matlab

Post by Vishal R » Fri Apr 02, 2021 2:46 am

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

User avatar
Sheeba Davis
Posts: 56
Joined: Sat Mar 23, 2019 5:19 am

Re: creating IK setup file in Matlab

Post by Sheeba Davis » Sat Apr 03, 2021 4:21 am

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

POST REPLY