Rolling Friction for Raycast Vehicle

thefurlong
Posts: 2
Joined: Fri Apr 23, 2010 6:09 pm

Rolling Friction for Raycast Vehicle

Post by thefurlong »

Hello,

Not only am I a Bullet newbie, but I am also a fairly large physics newbie as well. I am currently trying to compute how much braking force (setBrake()) per wheel is necessary to stop a raycast vehicle, moving at a velocity vi, such that it stops within x meters, if it is moving in a straight line. I was hoping that this would be a simple enough problem, but apparently I have no idea what Bullet does when it applies the braking force. In particular, I was hoping to be able to find clues to what the coefficient of rolling friction is (if there is any), and whether or how bullet applies friction in accordance with m_brake.

I looked at the code, but it involves concepts that I am not really familiar with, such as can be found in computing the value for the mysterious btWheelContactPoint::m_jacDiagABInv, which is multiplied by the relative velocity between two colliding rigid bodies. I don't understand what m_jacDiagABInv is supposed to be, let alone why we should clamp it between the maxImpulse (which would be the braking impulse in my case), and -maxImpulse. I can't even guess why the braking force should be maximum. Can someone please illuminate what is happening here. It would be immensely useful.

Thanks!
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: Rolling Friction for Raycast Vehicle

Post by bone »

I'll try my hand at explaining this really quickly.

Physics systems solve constraints. A very basic tries to force the relative velocity between two bodies to be zero. The Jacobian (m_jacDiagABInv in your case) helps define exactly which relative velocity is being constrained - is it between two offsets of the bodies? Is it a rotation? Etc. A more technical definition of the Jacobian requires some decent math skills (and can be found on Wikipedia or the like anyway).

In your case, the constraint is trying to prevent the contact point of the wheel from moving relative to the ground. But if the constraint eliminated this relative motion immediately in one timestep, your car would stop on a dime (or perhaps flip over from the extreme stop). That's where the min/max impulse comes from - it is basically preventing the force from exceeding your defined amount. If you set it to zero, then the wheel is free to move over the ground because no constraint impulse can be applied.

Hope this gives you a start to understanding.
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: Rolling Friction for Raycast Vehicle

Post by bone »

Let's also figure out the equation for the force to stop an object traveling at vi (meters/sec) in d meters:

Well the average velocity starting with vi and decelerating to 0, assuming uniform deceleration would simply be 0.5*vi. The distance traveled is easy enough:

d = t * 0.5 * vi, where t is the time it takes to decelerate from vi to 0

Solving for t:

t = d / (0.5 * vi)

So the acceleration is simply:

a = -vi / t

Given the mass of the object, you can calculate the force:

f = m * a

Replacing terms so you have it relative to the original inputs vi, d, and m:

f = m * (-0.5 * vi^2 ) / d

I have not double-checked this, please feel free to correct.
thefurlong
Posts: 2
Joined: Fri Apr 23, 2010 6:09 pm

Re: Rolling Friction for Raycast Vehicle

Post by thefurlong »

Hi,

Thanks for replying. That equation for force is precisely what I computed, which is good. I was concerned that there was some hidden friction force dependent on velocity which would mean my velocity curve would be exponential rather than linear, assuming I were to apply a constant force to it. This would mean that I couldn't just apply that simple equation. This afternoon, I did get it to what I wanted for the most part. I am still concerned that I am missing something, though. To elucidate, I wrote a function that applies the above solution by computing the necessary force every time frame. In other words, it is given a Vi (initial), a Vf (final), and Xcur, a remaining distance, then computes the force per wheel by applying that formula. It didn't work that well until I surmised that m_brake is not the break force to be applied, but rather the impulse. After making that change, the vehicle stopped exactly where I wanted it to. More specifically, it accelerated for a 3rd of the distance to a desired velocity, maintained that velocity for the second third, and finally decellerated for the last third. The part that makes me suspicious is that when I plotted the velocity curve, it turned out that the velocity changed at a monotone, non linear rate while accelerating, overshooting the desired velocity for the middle third of the trip, then decelerating at similar non linear monoton rate for the final third. I haven't analyzed it any further, so I don't know whether it is quadratic, exponential, or something else...