Matlab utilization of getLocationInParent function

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Emily Bachner
Posts: 1
Joined: Sun Dec 10, 2017 8:26 am

Matlab utilization of getLocationInParent function

Post by Emily Bachner » Thu Jul 18, 2019 7:06 am

Hi,
I have a fully functioning model and would like to do post-processing on this data. To do so, I need to access the 'location in parent' and 'orientation in parent' as seen in the Properties section in OpenSim for a given joint (that is already made and defined using .jnt and .msl files). I see in the API that there are functions 'getLocationInParent' and 'getOrientationInParent,' however these functions do not seem to work. From what I have gathered, everything that I have found online is geared for a situation in which the user has created the joints within the Matlab code so they have already defined Vec3 in Matlab.

Can someone please help me to access a specific joint from an existing OpenSim model (i.e. 'glenohumeral') in order to get the location in parent body that is seen within the joint properties on OpenSim (possibly using the 'getLocationInParent' function)

Much thanks!!

Tags:

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

Re: Matlab utilization of getLocationInParent function

Post by jimmy d » Thu Jul 18, 2019 8:03 am

In OpenSim 4.0 we exposed Frames. Joints have frames but you weren't really able to interact with them previously. This opens up a great deal more functionality and customization with model building and analysis but, on the downside, it does make it more complicated. In this case, you have to get the ask the Joint for its parent and child frames with each having their own translation and orientation.

Below is an example using a gait model. I get a reference to the hip joint, then get the parent and child frames, and ask for the translations and orientations.

Code: Select all

import org.opensim.modeling.*

model = Model('single_leg_scaled.osim');
model.initSystem()

% Get the Hip Joint
hip = model.getJointSet().get(1);

% Get the Parent Frame. In this case, the parent frame for the hip is the
% pelvis_offset frame
parent_frame = hip.get_frames(0);
% Get the translation and orientation
translation = parent_frame.get_translation();
orientation = parent_frame.get_orientation();

% Get the Child Frame. In this case, the child frame for the hip is the 
% femur_offset frame
child_frame = hip.get_frames(1);
translation = parent_frame.get_translation();
orientation = parent_frame.get_orientation();

OpenSim doesn't use .jnt or .msl files, I assume you mean Simm?

POST REPLY