42
AI Architecture AI Architecture for Racing Vehicle for Racing Vehicle Control Control November 3, 2004 November 3, 2004 Upmanyu Misra Upmanyu Misra

AI Architecture for Racing Vehicle Control November 3, 2004 Upmanyu Misra

Embed Size (px)

Citation preview

AI Architecture for AI Architecture for Racing Vehicle Racing Vehicle

ControlControl

November 3, 2004November 3, 2004

Upmanyu MisraUpmanyu Misra

ScopeScope

►8.1: Racing Vehicle Control using 8.1: Racing Vehicle Control using Insect IntelligenceInsect Intelligence

►8.2: Fast and Efficient Approximation 8.2: Fast and Efficient Approximation of Racing Linesof Racing Lines

►DownforceDownforce by Smartdog by Smartdog►Alex DarbyAlex Darby

Alex DarbyAlex Darby► Joint Honors in AI, Joint Honors in AI,

Psychology and CS Psychology and CS from Univ. of from Univ. of NottinghamNottingham

► Was senior developer Was senior developer at Smartdog, that at Smartdog, that developed PS2 developed PS2 futuristic racing game futuristic racing game DownforceDownforce

► Now works with Now works with FreeStyle Games Ltd.FreeStyle Games Ltd.

Futuristic?Futuristic?

►Video game titles in which players Video game titles in which players take control of not-yet-invented take control of not-yet-invented vehicles vehicles

►Different from NFSDifferent from NFS►Similar to Star Wars, anyone??Similar to Star Wars, anyone??

Big Deal, eh?Big Deal, eh?

►Deformable car models Deformable car models ►Off-the-wall additions to the F-1 racing Off-the-wall additions to the F-1 racing

genre genre Thrust blastersThrust blasters Super-enginesSuper-engines Insane speeds and stuntsInsane speeds and stunts

Right IntentionsRight Intentions

► Intelligent Intelligent

►Behavior must be intentionalBehavior must be intentional► Intentions Intentions ≡≡ Intelligence Intelligence

Agent’s view

Player’s view

Simplify F-1 RacingSimplify F-1 Racing

► Speed is highest prioritySpeed is highest priority► Keep on track, preferably on optimal racing curveKeep on track, preferably on optimal racing curve► Easy, yet realistic brakingEasy, yet realistic braking► Easy steeringEasy steering► Realistic throttle controlRealistic throttle control

OverviewOverviewDownforce Simulation

AI FrameworkData Representation

Brooks’ Subsumption Insect AITrack Spaces

The Four main layers of Downforce AI

Racing Lines

DEMO

MOVIE

DEMO

Data AbstractionData Abstraction

►Need Data Abstraction and Need Data Abstraction and representationrepresentation

- For - For DownforceDownforce, concept is “track , concept is “track space”space”

- Track space transforms 3-D position - Track space transforms 3-D position

to 2-D positionto 2-D position

Track SpaceTrack Space

Track SpaceTrack Space

►Calculating <fWidthPos, fLengthPos> Calculating <fWidthPos, fLengthPos> requires two vector normalizations per requires two vector normalizations per track positiontrack position

►Optimized by caching most common Optimized by caching most common vectors vectors

DisadvantageDisadvantage

►Unreliable for detecting fine-grain Unreliable for detecting fine-grain collisionscollisions

►To avoid that …To avoid that …

we transform the whole bounding we transform the whole bounding box box of the car to 2-Dof the car to 2-D

Downforce AIDownforce AI

►Used Rodney Brooks’ Subsumption Used Rodney Brooks’ Subsumption Architecture [Brooks91] and Insect AI Architecture [Brooks91] and Insect AI architecture [Porcino03]architecture [Porcino03]

►Downforce AI is primarily reactiveDownforce AI is primarily reactive

Brooks’ Subsumption Brooks’ Subsumption ArchitectureArchitecture

► Intelligent behavior can be generated Intelligent behavior can be generated without explicit representations or without explicit representations or abstract reasoning of the kind that abstract reasoning of the kind that symbolic AI proposessymbolic AI proposes

► Intelligence is an emergent property of Intelligence is an emergent property of certain complex systems. Each layer certain complex systems. Each layer does its job, they don’t necessarily does its job, they don’t necessarily coordinate. But the result seems coordinate. But the result seems “Intelligent”“Intelligent”

Brooks’ Subsumption Arch.Brooks’ Subsumption Arch.

Insect AIInsect AI

► Introduced by Nick Porcino Introduced by Nick Porcino ►Ch. 6.2Ch. 6.2► It providesIt provides

ArchitectureArchitecture NotationNotation Design MethodologyDesign Methodology

As smart as a Bug…As smart as a Bug…

► Insects demonstrate a wide variety of Insects demonstrate a wide variety of interesting and successful behaviorsinteresting and successful behaviors Seek (pursuit of a target)Seek (pursuit of a target) FleeFlee Steer (away/into)Steer (away/into)

