Brian Beckman: The Physics in Games - Real-Time Simulation Explained

Thoughts on Brian Beckman's comments relating to low speed behavior by Todd Wasson

My main interest in this discussion was the conversation that sprung up around Beckman's comments about low speed
behavior (video above). Over the last eleven years or so I've in part helped a lot of developers
through this (many of them just hobbyists, some of them went on to make some of the other racing sims) . They all (myself
included) have run up against the same thing which is what Brian discussed.

First the divide by zero problem: Obviously at 0 velocity you get a divide by 0 at least in the slip ratio calculation. I
never had the slip angle divide by zero Brian talked about because I don't have a division anywhere in my slip angle
equations. A simple dot product does the trick.

Regardless, when you start your simulation with the car at rest, that's a problem in slip ratio. But that's kind of
minor. The real trouble is when you get too close to 0. Once the car gains any velocity at all it's virtually impossible
to make the velocities return again to true 0 anyway. Even though the car looks like it's sitting perfectly still, it's
not really. So shortly after the simulation starts you'll never really get the divide by 0. I challenge anyone doing a
vehicle simulation to get all the velocities to return to 0 without setting them directly. Good luck with that The
major flight simulators used by airlines and the military have struggled with this same problem forever. It's not unique
to car simulations.

Here's an example of slip ratio working like it should. Instead of using rotational velocity of the tires I'll use linear
speed of the car and tires which will probably make more intuitive sense to the non-physics/math nerds that have made it
this far in the post and are still interested

slip ratio = 1 - (tire velocity / free rolling tire velocity)

A car going 50mph has a "free rolling tire velocity" of 50 mph. With no throttle/brake, the tire velocity is also 50mph.
Slip ratio becomes:

slip ratio = 1 - (50 / 50)
slip ratio = 1 - 1
slip ratio = 0

Now you hit the throttle and some number of time steps later the tire velocity hits 55mph. Slip ratio is now:

slip ratio = 1 - (55 / 50)
slip ratio = 1 - 1.1
slip ratio = 0.1

If we freeze frame at this instant and look at the tire we'll see the tire force produced by whatever tire model you have
(doesn't matter which one, whether it's transient or not, etc..). All that matters is that we have a forward force
produced at the tire. A couple things happen due to the force:

1) The car speeds up a little bit.
2) The tire has a reaction force on it from the road that attempts to slow the tire back down to 50mph. On the other end
you have engine torque trying to speed it up. Depending on which of those 2 torques is larger, at this moment the tire
will either speed up, slow down, or stay the same speed.

If we have a time step of 1/100 or 1/1000th second this means we're calculating the acceleration of the tire and then
allowing it to speed up however much it would speed up during a tiny little 1/100 or 1/1000th of a second period of time.
At 50mph the tire is not going to speed up or slow down very much. It might go from 55mph to 55.01 mph. No problem. You
drive off into the sunset and everything feels fine and works how you'd expect.

Now let's slow the car way down, almost to a standstill. Car speed is only 0.001mph. Practically not moving, but it does
have some velocity. If the tire speed is also 0.001mph we have a slip ratio of 0 and there may be no tire force
(regardless of whether transient effects are modeled or not). On the next time step the car may have slowed down to
0.0001mph. Now check out our slip ratio:

slip ratio = 1 - (0.0001 / 0.001)
slip ratio = 0.1

We have the same slip ratio as we had under very heavy throttle at 50mph before. Slip ratio 0.1 might very well be at
the peak of the longitudinal force. I.e., this might be the maximum forward force the tire can produce. The next two
things will happen again just as they did in the 50mph case:

1) The car speeds up a little bit.
2) The tire has a reaction force on it from the road that attempts to slow the tire back down to 50mph. On the other end
you have engine torque trying to speed it up. Depending on which of those 2 torques is larger, at this moment the tire
will either speed up, slow down, or stay the same speed.

Here let's say there's no throttle or brake applied. What the tire gets is a full backwards rotational "kick," with the
same amount of torque as though you had something like full throttle applied to the tire, but in the backwards direction.
Over our time step of 1/100th or 1/1000th second the car velocity might not change noticeably, but the tire's certainly
will. Earlier we assumed that the velocity would change 0.01 mph over one time step under this same condition. Here's
how they'll change:

The tire is now rotating backwards instead of forwards as a result of the very brief full kick applied by our tiny little
difference in velocities that gave us a slip ratio of +0.1 before this. And what happens to the slip ratio?

slip ratio = 1 - (-0.0099 / 0.001)
slip ratio = 10.9 <--- Holy crap!

Here's where we get to the part of Brian's video where he was talking about slip ratios going funky if the car is moving
forward but the tire is rotating backwards and other such combinations. I remember this vividly because back in probably
2000 I was drawing out all these combinations of tire versus car velocities, positive and negative, to try and get the
slip ratio directions to come out right. I had this big, nasty "if" block of code to solve it. It worked fine, but when
I ran across Brian's solution for this I slapped my forehead and said "of course!" So thank you, Brian Beckman, for
giving me that nice little equation that works regardless of the directions. I still use it.

Anyway, this is why he uses the absolute value of the tire velocity in the calculation. Really our slip ratio here should
be negative instead of positive since the tire is rotating backwards while the car is moving forward. To keep things
simple I'll just flip the sign of the slip ratio for this example.

