Clamping coordinates during forward dynamics

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Yannik Schröder
Posts: 14
Joined: Wed Apr 18, 2012 11:40 am

Clamping coordinates during forward dynamics

Post by Yannik Schröder » Fri Nov 02, 2012 3:47 am

Hi,
i am currently trying to run a forward dynamics simulation of a motor pulling on a finger (like a haptic glove would). For the first test i just added a muscle that simulates the force generated by the motor. To simulate the motion of the finger that would result i need the joints to stay inside the specified range, but this isn't the case, even if i set the clamped-flag to true.

I have added a picture of the problematic behaviour:
Image
(I have deactivated all of the other muscles and set the gravity to (0 0 0) for testing)

The angle of the MCP joint shouldn't exceed -10°, but it clearly does.

I found in an old thread, that clamping isn't enforced during dynamic simulations and was wondering why this is the case and if someone could maybe show me a workaround to fix this problem.

Thanks!

Best Regards,
Yannik

User avatar
Ayman Habib
Posts: 2235
Joined: Fri Apr 01, 2005 12:24 pm

Re: Clamping coordinates during forward dynamics

Post by Ayman Habib » Fri Nov 02, 2012 9:05 am

Hi Yannik,

The main reason we do not enforce clamping out of the box is that it's not physical (there're many different ways to model what stops a coordinate from getting out of bounds: e.g. contact, constraint, force, etc.). You can easily introduce a force element (CoordinateLimitForce documented here https://simtk.org/api_docs/opensim/api_ ... Force.html

that stops the coordinate from going beyond limits, you just need to specify the force applied and how fast the transition is and when it starts to take effect.

Please let me know if that answers your question and best of luck,
-Ayman

User avatar
Yannik Schröder
Posts: 14
Joined: Wed Apr 18, 2012 11:40 am

Re: Clamping coordinates during forward dynamics

Post by Yannik Schröder » Tue Nov 06, 2012 7:05 am

Thank you, Ayman, that was exactly what i was looking for.

And i've found a small bug: if you set the transition value to 0, or if it was 0 to any other value, inside of OpenSim 3.0, an empty "Information" box appears. I think it should say something like "setting the transition value to 0 is bad".

And another thing, where i'm not sure if it is a bug or intended. If i set one of the stiffness values to 0.0 and perform a forward simulation, after the first frame all bodies but the ground body disappear and the joint values are set to "�" and the values inside of the states_degree.mot file are set to either "1.#QNAN000" or "-1.#IND0000". (I believe the calculations are correct, but i think an error message or exception would clear things up, if you don't know, where the error origins from).

But these problems are all avoidable, so thanks again.


Best regards,
Yannik

User avatar
Margaret Van Horn
Posts: 16
Joined: Mon Jan 07, 2013 11:10 am

Re: Clamping coordinates during forward dynamics

Post by Margaret Van Horn » Thu Jun 27, 2013 9:08 am

Yannik and Ayman,

Could you tell me how I would go about adding in this CoordinateLimitForce? The documentation is not entirely clear to me how to add this into a model. I want to similarly enforce a coordinate to stay within its bounds during a dynamic simulation.

Thanks!
Margaret

User avatar
Yannik Schröder
Posts: 14
Joined: Wed Apr 18, 2012 11:40 am

Re: Clamping coordinates during forward dynamics

Post by Yannik Schröder » Mon Jul 01, 2013 2:53 am

Hi Margaret,
you can add the forces by adding the following in your .osim file of your model:

Code: Select all

<CoordinateLimitForce name="PP_LimitForce">
        <coordinate>PP</coordinate>
        <upper_stiffness>0.1</upper_stiffness>
        <upper_limit>90</upper_limit>
        <lower_stiffness>0.1</lower_stiffness>
        <lower_limit>-5</lower_limit>
        <damping>1</damping>
        <transition>5</transition>
        <compute_dissipation_energy>false</compute_dissipation_energy>
</CoordinateLimitForce>
The force needs to be added to your <ForceSet> (the part where your muscles are).

<coordinate>: Name of your coordinate, you want to add the limit force to.
<upper_stiffness>: Stiffness of the passive limit force when coordinate exceeds upper limit. Value in Nm/deg.
<lower_stiffness>: ~
<damping>: Damping factor on the coordinate's speed applied only when limit is exceeded. For translational has units N/(m/s) and rotational has Nm/(degree/s)
<transition>: Transition region width in the units of the coordinate (rotations in degrees). Dictates the transition from zero to constant stiffness as coordinate exceeds its limit.
<compute_dissipation_energy>: Option to compute the dissipation energy due to damping in the CoordinateLimitForce. If true the dissipation power is automatically integrated to provide energy.

Generally you don't want to have very stiff limit forces because they really slow down the calculations, so play around with the values a bit.

Hope this helps!

POST REPLY