Page 1 of 1

Apply External Force to OpenSim Model

Posted: Mon Feb 22, 2021 6:57 pm
by shakibarafiee
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

Re: Apply External Force to OpenSim Model

Posted: Mon Feb 22, 2021 8:41 pm
by shakibarafiee
I found this example:

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

It should hopefully help solve the problem.

Re: Apply External Force to OpenSim Model

Posted: Mon Mar 01, 2021 3:33 am
by samuelegould
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

Re: Apply External Force to OpenSim Model

Posted: Thu Mar 04, 2021 10:31 am
by shakibarafiee
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