Jitter when a btBoxShape moves against a btConvexHullShape.

Post Reply
Bernard
Posts: 2
Joined: Tue Nov 23, 2021 10:21 pm

Jitter when a btBoxShape moves against a btConvexHullShape.

Post by Bernard »

I've been running into an issue with the motion of btBoxShapes sliding against btConvexHullShapes[1], in this case using a custom friction callback[2] to simulate a box on a conveyor belt.

I've attached an example adapted from the BasicExample project that demonstrates the problem, the box on the left running on a btBoxShape and the box on the right running on btConvexHullShape. The box on running on the btBoxShape moves as I would expect -- in a straight line, no rotation, no jitter. The box on the btConvexHullShape judders and jitters as it travels, rotating.

The box appears to be penetrating the btConvexHullShape and being repeatedly forced out. Changing the margin changes the failure state (the box starts to roll along with larger margins, and lower margins do nothing). It may be that there is a sweet spot margin that causes the shape to act like the conveyor made of a btBoxShape, but if there is I do not know how to compute it.

I've seen reports that using more substeps or a higher fixed timestep can fix or allieviate the issue, and indeed changing CommonRigidBodyBase::stepSimulation's stepSimulation call to stepSimulation(deltaTime, 12, 1.0 / 240.0) makes the motion appear smoother, but it still spins about.

My question is if this is a bug or (more likely) from a misunderstanding or misuse of Bullet on my part? If the latter, can anyone point out my mistake?

As it stands, I ended up using btBoxShapes to model conveyor belts and it seems to work okay, but approximating curves and cut-offs (conveyors that start or end with an edge at an angle) with boxes is less than ideal, and would like to be able to model the more complex surfaces with different shapes.

Cheers!

[1]: In the example I've used a btConvexHullShape, but the problem occurs with a btBvhTriangleMeshShape and a btCompoundShape made up of btTriangleShapes.

[2]: I considered the alternative of setting the velocity of a static object causing dynamic objects that collide with that static object to move, but that behaviour seems to have regressed (or been intentionally removed) at some point: viewtopic.php?t=10121
Attachments
ConveyorDemo.zip
(5.53 KiB) Downloaded 212 times
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Jitter when a btBoxShape moves against a btConvexHullShape.

Post by drleviathan »

Make the conveyor kinematic instead of static, give it a non-zero velocity but don't change its position. Then dynamic objects that touch it will pick up the non-zero velocity from the collision and will move along.
Bernard
Posts: 2
Joined: Tue Nov 23, 2021 10:21 pm

Re: Jitter when a btBoxShape moves against a btConvexHullShape.

Post by Bernard »

drleviathan wrote: Thu May 05, 2022 2:59 pm Make the conveyor kinematic instead of static, give it a non-zero velocity but don't change its position. Then dynamic objects that touch it will pick up the non-zero velocity from the collision and will move along.
Thanks! As you said, using the CF_KINEMATIC_OBJECT flag and setting a linear velocity does work. Good to know.

I'm not shocked to see that the motion characteristics are unchanged; the box on the btConvexHull still judders and rotates. But at least I can eliminate incorrectly setting up the btManifoldPoint struct as a cause.
Post Reply