Sign in to follow this  
japro

Bias induced oscillation

Recommended Posts

Hi,

I wrote a 2d rigid body simulation with the algorithm that is used in Box2D lite. It works nicely if I just drop objects randomly so that they stack in a rather chaotic manner, but if I build a straight stack the whole stack oscillates as soon as there is more than a certain number of objects in it. Sometimes dropping another piece on the stack or nudging it will eliminate the oscillation. To investigate the behaviour I visualized the bias at the contact points and it looks like there is a "bias wave" travelling up and down the stack. In case of "chaotic stacking" those waves possibly get dampened out by three-way collisions and such. Dropping another piece at the right moment might cancel out the "bias energy" and leave the stack in a stable state. Also the problem vanishes when I comment out the parts of the code that are responsible for the "position correction" (that's what it's called in Box2d lite).

So how can I get rid of that oscillation? I thought about somehow identifying bias based impulse changes and damping them somehow, but failed at finding a way to identify them...

Share this post


Link to post
Share on other sites
Have you tried running your simulation with Box2D as a comparison with your own implementation? If I recall correctly, Box2D did have a number of options for handling stable contact groups. I might not recall correctly...may just be remembering some very old ideas from way back, maybe not even Box2D related...

You may find some useful ideas in Erin's GDC presentations, available here:

Box2D downloads

Share this post


Link to post
Share on other sites
I've been thinking about the damping thing and concluded that the method to calculate the bias in Box2d lite is flawed. The formula there is:

bias = -biasFactor/dt * min(0.0, penetration - allowedPenetration)

So the bias is an acceleration proportional to the penetration. This leads to harmonic oscillation which is not what I want. The obvious solution is to introduce a damping term so that the system is critically damped:

bias = -biasFactor/dt * min(0.0, penetration - allowedPenetration - dampingFactor * vn)

with dampingFactor = sqrt(biasFactor/mass) = sqrt(biasFactor*kn)

Like this, the bias resolves collisions asymptotically and doesn't make objects bounce back (inelastic collision).

This doesn't solve my problem completly, but now the stacks don't bounce around that much they.. uhm... sway like a very unstable jenga tower.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this