►Yet, their nervous systems are simpleYet, their nervous systems are simple►Hence its possible to analyze, compute Hence its possible to analyze, compute

and create simulation of their and create simulation of their behaviorsbehaviors

►This is called This is called Computational Computational NeuroethologyNeuroethology

Downforce AI System Downforce AI System ArchitectureArchitecture

BehaviorsBehaviors

►Each layer is composed of smaller sub-Each layer is composed of smaller sub-tasks called Behaviors tasks called Behaviors

►Each Behavior deals with a single Each Behavior deals with a single aspect of the task(s) that the parent aspect of the task(s) that the parent layer is responsible forlayer is responsible for

►The overall behavior of the layer The overall behavior of the layer emerges from the interaction between emerges from the interaction between constituent behaviorsconstituent behaviors

Interaction between LayersInteraction between Layers

►Three main ways of interactionsThree main ways of interactions Directly override the output of another Directly override the output of another

layer,layer, Directly affect the internal state of Directly affect the internal state of

another layer,another layer, One layer alters the input data of another One layer alters the input data of another

layer to achieve its own tasklayer to achieve its own task

Output Contention SystemOutput Contention System

► Based on three variablesBased on three variables SteeringSteering ThrottleThrottle BrakingBraking

► Every layer tries to manipulate them to Every layer tries to manipulate them to achieve their goalachieve their goal

► Contention system uses explicit priority Contention system uses explicit priority system based on order of execution of system based on order of execution of layers and state dependent rules for layers and state dependent rules for situations that cannot be handled situations that cannot be handled otherwise otherwise

Path Following LayerPath Following Layer

►Generates correct controller input for Generates correct controller input for vehicle to follow a specific path at max vehicle to follow a specific path at max speedspeed

►Consists of two independent behaviorsConsists of two independent behaviors Steering controlSteering control Speed ControlSpeed Control

Independent?!Independent?!

► Throughout the Throughout the DownforceDownforce system it is system it is assumed that other behaviors will assumed that other behaviors will fulfill their responsibilitiesfulfill their responsibilities

► This facilitates emergent natureThis facilitates emergent nature

reduced responsibilitiesreduced responsibilities

reduced problem spacereduced problem space

reduced computational load per taskreduced computational load per task

overall reduction in execution timeoverall reduction in execution time

Steering ControlSteering Control

►Calculates steering input that makes Calculates steering input that makes vehicle follow racing linevehicle follow racing line

►Needs to look ahead along the racing Needs to look ahead along the racing line from its current position to line from its current position to generate the valuegenerate the value

►Hence data needs to be represented Hence data needs to be represented accordingly (remember track space?)accordingly (remember track space?)

► Intelligent steering using PID Intelligent steering using PID controllers (Ch. 2.8 pg 171, demo on controllers (Ch. 2.8 pg 171, demo on CD)CD)

Wicked Speed ControlWicked Speed Control

►Only responsible for regulating speed Only responsible for regulating speed wrt pathwrt path

►Uses Newtonian physics equations for Uses Newtonian physics equations for bodies in circular motion (remember bodies in circular motion (remember centripetal/centrifugal forces?) to centripetal/centrifugal forces?) to calculate max speed for any given calculate max speed for any given track sectiontrack section

►Uses FSM based around cornersUses FSM based around corners

Corner IdentificationCorner Identification

►StartStart – point from where the current – point from where the current speed becomes unfeasiblespeed becomes unfeasible

►ApexApex – first point after the start when – first point after the start when the change in turn radius is opposite the change in turn radius is opposite to that of the start of the corner to that of the start of the corner (where the corner begins to “open (where the corner begins to “open out”)out”)

Approaching a CornerApproaching a Corner

►Calculate difference between the Calculate difference between the calculated max speed for the corner calculated max speed for the corner and the current speedand the current speed

►Derive the braking distance based on Derive the braking distance based on maximum braking (using good ol’ maximum braking (using good ol’ Newtonian eqns.)Newtonian eqns.)

► If vehicle is outside the braking zone If vehicle is outside the braking zone simply keep accelerating simply keep accelerating

Round the CornerRound the Corner

►Once the braking zone is reached, Once the braking zone is reached, apply maximum breakingapply maximum breaking

►On reaching max acceptable speed for On reaching max acceptable speed for the corner, cruise to apexthe corner, cruise to apex

►By the time apex is reached, the By the time apex is reached, the system will be ready with another set system will be ready with another set of behaviors (hopefully!)of behaviors (hopefully!)

Tactical Racing LayerTactical Racing Layer

►Assesses the race conditions and Assesses the race conditions and changes the speed and racing line to changes the speed and racing line to gain racing advantage gain racing advantage

►Transforms an Expert Driver to an Transforms an Expert Driver to an Expert RacerExpert Racer

►Consists three behaviorsConsists three behaviors Optimum road positionOptimum road position New racing lineNew racing line Collision avoidance speed controlCollision avoidance speed control