slip ratio = -10.9

Check this out: We've gone from +0.1 slip ratio, which is the peak of the forward force curve, what you would get when
accelerating at the limit of traction, to a negative 10.9 slip ratio. You now effectively have full braking torque
applied to the tire. Not from the brakes, but from the reaction between the tire and the road. On the next time step it
kicks back forward and you get a really big positive slip ratio again. Probably something at +0.1 or higher. The next
step it kicks backward to -6 or something huge again. Back and forth, back and forth. It will only hit exactly 0 again as
a matter of unbelievable luck. In 11 years I've never seen it hit 0. So it's pretty rare. (Granted, you can still get
overflows from the division, but even if we had magic processors that never overflowed and didn't care about divide by
zero problems, this phenomenon would still be something to deal with).

The tire oscillates backward/forward every time step with really big forces. All of these forces are at the maximum tire
force. First forwards, then backwards, then forwards, etc.. The tire never stops and rests at slip ratio 0.

The same thing happens at slightly higher forward speeds. However, at these slightly higher speeds the tire doesn't
literally go backwards anymore. Instead it might oscillate between +0.3 and +0.05 slip ratio. Again, the tire forces are
jumping around like crazy and the car feels a little bit like it's floating. The rpm's jitter up and down a little bit
even though your foot is off the throttle. If you happen to be turning the car while doing this, the lateral forces are
going to be jumping up and down like crazy too.

And again, this has nothing to do with whether or not transient tire effects are modelled or anything to do with the
complexities of measuring transient phenomena in a tire on a tire rig. The same thing will happen regardless of the
tire model used as long as slip ratio is used as a direct input into the tire model in this manner.

Something similar happens in slip angle. If Brian's slip angle calculations have a denominator that can go toward 0 or
not doesn't matter all that much. If we rotate things 90 degrees so we're looking at the car's side to side motion and
forget about the rotation of the tire, when we get close to 0 velocity you get the same kind of oscillation, but this
time it's got nothing to do with the slip ratio.

For instance, if the lateral (sideways) velocity of the car is 0.00000001 mph to the right and the forward velocity is
exactly 0, the slip angle is 90 degrees. Your tire model gives you 100% force back to the left. On the next time step
your velocity might now be -0.0035 mph. Your slip angle is now -90 degrees and the tire model gives you 100% force back
to the right. The car oscillates between + and - 90 degrees. If we introduce a little bit of forward speed we get the
same basic thing happening, but now the slip angles might oscillate wildly between -30 and +30 degrees.

In practice even the slightest slope on the ground or outside effect on the car will throw this off a little bit. What
you get is the slip ratio oscillating and the slip angle oscillating at the same time. With slip angles seemingly
randomly jumping between -30 and +30 with slip ratio jumping between +0.3 and -0.01, the tire forces are going all over
the place. When you change the steering or throttle/brake input a little bit nothing really seems to happen. The feeling
changes completely and you feel disconnected with the ground. When Brian Beckman talked about how you could feel the car
change in some sims at lower speeds, this is the real reason for it.

Every sim developer in history has probably run up against this problem and I believe this is precisely what Brian
Beckman was talking about. This aspect has nothing to do with whether or not somebody models transient effects in the
tire itself. +0.1 slip ratio is going to be a big force regardless of the tire model. -0.3 will be a big force in the
opposite direction. Therefore you get the oscillations, and they get more severe as the speed of the car is reduced.
This is why when you park a car on a hill or banked corner in any orientation you'll often find the car very slowly
slides down the hill anyway even though you're on the brakes.

Like this:

I recall Matt Jessick (an iRacer too) back in the rec.autos.simulators days calling this the "bang bang" problem. It
happens in simulation any time something is "supposed to" go back to 0 velocity. Instead it oscillates back and forth.
This happens in clutch modelling too and is a pain to deal with.

There are ways around this problem in tire models of course, some work better than others but usually they need to be
fine tuned very carefully to work well. One is to introduce the relaxation length of the tire which effectively is having
you calculate the slip ratio or slip angle with two different methods and then use some sort of "psuedo slip ratio" or
angle that reduces the oscillation and lets the slip ratio that's input into the tire model "chase" the normal
calculated slip ratio. SAE950311 paper is one popular example among sim developers, but there are others. I never had
much luck with these kinds of approaches. They're too finicky and difficult to tune for the most part, but they're
certainly better than nothing.

Every sim developer struggles with this kind of thing and has put a ridiculous amount of time into minimizing or
eliminating it. My first sim released in 2004, VRC, was much worse in this regard than iRacing is.
I've only fairly recently worked out a great solution for it.

I eventually figured out a great way around all this in my most recent tire model which no longer uses either slip angle
or slip ratio directly as inputs. Presto, problem solved. Car can park on hills, there's no low/high speed swap to slip
ratio calculations, relaxation lengths come out of it automatically, etc.. It completely eliminates the problem Brian
discussed in the video.

Anyway, I hope that helps to clear up the issue Brian Beckman's video brought up concerning slip ratio and illustrates
the consequences of having the velocity in the denominator.

Article written by Todd Wasson.

Below demonstrates some of the projects Todd has worked on.