Creating Vehicular Traffic Simulation with OSS

0
8039

Traffic light

Here is a tutorial on creating real-time vehicular traffic simulation using SUMO and OpenStreetMap.

SUMO stands for Simulation of Urban Mobility. It is designed as an open source package for microscopic road traffic simulation, while OpenStreetMap is an editable, open source map of the world. This article tells you how to simulate real-time traffic using SUMO and OpenStreetMap.

Prerequisites
I have used SUMO 0.22.0 and Ubuntu 12.04 for this simulation.
For installing SUMO in Ubuntu, follow the steps given below:
1. Download SUMO from http://sourceforge.net/projects/sumo/files/sumo/
2. Install some packages that are necessary to build SUMO with a GUI:

sudo apt-get install libgdal1-dev proj libxerces-c2-dev
sudo apt-get install libfox-1.6-dev libgl1-mesa-dev libglu1-mesa-dev

3. Ubuntu 12.04 does not ship with libgdal.so; it ships only with libgdal1.7.0.so. So, create a symbolic link:

sudo ln -s /usr/lib/libgdal1.7.0.so /usr/lib/libgdal.so

4. Now decompress the downloaded file by using the following command:

tar xzvf filename.tar.gz

5. Enter into the source directory and call configure, make and make install:

cd sumo-0.22.0/
./configure --with-fox-includes=/usr/include/fox-1.6 --with-gdal-includes=/usr/include/gdal --with-proj-libraries=/usr --with-gdal-libraries=/usr --with-proj-gdal
make
sudo make install

6. To start SUMO from the command line, run the following command:

sumo or sumo-gui

OpenStreetMap is a free editable map of the whole world. It creates and provides free geographic data such as street maps, to anyone who wants them. The project was started because most maps that you think of as ‘free’ actually have legal or technical restrictions on their use, preventing people from using them in creative, productive or unexpected ways.
You can use http://www.openstreetmap.org/#map=5/51.500/-0.100 to download your map.
An OpenStreetMap file contains a map with the following features related to traffic simulation:

  • The nodes and their connections define the position and form of all streets and junctions.
  • The type of a street specifies its size and importance (key highway).
  • The speed limit of a street is usually determined implicitly by law. The implicit value may depend on the value of the highway attribute. In case the speed limit differs from the implicit legal value, it is given explicitly through the key maximum speed of a street.
  • The total number of lanes (for both directions) has an implicit value depending on the highway property. If the real value differs from the default value, it can be given through the key lanes.
  • The position of every traffic light is described as a node with the key-value pair highway=traffic_signals.
  • One-way streets are marked with the key-value pair oneway=yes.
OSM file
Figure 1: Map exported from www.openstreetmap.org

Figure 1 shows the map that I downloaded from openstreetmap.org.
You need to select the map that you want to simulate and export it. After you export the map, it will ask you to download it. Save the file. Copy the downloaded file to your working directory.
Now run the following commands, one by one.
Netconvert imports digital road networks from different sources and generates road networks that can be used by other tools from the package. It 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.
To interpret the OSM-data, an additional typemap file is required.
Go to http://sumo.de/wiki/Networks/Import/OpenStreetMap, 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 imports geometrical shapes (polygons or points of interest) from different sources and converts them to a representation that may be visualised using SUMO-GUI.

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 the 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 file name for the resulting route file) is given. The trips are distributed evenly in an interval defined by the 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 the sumo-gui. This is what your sumo.cfg file looks like:

<configuration xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”http://sumo.sf.net/xsd/sumoConfiguration.xsd”>

<input>
<net-file value=”map.net.xml”/>
<route-files value=”map.rou.xml”/>
<additional-files value=”map.poly.xml”/>
</input>

<time>
<begin value=”0”/>
<end value=”1000”/>
<step-length value=”0.1”/>
</time>
</configuration>

Save the above file with a file name. I saved it as map.sumo.cfg
Now run the following command from the terminal:

sumo-gui map.sumo.cfg
Screenshot from 2015-03-01 00_46_34
Figure 2: Final map after feeding command into SUMO

After you enter the command, the SUMO-GUI window will pop up. Figure 2 shows what your window should look like.

If you are interested in vehicular ad hoc networks (VANETs), this article can be your starting point. It will teach you how to simulate real-time networks. You can then proceed further and add your research or project component to it.
You can refer to the complete video on YouTube;
here is the link: https://www.youtube.com/watch?v=zm5h90H5OS8

References
[1] http://www.dlr.de/ts/en/desktopdefault.aspx

LEAVE A REPLY

Please enter your comment!
Please enter your name here