Table of Contents
This over-engineered game is my attempt to brush up on vehicle dynamics and path tracking algorithms by coding them from scratch. The game conceals an underlying framework of tunable path tracking controllers (Pure-Pursuit, Stanley, Kinematic/Dynamic LQR), customizable vehicle dynamics models, spline-based path generation, etc.
The game involves the user drawing a path (B-spline) with their mouse that the autonomous vehicle will follow using one of several path tracking algorithms. The goal is to guide the AV safely to the end of each level, avoiding collisions with the walls.
Sandbox mode allows the user to interactively experiment and tune a variety of parameters, controlling everything from the vehicle dynamics model to the path tracking algorithms and tuning parameters. The code is written following several OOP software design patterns (Composite, Factory, Bridge, etc.) to enable abstraction (e.g. any controller can be run with any vehicle model and any path generation type) and maintainability.
Users can tune (in realtime) and experiment with several path tracking controllers of varying complexity. See below video for example:
Brief comparison of the various path tracking controllers implemented:
Description | Model Used | Robustness | Stability | Linearity | |
---|---|---|---|---|---|
Pure Pursuit | Geometric method that follows a look-ahead point on the path based on vehicle speed | Kinematic, simple bicycle model | Less robust to dynamic changes, struggles with sharp turns | Generally stable but can lose stability in sharp turns, high speeds, or small lookahead | Non-linear |
Stanley Controller | Minimizes cross-track error and heading error through a proportional control strategy, used in DARPA's Grand Challenge by Standford's team | Kinematic, bicycle model | Robust to small disturbances, but may oscillate in certain conditions | Lyapunov stable, particularly for straight paths | Non-linear |
Kinematic LQR | Uses linear quadratic regulator to minimize deviations in position and velocity using a kinematic model | Kinematic, linearized model | Moderately robust with careful tuning | Stable within the Region of Attraction (ROA) | Linearized around operating point |
Dynamic LQR | Uses linear quadratic regulator to minimize deviations including dynamic effects like forces and acceleration | Dynamic, linearized model | Highly robust, especially in dynamic and high-speed environments | Stable within the Region of Attraction (ROA) | Linearized around operating point |
Users can also click the Docs
button to go to a Jupyter Notebook page containing derivations of some of the control strategies as well as sample code calling the controllers:
The user can switch between kinematic vs dynamic vehicle models as well as different integration schemes. The user can also update the vehicle model parameters (mass, length, etc) in real time which will also update the parameters used by the path tracking algorithm (where relevant).
Users can also click the Docs
button to go to a Jupyter Notebook page containing derivations of the dynamic/kinematic bicycle model equations-of-motion as well as sample code calling the models:
Paths are generated with B-Splines for
- Manual Gen: path spawns from the mouse cursor which the user controls
- Auto Gen: path is generated by some parameterizable function generator (e.g. sine wave)
First time only:
pip install --user pipenv
pip install --user pipenv-shebang
pipenv sync
pipenv run ipykernel_setup
Start game:
./TheTrolleyProblemGame.py
Jesse Miller - [email protected]
Project Link: https://github.com/jam643/TheTrolleyProblemGame