Page 1 of 1

Problem with vibrating bodies (alt. Character riding a bike)

Posted: Fri Aug 22, 2014 10:26 pm
by jonkan
Hi, I've been trying out Bullet for some time now trying to make an BMX game but struggle with an annoying problem; The rider's limbs are vibrating.

You can try it out and see what I mean here (WebGL): http://j0nas.se/bmx

Basically, I have a character based off the ragdoll example and a bike made up of five ridgid bodies (frame, wheels and handlebar).
The rider's forearms/hands are constrained to the handlebar and the shins/feets to the frame/pedals via btPoint2PointConstraint's. Then I use a btGeneric6DofConstraint to force the rider's body above the bike (with some amount of freedom to move and rotate).
For the riders joints I use the constraint's motors to set target rotations for each joint (e.g. shoulder, elbow, knee, etc) to make the rider keep his riding position.

I feel that the vibrations might be caused by constrains fighting with each other, but I'm not sure how I could avoid that?
I'm not sure if I'm simply using too many constraints here, if my approach of using constraints to "strap" the rider onto the bike is particularly good, maybe there's a better way?

If anyone has some tips or general advice I'd be grateful :)

Cheers,
Jonas

Re: Problem with vibrating bodies (alt. Character riding a b

Posted: Sat Nov 08, 2014 2:26 pm
by jonkan
Anyone got some clues to what might cause these vibrations?
Is it expected that multiple bodies connected to each other in this chain/circle-like manner will behave like this?

Image

Re: Problem with vibrating bodies (alt. Character riding a b

Posted: Sat Nov 08, 2014 3:35 pm
by drleviathan
I saw the same behavior when I experimented with the ragdoll demo. This is a known problem when simulating many constraints using the "full coordinate method" which is what the btGeneric6DofConstraint is using.

The first thing to try is to take multiple substeps each frame. There is a wiki page about stepping the world.

If that doesn't work then you could try a custom verlet relaxation scheme as per this thread: http://www.bulletphysics.org/Bullet/php ... 17&t=10189

Finally, it might be possible to use Bullet's Featherstone implementation which uses a "reduced coordindate method", however I haven't seen any character demos that use Feathestone yet, only long simple chains.

Re: Problem with vibrating bodies (alt. Character riding a b

Posted: Sat Nov 15, 2014 2:21 am
by lunkhound
I've run into the same sort of problem. I managed to tame the shakes somewhat by switching to the btGeneric6DofSpringConstraint for most things and btConeTwistConstraint for shoulders. I had to tune the spring strength and spring damping parameters.

Re: Problem with vibrating bodies (alt. Character riding a b

Posted: Tue Nov 18, 2014 12:57 am
by kingchurch
jonkan wrote:Anyone got some clues to what might cause these vibrations?
Is it expected that multiple bodies connected to each other in this chain/circle-like manner will behave like this?

Image
One possible reason of the instability is the close loop topology of your character. Try to remove the "loops" in your character-bike mechanism and check if the jiggling goes away. For example: detaching the hands and feet from the bike and only constrain the character's butt to the bike.

After reducing the topology to a "tree" if you get the jiggling away, then you can one by one close the "loops" using some soft constraint / spring and start with very soft springs.