racing vehicle control adam balgach [email protected] adam balgach [email protected]

31
Racing Vehicle Control Adam Balgach [email protected]

Upload: isai-home

Post on 31-Mar-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Racing Vehicle ControlRacing Vehicle Control

Adam Balgach

[email protected]

Adam Balgach

[email protected]

Page 2: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Alex DarbyAlex Darby

FreeStyleGames Ltd (www.freestylegames.com)

Downforce PS2 Moves Track Not Car

FreeStyleGames Ltd (www.freestylegames.com)

Downforce PS2 Moves Track Not Car

Page 3: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Track SpaceTrack Space

Track modeled as long strip with fixed width=1 and an infinite length

2 Major pieces of knowledge about car Horizontal position on the track (fWidthPos) Location from some “start” point (fLengthPos)

This location is course and track dependent

Track modeled as long strip with fixed width=1 and an infinite length

2 Major pieces of knowledge about car Horizontal position on the track (fWidthPos) Location from some “start” point (fLengthPos)

This location is course and track dependent

Page 4: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Track SpaceTrack Space

Page 5: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Downforce AI SystemDownforce AI System

Page 6: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Layers in AILayers in AI

Operate in Psudeo-Parallel Code executed serially Congitative System not used until all layers are

done processing

Behaviors Each layer composed of behaviors Behaviors are independent but operate much

the way the overall layers work

Operate in Psudeo-Parallel Code executed serially Congitative System not used until all layers are

done processing

Behaviors Each layer composed of behaviors Behaviors are independent but operate much

the way the overall layers work

Page 7: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Path Following LayerPath Following Layer

Correct controller inputs so a vehicle can follow a specific path at max speed.

Two behaviors Steering Control Corner Speed Regulation

Steering Control Steering to follow vehicle racing line Steering to converge back onto racing line if lost

Correct controller inputs so a vehicle can follow a specific path at max speed.

Two behaviors Steering Control Corner Speed Regulation

Steering Control Steering to follow vehicle racing line Steering to converge back onto racing line if lost

Page 8: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Path Following Cont...Path Following Cont...

Corner Speed Regulation Only following race line, cares about nothing else (ie

obstacles, track conditions, etc) Dead-Reckoning Approach FSM based around corners

Corner Identification – including corner apex Braking distance is calculated based on current speed

Braking For Corner – break until the current speed is the same as the necessary speed to clear the corners apex

Cruse To Apex – controls throttle so that it does not go too below corner breaking speed, and then accelerates once the apex of the corner is reached.

Corner Speed Regulation Only following race line, cares about nothing else (ie

obstacles, track conditions, etc) Dead-Reckoning Approach FSM based around corners

Corner Identification – including corner apex Braking distance is calculated based on current speed

Braking For Corner – break until the current speed is the same as the necessary speed to clear the corners apex

Cruse To Apex – controls throttle so that it does not go too below corner breaking speed, and then accelerates once the apex of the corner is reached.

Page 9: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Fine Grain Avoidance LayerFine Grain Avoidance Layer

Deals with potential collisions the other layers have not

Two behaviors Race Priority Collision Avoidance (side-to-side)

Race Priority selects which AI will back off incase of collision Player has significantly higher priority “Inside” car around a corner gets priority

Deals with potential collisions the other layers have not

Two behaviors Race Priority Collision Avoidance (side-to-side)

Race Priority selects which AI will back off incase of collision Player has significantly higher priority “Inside” car around a corner gets priority

Page 10: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Avoidance Cont…Avoidance Cont… Side-to-Side collisions

Overrides steering/speed from Path Following Layer

Dependent on Race Priority If “outer” car will collide with inner car, limits the

speed and steering to run parallel slightly behind the inner car

Front-to-Back collisions Rear car must make sure not to hit car in front of

it. Override Breaking/Throttle from P.F.L.

Side-to-Side collisions Overrides steering/speed from Path Following

Layer Dependent on Race Priority If “outer” car will collide with inner car, limits the

speed and steering to run parallel slightly behind the inner car

Front-to-Back collisions Rear car must make sure not to hit car in front of

it. Override Breaking/Throttle from P.F.L.

Page 11: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Tactical Racing LayerTactical Racing Layer

Assists in change of speed & racing line in a pack of cars to gain an overall advantage

Three behaviors Optimum Road Position New Race Line Collision Avoidance Speed Control

Assists in change of speed & racing line in a pack of cars to gain an overall advantage

Three behaviors Optimum Road Position New Race Line Collision Avoidance Speed Control

Page 12: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Optimum Road PositionOptimum Road Position

Each Car has 4 simple “eyes” to find relative speed of other cars, and their proximity

Each eye stores a 1D that represents the entire track width.

The 4 eyes give a low resolution image of what is ahead, next to and behind the car

Each Car has 4 simple “eyes” to find relative speed of other cars, and their proximity

Each eye stores a 1D that represents the entire track width.

The 4 eyes give a low resolution image of what is ahead, next to and behind the car

Page 13: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Determining Optimal Line Determining Optimal Line

4 “Eye” images combined, current racing line added in.

Determine best place to “be” based on the locations of others and racing line

Simple mathematical average of current positions

Must be fine tuned for each track

4 “Eye” images combined, current racing line added in.

Determine best place to “be” based on the locations of others and racing line

Simple mathematical average of current positions

Must be fine tuned for each track

Page 14: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Path GenerationPath Generation

Once a new position have been identified to give vehicle an “advantage” a new race line must be constructed

Old racing line is buffered, and simply interpolated in track space toward the new optimal position

