Tips for how to build a variable angular spring constraint

Post Reply
Mwni
Posts: 9
Joined: Thu Jul 12, 2018 4:43 pm

Tips for how to build a variable angular spring constraint

Post by Mwni »

Hi there,

I'm using Generic6DofSpring2Constraint to simulate ragdoll joints. It's working great so far but to increase realism i would like to add a variable angular spring to it.

Take a look at this illustration:
Image
This shows one axis of the constraint. The constraint limits are shown as red (set by setAngularLower/UpperLimit). The joint itself is the black line.

Now what I'm trying to achieve is to have the angular spring disabled when the joint is in the green area. As soon as it enters the red area, it should apply a proportional force, so that the joint rotates back to the green area.

My current solution is to adjust the spring stiffness based on the factor of how far the joint entered the red area. (0 = outside, 1 = at angular limit)*max_stiffness.

The problem is, in a world with gravity, this obvioulsy jumps back and forth. Playing around with the damping and the function applied to the factor (pow(factor,2)) helps a little but is nowhere near perfect.

Does anybody have an idea? I took a look into the constraint motor but it doesnt really have the spring character I'd like.
Mwni
Posts: 9
Joined: Thu Jul 12, 2018 4:43 pm

Re: Tips for how to build a variable angular spring constraint

Post by Mwni »

Managed to do it by setting the constraint limits to the soft limits (green) and then tweaking the CFM & ERP values accordingly.
Post Reply