Units and expression for SpringGeneralizedForce

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Ross Miller
Posts: 371
Joined: Tue Sep 22, 2009 2:02 pm

Units and expression for SpringGeneralizedForce

Post by Ross Miller » Tue Jan 05, 2021 7:05 am

Hi all,

For a simple model of walking with a transtibial prosthesis, I remove all the ankle muscles and replace them with a linear torsional spring-damper: F = k*q + b*qdot, where q and qdot are the coordinate and its speed and F is the moment at the coordinate. Previously I've done this with ExpressionBasedCoordinateForce, which works well (optimizer converges on good results):

Code: Select all

<ExpressionBasedCoordinateForce name="prosthetic_ankle_r">
	<coordinate>ankle_angle_r</coordinate>
	<expression>-400.0*q-1.0*qdot</expression>
</ExpressionBasedCoordinateForce>
In this example the spring stiffness k = -400 Nm/rad and the damping b = -1.0 Nm/(rad/s). I would like to have Moco optimize the values of these parameters (k and b), which I think can't be done using ExpressionBasedCoordinateForce, so I've switched to SpringGeneralizedForce and am struggling to get good results:

Code: Select all

<SpringGeneralizedForce name="prosthetic_ankle_r">
	<isDisabled>false</isDisabled>
	<coordinate>ankle_angle_r</coordinate>
	<stiffness>-400.0</stiffness>
	<rest_length>0</rest_length>
	<viscosity>-1.0</viscosity>
</SpringGeneralizedForce>
I first tried SpringGeneralizedForce with stiffness = 400 and viscosity = 1.0 and the optimizer would not converge. I then tried it with the values above, stiffness = -400 and viscosity = -1.0. This time the optimizer converged but the result was not good, bad tracking of the target data and too-high muscle activity.

For SpringGeneralizedForce, can anyone confirm what the units should be on stiffness and viscosity for rotational coordinates, e.g. Nm/rad vs. Nm/deg, and if the negative signs in the XML tags above are needed, i.e. is the expression that's implemented F = -k*q - b*qdot or F = k*q + b*qdot, or something else? I checked the SpringGeneralizedForce documentation but couldn't find this info.

Thanks much!
Ross

Tags:

User avatar
Nicholas Bianco
Posts: 972
Joined: Thu Oct 04, 2012 8:09 pm

Re: Units and expression for SpringGeneralizedForce

Post by Nicholas Bianco » Tue Jan 05, 2021 3:56 pm

Hi Ross,

Here's the source for reference: https://github.com/opensim-org/opensim- ... e.cpp#L234.

It is implemented as F = -k*q - b*qdot. So stiffness = 400 and viscosity = 1.0 should give you equivalent performance to the ExpressionBasedCoordinateForce. Not sure why it doesn't work though. Perhaps you could try using smaller stiffness values until it convergences. Or maybe create a simple motion to make sure the two components produce the same force.

-Nick

User avatar
Ross Miller
Posts: 371
Joined: Tue Sep 22, 2009 2:02 pm

Re: Units and expression for SpringGeneralizedForce

Post by Ross Miller » Wed Jan 06, 2021 9:51 am

Thanks Nick. It worked when I used the solution from a model with ExpressionBasedCoordinateForce as the initial guess for a model with SpringGeneralizedForce. The former was produced using a solution from a "two intact legs" simulation. I was expecting they would both work identically when starting from the same initial guess but maybe there is some small difference in implementation that affects IPOPT.

Ross

User avatar
Nicholas Bianco
Posts: 972
Joined: Thu Oct 04, 2012 8:09 pm

Re: Units and expression for SpringGeneralizedForce

Post by Nicholas Bianco » Wed Jan 06, 2021 4:54 pm

Glad that it works now. Yes, maybe there's a small difference in how the force is applied. I'm not familiar enough with the ExpressionBasedCoordinateForce to say for sure.

POST REPLY