Page 1 of 1

Calling markers of arm26 in python

Posted: Tue Nov 21, 2017 12:41 am
by gautamr1858
Hi,
Need help in calling the marker function and getting its coordinates in python , for example when we want to call the joint coordinate we use this

Code: Select all

self.osim_model.joints[0].getCoordinate(0).getValue(self.osim_model.state)
likewise how to get the x,y,z for the marker that is attached to the arm model on the wrist ?

Re: Calling markers of arm26 in python

Posted: Tue Nov 21, 2017 12:31 pm
by jimmy
Are you using the 3.3 or 4.0 API?

In 3.3 (Matlab, you can make the Python changes)

Code: Select all

model = Model('path2model.osim');
s = model.initSystem();

% get a reference to a marker (0 index)
m = modelgetMarkerSet().get(0);
b = m.getBody();
% get marker offset on the body
p_l = m.getOffset();

% Use the Simbody Engine to compute location in ground
sbe = model.getSimbodyEngine();
% Define an empty vec3 to put the posiion data into
p_g = Vec3()
% get the position
sbe.getPosition(s, b, p_l, p_g);
in 4.0

Code: Select all

p_g = model.getMarkerSet().get(0).getLocationInGround(s);

Re: Calling markers of arm26 in python

Posted: Wed Nov 22, 2017 10:20 am
by gautamr1858
Thank you for the reply, I use 4.0 and used this

Code: Select all

 self.osim_model.model.getBodySet().get("r_ulna_radius_hand") 
but as the hand moves the coordinate are not changing it is repeating the same coordinate

and if I use this

Code: Select all

p_g = model.getMarkerSet().get(0).getLocationInGround(s);
by default it will take the shoulder marker but I need to call the marker found on the wrist

Re: Calling markers of arm26 in python

Posted: Wed Nov 22, 2017 6:10 pm
by jimmy
but as the hand moves the coordinate are not changing it is repeating the same coordinate
I am not sure how to interpret that. How do you know the hand is moving? When are you doing this analysis? Shouldn't you be setting the value of the coordinate using setValue()
by default it will take the shoulder marker but I need to call the marker found on the wrist
Did you bother to change the index value in .get()?

Re: Calling markers of arm26 in python

Posted: Wed Nov 22, 2017 8:55 pm
by gautamr1858
Thanks I got it, had made a mistake in my program, my objective function was not right.