Optimum Road PositioningOptimum Road Positioning

►Visual perceptionVisual perception One pair of eyes facing in each directionOne pair of eyes facing in each direction

►One eye responds to relative speed of other One eye responds to relative speed of other carscars

►Other responds to their proximityOther responds to their proximity

Each eye stores a one-dimensional image Each eye stores a one-dimensional image that represents the entire track width and that represents the entire track width and has a resolution of 20 “perceptual pixels” has a resolution of 20 “perceptual pixels” or percepcels. or percepcels.

PercepcelsPercepcels

Compound EyeCompound Eye

►Products of the proximity and relative Products of the proximity and relative speed is stored in an arrayspeed is stored in an array

► Finally, we add the effect of the racing Finally, we add the effect of the racing line to the compound eye with a high line to the compound eye with a high weightageweightage

►The tuning of the parameters takes The tuning of the parameters takes time and experimentation. Makes it time and experimentation. Makes it essential to have a method of editing essential to have a method of editing parameters at run-time, ideally real-parameters at run-time, ideally real-time Scriptingtime Scripting

Collision Avoidance Speed Collision Avoidance Speed ControlControl

►Overrides the speed control set by the PF Overrides the speed control set by the PF layer to avoid collision, primarily front to layer to avoid collision, primarily front to backback

►Collision test is performed using velocities Collision test is performed using velocities measured in the track space domainmeasured in the track space domain

► Its further refined by calculating the Its further refined by calculating the relative fWidthPos component of the relative fWidthPos component of the track space velocity wrt that of the racing track space velocity wrt that of the racing lineline

Fine Grain Avoidance LayerFine Grain Avoidance Layer

►Deals with potential collision situations Deals with potential collision situations that were missed by previous layersthat were missed by previous layers

►Consists of two behaviorsConsists of two behaviors Race Priority/Racing EtiquetteRace Priority/Racing Etiquette

►Decides which car should back downDecides which car should back down Fine Grain Collision Avoidance (they ran Fine Grain Collision Avoidance (they ran

out of names!)out of names!)►To avoid side-on collisions by restricting To avoid side-on collisions by restricting

throttle and steeringthrottle and steering

Driving Assist LayerDriving Assist Layer

►Controls problems such as wheel spin Controls problems such as wheel spin and brake locksand brake locks

►Consists of two behaviorsConsists of two behaviors Traction ControlTraction Control

►Minimizes wheel spin/slideMinimizes wheel spin/slide►The slip/spin of the wheel is normalized The slip/spin of the wheel is normalized

between their corresponding min and maxbetween their corresponding min and max►Modifies throttle speeds set by other layersModifies throttle speeds set by other layers

Anti-lock BrakingAnti-lock Braking►Same as traction control except that the brake Same as traction control except that the brake

value is scaled instead of the throttlevalue is scaled instead of the throttle

DEMODEMO

►http://http://www.atomicmedia.comwww.atomicmedia.com/autonomous//autonomous/

►By Clint Hannaford By Clint Hannaford ►Based on Reynolds’ work on Based on Reynolds’ work on

Autonomous Character LocomotionAutonomous Character Locomotion

Fixing Racing LinesFixing Racing Lines

►They are desirableThey are desirable give AI vehicles a hint of realismgive AI vehicles a hint of realism helps AI vehicles to present better helps AI vehicles to present better

challengechallenge

►Record path taken by an AI vehicle Record path taken by an AI vehicle driven by a competent human playerdriven by a competent human player fast and efficientfast and efficient cannot be used for randomly generated or cannot be used for randomly generated or

player created tracksplayer created tracks

Fixing Racing LinesFixing Racing Lines

►Restrict random and player created Restrict random and player created tracks to being assembled from tracks to being assembled from predefined segments with pre-predefined segments with pre-computed racing linescomputed racing lines

►ButBut its not that much funits not that much fun racing line is context dependent and racing line is context dependent and

cannot be produced by plugging cannot be produced by plugging predefined sectionspredefined sections

ApproximatingApproximating

► Ignore the physics of vehicle movementIgnore the physics of vehicle movement► Concentrate on minimizing curvatureConcentrate on minimizing curvature► Start with mid-points on the trackStart with mid-points on the track

SourcesSources

►AI Game Programming Wisdom 2AI Game Programming Wisdom 2►http://www.gamespot.com/ps2/driving/http://www.gamespot.com/ps2/driving/

downforce/index.htmldownforce/index.html► Rodney A. BrooksRodney A. Brooks, , “A Robust Layered Control “A Robust Layered Control

System for a Mobile Robot”System for a Mobile Robot”

► Brian BeckmanBrian Beckman, , “The Physics of Racing,”“The Physics of Racing,” www.miata.net/sport/Physics/www.miata.net/sport/Physics/

THANKSTHANKS

PHEW!!!PHEW!!!