Skip to content

Repository files navigation

Simple Traffic Simulation of a Single Intersection

Showcase

Motivation

This simulation was made for a project at the University of Rostock, with the motivation of simulating an intersection close to our main building to see whether it is possible to improve the intersection.

As that is quite an ambitious project we limited our scope to solely simulating road users, i.e. no bikes, pedestrians or trams. It only simulates cars, buses and trucks.

The simulation is capable of simulating arbitrary intersections, due to limitations with python these can't be all that big though.

Requirements

This project uses uv for dependency management. Install it, then run:

uv sync

This creates a virtual environment with the correct Python version (see .python-version) and all dependencies. uv run (see below) also does this automatically, so an explicit uv sync is optional.

Note that a specific version of arcade is pinned in pyproject.toml since newer versions introduced differences which were interfering with our implementation.

The graphical interface additionally needs system OpenGL libraries (libGL/libGLU), which are not installable via uv.

Introduction to the project structure

The simulation is started through a single entry point:

uv run traffic-sim runs a graphical user interface to visually show the simulation

uv run traffic-sim --no-gui runs the simulation without a graphical interface, to test the maximum speed of the simulation

The python files in the parent directory are the modules behind these two modes and can also be run directly, e.g. uv run gui_sim.py or uv run speed_test_sim.py.

As you can see the visualizer and the simulator are separated from each other therefore the simulation can work entirely without the visualizer.

Subfolders

  • Simulator - Contains the simulator
  • Visualisation - Contains the gui which can draw
  • Data - The data when running the simulation is saved here
  • Evaluation - Data evaluation from the data we have been given
  • Intersections - A number of intersections which can be loaded in the simulation

Loading a different intersection

There is no way of loading a different intersection without editing code right now. To change the intersections go to Simulator/simulator.py, then change real_intersection to one of the other possible intersections. For example threeway_intersection.

License

GPLv3, see LICENSE

About

Traffic simulation written in Python for a single intersection with various types of cars

Topics

Resources

Stars

13 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages