Getting Joint Location in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Maarten Sarens
Posts: 7
Joined: Sat Oct 10, 2015 11:34 am

Getting Joint Location in Matlab

Post by Maarten Sarens » Mon Apr 04, 2016 10:17 am

Hi everybody,

I'm trying to get the joint location of an .osim model. My ultimate goal is calculating the length of a bone, for instance the tibia. For example I want to know the joint location of the right foot of the .osim model. I try to do this by :

clc
close all
clear all

import org.opensim.modeling.*

osimModel= Model(modelFile1);
osimModel.getJointSet().get("ankle_r").getLocationInParent();

While runnig this piece of code in Matlab I get the next error :
No method 'getLocationInParent' with matching signature found for class 'org.opensim.modeling.Joint'.

Can some one help me with this error?

Greetings Maarten

User avatar
Brad Humphreys
Posts: 79
Joined: Thu Feb 03, 2011 11:32 am

Re: Getting Joint Location in Matlab

Post by Brad Humphreys » Mon Apr 04, 2016 5:15 pm

Try this:

Code: Select all

import org.opensim.modeling.*

osimModel= Model(modelFile1);
p=Vec3();   % This creates an empty opensim vector which will contain the location in the parent frame
osimModel.getJointSet().get("ankle_r").getLocationInParent(p);

%Now convert into native MATLAB double
pval(1)=p.get(0);
pval(2)=p.get(1);
pval(3)=p.get(2);
And take a look at "Working with Vectors" info here: http://simtk-confluence.stanford.edu:80 ... g+Commands

If the documentation for an API function has a "Vec3" argument (https://simtk.org/api_docs/opensim/api_ ... c459c37081), that's what you will need to do.

Brad

User avatar
Maarten Sarens
Posts: 7
Joined: Sat Oct 10, 2015 11:34 am

Re: Getting Joint Location in Matlab

Post by Maarten Sarens » Mon Apr 04, 2016 11:59 pm

Thank you very much for your help !
I now understand what I did wrong !

User avatar
Yanis AMMOUCHE
Posts: 23
Joined: Mon Apr 24, 2017 6:09 am

Re: Getting Joint Location in Matlab

Post by Yanis AMMOUCHE » Sat Jun 10, 2017 2:21 pm

Dear all,

Sorry to revive this topic, but it seems this manipulation doest not work now, as the function getLocationInParent has to have a VEC3 and a "rLocation" argument but i don't know to create this kind of object in matlab.

Any ideas ?

Thank you

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

Re: Getting Joint Location in Matlab

Post by Thomas Uchida » Sat Jun 10, 2017 9:45 pm

it seems this manipulation doest not work now
What version of OpenSim are you using?

User avatar
Yanis AMMOUCHE
Posts: 23
Joined: Mon Apr 24, 2017 6:09 am

Re: Getting Joint Location in Matlab

Post by Yanis AMMOUCHE » Sun Jun 11, 2017 2:07 am

OpenSim 3.3. For information, I use matlab 2015 and both are in 32 bits.

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

Re: Getting Joint Location in Matlab

Post by Thomas Uchida » Sun Jun 11, 2017 1:03 pm

Sorry to revive this topic, but it seems this manipulation doest not work now, as the function getLocationInParent has to have a VEC3 and a "rLocation" argument but i don't know to create this kind of object in matlab.
I did not encounter any issues using the getLocationInParent() method. I think there is confusion about the doxygen for this method (https://simtk.org/api_docs/opensim/api_ ... c459c37081):

Code: Select all

void OpenSim::Joint::getLocationInParent ( SimTK::Vec3 & rLocation ) const
There is only one argument; "SimTK::Vec3 &" is its type and "rLocation" is the name of the variable used in the implementation. Here is an example of how to use this method in MATLAB:

Code: Select all

import org.opensim.modeling.*

model = Model('arm26.osim');
state = model.initSystem();

elbow = model.getJointSet().get('r_elbow');
locInParent = Vec3(0);
elbow.getLocationInParent(locInParent);
locInParent
The following will be printed to the MATLAB Command Window:

Code: Select all

locInParent =
 
~[0.0061,-0.2904,-0.0123]

User avatar
Yanis AMMOUCHE
Posts: 23
Joined: Mon Apr 24, 2017 6:09 am

Re: Getting Joint Location in Matlab

Post by Yanis AMMOUCHE » Sun Jun 11, 2017 1:42 pm

Thanks for the answer !

I know what went wrong.

POST REPLY