Apply External Force to OpenSim Model

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
shakiba rafiee
Posts: 6
Joined: Thu Mar 26, 2015 2:19 pm

Apply External Force to OpenSim Model

Post by shakiba rafiee » Mon Feb 22, 2021 6:57 pm

Hi all,

I am trying to add an external force perturbation to an OpenSim model. I was just wondering if there is an easy way to do this.

I am working with a modified version of this reflex-based OpenSim model in Python that was published for the NeurIPS 2019 Learn to Move - Walk Challenge.

https://github.com/stanfordnmbl/osim-rl ... roller1.py

This is forward dynamics predictive simulation. I am running it in 2D mode and it is using this "gait14dof22musc_planar_20170320.osim" model. Is there an easy way to add a time-varying external force to this model?

Thanks in advance.
Shakiba Rafiee

Tags:

User avatar
shakiba rafiee
Posts: 6
Joined: Thu Mar 26, 2015 2:19 pm

Re: Apply External Force to OpenSim Model

Post by shakiba rafiee » Mon Feb 22, 2021 8:41 pm

I found this example:

https://github.com/mitkof6/OpenSim_API_ ... d_force.py

It should hopefully help solve the problem.

User avatar
Samuele Gould
Posts: 16
Joined: Tue Nov 19, 2019 5:53 am

Re: Apply External Force to OpenSim Model

Post by Samuele Gould » Mon Mar 01, 2021 3:33 am

Hi Shakiba,

If you are running forward dynamics one option would be to apply an external force using an external load through the forward tool. Use an external loads .xml file to specify the bodies you apply the force to and a .mot file (experimental data but you can create your own) to specify the position and time varying properties of the load.
You can see an examples of these file and how to use them in the OpenSim tutorial for the tug of war model.

Best,
Samuele

User avatar
shakiba rafiee
Posts: 6
Joined: Thu Mar 26, 2015 2:19 pm

Re: Apply External Force to OpenSim Model

Post by shakiba rafiee » Thu Mar 04, 2021 10:31 am

Hi Samuele,

Thank you for the response.

It is good to know that I can modify the xml file. However, since I want to run the model several times (i.e. 100 times), I was hoping to avoid making several .mot files. I ended up using the opensim.PrescribedForce() function, and it seems to be working fine.

Best,
Shakiba

POST REPLY