A python package that computes an optimal motion plan for approaching a red light

Overview

Code style: black License: AGPL v3

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

  1. Linux or macOS

  2. Miniconda or Anaconda
    To install, visit Conda Installation

  3. SUMO: Installation instructions for Linux (Ubuntu) and macOS

Install SUMO (Ubuntu)

  1. 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)

  1. Install Homebrew if you don't have it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install XQuartz with Homebrew:
brew install --cask xquartz
  1. Install SUMO with Homebrew:
brew tap dlr-ts/sumo
brew install sumo

Installation of redlight_approach

  1. 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 with which sumo.

  • Replace /path/to/parent above with the directory into which you clone this repo, which you can find with pwd.

  • Load these environment variables with

    source ~/.bashrc
    # or 
    source ~/.zshrc
    
  1. Clone this repository:
git clone https://github.com/basilforlife/redlight_approach.git
  1. Change directories to the root of redlight_approach:
cd redlight_approach
  1. Create and activate conda env:
conda env create -f environment.yml
conda activate rla
  1. 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.

You might also like...
A tool for light-duty persistent memoization of API calls

JSON Memoize What is this? json_memoize is a straightforward tool for light-duty persistent memoization, created with API calls in mind. It stores the

A light library to build tiny websites
A light library to build tiny websites

A light library to build tiny websites

Homed - Light-weight, easily configurable, dockerized homepage
Homed - Light-weight, easily configurable, dockerized homepage

homed GitHub Repo Docker Hub homed is a light-weight customizable portal primari

Stopmagic gives you the power of creating amazing Stop Motion animations faster and easier than ever before.
Stopmagic gives you the power of creating amazing Stop Motion animations faster and easier than ever before.

Stopmagic gives you the power of creating amazing Stop Motion animations faster and easier than ever before. This project is maintained by Aldrin Mathew.

PSP (Python Starter Package) is meant for those who want to start coding in python but are new to the coding scene.

Python Starter Package PSP (Python Starter Package) is meant for those who want to start coding in python, but are new to the coding scene. We include

PyPIContents is an application that generates a Module Index from the Python Package Index (PyPI) and also from various versions of the Python Standard Library.

PyPIContents is an application that generates a Module Index from the Python Package Index (PyPI) and also from various versions of the Python Standar

Example python package with pybind11 cpp extension

Developing C++ extension in Python using pybind11 This is a summary of the commands used in the tutorial.

qecsim is a Python 3 package for simulating quantum error correction using stabilizer codes.

qecsim qecsim is a Python 3 package for simulating quantum error correction using stabilizer codes.

A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

Comments
  • Distribution classes are inconsistent, unclear, and/or dependent on timestep length

    Distribution classes are inconsistent, unclear, and/or dependent on timestep length

    The UniformDistribution class gets initialized with parameters in time in seconds, and ArbitraryDistribution uses timesteps. UniformDistribution should also be more clear about when it stops and ends, and shouldn't have a continuous version for sampling. Both classes should have distributions that are independent of the approach timestep length.

    bug 
    opened by basilforlife 2
Owner
Jonathan Roy
Jonathan Roy
emoji-math computes the given python expression and returns either the value or the nearest 5 emojis as measured by cosine similarity.

emoji-math computes the given python expression and returns either the value or the nearest 5 emojis as measured by cosine similarity.

Andrew White 13 Dec 11, 2022
Blender Light Manipulation - A script that makes it easier to work with light

Blender Light Manipulation A script that makes it easier to work with light 1. Wstęp W poniższej dokumentacji przedstawiony zostanie skrypt, który swo

Tomasz 1 Oct 19, 2021
BloodCheck enables Red and Blue Teams to manage multiple Neo4j databases and run Cypher queries against a BloodHound dataset.

BloodCheck BloodCheck enables Red and Blue Teams to manage multiple Neo4j databases and run Cypher queries against a BloodHound dataset. Installation

Mr B0b 16 Nov 5, 2021
A Red Team tool for exfiltrating sensitive data from Jira tickets.

Jir-thief This Module will connect to Jira's API using an access token, export to a word .doc, and download the Jira issues that the target has access

Antonio Piazza 82 Dec 12, 2022
Project Faros is a reference implimentation of Red Hat OpenShift 4 on small footprint, bare-metal clusters.

Project Faros Project Faros is a reference implimentation of Red Hat OpenShift 4 on small footprint, bare-metal clusters. The project includes referen

project: Faros 9 Jul 18, 2022
A new mini-batch framework for optimal transport in deep generative models, deep domain adaptation, approximate Bayesian computation, color transfer, and gradient flow.

BoMb-OT Python3 implementation of the papers On Transportation of Mini-batches: A Hierarchical Approach and Improving Mini-batch Optimal Transport via

Khai Ba Nguyen 18 Nov 14, 2022
A tool to determine optimal projects for Gridcoin crunchers. Maximize your magnitude!

FindTheMag FindTheMag helps optimize your BOINC client for Gridcoin mining. You can group BOINC projects into two groups: "preferred" projects and "mi

null 7 Oct 4, 2022
Supply Chain will be a SAAS platfom to provide e-logistic facilites with most optimal

Shipp It Welcome To Supply Chain App [ Shipp It ] In "Shipp It" we are creating a full solution[web+app] for a entire supply chain from receiving orde

SAIKAT_CLAW 25 Dec 26, 2022
A test repository to build a python package and publish the package to Artifact Registry using GCB

A test repository to build a python package and publish the package to Artifact Registry using GCB. Then have the package be a dependency in a GCF function.

null 1 Feb 9, 2022
skimpy is a light weight tool that provides summary statistics about variables in data frames within the console.

skimpy Welcome Welcome to skimpy! skimpy is a light weight tool that provides summary statistics about variables in data frames within the console. Th

null 267 Dec 29, 2022