Collect ligament force and length using API. Please help!

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Xijin Hua
Posts: 29
Joined: Tue Feb 12, 2019 4:45 pm

Collect ligament force and length using API. Please help!

Post by Xijin Hua » Mon Feb 07, 2022 3:52 pm

Hi, all

I am now using OpenSim to model an ankle with some ligaments, and would like to get ligament forces and lengths during a drop landing simulation. I can now use python to get the ligament lengths, as show below, but I don't know how to get the ligament forces. I have read the API documentations and many posts here but didn't find the function of getting the forces through API. Could you please tell me how to use API (python) to collect the ligament forces during simulation? Which function should I use? I really need help so any suggestions would be greatly appreciated.

Code: Select all

osimModel='D:\Drop landing\Fullbodymodel_droplanding.osim'
myModel=opensim.Model(osimModel)
fset=myModel.getForceSet()
lig1=opensim.Ligament.safeDownCast(fset.get("ligament_1"))
state=myModel.initSystem()
lig_length=lig1.getLength(state)
Thanks

Xijin

Tags:

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

Re: Collect ligament force and length using API. Please help!

Post by Thomas Uchida » Mon Feb 07, 2022 7:00 pm

I think you're looking for the getTension() method (https://simtk.org/api_docs/opensim/api_ ... 7aff29e512). Here are some examples: https://github.com/opensim-org/opensim- ... getTension.

User avatar
Xijin Hua
Posts: 29
Joined: Tue Feb 12, 2019 4:45 pm

Re: Collect ligament force and length using API. Please help!

Post by Xijin Hua » Thu Mar 03, 2022 8:37 am

Hi, Thomas

This is what I am looking for. Thank you so much!

Xijin

POST REPLY