# Bias induced oscillation

This topic is 2930 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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:

##### 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.

1. 1
2. 2
Rutin
20
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633761
• Total Posts
3013724
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!