rec.autos.simulators

Car physics; AI steering damping

Ruud van Ga

Car physics; AI steering damping

by Ruud van Ga » Fri, 20 Sep 2002 22:39:32

Hi all,

To simulate an AI driver steering, I have a class lying around; SMD
(spring-mass-damper). I can set a goal location for the object, and
much like a wheel attached to a damper the object will move towards
the target.

I want to apply this principle to the steering wheel, so even if the
AI driver wants to move the steering wheel the other way, it does so
gradually (now it just gets there in a single timestep).

However, I'm not sure what numbers to start with that may be
realistic. I would say that the mass might be the steering wheel's
inertia (in the steering rotational direction) plus the mass that is
controlled behind it.
Power steering would then decrease this mass/inertia.

As for damping, does one experience some kind of damping on the
steering wheel due to the steering system? (note the AI driver doesn't
experience force feedback forces, although I might need to add those
in to make it more believable, hm).

So I would get something like:
mass (inertia) = ...
springrate (k) = ...      (how hard the driver pulls the wheel)
damping        = ...

This SMD system generates forces just like a normal spring, so F=k*d,
where d=wantedSteering-currentSteering. I could easily then add in Mz
(the aligning moment) so the AI would indeed have to deal with
steering feedback forces.

That does bring up one other question; suppose Mz=10Nm at the wheels;
when fed back (assuming no powersteering) to the steering wheel, what
would be a realistic ratio of the force that the driver experiences?
In the end it's F_on_hand = Mz*ratio*steeringWheelRadius, but what
kind of ratio's are used in steering houses?

Thanks for any ideas on this,
Ruud

PS Thanks for the responses on the spring problems everyone. It seems
the springs are working ok, but the spring space probably isn't on
most cars.

PPS I did AI yesterday evening and things are driving already; the
inspiration came from 'AI Game Programming Wisdom' which has 3
chapters on AI driving & training, which fortunately really snapped
right into my spline system. Ofcourse it's grandpa driving, but hey,
he's driving by itself around the track. ;-)

Ruud van Gaal
Free car sim: http://www.racesimcentral.net/
Pencil art  : http://www.racesimcentral.net/

Alex Smit

Car physics; AI steering damping

by Alex Smit » Sat, 21 Sep 2002 05:17:47

I don't really know much about such things, but do you have a steering
torque force implemented when steering? With the steering gears and the
like.
I think I read about this in RCVD (p 399, 402)

You may have already read this anyway, but it talks about steering forces
(manual steering) "come from the tire self-aligning torque, mechanical trail
(dunno
what that means :) and from steering gear friction, the forces of which are
divided by the steering gear ratio before they reach the driver" It also
goes on to
talk about steering kickback (??)

It is probably okay to have a simple inertia about the steering wheel, but
according
to RCVD changing the steering geometry (such as caster and things) changes
the amount of steering force, so you would need to change the inertia. But
then
I guess it depends how deep you want to get. You could just get aligning
moment and
multiply it by some 'steering geometry factor' and then by the 'power
steering' factor.

Hope I may have given some help somewhere in there :)

it's good to hear you have AI implemented into it apparently so easily!
Although I thought AI would have come in after the physics is done, maybe
you are close to finishing the physics? (surely not!) Bet it was satisfying
to see car(s) driving around a track for the first time :)

Keep up with the good work!

Gunnar Horrigm

Car physics; AI steering damping

by Gunnar Horrigm » Sat, 21 Sep 2002 06:01:24


why don't you just measure how fast _you_ move _your_ steering wheel?

--
Gunnar
    #31 SUCKS#015 Tupperware MC#002 DoD#0x1B DoDRT#003 DoD:CT#4,8 Kibo: 2
                               myk, trygg og god.

Jim Seamu

Car physics; AI steering damping

by Jim Seamu » Sat, 21 Sep 2002 06:07:09

Given that you don't want the AI to munch too much CPU time, why not just
limit both the maximum rotational velocity and acceleration of the steering
wheel for the AI, and also ignore force feedback for them?
Alex Smit

