I know this question has been asked before, but I haven't been able to find a good answer:
What is the correct approach to get the location of a joint in the parent or child reference frame?
In OpenSim 3, this could be achieved through getLocationInParent() / getLocationInChild(), but these methods have been removed from the OpenSim 4 API.
I suspect I should use getParentFrame() / getChildFrame(), but I can't seem to figure out how to extract the local translation from a PhysicalFrame.
Get joint location in parent / child
- Thomas Geijtenbeek
- Posts: 445
- Joined: Wed Mar 12, 2014 8:08 am
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Get joint location in parent / child
Hi Thomas,
As you correctly figured out, you can get handles to the frames using the getChildFrame/getParentFrame methods. Then you can use the "Frame" class methods to get the location and orientation of the frame in any other frame or ground as described here
https://simtk.org/api_docs/opensim/api_ ... Frame.html
Hope this helps,
-Ayman
As you correctly figured out, you can get handles to the frames using the getChildFrame/getParentFrame methods. Then you can use the "Frame" class methods to get the location and orientation of the frame in any other frame or ground as described here
https://simtk.org/api_docs/opensim/api_ ... Frame.html
Hope this helps,
-Ayman
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: Get joint location in parent / child
There's a section on Frames in the API Guide that might also be helpful: https://simtk.org/api_docs/opensim/api_ ... tml#frames.
- Thomas Geijtenbeek
- Posts: 445
- Joined: Wed Mar 12, 2014 8:08 am
Re: Get joint location in parent / child
Thank you for the references.
I'm still somewhat confused though; from the API guide, I would expect to get a frame of type PhysicalOffsetFrame, on which I could then call getOffsetTransform() to get the (fixed) offset of the joint frame.
However, the getParent/ChildFrame() methods in Joint return a PhysicalFrame. This seems to only give me the following options to get the joint position in the parent/child body frame:
Please let me know if I'm missing something obvious. Otherwise, which approach would you recommend?
I'm still somewhat confused though; from the API guide, I would expect to get a frame of type PhysicalOffsetFrame, on which I could then call getOffsetTransform() to get the (fixed) offset of the joint frame.
However, the getParent/ChildFrame() methods in Joint return a PhysicalFrame. This seems to only give me the following options to get the joint position in the parent/child body frame:
- call findTransformInBaseFrame()
- call findStationLocationInAnotherFrame() using the body frame
- call getPositionInGround() for both joint and body and transform back to the local frame of the body
Please let me know if I'm missing something obvious. Otherwise, which approach would you recommend?
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: Get joint location in parent / child
Hello,
I had some success with extracting the PhysicalOffsetFrame as follows in Matlab - OpenSim 4.3:
myModel = Model('2D_gait.osim');
hip_joint = myModel.getJointSet().get(1);
pelvis_offset = hip_joint.get_frames(0);
femur_offset = hip_joint.get_frames(1);
pelvis_offset_trans = pelvis_offset.get_translation();
pelvis_offset_rot = pelvis_offset.get_orientation();
Hopefully that is what you were looking for!
Best wishes,
Nicos Haralabidis
I had some success with extracting the PhysicalOffsetFrame as follows in Matlab - OpenSim 4.3:
myModel = Model('2D_gait.osim');
hip_joint = myModel.getJointSet().get(1);
pelvis_offset = hip_joint.get_frames(0);
femur_offset = hip_joint.get_frames(1);
pelvis_offset_trans = pelvis_offset.get_translation();
pelvis_offset_rot = pelvis_offset.get_orientation();
Hopefully that is what you were looking for!
Best wishes,
Nicos Haralabidis
- Thomas Geijtenbeek
- Posts: 445
- Joined: Wed Mar 12, 2014 8:08 am
Re: Get joint location in parent / child
Thank you, that was helpful.
It turns out there is a matching C++ interface to get the PhysicalOffsetFrame:
It works for my current model, but I'm not sure if it's safe. Index 0 and 1 might not always exist, and they might point to other frames than the child or parent frame.
It turns out there is a matching C++ interface to get the PhysicalOffsetFrame:
Code: Select all
auto locationInParent = joint.get_frames( 0 ).get_translation(); // parent?
auto locationInChild = joint.get_frames( 1 ).get_translation(); // child?