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

Post Reply
jonkan
Posts: 2
Joined: Fri Aug 22, 2014 8:06 pm
Location: Sweden

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

Post 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
jonkan
Posts: 2
Joined: Fri Aug 22, 2014 8:06 pm
Location: Sweden

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

Post 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
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

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

Post 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.
lunkhound
Posts: 99
Joined: Thu Nov 21, 2013 8:57 pm

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

Post 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.
kingchurch
Posts: 28
Joined: Sun May 13, 2012 7:14 am

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

Post 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.
Post Reply