Collision response / kinematic / friction issue

fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Collision response / kinematic / friction issue

Post by fred »

Hello,

I try to put a rigid body ( ex : a box ) on a kinematic body who move.

The result appear to be very unstable, the box on top of the kinematic platform take some undesirable impulses who make the simulation not realistic. I try to change some parameters, restitution, damping, change the center of mass with a compound shape, but I'm not obtained a visually realistic result...

Am I doing something wrong ?

Cheers.

Fred.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Did you check already CcdPhysicsDemo with #define USE_KINEMATIC_GROUND enabled? It has stacking objects on a kinematic moving ground object.

You should disable sleeping for the kinematic object, and set the flag kinematic:

Code: Select all

	body->setCollisionFlags( body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
	body->setActivationState(DISABLE_DEACTIVATION);
Also make sure to set the worldtransform through the motionstate, if you are using a motionstate (see CcdPhysicsDemo for example).

Hope this helps,
Erwin
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

Hi,

thanks,

yes, I make all of that.

I think the problem is that the new linear & angular velocities are applied on the rigid body directly, not regard to the body mass or inertia. In a old previous collision engine that I made, I had the same problem and I resolved it by splitting the collision response in two vectors, a velocity (integrated during several steps) for the body motion and a repulsion vector (applied current step only) to move body in case of invalid position.

Cheers,

Fred.
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

Hello,

Is it normal that btGjkPairDetector::getClosestPoints report only one contact point for a body collision pair ? even if the two bodies have several contacts or penetrations ?

This introduce bad results because there is not enough entries for the contact solver...

Thanks,

Fred.
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

Hi,

Sorry for this newbie question ! :wink:

What is the difference of speed, accuracy, history, between these collision detection methods in Bullet ?

calcTimeOfImpact:
btContinuousConvexCollision
btGjkConvexCast
btSubsimplexConvexCast

calcPenDepth:
btGjkEpaPenetrationDepthSolver
btMinkowskiPenetrationDepthSolver

getClosestPoints:
btGjkPairDetector

Is there a forum, a post who already talk about that ?

Thanks,

cheers,

Fred.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

All the algorithms you mention use btGjkPairDetector (GJK). GJK gives the closest points and shallow penetration (if used with some collision margin).

If objects move fast, you will get either deep penetration, which requires btGjkEpaPenetrationDepthSolver (EPA) or btMinkowskiPenetrationDepthSolver (sampling). EPA is more accurate and potentially slower then the sampling approximation. Minkowski sampling approximation works good for small sized objects but not so good for large sloped triangles.

Alternatively you use time of impact to (partially or complete) prevent penetration, using one of btContinuousConvexCollision, btGjkConvexCast or btSubsimplexConvexCast. Those time of impact methods are all based on conservative advancement. btGjkConvexCast and btSubsimplexConvexCast don't support angular motion (rotation), so they are a pure linear sweep. So you still need penetration depth to recover. btSubsimplexConvexCast is the fastest of the two, it merges the GJK loop with the conservative advancement.
btContinuousConvexCollision includes angular motion (rotation) so it is a bit slower, but more generic.

There should be several forum postings discussing some of those concepts (penetration depth, time of impact). Some clever searching should help out (in particular involving Gino van den Bergen and me).
If you are more interested in the algorithms, check out Gino's dtecta website. The 'interesting' section of http://www.dtecta.com contains papers/GDC presentations of all those algorithms.

Hope this helps,
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

GJK returns one contact per frame, but each contact point is passed into the btPersistentManifold. This gathers several contact points so you have more then one very quickly: points are not thrown away each frame, unless they become obsolete. There are forum postings / discussions about this topic.
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

Hi,

thanks a lot for all these precisions :)

regards,

Fred.
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

Hello Erwin,

on the lastest version of Bullet (2.50b), there is a problem when a stack of box ( wallHeight = 15 for ex ) with a friction > 0.5 is on a kinematic object ( with state DISABLE_DEACTIVATION ).

After a moment, the boxes on the ground start to have a strange behavior and the stack become unstable.

You can see that in CcdPhysicsDemo demo.

Cheers,

Fred.
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

The strange things appear slowly with a friction of 0.8 and more quickly with a bigger friction (ex : 5).

Some box edges are climbing on the plane of the neighbour box.

Maybe, I forget something...

Do you reproduce that ?

Fred.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

The friction model is an approximation, and might show artifacts under certain circumstances.

There are not many resources/time to make a reproducing demo, so if you need to have this fixed it would help if you provide a demo that compiles with latest Bullet version that shows the issue. Alternatively, please try to find some workarounds that makes your configuration work (less high stacking, friction coefficient etc).

Thanks for the feedback,
Erwin
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

Thanks for the reply Erwin,

currently, I try to handle friction in Bullet like Erin Catto in box2d sample.

My problem is the calcul of a good and stable tangent.

Do you have a idea ?

Thanks,

Fred.
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

Hello,

I change the friction constraint calcul and the results are really better :

btVector3 dv = body2.getVelocityInLocalPoint(rel_pos2) -
body1.getVelocityInLocalPoint(rel_pos1);

btVector3 Pt = -dv * 0.1f; // temp coef

if (body1.m_invMass)
{
body1.m_linearVelocity -= body1.m_invMass * Pt;
body1.m_angularVelocity -= body1.m_invInertiaWorld * contactConstraint.m_relpos1.cross(Pt);
}
if (body2.m_invMass)
{
body2.m_linearVelocity += body2.m_invMass * Pt;
body2.m_angularVelocity += body2.m_invInertiaWorld * contactConstraint.m_relpos2.cross(Pt);
}

What do you think about that ?

I'm novice in physic, what is the name of this kind of solver code ?

Thanks for all.

Fred.
fred
Posts: 19
Joined: Tue Apr 24, 2007 12:38 pm

Post by fred »

Hello Erwin,

how are you ?

forget my last post, it's a bad question ! :wink:

I finally find a good tangent to handle the friction, thanks to the paper of Jan Bender.

Have a good day ! :D

Fred.