Sometimes this new line may go off the track, in which case other layers have to deal with it

Once a new position have been identified to give vehicle an “advantage” a new race line must be constructed

Old racing line is buffered, and simply interpolated in track space toward the new optimal position

Sometimes this new line may go off the track, in which case other layers have to deal with it

Page 15: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Collision AvoidanceCollision Avoidance

Handles most of front-to-back collisions Only occurs if vehicle in front is currently

going slower. Ignores curves in track, simply brakes to

avoid a car in front based on current speeds and fWidthPos of both cars

Not super efficient, but cheap, reliable and sufficiently accurate

Handles most of front-to-back collisions Only occurs if vehicle in front is currently

going slower. Ignores curves in track, simply brakes to

avoid a car in front based on current speeds and fWidthPos of both cars

Not super efficient, but cheap, reliable and sufficiently accurate

Page 16: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Driving Assist LayerDriving Assist Layer

Controls obscure events such as brake lock, wheel spins and washing out

Two behaviors Traction Control Anti-Lock Braking

Traction Control minimizes slippage Once the slip in the lengthwise axis > threshold

value, actual slip is calculated

Controls obscure events such as brake lock, wheel spins and washing out

Two behaviors Traction Control Anti-Lock Braking

Traction Control minimizes slippage Once the slip in the lengthwise axis > threshold

value, actual slip is calculated

Page 17: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Slip Cont…Slip Cont…

Also a min throttle value to start slipping to force high power-weight cars wouldn’t slip a greater amount then expected when at a standstill.

Type of car (4wd, fwd, rwd) must be taken into account, as to which wheels to measure slip from and how to determine curvature of car from slippage. (direction of the skid)

Also a min throttle value to start slipping to force high power-weight cars wouldn’t slip a greater amount then expected when at a standstill.

Type of car (4wd, fwd, rwd) must be taken into account, as to which wheels to measure slip from and how to determine curvature of car from slippage. (direction of the skid)

Page 18: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Anti-Lock BreakingAnti-Lock Breaking

Same Code as Traction Control System, but by scaling brake value under breaking, instead of throttle under acceleration

In straight line, forces wheels to lock up, but breaking efficiency is less then with a drum break wheel lockup. This is not how the real world works, but was deemed acceptable in the game.

Same Code as Traction Control System, but by scaling brake value under breaking, instead of throttle under acceleration

In straight line, forces wheels to lock up, but breaking efficiency is less then with a drum break wheel lockup. This is not how the real world works, but was deemed acceptable in the game.

Page 19: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Demo 2Demo 2

Show the Demo… Show the Demo…

Page 20: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

AI System Wrap UpAI System Wrap Up

Modular Independent Scalable Representational abstractions

Sensor “eyes” Track Space

Modular Independent Scalable Representational abstractions

Sensor “eyes” Track Space

Page 21: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Optimal Racing LinesOptimal Racing Lines

Not easy task, math/physics intensive and track dependent

How to overcome Limit custom built tracks, only allow users to

use predefined segments Boring, lack of variety for users Just because pieces have racing lines, doesn’t mean

an optimal race line will occur from sticking pieces together

Not easy task, math/physics intensive and track dependent

How to overcome Limit custom built tracks, only allow users to

use predefined segments Boring, lack of variety for users Just because pieces have racing lines, doesn’t mean

an optimal race line will occur from sticking pieces together

Page 22: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Race Lines Cont…Race Lines Cont…

Search for line of minimum curvature Does not account for car (width, weight), or

speed. Is simply the most effective path along a track

Very quick, efficient and highly reliable.

Search for line of minimum curvature Does not account for car (width, weight), or

speed. Is simply the most effective path along a track

Very quick, efficient and highly reliable.

Page 23: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

How to do it…How to do it…

Initially put points equally spaced in the center of the track from start to finish

In sets of three points, gradually reduce the curvature by using the sum of the squares of the angles between them.

Initially put points equally spaced in the center of the track from start to finish

In sets of three points, gradually reduce the curvature by using the sum of the squares of the angles between them.

Page 24: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Points, and Vectors…Points, and Vectors…

Page 25: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Anyone Remember Physics 21?Anyone Remember Physics 21?

Page 26: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Model AppModel App

Show the App Show the App

Page 27: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Surviving a SimulationSurviving a Simulation

Simulation AI very important Controls all the other things in a single player

game Is used as to show how the game development

is “progressing” Overall quality of game play is based on how

good the AI is

Simulation AI very important Controls all the other things in a single player

game Is used as to show how the game development

is “progressing” Overall quality of game play is based on how

good the AI is

Page 28: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Design & ImplementationDesign & Implementation

Code well Create a Prototype Test

Force the AI to use the same inputs a player would use

Make the AI do real-world logical things. Layer the AI Design

Code well Create a Prototype Test

Force the AI to use the same inputs a player would use

Make the AI do real-world logical things. Layer the AI Design

Page 29: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

Layered ExampleLayered Example

Page 30: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

What else can be done?What else can be done?

Include a debugger Make AI visible to players

Include a debugger Make AI visible to players

Page 31: Racing Vehicle Control Adam Balgach asb7@cse.lehigh.edu Adam Balgach asb7@cse.lehigh.edu

SummarySummary

A Good AI System is made of Layers Layers operate in parallel Goal To generate lifelike racing AI with ability

to pass and force the player to react more

Mathematics Influenced Optimizing Best Race Line

A Good AI System is made of Layers Layers operate in parallel Goal To generate lifelike racing AI with ability

to pass and force the player to react more

Mathematics Influenced Optimizing Best Race Line