Using constraints to calculate Raycast Vehicle friction

Post Reply
jauthu
Posts: 12
Joined: Tue Feb 28, 2012 7:34 pm

Using constraints to calculate Raycast Vehicle friction

Post by jauthu »

So, the problem with vanilla btRaycastVehicle is that whenever you try to park a car on slope, car keeps rolling down slightly.

To find out impulse needed to stop the wheel from moving sideways, btRaycastVehicle uses resolveSingleBilateral(src) method.

To apply brakes, the impulse is found through calcRollingFriction (src).

Combining this 2 approaches does not work completely well. Sideways impulse is pretty damn correct and it works good for all 4 wheels, but this calcRollingFriction does not stop the car from slowly rolling from a slope.

Things I tried so far:
1. Using resolveSingleBilateral both for side impulse and for forward impulse. This brings jittering and somehow fails to do the job in the end. It can stop the car eventually, but only on a level ground.
2. Using resolveSingleBilateral in the direction that follows current wheel movement, then projecting the backward impulse on side and front vector of the wheel. This one ended up failing aswel. Then I found out that for some reason, even if you apply the result of resolveSingleBilateral in the direction of movement, the car still keeps rolling off a slope.

Then I got back to good old Kester Maddock's document Vehicle Simulation With Bullet, section Friction Model, and there he describes approach of implementing a constraint for that. Howewer I couldn't make his drafty code working.

Since then I am thinking whether it is possible to use any of bullet's constraints as a base to make a friction constraint. Basically, what I need is a constraint that prevents moving on specific axle, which can be called like "Point to plane" constraint, which must have configurable mixing force (like with 0 it doesn't act at all, and with 1 it stops moving on that axle). Also I need to change that limiting axle with every simulation step, for obvious reasons.

So can someone guide me where to start from?

Looking at the btTypedConstraint, I can see that you need to register the constraint inside the bullet codebase (because you need to introduce new element in btTypedConstraintType enum.

Would appreciate any tips on implementing a constraint in bullet in general or any tips on implementing "Point to plane" constraint.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Using constraints to calculate Raycast Vehicle friction

Post by benelot »

Hi jauthu,

First, what is the issue here? Does the vehicle roll down because the wheel still turns and the car rolls down or does the wheel not turn and the vehicle slips down? Slippage could be solved using a higher friction on the wheels, the other should be solvable by completely locking the wheel somehow. Your solution sounds a bit harsh, but could simply be implemented using a fixed constraint. Hook the vehicle COM with a fixed constraint to the plane it is rolling on using the specific position is is currently standing on and your vehicle should be fixed to the ground. Of course you would need to unhook it every time you want to unlock your car by removing the constraint again.
Post Reply