Page 1 of 1

Retrieve joint from model in python

Posted: Sun Jan 15, 2023 2:57 am
by haolee
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.

Re: Retrieve joint from model in python

Posted: Sun Jan 15, 2023 8:59 am
by tkuchida
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.