Sunday, 1 March 2015

Creating Real Time Vehicular Traffic Simulation Using SUMO and Openstreetmap

This article is published in the "Open Source For you" magazine in India in this month August 2015 edition. This post will tell you how to create a real time traffic using SUMO and Openstreetmap.

I have used SUMO 0.22.0 for this simulation.

Prerequisite: SUMO required

Use openstreetmap to download your map

You need to select the map that you want to simulate and export it. After you export the map, it will ask for you to download it. Save the file.

Copy the downloaded file to your working directory.


Now run the following commands by seeing the video below

netconvert imports the road network stored in "map.osm" and stores the SUMO-network generated from this data into "map.net.xml":

netconvert --osm-files map.osm -o map.net.xml

OSM-data not only contains the road network but also a wide range of additional polygons such as buildings and rivers. These polygons can be imported using polyconvert and then added to a sumo-gui-configuration.

click here and copy the typemap file and save it to your working directory with the name typemap.xml

Using the file typemap.xml, polyconvert imports polygons from OSM-data and produces a Sumo-polygon file.

polyconvert --net-file map.net.xml --osm-files map.osm --type-file typemap.xml -o map.poly.xml

randomTrips.py generates a set of random trips for a given network (option -n). It does so by choosing source and destination edge either uniformly at random or weighted by length (option -l), by number of lanes (option -L) or both. The resulting trips are stored in an xml file (option -o, default trips.trips.xml) suitable for the DUAROUTER which is called automatically if the -r option (with a filename for the resulting route file) is given. The trips are distributed evenly in an interval defined by begin (option -b, default 0) and end time (option -e, default 3600) in seconds. The number of trips is defined by the repetition rate (option -p, default 1) in seconds. Every trip has an id consisting of a prefix (option --prefix, default "") and a running number.

python /home/kunal/sumo-0.22.0/tools/trip/randomTrips.py -n map.net.xml -e 100 -l

python /home/kunal/sumo-0.22.0/tools/trip/randomTrips.py -n map.net.xml -r map.rou.xml -e 100 -l

Now you need to make a sumo.cfg file for the configuration of sumo-gui. You can see that in the video below.

Now save the above file with a file name. I saved it with map.sumo.cfg

Now run the following command from terminal

sumo-gui map.sumo.cfg

After you enter the command, sumo GUI window will pop out.

You can have a look at this video for complete simulation


Share your experience with us, Any queries please comment below

No comments:

Post a comment