Car physics; AI steering damping

by Alex Smit » Sat, 21 Sep 2002 06:07:12

Not sure I follow what you mean, but if you are talking about the human
driver, thats what happens when steering. But, with AI there is no input
device, it has to be simulated, in this case Ruud is using a SMD system.

Alex Smit

Car physics; AI steering damping

by Alex Smit » Sat, 21 Sep 2002 06:15:54

Pretty good idea, although it makes the AI fairly rigid as they will all
have the same steering ability. I guess that is the nature of AI

You could always have a debug flag ai_experience_steering_feedback, see how
much of a hit it is.
Probably wouldn't be that much more of a hit considering the amount of CPU
time to work out the acceleration of the steering wheel anyway


Jonny Hodgso

Car physics; AI steering damping

by Jonny Hodgso » Sat, 21 Sep 2002 02:09:49


If it's any help, IIRC a human driver is not capable of producing
steering inputs above 5 Hz...

I think the values in GPL aren't far off.  Alternatively, you
could try assuming a maximum road wheel lock angle; a maximum
steering wheel angle; and a little bit of non-linearity (steering
linkages usually seem to produce a slightly 'soft centre').

HTH,
Jonny

Jim Seamu

Car physics; AI steering damping

by Jim Seamu » Sat, 21 Sep 2002 10:38:47


I always thought that soft centre was tyre sidewall flex....... but I have
no idea where I got that idea from. Hmm.

Matthew V. Jessic

Car physics; AI steering damping

by Matthew V. Jessic » Sat, 21 Sep 2002 14:05:42

Ruud van Gaal wrote:
> Hi all,

> To simulate an AI driver steering, I have a class lying around; SMD
> (spring-mass-damper). I can set a goal location for the object, and
> much like a wheel attached to a damper the object will move towards
> the target.

This turned out way too long, but I found it interesting.
"If only one developer's soul can be saved, it will all
have been worth it" ;);)

Hopefully this will be of some use:

TWICE DIFFERENTIABLE PATHS ARE GOOD
SEQUENTIAL STRAIGHT LINE SEGMENTS ARE EVIL

I don't like this system because it basically is a
heading command system. It generates a path made up
of a sequence of straight lines. This kind of path
isn't twice differentiable so looking ahead at
the next several goal points to decide when to brake may
be difficult because you can't easily determine what
lateral acceleration you will need at speed and then
what speed you will want given an assumed capability.

The heading commands don't restrict a path completely,
so you don't have precise control of crosstrack position.
If you slop to the side you won't recover back to the
desired "line" - because there isn't one ;).
Sometimes this is useful, but in a racing game with
hard constraints often surrounding the path there are
other ways to get the same behavior of not immediately
fixing crosstrack errors if it isn't important yet.
But when it IS important you have no real way of
telling the algorithm that.

If you have a twice differentiable path you can calculate
the desired path's curvature and thereby the
lateral acceleration capability required at any speed.
(Thus the needed speed given an assumed constant
capability.) You can build a crosstrack controller
that you can adjust the bandwith of to return to the
path quickly or slowly as desired.

Twice differentiable paths don't have to be fancy splines.
Straights and circles is a good first order approximation
to a road course.

"Flocking"-ish stuff is useful if you don't mind going
slow (far off optimum) and it doesn't hurt to go off the
path a bit once in a while. Neither situation is
usually a luxury that real racing offers :)

If you want to stay near optimum, the AI has to
have/find a near optimum path and be able to control
speeds carefully as it follows it. Using a path
formulation that makes it as easy as possible for
the AI to determine the needed speeds just seems
very useful.

GAIN SCHEDULING:

