Anti-penetration (stabilization for ineq joints)

Please don't post Bullet support questions here, use the above forums instead.
FD
Posts: 26
Joined: Thu May 18, 2006 9:25 pm

Anti-penetration (stabilization for ineq joints)

Post by FD »

Hi people!

I use Baumgarte stabiliztion, and it's ok for equality joints.
I treat penetration case as a violation of a joint, so I use typical stabilization there, as in case of any other joint.

The problem is that an inequality joint, including a contact joint, may become inactive (disjoint) after the compensatory impulse is applied as a result of Baumgarte stabilization, and after that the joint is inactive and the impulse is not compensated in any way. In case of equality joints, the compensatory impulse is compensated with another compensatory impulse in the next frame, and so on, but in case of inequality joints the impulse has an uncompensated effect on the body's momentum and I have the unwanted motion.

How do you people do stabilization for inequality joints, particularly how do you resolve penetration (after you have decided about the penetration depth and direction) ?
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine

Post by Erin Catto »

There are a couple things you can do to improve the position resolution for inequality constraints:

- Use some position slop. Don't apply Baumgarte unless the position error is greater than the slop value. This should get rid of jitter.
- Use a separate solver for position error. This can be in the form of pseudo velocities that don't affect the momentum. This will eliminate momentum gain and make the simulation a bit more stable.
samy
Posts: 8
Joined: Wed Nov 29, 2006 12:36 am

Post by samy »

What ill effects arise from directly changing the position of rigidbodies to enforce constraints?
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine

Post by Erin Catto »

You can directly change the position for tree structures, working from the root out to the leaves. For systems with cycles (loops) you might have convergence problems. It's really a nonlinear problem.

In a sense Baumgarte stabilization is directly modifying position, but in a relaxed, sequential manner.
FD
Posts: 26
Joined: Thu May 18, 2006 9:25 pm

Post by FD »

In what way shall I screw the separate solver in? Shall I first solve the system ignoring the position errors, then apply the second solver, taking the position errors into consoderation and feeding the newly computed momenta in (but not integrating positions), and apply the velocities computed in the second solver in the integration step, leaving the momenta remaining from the forst step? Won't it affect badly the convergence with the cached lambdas? I believe there must be a way to make the single solver apply impulses of the two kinds...
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Post by Dirk Gregorius »

The usual mathematical way to simualte these kind of stuff is:

a) Compute Lagrange multiplies (e.g. Baraff)
b) Update velocities
c) Project new velocities back onto velocity constraint manifold
d) Update positions
e) Project new positions back onto position constraint manifold

Since position constraints (as opposed to velocity constraints which are mostly linear) are non-linear step e) requires the solution of a non-linear system. Erin implemeted an example of this called "Super-Split"...

The way to make a single solver apply impulses of both kinds is using Baumgarte stabilization. But when we feed the position constraint into the velocity constraint we "linearize" the position constraint and this might create problems. So it depends on what you want. When you can get away with Baumgarte stabilization you stick to it, since it is the fastes way to step the simulation. It also a good idea to use split-impulses for contacts since it gives you more rigid contacts and makes it also a little more stable. If you encounter stretchy or jittering constraints and weak limits you can try to modify the inertia and also try to make the more outer bodies in a ragdoll lighter than the inner ones or use a smaller timestep of course, but at some point all these tricks will not help anymore and I doubt there is some Voodo art that can be applied then...


HTH,
-Dirk