Skip to content

oykukapcak/APS_TrafficProject

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS4010 Traffic Simulation Guide

Necessary installations

  • Python
  • SUMO
    • You will need to set the environment variable SUMO_HOME to the base directory of your installation. This can be done temporarily by running export SUMO_HOME="/your/path/to/sumo". More details here.

You will also be using TraCI to interface with SUMO on-line in Python. TraCI comes bundled with SUMO.

To test your installations:
Open a command line, run python test.py. The SUMO GUI should open and allow you to play the simulation.

Getting started

You can design your own road network by modifying the files in the /data folder (see SUMO tutorial here)

Notes:

  • After modifying node and edge files, run netconvert --node-files=cross.nod.xml --edge-files=cross.edg.xml --output-file=cross.net.xml in the data folder to generate the net file.
  • Routes are generated automatically by the generate_routefile() method in runner.py. This can be modified to change the probability distributions of vehicle departures and the paths of the vehicles.
  • Outside of testing, you will likely want to run your simulations without the GUI. This can be done by calling the method simulate_n_steps(N,'nogui') in runner.py with 'nogui'.

Induction loops and lane area detectors

Induction loops and lane area detectors provide information about the state of the network at that area of interest.

The example code includes two induction loops (the yellow rectangles in diagram below) in the network and one lane area detector (the blue strip), defined in data/cross.det.xml.

The state of these can be read on-line during the simulation using TraCI. See the TraCI documentation for induction loops and lane area detectors. For example, traci.inductionloop.getLastStepVehicleNumber("nA0") will return the number of vehicles that were on the induction loop nA0 within the last simulation step. Make sure to read the documentation both from SUMO and TraCI to know how to interpret these variables.

An output summary of elements listed in data/cross.det.xml is printed in data/cross.out after the simulation is run, where the state of each detector/induction loop/traffic signal etc. is printed at the time step interval defined by freq in the element definition.

Traffic lights

A node is indicated to be a traffic-signal-controlled intersection in data/cross.nod.xml. The phases of the signal can be defined in data/cross.det.xml; see http://sumo.dlr.de/wiki/Simulation/Traffic_Lights for further explanation on signal phases.

Using TraCI, the current phase of the signal can be read or set. For example, traci.trafficlight.setPhase("A",0) will set the phase of light A to 0. Further documentation on interacting with lights using TraCI is here.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%