Crosstrack controllers are easier to gain schedule
(although this isn't really a big problem) because
the gains are independent of velocity.
(The velocity terms happen to cancel out.)

Heading gains have to change with velocity.
If you aren't used to doing linear analysis of
controllers though, you could either mess that
up and have to figure it out from practice - or
just live with less capability, possibly without
even realizing. If you include compensation for
the damping reduction of the "path curvature
stiffness" lateral stability derivative as the
speed increases, this requires extra gain
scheduling for both formulations.
(see chapter 5 IIRC of Race Car Vehicle Dynamics
for the physics behind this)

You can end up with exactly the same controller
transfer function with both crosstrack and
heading systems (for small errors in the
linear range) but I think the heading system is
much harder to analyze because it is subtler.
The non-linearites occur sort of in the middle
of the whole flow rather than at the end.
This may just be a familiarity thing.
I've worked with real vehicles using crosstrack
controllers and none with heading controllers.

RAMPS AND STEPS:

A steady turn is a ramp command in heading.
Simplistic controllers result in standoff
errors to ramp command inputs.
For a crosstrack command, ateady turning can be
made just a constant "feed forward"
acceleration signal. This simplifies analysis
of the control loop for a beginner. It provides
good performance because the feed forward
can give good speed of response to sudden
turn ins without requiring high gains
in the controller (possibly resulting in
increased overshoot which is bad when racing
near walls, or stability problems because
of too little gain margin for bad conditions
like crests, curbs, or slippery surfaces.)
With a good twice differentiable path, the
acceleration feed forward is straight forward
to calculate. (Not easy, but at least you can
be sure when you have gotten it right.)

OVERRUNNING WAYPOINTS IN A HEADING SYSTEM:

The acceleration you will calculate
to follow a heading command goes to infinity
as you overrun the goal point.
So you need to drop that goal at some point
before you reach it and go on to considering
the next. This means that performance is highly
influenced by the exact placement of goal points
in and near corners. (Because the distance between
them can interact with your goal switching
algorithm.)

Crosstrack controllers don't twitch if they
pass a particular point on their commanded path
0.5 meter off. A heading controller will go crazy.
Again, this can feed back into the total system.
Suppose you decide for car A that 20 meters is the
correct distance between waypoints around a corner
with your switching logic. If you change to a
faster car B the periodic twitches will change
frequency getting faster. If you
happen to approach the car's yaw frequency...
you can have hard to repeat stability problems.

SATURATING CONTROLS AND THE "UNDERSTEER TRAP":

If you let your controls saturate then you will have
a large standoff error as you go around the corner
(missing the apex). This is harder to keep away
from IMO with a heading controller than a crosstrack
because of the ramp input vs step input thing.
The cause of this saturating is that you are too
fast. Your AI will understeer around the corners.

This can masquerade as close to optimum, but only
if you very very carefully control the turn entry
speeds. If you get into this situation, you can
easily fall into the real trap of adjusting your
driving line such that it will only work well
for one vehicle at one weight at one tire
condition at one... etc. Also, remember
far far above ;)  where it was mentioned that the
"sequence of straight lines" path type makes it
very difficult to figure out what speed you need
to be at. You've just made your controller
incredibly sensitive to a value you've also made
very hard to calculate.

The last paragraph was for final understeer vehicles.
If your vehicle is final oversteer and you let it
saturate you will spin. All sorts of logic paths
to detect and control out of that condition
would need to be added.

HOW TO DESTABILIZE YOUR ENTIRE
GAME PROJECT DEVELOPMENT LOOP:

The understeer trap interacts horribly with
physics changes. You have "optimized" your driving
line but decide later to add 0.25 G of turning
capability: Suddenly your AI is bouncing off the
curbs well inside the apexes. So start over
"optimizing" the driving lines tweaking the points
outward because you can now turn faster.
If you instead reduce the G capability the
effect is even worse. Possibly understeering
off the course at almost every corner.
Because the straight line segments
path is so hard to use to get allowable speeds,
you might be tempted to hold the algorithms hand
helping with the speed decision or help
finding where to start braking or even both.
(Ouch).  This means you also have to
redesign when you change braking performance.
(Or burn fuel, or have wet weather, or worn
tires or...)

LANE CHANGES ARE EASY WITH CROSSTRACK CONTROL:

Lane changes or passing is a maneuver that can
be handled "naturally" using a step change in
crosstrack command. Steps are easy to analyze.
Imagine how you would perform such a maneuver using
heading commands. (Kind of complicated, hmm?)

