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
Getting Joint Location in Matlab
- Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Re: Getting Joint Location in Matlab
Try this:
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
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);
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
- Maarten Sarens
- Posts: 7
- Joined: Sat Oct 10, 2015 11:34 am
Re: Getting Joint Location in Matlab
Thank you very much for your help !
I now understand what I did wrong !
I now understand what I did wrong !
- Yanis AMMOUCHE
- Posts: 23
- Joined: Mon Apr 24, 2017 6:09 am
Re: Getting Joint Location in Matlab
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
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
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Getting Joint Location in Matlab
What version of OpenSim are you using?it seems this manipulation doest not work now
- Yanis AMMOUCHE
- Posts: 23
- Joined: Mon Apr 24, 2017 6:09 am
Re: Getting Joint Location in Matlab
OpenSim 3.3. For information, I use matlab 2015 and both are in 32 bits.
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Getting Joint Location 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):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.
Code: Select all
void OpenSim::Joint::getLocationInParent ( SimTK::Vec3 & rLocation ) const
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
Code: Select all
locInParent =
~[0.0061,-0.2904,-0.0123]
- Yanis AMMOUCHE
- Posts: 23
- Joined: Mon Apr 24, 2017 6:09 am
Re: Getting Joint Location in Matlab
Thanks for the answer !
I know what went wrong.
I know what went wrong.