Collision response / kinematic / friction issue
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
Collision response / kinematic / friction issue
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.
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.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
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:
Also make sure to set the worldtransform through the motionstate, if you are using a motionstate (see CcdPhysicsDemo for example).
Hope this helps,
Erwin
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);
Hope this helps,
Erwin
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
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.
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.
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
Hi,
Sorry for this newbie question !
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.
Sorry for this newbie question !
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.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
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
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
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
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.
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.
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
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
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
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm
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.
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.
-
- Posts: 19
- Joined: Tue Apr 24, 2007 12:38 pm