How to get started with SUMO simulator

Taher Almoussali
5 min readJun 2, 2023
SUMO (Simulation of Urban MObility)

SUMO (Simulation of Urban MObility)

SUMO is an open-source traffic simulation platform widely used for studying and analyzing traffic behavior in urban environments. It provides a realistic simulation environment for modeling road networks, traffic flow, and various transportation-related scenarios.

To get started with SUMO, follow these steps:

  1. Download SUMO: Visit the official SUMO website at sumo Download Choose the appropriate version for your operating system (Windows, macOS, or Linux) and download the installation package.
  2. Install SUMO: Run the downloaded installation package and follow the on-screen instructions to install SUMO on your system.
  3. Verify Installation: Once the installation is complete, open a terminal or command prompt window and type the following command to verify that SUMO is correctly installed:
sumo --version

If the installation was successful, you should see the version information of SUMO displayed in the terminal or command prompt.

How to create a traffic network in the SUMO?

there are two ways to create traffic network:

  • Use the Netedit program (included in the SUMO package)
  • Use the OSM (OpenStreetMap)

Netedit program:

This tool offers a user-simpley interface that enables you to create your custom road network, including pedestrian and vehicles roads, and create traffic lights at intersections … etc

Netedit Tool

To obtain further information on how to use this tool, you can visit this page (netedit — SUMO Documentation)

OSM (OpenStreetMap)

OSM provides an alternative method to create a traffic network in SUMO. It allows users to leverage existing map data available in OpenStreetMap for their traffic simulations.

Using OSM:

  1. Access OpenStreetMap: Start by navigating to the OpenStreetMap website to find the area you wish to simulate in SUMO.
  2. Download OSM File: Identify the region or city you want to simulate and download the corresponding OSM file. This file contains the geographical data needed for your simulation. it is explore in image
using OpenStreetMap

3. Conversion to SUMO Format: Start by converting the OSM file into a format SUMO can read. You can do this using the ‘netconvert’ tool that comes with SUMO. This tool transforms the OSM file into a SUMO-compatible format, making the map data usable for your simulation.

For example, use the following command in your terminal or command prompt:

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

Additionally, you can customize the conversion process using options like --geometry.remove, --ramps.guess, --junctions.join, --tls.guess-signals, --tls.discard-simple, --tls.join, and --tls.default-type actuated. These options allow you to tailor how the conversion takes place based on your needs.

For more information, refer to this page on processing OSM file

Generating Random Trips in SUMO

In SUMO, creating random trips for your simulations is a straightforward process using the randomTrips.py script. Here's a step-by-step guide:

Step 1: Generating Random Trips

Using randomTrips.py: Begin by utilizing the randomTrips.py script. Execute the following command in your terminal or command prompt:

randomTrips.py -n map.net.xml -e 1000 -o map.trips.xml

This command generates random trips for your SUMO network. Adjust the parameters (-n, -e, -o) to suit your specific simulation needs. For instance, -e denotes the number of trips to generate.

If the command above doesn’t work or opens the randomTrips file in your IDE, use this alternative command:

python "C:\Program Files (x86)\Eclipse\Sumo\tools\randomTrips.py" -n map.net.xml -e 1000 -o map0.trips.xml

Make sure to replace the file path based on your device’s configuration.

Step 2: Assigning Routes to Trips

Using duarouter: Once the trips are generated, employ the duarouter tool to assign routes to these trips. Run the following command:

duarouter -n map.net.xml --route-files map.trips.xml -o map.rou.xml --ignore-errors

This command associates routes with the generated trips. Customize the options (-n, --route-files, -o, --ignore-errors) based on your SUMO network specifications and project requirements.

Creating a SUMO Configuration File

Once you have obtained the map.net.xml (containing network information) and map.rou.xml (containing vehicle and route information) files, follow these steps to compile them into a sumocfg file:

  1. Compilation Process:

Open a text editor or an XML editor of your choice.

  1. XML Configuration:

Structure the contents as follows to create your sumocfg file:

<configuration>
<input>
<net-file value="path/to/map.net.xml"/>
<route-files value="path/to/map.rou.xml"/>

</input>

</configuration>
  1. Replace "path/to/map.net.xml" with the file path of your map.net.xml and "path/to/map.rou.xml" with the file path of your map.rou.xml accordingly.
  2. Saving the File:

Save this file with a .sumocfg extension, ensuring it encapsulates the necessary network and route information for your SUMO simulation.

With the configuration file ready, your simulation is prepared to run on the SUMO-GUI.

In the repository below, you can find a simple example of a SUMO simulation.

Simple scenario

As we conclude this guide to SUMO’s functionalities for traffic simulation, we’ve explored how to create networks, generate trips, and simulate traffic scenarios. In our next article, we delve deeper into the Traffic Control Interface (TraCI) library, a powerful tool within SUMO. We’ll discover how TraCI enables interaction with running simulations, allowing us to control vehicles, gather real-time data, and implement dynamic traffic management strategies.

--

--