Body::getJoint() method removed from OpenSim 4.0
Posted: Mon Dec 16, 2019 6:58 pm
Hi,
I'm attempting to update a piece of code to OpenSim 4.0, however, am running into an issue about getting the joints of a particular body.
In previous versions, you could easily access this through: Body::getJoint(). However, this method has now been removed.
Essentially, I am trying to create a list of joints (which have at least 1 dof) which are spanned by a certain muscle (bodies are given in the particular muscle's PathPointSet).
I have a list of the bodies, e.g.,
My current work around is to get the jointSet from the current OpenSim model, and then see if the parent body of each joint in the jointSet is in the list (list is in order of proximal to distal)
I am wondering if there is a more elegant and fool proof way of getting the joint?
Thanks for your help
I'm attempting to update a piece of code to OpenSim 4.0, however, am running into an issue about getting the joints of a particular body.
In previous versions, you could easily access this through: Body::getJoint(). However, this method has now been removed.
Essentially, I am trying to create a list of joints (which have at least 1 dof) which are spanned by a certain muscle (bodies are given in the particular muscle's PathPointSet).
I have a list of the bodies, e.g.,
Code: Select all
muscle_attach_bodies = ['pelvis', 'femur_l']
Code: Select all
distal_body_name = muscle_attach_bodies[-1]
body_name = distal_body_name
counter = 1
next_proximal_body_name = muscle_attach_bodies[-1 - counter]
joint_set = osim_model.getJointSet()
# Work around because Body.getJoint() has been removed in OpenSim 4.0
for joint in joint_set:
# Parent body of joint is the more proximal body to the current body
if next_proximal_body_name in joint.getParentFrame().getName():
spanned_joint = joint
spanned_joint_name = str(spanned_joint.getName())
Thanks for your help