Usage
Installation
Install Python (>=3.7,<=3.9)
Install PlaFoSim from pypi:
pip install plafosim
NOTE: The project is developed and tested only on Linux.
Running a Simulation
NOTE: Since PlaFoSim is a command-line interface (CLI) application, running PlaFoSim requires using a shell.
Quickstart
Run PlaFoSim with:
plafosim
You can use PlaFoSim’s help to get a list of available parameters:
plafosim -h, --help
Or, run a simulation with the default configuration (-d
):
plafosim -d
Live GUI
You can visualize the simulation via a simple live GUI based on sumo-gui, using the argument gui
:
plafosim --gui
A screenshot of PlaFoSim’s live GUI showing 2 platoons and various individual vehicles. Copyright © 2021 IEEE.
More options for the live GUI can be found within the GUI properties
section of the help.
NOTE: This requires installation of SUMO (>=1.6.0) and declaration of the SUMO_HOME
variable (see documentation).
Advanced Simulation Control
You can use a variety of different parameters to customize the scenario and the simulation itself.
E.g., use the parameter vehicles
to configure the number of vehicles in the simulation:
plafosim --vehicles 1000
The available parameters are grouped into different categories:
- road network properties
- vehicle properties
- trip properties
- communication properties
- platoon properties
- formation properties
- infrastructure properties
- simulation properties
- GUI properties
- result recording properties
You can find a list of available parameters for each category in the help:
plafosim -h, --help
Examples
# Configure a 100km freeway with ramps at every 10km
plafosim --road-length 100 --ramp-interval 10
# Configure random (normally distributed) desired driving speed of 130km/h
plafosim --random-desired-speed true --desired-speed 36
# Configure random trips for 500 vehicles
plafosim --vehicles 500 --random-depart-position true --random-arrival-position true --depart-desired true
# Pre fill the freeway with 1000 vehicles
plafosim --vehicles 1000 --pre-fill true
# Configure 50% of the vehicles with Advanced Cruise Control (ACC) and a headway time of 1.5s
plafosim --penetration 0.5 --acc-headway-time 1.5
# Enable a simple, distributed platoon formation algorithm [1] in order to form platoons every 30s
plafosim --formation-algorithm SpeedPosition --formation-strategy distributed --execution-interval 30
Faster Simulation
You can speed up the simulation performance by enabling Python’s optimization PYTHONOPTIMIZE
, e.g., in order to disable assertions:
PYTHONOPTIMIZE=1 plafosim
See the Python documention for more details.
Re-Playing a Simulation
The simulation can write a trace file including the mobility details of every simulated vehicle (default results_vehicle_traces.csv
).
You can replay the simulation in the GUI (see above) based on the trace file by using the corresponding binary:
plafosim-replay results_vehicle_traces.csv
To see all options of this script, run:
plafosim-replay -h, --help
NOTE: This requires installation of SUMO (>=1.6.0) and declaration of the SUMO_HOME
variable.
Recording of Screenshots and Video from a Simulation
PlaFoSim offers functionality to automatically record a screenshot of the GUI in every simulation step with
plafosim --gui --screenshot-file screenshot
These screenshots can be used to create a video by using an integrated script based on ffmpeg:
plafosim-img2video 'screenshot_*.png' video.mp4
NOTE: This requires installation of ffmpeg.