Add Physical Offset frame to Joint API
Posted: Thu May 05, 2022 7:36 am
HI all,
I am trying to programatically add a physiscal offset frame to an existing model which currently does not have any frame. My primary problem is that I cannot edit/update the " socket_parent " is the Physical Offset Frame - and the " socket_parent_frame " of the joint which I suspect is becuase of a related issue. The lines which " do not work" are markerd with # % DOES NOT UPDATE
My code is below
Using this code - the physcial frame is added to the joint BUT the socket_frame , and socket_parent_frame are still from the "cloned" physical frame.
Thanks in advance for any tips/advice
Bryce
I am trying to programatically add a physiscal offset frame to an existing model which currently does not have any frame. My primary problem is that I cannot edit/update the " socket_parent " is the Physical Offset Frame - and the " socket_parent_frame " of the joint which I suspect is becuase of a related issue. The lines which " do not work" are markerd with # % DOES NOT UPDATE
My code is below
Code: Select all
import opensim as osim
model = osim.Model('lenhart2015_updMuscPath.osim')
# make a copy of an exist physcial offset frame
pfo = model.getJointSet().get('femur_femur_distal_r').get_frames(0).clone()
# rename the frame
pfo.setName('knee_align_r')
# set orientation
pfo.set_orientation(osim.Vec3(1.5,0,0))
# set translation
pfo.set_translation(osim.Vec3(0,0,0))
# update the socket_parent of the frame
# % DOES NOT UPDATE pfo.setParentFrame(model.getBodySet().get('femur_distal_r'))
# ATEMPT 2 to update the socket_parent of the frame
# % DOES NOT UPDATE pfo.connectSocket_parent(model.getBodySet().get('femur_distal_r'))
# add the Physcial offset frame to the joint
model.getJointSet().get('knee_r').set_frames(0,pfo)
# Try and change the socket_parent_frame of the joint
# % DOES NOT UPDATEmodel.getJointSet().get('knee_r').connectSocket_parent_frame(model.getJointSet().get('knee_r').get_frames(0))
model.updJointSet()
model.printToXML('testModel.osim')
Thanks in advance for any tips/advice
Bryce