Modifying a model to add degrees of freedom

Provide a space for people developing and using musculoskeletal models to collaborate and learn from each other.
POST REPLY
User avatar
Edith Arnold
Posts: 44
Joined: Fri Apr 06, 2007 2:07 pm

Modifying a model to add degrees of freedom

Post by Edith Arnold » Thu Oct 14, 2010 5:18 pm

This question was posted to the Lower Limb Model project that I administer. I'm cross posting it here because the answer will be generally useful.

"I'm a begginer in OpenSim. I've already read the user's guide but I dont't know where I can find how to insert degrees of freedom in the pelvis. Can you help me pointing where I can find how to do it ?!"

User avatar
Edith Arnold
Posts: 44
Joined: Fri Apr 06, 2007 2:07 pm

RE: Modifying a model to add degrees of freedom

Post by Edith Arnold » Thu Oct 14, 2010 6:02 pm

The OpenSim GUI does not yet support many types of model modifications, so you'll need to edit the .osim file directly. The files are long with lots of unfamiliar xml tags, but editing them is not difficult once you know what to look for.

Step 1: Get an xml editor. I use Notepad++ which is freely downloadable.

Step 2: Tell your xml editor what a .osim file is.
In Notepad++ do this by going to Settings > Style Configurator
Scroll down in the "Language:" list until you find XML. Below this you'll see an uneditable box called "Default ext:" Next to that is a box called "User ext:"
Type "osim" (without the quotes) in that box, click "Save&Close"
Now .osim files will have all their xml tags colored and collapsible, making them much easire to read.

There's lots of stuff at the beginning of the file that we don't need to worry about for adding degrees of freedom to a joint, so I'll get to those another time. For now, click the little box with a - in it next to "defaults" and hide that stuff. Same for "publications" and anything else you don't want to see. In Notepad++ you can use alt+anumber to collapse everything to that level.

Step 3: Find the pelvis body. Open and close levels until you find
BodySet > objects> Body name = "pelvis"

Step 4: Find the joint that connects the pelvis to something else.
In the case of the 2 leg, lower limb model from 2010, or the gait 2392 model this will be a joint between the pelvis body and the parent_body "ground"

What type of joint is it?

If it is a WeldJoint, then there are zero degrees of freedom between the pelvis and ground. The location and orientation attributes will describe how the pelvis relates to ground, but this cannot change.

For a 6-dof joint, we'll want a CustomJoint.

Step 5: Replace the WeldJoint with a 6-dof CustomJoint.
Find a model that has a 6-dof custom joint similar to the one you want. Copy everything from <CustomJoint name="ground_pelvis" to /CustomJoint>. Paste it into your model where there was a WeldJoint. Look at the names and parameters for each coordinate like initial_value, range, etc. (these are in radians) and change any that are not appropriate for your use. Give credit to the people who made the model you're adapting.
Save, open it in OpenSim to make sure you've got what you wanted.
If you see a message that says something like "XMLDocument.XMLDocument: ERROR- SAX exception while attempting to parse..." Then you probably forgot to close an xml tag.
You're done!

The "copy, modify, credit" method is also useful for adding new bodies onto a model. In this case you'll also have to locate those bodies in the frame of the parent body. One easy way to do this is to place the body approximately, open the model in the GUI and add a marker in the frame of the parent body. Click on it while holding control, then drag it around until it's where you want your new body to be located. Use the coordinate of this marker for the location_in_parent value of your xml file. Save, open, see if it's in the right place. Lather, rinse, repeat.

I hope that helps!

-Edith

POST REPLY