Now imagine you wanted to pass
the car in front 1 meter farther to the
left than before: how much more heading error
do you want to induce by adjusting your future
target point or some such strangeness?
Can't guess? Have to experiment?
I prefer just to subtract 1 meter from my
crosstrack command ;).

With a crosstrack controller, knowing the
bandwidth and damping of the overall system
and the resulting step response you've made
constant over a wide speed range, you will
know exactly how long it should take to do
the lane change. (So you also know when to start
the manuever!)  When you picked your gains you
even chose what kind of overshoot behavior in
crosstrack you wanted: and you thereby know
whether you can expect to safely fit between
the passed car and the wall.

CROSSTRACK ERROR MORE INTUITIVE WHEN
EVALUATING PERFORMANCE:

Finally, if you have a desired path, the crosstrack
error can be easily used to evaluate the systems
performance. The heading error performance of a
heading controller isn't so intuitive.
To me, "5 ft outside at the apex"
is easier to evaluate than "14 deg of heading error
at the apex."  You can get crosstrack error statistics
from the heading controller but remember that you
didn't really want to exactly follow the set of
straight line segments. You really wanted to sort
of curve around the corner in a unknown one of the
infinite number of smooth curves that passes through
the waypoints.

So a plot of crosstrack errors versus the
straight lines is harder to use for a heading
controller because zero error
isn't perfect in this case. Not having a
physically realizable desired path makes it
both hard to follow and hard to evaluate afterwards.

Gasp ;)

- Matt

Jim Seamu

Car physics; AI steering damping

by Jim Seamu » Sun, 22 Sep 2002 00:12:21

Yeah, I, um... agree with Matt.

<g>

Ruud van Ga

Car physics; AI steering damping

by Ruud van Ga » Sun, 22 Sep 2002 00:20:41

On Thu, 19 Sep 2002 18:09:49 +0100, "Jonny Hodgson"



...
>> That does bring up one other question; suppose Mz=10Nm at the wheels;
>> when fed back (assuming no powersteering) to the steering wheel, what
>> would be a realistic ratio of the force that the driver experiences?
>> In the end it's F_on_hand = Mz*ratio*steeringWheelRadius, but what
>> kind of ratio's are used in steering houses?

>I think the values in GPL aren't far off.

Any ideas what those values are? ;-)

Ruud van Gaal
Free car sim: http://www.racer.nl/
Pencil art  : http://www.marketgraph.nl/gallery/

Jim Seamu

Car physics; AI steering damping

by Jim Seamu » Sun, 22 Sep 2002 00:22:47



My GPL allows me to select steering ratios between 7:1 and 20:1..... I
usually use 15:1.

I guess this is the ratio of steering wheel lock angle to front wheel lock
angle - the steering wheel lock angle appears to be fixed but I don't know
what angle they use.

Ruud van Ga

Car physics; AI steering damping

by Ruud van Ga » Sun, 22 Sep 2002 00:58:18

On Thu, 19 Sep 2002 20:17:47 +0000 (UTC), "Alex Smith"

...

Actually, steering is taken directly from the user input. The steering
wheels are then set directly to match the steering wheel.

Mechanical trail is what you get with caster. It's a bit like
self-aligning torque. The Mz is present because the average force
application is not really directly above the center tire (vertically).
The distance of the center of the wheel and the average longitudinal
force point is the trail that gives Mz.

Now picture an office chair with those little wheels. If you move the
chair, the wheels will follow. That's mechanical trail; the attachment
point of the chair and the center of the contact patch of the wheel
are quite a distance apart; that is the mech. trail.
Which is exactly like caster in car terms.

Any ideas often help to get a clearer picture and decide where to go,
thanks. :)

...

Well, I had a spline system, and the surface detection code already
knows on which spline sector it is. So I just take the next spline
lateral line, average it (giving a point halfway the road) and that's
my target (well, it should look more than a couple of sectors ahead,
and it is in fact, but not speed-dependent yet).

