Retrieve joint from model in python

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Hao Lee
Posts: 32
Joined: Sun Jun 12, 2016 11:52 pm

Retrieve joint from model in python

Post by Hao Lee » Sun Jan 15, 2023 2:57 am

Hi everyone

I am kind of new in using OpenSim in python. I wonder how can I get the joint, muscles, etc from an existing model.
For instance

Code: Select all

import opensim as osim
model = osim.Model('model_path.osim')
Does there exist any function like GetJoint?
Currently I found getJointList(), but it only returns me an iterator, which I am not 100% sure what it means in python (c++ I suppose I can ++ to advance, but python?)

Also, is there any good API on OpenSim python? I try to google for it but did not really find one.

Tags:

User avatar
Thomas Uchida
Posts: 1777
Joined: Wed May 16, 2012 11:40 am

Re: Retrieve joint from model in python

Post by Thomas Uchida » Sun Jan 15, 2023 8:59 am

The following pages in the documentation might be helpful: You can find some example scripts in your local "Resources" directory (e.g., C:\OpenSim4\Resources\Code\Python) as well as on GitHub: The API Guide (https://simtk.org/api_docs/opensim/api_docs/) provides information about the capabilities of each class. To answer your specific question, you can call something like "myModel.getJointSet().get("myJointName")"; here's an example: https://github.com/opensim-org/opensim- ... uts.py#L32.

POST REPLY