Body::getJoint() method removed from OpenSim 4.0

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Alex Woodall
Posts: 3
Joined: Wed Aug 07, 2019 3:22 pm

Body::getJoint() method removed from OpenSim 4.0

Post by Alex Woodall » 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.,

Code: Select all

muscle_attach_bodies = ['pelvis', 'femur_l']
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)

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())
I am wondering if there is a more elegant and fool proof way of getting the joint?

Thanks for your help

Tags:

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

Re: Body::getJoint() method removed from OpenSim 4.0

Post by jimmy d » Wed Dec 18, 2019 11:47 am

Hi, Alex-

Good question. I'll give some context on why getJoint() doesn't exist anymore; prior to 4.0, joints were always contained inside bodies. From 4.0, we moved to a Component architecture and so Bodies and Joints are their own components. Joints have sockets that take Frames, which can be a body frame or some other types of frame. In this way, the body doesn't really know anything about the joints. This gives a lot more freedom to people building models, but it also makes it more difficult conceptually. I have also found it hard at times to figure out how to traverse the tree of bodies, joints, and connecting frames.

If you are looking for joints (coordinates?) that a muscle crosses, one alternative way of thinking about that is to figure out non-zero moment arms for the model coordinates. There is an example of this here. For this script, I had to generate the force-length curve of an arbitrary muscle by figuring out which coordinates the muscle spans.

I hope that helps.

POST REPLY