Vehicle starts rolling after braking to rest - possible fix

Post Reply
Jonathan Green
Posts: 1
Joined: Wed Nov 21, 2012 12:18 pm

Vehicle starts rolling after braking to rest - possible fix

Post by Jonathan Green »

I am using the raycast vehicle. I have tried applying a brake force to all four wheels of my car. I noticed that even though the car appears to come to a stop, as soon as I release the brake, it starts rolling slowly either forwards or backwards, even though standing on a flat surface. I added some logging to see what is happening. Once the vehicle reaches a speed close to zero, while the brake is applied, the vehicle speed oscillates between a small but significant positive and negative value. When the brake is released, it continues moving with that small speed, whichever happened to be last.

Looking at the code in btRaycastVehicle::updateFriction(), it seems that for each wheel the necessary impulse required to bring the vehicle to rest is computed, and then clamped to the applied brake force for that wheel. This impulse for each wheel is then applied to the vehicle rigid body. But that means at low speeds, and if braking with four wheels, that four times the necessary impulse is applied - one for each wheel. So I changed the following line:

rollingFriction = calcRollingFriction(contactPt);

to

rollingFriction = 0.25f * calcRollingFriction(contactPt);

(Just as a quick test as I know I have 4 wheels applying the force). Sure enough the car comes smoothly to rest and the vehicle speed reduces to a neglible value.

So it seems to me that this function needs to be altered to divide the braking rolling friction by the number of wheels which are applying a braking force, at least when the dead-stop impulse is less than N times the max brake force.

Maybe one of the developers would like to comment?
Post Reply