Page 1 of 1

Contact penetration resolution

Posted: Thu May 09, 2013 6:37 pm
by sphet
I'm in the process of revisiting an old physics system and have a question about resolving penetrations with contacts. Is ERP the right (only?) way to resolve contact penetration, or should something be done outside of the simulation? I'm trying to remember where I saw it, but I feel like ODE or Havok might have had contact relaxation that operated outside of the dynamics solver, driving objects back towards their ideal contact threshold. Certainly this old system has a step like that, but it seems to me that ERP is more efficient and appropriate.

Any thoughts on this?

S

Re: Contact penetration resolution

Posted: Thu May 09, 2013 8:49 pm
by Dirk Gregorius
ODE uses ERP - they invented the term. The correct term for ERP is Baumgarte stabilization. ERP/Baumgarte means that instead of computing the relative velocity at your contact to become zero you add a little bias proportional to the penetration depth. If the penetration is deep this can go terrible wrong and your objects gain a lot of momentum and shoot off to the starts. The other alternative is to have a non-linear penetration solver which only operates on the position and doesn't effect the momentum. This is a separate pass over the constraints after solving the position. Box2D has such a system. A hybrid method is the split impulse as found e.g. in Bullet. The difference between the later two is that you recompute the Jacobian for each constraint while the split impulse uses the Jacobian from the beginning of the timestep and keeps it constant.

Baumgarte is more efficient. Split impulse works reasonable good for contacts, but sucks for joints. Post-projection gives the best quality, but is the most expensive. You can find a comparison here (check the position correction notes):

https://code.google.com/p/box2d/source/ ... Island.cpp

Re: Contact penetration resolution

Posted: Thu May 09, 2013 10:30 pm
by sphet
Dirk,

Once again thanks for the information. I guess the code I am looking at has the post-step because it is quite exact, adjusting the position only, but also contains the ERP. I'll do some thinking about what I can afford to do in our environment.

Best,

S

Re: Contact penetration resolution

Posted: Thu May 09, 2013 11:58 pm
by Dirk Gregorius
You should not mix Baumgarte Stabilization and Post-Projection. Just use one or the other! I would also not correct the full error in the penetration solver. I usually use a factor between 0.1-0.2 even though it seems feasible to correct the full penetration. The reason is that for oblong shapes you will overshoot quite significantly.

I would make sure that your velocity solver doesn't add any bias for the penetration recovery. There might be some bias to model restitution though. If you have a post projection solver make sure you only resolve a fraction of the penetration. Usually something between 0.1-0.2 to avoid overshooting.

Re: Contact penetration resolution

Posted: Fri May 10, 2013 4:01 am
by sphet
Dirk,

I agree - after experimenting with the code base using an ERP of 0.2 works quite well. When I used it after defeating the contact position relaxation step, contacts seem to be resolving pretty well. Thanks again.

S