430 likes | 1.2k Views
AI Architecture for Racing Vehicle Control November 3, 2004 Upmanyu Misra Scope 8.1: Racing Vehicle Control using Insect Intelligence 8.2: Fast and Efficient Approximation of Racing Lines Downforce by Smartdog Alex Darby Alex Darby
E N D
AI Architecture for Racing Vehicle Control November 3, 2004 Upmanyu Misra
Scope • 8.1: Racing Vehicle Control using Insect Intelligence • 8.2: Fast and Efficient Approximation of Racing Lines • Downforce by Smartdog • Alex Darby
Alex Darby • Joint Honors in AI, Psychology and CS from Univ. of Nottingham • Was senior developer at Smartdog, that developed PS2 futuristic racing game Downforce • Now works with FreeStyle Games Ltd.
Futuristic? • Video game titles in which players take control of not-yet-invented vehicles • Different from NFS • Similar to Star Wars, anyone??
Big Deal, eh? • Deformable car models • Off-the-wall additions to the F-1 racing genre • Thrust blasters • Super-engines • Insane speeds and stunts
Right Intentions • Intelligent • Behavior must be intentional • Intentions ≡ Intelligence Agent’s view Player’s view
Simplify F-1 Racing • Speed is highest priority • Keep on track, preferably on optimal racing curve • Easy, yet realistic braking • Easy steering • Realistic throttle control
Overview MOVIE Downforce Simulation Data Representation AI Framework Track Spaces Brooks’ Subsumption Insect AI The Four main layers of Downforce AI Racing Lines DEMO DEMO
Data Abstraction • Need Data Abstraction and representation - For Downforce, concept is “track space” - Track space transforms 3-D position to 2-D position
Track Space • Calculating <fWidthPos, fLengthPos> requires two vector normalizations per track position • Optimized by caching most common vectors
Disadvantage • Unreliable for detecting fine-grain collisions • To avoid that … we transform the whole bounding box of the car to 2-D
Downforce AI • Used Rodney Brooks’ Subsumption Architecture [Brooks91] and Insect AI architecture [Porcino03] • Downforce AI is primarily reactive
Brooks’ Subsumption Architecture • Intelligent behavior can be generated without explicit representations or abstract reasoning of the kind that symbolic AI proposes • Intelligence is an emergent property of certain complex systems. Each layer does its job, they don’t necessarily coordinate. But the result seems “Intelligent”
Insect AI • Introduced by Nick Porcino • Ch. 6.2 • It provides • Architecture • Notation • Design Methodology
As smart as a Bug… • Insects demonstrate a wide variety of interesting and successful behaviors • Seek (pursuit of a target) • Flee • Steer (away/into) • Yet, their nervous systems are simple • Hence its possible to analyze, compute and create simulation of their behaviors • This is called Computational Neuroethology
Behaviors • Each layer is composed of smaller sub-tasks called Behaviors • Each Behavior deals with a single aspect of the task(s) that the parent layer is responsible for • The overall behavior of the layer emerges from the interaction between constituent behaviors
Interaction between Layers • Three main ways of interactions • Directly override the output of another layer, • Directly affect the internal state of another layer, • One layer alters the input data of another layer to achieve its own task
Output Contention System • Based on three variables • Steering • Throttle • Braking • Every layer tries to manipulate them to achieve their goal • Contention system uses explicit priority system based on order of execution of layers and state dependent rules for situations that cannot be handled otherwise
Path Following Layer • Generates correct controller input for vehicle to follow a specific path at max speed • Consists of two independent behaviors • Steering control • Speed Control
Independent?! • Throughout the Downforce system it is assumed that other behaviors will fulfill their responsibilities • This facilitates emergent nature reduced responsibilities reduced problem space reduced computational load per task overall reduction in execution time
Steering Control • Calculates steering input that makes vehicle follow racing line • Needs to look ahead along the racing line from its current position to generate the value • Hence data needs to be represented accordingly (remember track space?) • Intelligent steering using PID controllers (Ch. 2.8 pg 171, demo on CD)
Wicked Speed Control • Only responsible for regulating speed wrt path • Uses Newtonian physics equations for bodies in circular motion (remember centripetal/centrifugal forces?) to calculate max speed for any given track section • Uses FSM based around corners
Corner Identification • Start – point from where the current speed becomes unfeasible • Apex – first point after the start when the change in turn radius is opposite to that of the start of the corner (where the corner begins to “open out”)
Approaching a Corner • Calculate difference between the calculated max speed for the corner and the current speed • Derive the braking distance based on maximum braking (using good ol’ Newtonian eqns.) • If vehicle is outside the braking zone simply keep accelerating
Round the Corner • Once the braking zone is reached, apply maximum breaking • On reaching max acceptable speed for the corner, cruise to apex • By the time apex is reached, the system will be ready with another set of behaviors (hopefully!)
Tactical Racing Layer • Assesses the race conditions and changes the speed and racing line to gain racing advantage • Transforms an Expert Driver to an Expert Racer • Consists three behaviors • Optimum road position • New racing line • Collision avoidance speed control
Optimum Road Positioning • Visual perception • One pair of eyes facing in each direction • One eye responds to relative speed of other cars • Other responds to their proximity • Each eye stores a one-dimensional image that represents the entire track width and has a resolution of 20 “perceptual pixels” or percepcels.
Compound Eye • Products of the proximity and relative speed is stored in an array • Finally, we add the effect of the racing line to the compound eye with a high weightage • The tuning of the parameters takes time and experimentation. Makes it essential to have a method of editing parameters at run-time, ideally real-time Scripting
Collision Avoidance Speed Control • Overrides the speed control set by the PF layer to avoid collision, primarily front to back • Collision test is performed using velocities measured in the track space domain • Its further refined by calculating the relative fWidthPos component of the track space velocity wrt that of the racing line
Fine Grain Avoidance Layer • Deals with potential collision situations that were missed by previous layers • Consists of two behaviors • Race Priority/Racing Etiquette • Decides which car should back down • Fine Grain Collision Avoidance (they ran out of names!) • To avoid side-on collisions by restricting throttle and steering
Driving Assist Layer • Controls problems such as wheel spin and brake locks • Consists of two behaviors • Traction Control • Minimizes wheel spin/slide • The slip/spin of the wheel is normalized between their corresponding min and max • Modifies throttle speeds set by other layers • Anti-lock Braking • Same as traction control except that the brake value is scaled instead of the throttle
DEMO • http://www.atomicmedia.com/autonomous/ • By Clint Hannaford • Based on Reynolds’ work on Autonomous Character Locomotion
Fixing Racing Lines • They are desirable • give AI vehicles a hint of realism • helps AI vehicles to present better challenge • Record path taken by an AI vehicle driven by a competent human player • fast and efficient • cannot be used for randomly generated or player created tracks
Fixing Racing Lines • Restrict random and player created tracks to being assembled from predefined segments with pre-computed racing lines • But • its not that much fun • racing line is context dependent and cannot be produced by plugging predefined sections
Approximating • Ignore the physics of vehicle movement • Concentrate on minimizing curvature • Start with mid-points on the track
Sources • AI Game Programming Wisdom 2 • http://www.gamespot.com/ps2/driving/downforce/index.html • Rodney A. Brooks, “A Robust Layered Control System for a Mobile Robot” • Brian Beckman, “The Physics of Racing,”www.miata.net/sport/Physics/
THANKS PHEW!!!