The AI Wisdom book gave a formula for setting the steering direction
to go to the target. Then I added some throttle (if v<10 throttle=0.8
else v reduces to 0), and off it went. :)

Nah, it's definitely not finished, though far enough for a lot of fun.
I vary programming areas here & there, since getting caught up in
physics-only programming is no fun! ;-) In the end, all things have to
move forward a little, and it often helps keeping the spirit up by
switching to an easier task for a moment.
Yes, getting a car to drive a bit was quite easy at this point. :)

Hehe, in fact I now have 6 cars driving around (a little train as
they're too dumb for words). Must make that an option, and see how
easy it is to do car-car (OBB-OBB) collisions. If it's a snap (I'm
using ODE) then a 'Race against Grandpa' option may be a nice
diversion, hehe. (GT3 also never took a look at where the real driver
is anyway, lol).

Ruud van Gaal
Free car sim: http://www.racer.nl/
Pencil art  : http://www.marketgraph.nl/gallery/

Ruud van Ga

Car physics; AI steering damping

by Ruud van Ga » Sun, 22 Sep 2002 01:01:08

On Thu, 19 Sep 2002 21:15:54 +0000 (UTC), "Alex Smith"


>Pretty good idea, although it makes the AI fairly rigid as they will all
>have the same steering ability. I guess that is the nature of AI

>You could always have a debug flag ai_experience_steering_feedback, see how
>much of a hit it is.

Not much I guess; although I must start optimizing here & there I
think. Mz is always calculated, so that's one thing to optimize out if
unused.
Main CPU eater is I think the matrix calculations. Lots of that going
on. Currently the AI is a no-brainer (hardly any CPU time), but I
think tuning down the real-life physics for them might save a lot of
CPU time.
(with 6 Ferrari 312's on a PII400/GF2MX400/Linux, I get about 35% of
CPU time).

Ruud van Gaal
Free car sim: http://www.racer.nl/
Pencil art  : http://www.marketgraph.nl/gallery/

Ruud van Ga

Car physics; AI steering damping

by Ruud van Ga » Sun, 22 Sep 2002 01:11:35

On Fri, 20 Sep 2002 05:05:42 GMT, "Matthew V. Jessick"

...

Interesting to keep your writing for later rereads, as I'm not that
deep into the matter yet. :)

But what is a 'crosstrack' controller? Have never heard of it.
I guess I'm using a heading system: look what sector a car is in,
predict in what sector it will be in some time, take a point there,
and target it by modifying the steering wheel to head to that point.

The AI Wisdom book then goes on to explain detecting under/oversteer,
and how to correct it (opposite lock; very interesting read with
actual formulae).

As I've got such a big bunch of varying cars & tracks, the AI must
learn a bit. Not the hard way at first; just detecting when it goes
too fast (understeer) and slow (ehm, no understeer I guess). Then you
should let it drive a couple of laps and figure things out. Ah well,
it's not high priority at this point, but will be so interesting to
watch. ;-)

As for the racing line; I want to do 3 (or more?) lines; racing line,
and left & right overtake lines. Problem is if these lines cross
eachother (in a turn for example).
As tracks in Racer should be splined anyway, I can use the same
splines to give a smooth edge to the targeting perhaps.

AI should also keep detecting how it's doing, for tire temp/pressure
changes as you say. I'd rather leave that to a bit of code that
detects over/understeer situations than to try and predict the
upcoming forces too much.

What are the 'gains'? Throttle, brake and heading changes?

Thanks for the big read, although I'll have to come back and read it
at least a couple of times before it begins making sense I guess. :)
Time to code and all will reveal itself in due time.

Ruud van Gaal
Free car sim: http://www.racer.nl/
Pencil art  : http://www.marketgraph.nl/gallery/


rec.autos.simulators is a usenet newsgroup formed in December, 1993. As this group was always unmoderated there may be some spam or off topic articles included. Some links do point back to racesimcentral.net as we could not validate the original address. Please report any pages that you believe warrant deletion from this archive (include the link in your email). RaceSimCentral.net is in no way responsible and does not endorse any of the content herein.