Page 1 of 1

How to use PrescribedForce just in the opensim GUI?

Posted: Sun Apr 07, 2019 8:05 pm
by wangkun2019
hello everyone, I want to add an ankle spring on the foot like the Tutorials 'Simulation-Based Design to Reduce Metabolic Cost', the code is:

# Get a handle to the current model and create a new copy
baseModel = getCurrentModel()
ankleSpringModel = baseModel.clone()
ankleSpringModel.setName(baseModel.getName() + '_ankle_spring')

# Create the spring we'll add to the model (a CoordinateLimitForce in OpenSim)
ankleSpring = modeling.CoordinateLimitForce()
ankleSpring.setName('AnkleLimitSpringDamper')

# Set the coordinate for the spring
ankleSpring.set_coordinate('ankle_angle_r')

# Add the spring to the model
ankleSpringModel.addForce(ankleSpring)

# Load the model in the GUI
loadModel(ankleSpringModel)

I need to apply a linear force changing with time , PrescribedForce may work. I have read the Doxygen of the PrescribedForce, But I know little about programming languages, so could someone good enough to give me some examples of PrescribedForce code in the opensim GUI.

Re: How to use PrescribedForce just in the opensim GUI?

Posted: Mon Apr 29, 2019 1:08 am
by wopt
If you want to add the force in GUI .osim file, you can refer to viewtopicPhpbb.php?f=91&t=10026&p=27688&start=0&view=
You can know the frame of Prescribedforce in GUI's XML Brown, then you can add it to your .osim file. Finally, you can adjust the value to your data. This can also be done in GUI.