Custom vehicle braking

note173
Posts: 16
Joined: Wed Jan 25, 2012 6:32 pm

Custom vehicle braking

Post by note173 »

There is a custom vehicle made of rigid bodies and joints, wheels are cylinder shapes connected to body using hinge constraints. I can't figure out how to implement brakes. Wheels have very large friction coefficient, and the vehicle must be able to stand still on very steep (almost vertical) surfaces. It already can ride up such cliffs.

Tried to apply large constant torque to both wheels opposite to their angular velocity in every simulation tick. But wheels then are still rotating with small angular velocity, and the vehicle moves. It happens on an almost horizontal surface, so it's strange.
Then, if I apply too large force wheels start to jitter. If I apply too small force, the brakes "slip", wheels rotate and vehicle moves.
CookieMonster
Posts: 49
Joined: Sun Jan 29, 2012 10:01 pm

Re: Custom vehicle braking

Post by CookieMonster »

You could try applying a force on each tick callback based on how far the wheel has rotated since you started breaking. I don't know exactly how it would be implemented because bullet is still new to me.
note173
Posts: 16
Joined: Wed Jan 25, 2012 6:32 pm

Re: Custom vehicle braking

Post by note173 »

I've managed to emulate static friction by remembering constraint angle when wheel's angular velocity reaches small threshold or changes direction, then setting it's angular velocity to [(angle - angle_static) / fps]. It's not perfect, the wheel still has some difference from the state it should be in (1-2 degrees), but at least it's stable.

Bullet really needs to have a strong constraint solver.
CookieMonster
Posts: 49
Joined: Sun Jan 29, 2012 10:01 pm

Re: Custom vehicle braking

Post by CookieMonster »

With my own physics engine, I use around 600 steps per second to get things rock hard and stable.
note173
Posts: 16
Joined: Wed Jan 25, 2012 6:32 pm

Re: Custom vehicle braking

Post by note173 »

PhysX does it too, but probably faster, since it runs very smooth on mobiles.