redlight_approach
redlight_approach is a Python package that computes an optimal motion plan during traffic light approach.
RLA_demo.mov
Given the parameters of the road and vehicle, and a probability distribution describing when the traffic light will turn green, redlight_approach finds the optimal motion plan to minimize the expected amount of time spent traversing the intersection. It enacts the motion plan in a SUMO simulation, and a standard human driver is simulated for comparison. It reports the difference in time between the vehicles. The simulation above is cherry-picked, but typical use involves running many simulations with the red light duration sampled from the probability distribution. Preliminary findings show that this traffic light approach planner will save vehicles time in realistic scenarios.
Next Steps: Baysian Updating from World State
Currently, redlight_approach uses a fixed green light event probability distribution throughout a single approach. It's clear this is naive, as there is information about the traffic light cycle available through observation of the world state. For instance, seeing a vehicle slow down that is approaching the intersection perpendicular to your approach, indicates that their traffic light is no longer green. This suggests that your light may turn green soon, depending on the traffic light cycle. There are other possible information sources, like direct observation of the light from another vehicle of a connected fleet. Updating the distribution from an observation of the world during approach would increase the performance of the system.
Formally, the goal of this part of the project is to map world state to a Baysian update of the probability distribution. Specifically, this will involve using a neural net to map an aspect of world state, like the position of other vehicles, to a likelyhood function defined over the support of the green light event. This requires a dataset which will be generated by running many simulations. This effort is currently underway in the baysian_update
branch.
Requirements
-
Linux or macOS
-
Miniconda or Anaconda
To install, visit Conda Installation -
SUMO: Installation instructions for Linux (Ubuntu) and macOS
Install SUMO (Ubuntu)
- Build SUMO from source (see SUMO Linux Build for more details)
sudo apt-get install git cmake python3 g++ libxerces-c-dev libfox-1.6-dev libgdal-dev libproj-dev libgl2ps-dev
git clone --recursive https://github.com/eclipse/sumo
export SUMO_HOME="$PWD/sumo"
mkdir sumo/build/cmake-build && cd sumo/build/cmake-build
cmake ../..
make -j$(nproc)
sudo make install
Install SUMO (macOS)
- Install Homebrew if you don't have it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install XQuartz with Homebrew:
brew install --cask xquartz
- Install SUMO with Homebrew:
brew tap dlr-ts/sumo
brew install sumo
Installation of redlight_approach
- Edit
.bashrc
or.zshrc
:
-
Add these lines to your shell's config file:
# Your .bashrc or .zshrc file export SUMO_HOME="/path/to/sumo" export PYTHONPATH="$PYTHONPATH:/path/to/parent/"
-
Replace
/path/to/sumo
above with your sumo location, which you can find withwhich sumo
. -
Replace
/path/to/parent
above with the directory into which you clone this repo, which you can find withpwd
. -
Load these environment variables with
source ~/.bashrc # or source ~/.zshrc
- Clone this repository:
git clone https://github.com/basilforlife/redlight_approach.git
- Change directories to the root of redlight_approach:
cd redlight_approach
- Create and activate conda env:
conda env create -f environment.yml
conda activate rla
- If you're going to contribute, add pre-commit hooks:
pre-commit install
Usage
Confirm installation was successful with the test suite:
pytest
Typical Use
Run the default scenario with the -g
(graphical) option:
Note: on macOS, XQuartz must be running in order to use the graphical option. Start XQuartz from the application folder.
python simple_comparison.py -c parameter_files/original.json -g
To speed up future runs use the the -p
option:
python simple_comparison.py -c parameter_files/original.json -p original.pickle
On subsequent runs, use -u
to load the same configuration as before:
python simple_comparison.py -u original.pickle
To plot the result of N runs, use the -N
option:
python simple_comparison.py -u original.pickle -N 100
For a complete list of options, use the -h
option:
python simple_comparison.py -h
License
This work is licensed under the GNU Affero General Public License v3.0. Feel free to contact me if you have any questions about the project.