Adding Joint Makes Collison Spongy (Sequential Impulses)

Please don't post Bullet support questions here, use the above forums instead.
crashlander
Posts: 41
Joined: Sat Apr 08, 2006 11:20 am

Adding Joint Makes Collison Spongy (Sequential Impulses)

Post by crashlander »

I'm using sequential impulses for my 2d engine. Most the code is very similar to Erin Cattos sequential impulse paper.

I've notice when I add revolute joints between bodies the collision of the connected bodies with other bodies becomes spongy.

Example: If I make a car and attach 2 wheels using revolute joints, then place the car on a static body the wheels sink into the body more than if the bodies were not attached by a joint. I noticed it only occurs when the force is acting from one body, thru the joints, and into the second body. In this case, the second bodies collision with the underlying static body will lose a lot of it's rigidness.

The only thing I found to counter this is to swap the order in which I apply collision response impulses and joint correction impulses. If I do collision impulse first and joint correction second, I get the spongy behavior. If instead I do the joint correction first, I do not see the spongy behavior.

So, my question is does it matter in which order I do these? Is one way better than another. (for me it is, but I could have something else wrong.)

-thanks.
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine

Post by Erin Catto »

One limitation of most iterative methods is that they aren't stable when you have a low mass body (wheels) supporting a higher mass body (chassis). This can be resolved by:
1) Using more iterations
2) Faking the masses (make the wheels heavier than they would normally be).
3) Using rays instead of wheels (my preferred solution). This requires a custom suspension+friction contact constraint.

Also, make sure your code has joints and contacts in the same iteration loop. This helps them see each other.
crashlander
Posts: 41
Joined: Sat Apr 08, 2006 11:20 am

Post by crashlander »

This occurs even when the wheels and mass are equal.

I suspect this: "Also, make sure your code has joints and contacts in the same iteration loop. This helps them see each other." may be my issue.

So, currently I do this (psuedo code):

1. for each joint do PreStep

2. for each joint apply correction impulses (iterate 10 times)

3. for each contact do PreStep

4. for each contact apply correction impulses (iterate 10 times)

Looking at your Box2D code, this should be something like:

1. for each joint do PreStep

2. for each contact do PreStep

3. for each joint and contact apply correction impulses (iterate 10 times)?

Not sure how I missed that.

Thanks for the help.
Jan Bender
Posts: 111
Joined: Fri Sep 08, 2006 1:26 pm
Location: Germany

Post by Jan Bender »

Hi,
1. for each joint do PreStep

2. for each contact do PreStep

3. for each joint and contact apply correction impulses (iterate 10 times)?
This should work better than the first version since you correct joints and contacts in the same iteration. Both, joints and contacts, define a position constraint and they have to be solved at the same time. Otherwise the dependencies between both are not taken into consideration.

Jan