Restitution handling

Please don't post Bullet support questions here, use the above forums instead.
stbuzer
Posts: 23
Joined: Fri Dec 08, 2006 10:16 am

Restitution handling

Post by stbuzer »

Hi!
Recently, I've tried to impose restitution to my own physics simulator(based on sequentially impulses algorithm presented by E.Catto),
but faced a problem of making box bounce(Restitution works pretty good on bouncing spheres)
I guess that the reason is that sequentially applying impulses at more than 1 collision point makes the total impulse zero. It works correctly for objects with restitution of zero, but makes another objects behave the same way.
I've noticed that bullet physics simulation works with restitution a bit
better - an axis aligned box falling from some height jumps up just a little, gets angular velocity, falls down and rests.
In contrast, PhysX solves this problem - at restitution 1 the box jumps up about 12 times, than getting angular velocity(i think 12 times is comprehensible precision).

Now I consider applying restitution impulse after all the contact solving iterations should help. And possibly apply it not at particular contact points
but to the whole body?

Any suggestions?
Jan Bender
Posts: 111
Joined: Fri Sep 08, 2006 1:26 pm
Location: Germany

Post by Jan Bender »

I have a method that solves collisions also by impulses. I just tried the example you mentioned with an axis aligned box falling down. If the restitution is 1 the box jumps up and has the same height as before. The box jumped up about 1 hour of simulation time and then it got an angular velocity due to numerical errors.

Maybe you will find the paper "Constraint-based collision and contact handling using impulses" about my method interesting. You can download it from my homepage http://www.impulse-based.de

Jan
stbuzer
Posts: 23
Joined: Fri Dec 08, 2006 10:16 am

Post by stbuzer »

Thanks, Jan. Wow 1 hour of bouncing - it's really high precision. I've downloaded the paper and just started to read it.
But what about solutions based on the same constraint solver?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

For single contact point cases like sphere-sphere, the restitution in Bullet works fine (apart from floating point drift, we could use energy-preserving post processing to solve this drift). This indicates that the problem is not the impulse method / constraint solving, but contact manifold/point generation:

At the moment in Bullet, one contact point is added per frame, so it takes 3 ~ 4 frames to get the full manifold.
This is fine for most cases, but 'perfect' restitution will not work, because the first frame will add a torque impulse, as there is only one corner point.

So for 'perfect' or 'better' restitution, you will need at least full manifold in one go/instantaneously.
Bullet already contains code in Extras/SATcollision to calculate all points for the convex polyhedral cases. However Bullet also supports non-polyhedal convex objects, like implicit cylinders, cone and much more complicated shapes involving minkowski sums and convex hull of any combination of objects.
Also, I got several contributions, including one from Jan Bender and John Nagle to do the same, but again just for polyhedral cases.
There is also a special box-box in Bullet/Extras/AlternativeCollisionAlgorithms that you can try, it's the code from ODE, compatible with Bullet. It produces all contact points at once.

From the constraint solver perspective, having impulse based method + restitution:
In Bullet, which uses a similar sequential impulse method as described by Erin Catto we use approach 1 for restitution:

1) the 'desired resulting velocity' which includes the restitution is calculated and stored before the solver / impulse iterations start. This is what Bullet does, see
2) Another approach is to just scale the resulting impulse after all iterations finish by the restitution factor.

Jan, are you using one of above 2 methods to handle restitution, or another one?
Erwin
Jan Bender
Posts: 111
Joined: Fri Sep 08, 2006 1:26 pm
Location: Germany

Post by Jan Bender »

1) the 'desired resulting velocity' which includes the restitution is calculated and stored before the solver / impulse iterations start. This is what Bullet does, see
2) Another approach is to just scale the resulting impulse after all iterations finish by the restitution factor.

Jan, are you using one of above 2 methods to handle restitution, or another one?
I use both :wink:

In fact I implemented one method which is based on Newton's impact law. This method computes first the 'desired resulting velocity' for every contact point and stores it. Afterwards impulses are computed to reach these velocities. Of course you have to do this in a loop since new collision can occur due to the impulses.

I also implemented a method based on Poisson's hypothesis. It works in the same way but in the beginning the 'desired resulting velocity' is set to zero. In this way I get the impulses of impact. Then I use Poisson's hypothesis to compute the resulting impulses of the collisions.

Jan
stbuzer
Posts: 23
Joined: Fri Dec 08, 2006 10:16 am

Post by stbuzer »

Thanks Erwin. Yes, the problem with 'perfect' restitution in Bullet was mostly because of insufficient contact points at the first frames of collision. I replaced GJK algorithm with custom Box-Box, as you advised, and bouncing became much more realistic.
Before posting the topic I tried something like the second approach, but
in this case the simulation became unstable because of jittering.
I applied restitution * accumulatedImpulse after all iterations. I guess it was needed to add a threshold of applying restitution(to relative velocity) to achieve system stability.
I've implemented the first method. it works pretty good, but still suffers from getting angular velocity.
I consider the question solved, but if you have any other ideas it would be very interesting to me.

Stepan