Calling markers of arm26 in python

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Gautam Ramachandra
Posts: 65
Joined: Thu Sep 03, 2015 11:04 pm

Calling markers of arm26 in python

Post by Gautam Ramachandra » Tue Nov 21, 2017 12:41 am

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 ?

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Calling markers of arm26 in python

Post by jimmy d » Tue Nov 21, 2017 12:31 pm

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);

User avatar
Gautam Ramachandra
Posts: 65
Joined: Thu Sep 03, 2015 11:04 pm

Re: Calling markers of arm26 in python

Post by Gautam Ramachandra » Wed Nov 22, 2017 10:20 am

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

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Calling markers of arm26 in python

Post by jimmy d » Wed Nov 22, 2017 6:10 pm

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()?

User avatar
Gautam Ramachandra
Posts: 65
Joined: Thu Sep 03, 2015 11:04 pm

Re: Calling markers of arm26 in python

Post by Gautam Ramachandra » Wed Nov 22, 2017 8:55 pm

Thanks I got it, had made a mistake in my program, my objective function was not right.

POST REPLY