Keywords: sumo
Summary
This is a baseline simulation that features a traffic pattern produced by the Simulation of Urban MObility (SUMO) model. All the input files for both the SUMO simulation and the DIRSIG simulation that ingests the output of the SUMO simulation are included. This is not intended to be a detailed tutorial on using SUMO itself, as there is a wealth of existing documentation, tutorials and examples available on the SUMO website.
Related Materials
The following demos, manuals and tutorials can provide additional information about the topics at the focus of this demo:
-
Related Demos
-
None.
-
-
Related Manuals
-
The GLIST manual.
-
The DeltaMotion manual.
-
-
Related Tutorials
-
None.
-
Important Files
This section will walk through the entire progress of generating the SUMO inputs, running SUMO and ingesting the output into DIRSIG.
SUMO Road Network
The road network in SUMO describes the roads, intersections, traffic
control devices (stop signs, signals, etc.) that the vehicles drive
in. The SUMO documentation describes how to create "real" road networks
from data sources include OpenStreetMap. The process for making a "real"
road network is beyond the scope of this demo. Instead, we will use
the SUMO netgenerate
tool to create what they call an abstract network.
Specifically, we will generate a simple 5x5 grid road network. We want
2 lanes in each direction of travel and the length of each road segment
in the grid to be 200 meters. This network can be generated using the
following command:
$ netgenerate --grid --default.lanenumber=2 --grid.number=5 --grid.length=200 --output-file=grid_5x5_2lanes.net.xml
Note
|
The netgenerate tool has an extensive list of commands that can
help to make this parametrically defined network less uniform and
more complex.
|
A road segment in the network is composed of at least one edge.
An edge supports uni-directional flow from one junction to another.
An edge can have more than one lane. A road segment between two
intersections will usually have a pair of edges, one for each
direction of travel (unless the road is one-way, of course). In
order to later describe how traffic flows in this network, it is
important to understand how netgenerate
generates IDs for the
road edges it generates. Road intersections and edges in the network
grid are named using a letter + number "coordinate" system. The
intersection nodes are labeled in the XY plane using letters (e.g.
A
, B
, C
… etc.) in the X dimension and using numbers (e.g.
0
, 1
, 2
, … etc.) in the Y dimension. The "origin" of the
network is in the top-left.
A road edge is defined by the pair of nodes at each end of the segment.
Hence, the first segment leaving the origin and flowing to the right (+X)
has an edge named A0B0
, since it starts at A0
and ends at B0
. The
corresponding edge flowing in the opposite direction is named B0A0
.
SUMO Traffic Flows
Once the road network is generated, the next step is to generate traffic that is traversing the network. This can be accomplished in multiple ways in SUMO, including the manual creation of specific routes that vehicles will follow. SUMO also lets you manually generate entries for every vehicle traversing the network. These manual route and vehicle definition options are generally reserved for programmatically importing data from other sources since manually defining every route and vehicle would be tedious. To facilitate automatic route and vehicle generation, SUMO has two similar features that can be employed: trips and flows.
- trip
-
A trip specifies a origin and destination of a single vehicle in the road network. This is defined by specifying the starting and ending edge pair and an optional departure time.
- flow
-
A flow specifies the origin and destination of a multiple vehicles in the road network. This is defined by specifying the starting and ending edge pair, a range of departure times and the number of vehicles in the flow.
A program will read in trip and/or flow descriptions and generate routes that connect the specified start and end edges. This program will also generate the vehicle descriptions (one per trip or many per flow) that utilize the generated routes. For this demo, we will use the "flow" feature since it allows the route generation program to produce both the routes and multiple vehicles.
For this network we will define a variety of flows to utilize the network. A set of flows will be defined for each of the 5 primary routes in both the X and Y dimensions (the network is a 5 x 5 grid), which will produce vehicles that don’t make any turns. A set of flows will also be defined that traverse from each corner to the opposite corner, which will obviously result in routes with at least one turn. Finally, a set of flows traversing from one edge to another location on the opposite edge will be added.
All of the flows are defined in the file sumo/flows.xml
included
in this demo. Like all the SUMO inputs, this is an XML file that
can be manually created with any text editor, but an editor that
has basic XML features (matching element checks, auto-indentation, etc.)
can make the process easier. The first <flow>
pair is for vehicles
traveling along the top of the network, with a flow for each directional
edge:
<routes>
<flows>
<flow id="0" from="A0A1" to="A3A4" begin="20" end="120" number="10"/>
<flow id="1" from="A4A3" to="A1A0" begin="20" end="120" number="10"/>
...
</flows>
</routes>
So A0A1
is the left-most edge along the top and A3A4
is the
right-most edge. The 2nd flow is in the opposite direction. The
next 8 flows are for the remaining 4 roads aligned in the X direction.
The next 10 flows are for the 5 roads aligned in the Y direction. The excerpt below are the flows for vehicles traveling along the left-side of the network:
<routes>
<flows>
...
<flow id="10" from="A0B0" to="D0E0" begin="20" end="120" number="10"/>
<flow id="11" from="E0D0" to="B0A0" begin="20" end="120" number="10"/>
...
</flows>
</routes>
where A0B0
is the top-most edge on the left side and D0E0
is the
bottom-most edge on the left side.
The remainder of flows describe the various corner to corner and additional edge to edge flows.
The generation of the actual routes and vehicles traveling those routes
is accomplished with the SUMO duarouter
program. The input to the
program is the road network and the flows file:
duarouter
tool to generate traffic routes.$ duarouter --net-file=grid_5x5_2lanes.net.xml --route-files=flows.xml --output-file=flows.rou.xml
The resulting flows.rou.xml
is a SUMO routes file and contains the
generated <route>
and <vehicle>
descriptions for the simulation.
SUMO Simulation
The final step is to run the SUMO simulation, which is where SUMO will compute the traffic flow for all the defined vehicles along their respective routes. This primary output of this simulation is the location of each vehicle as a function of time, which we will capture in a SUMO network "dump" file. The inputs to the SUMO simulation are the road network file and the file containing the routes and vehicles:
$ sumo --net-file=grid_5x5_2lanes.net.xml --route-files=flows.rou.xml --ndump=flows.dump.xml
SUMO Import
The next step is to import the SUMO output into a format that DIRSIG
can ingest. This is currently handled by the sumo2dirsig
program,
which will read in the SUMO "dump" file (flows.dump.xml
) and
produce a DIRSIG motion description file for each of the vehicles
in the SUMO simulation. This program will also produce a GLIST
file fragment that includes all the <dynamicinstance>
entries for
each vehicle:
sumo2dirsig
tool.$ sumo2dirsig --sumo_network=sumo/grid_5x5_2lanes.net.xml \ --sumo_netdump=sumo/flows.dump.xml \ --input_scene=wo_traffic.scene \ --output_glist=geometry/sumo.instances \ --mov_folder=geometry/motion --mov_path=motion \ --scene_origin=400,400
Below is an example of one of the DeltaMotion MOV files produced by the
sumo2dirsig
tool:
geometry/motion/sumo_car_18.2.mov
file.DIRSIG_MOV = 1.0 OPTIONS { START_HIDDEN = TRUE END_HIDDEN = TRUE } INIT_POSITION { TRANSLATION = -388.5, 395.2, 0 SCALE = 1.0, 1.0, 1.0 ROTATION = 0.0, 0.0, 1.5708 } MOVES { MOVE = 40, 0, 0, 0, 0, 0, 0, 0, 0, 0 MOVE = 1, 2.05, 0, 0, 0, 0, 0, 0, 0, 0 ... }
Below is the what the geometry/sumo.instances
file looks like. This is a
GLIST file fragment that contains all the <dynamicinstance>
entries for
each vehicle in the SUMO simulation:
geometry/sumo.instances
file. <dynamicinstance>
<motion type="delta">
<filename>motion/sumo_car_0.0.mov</filename>
</motion>
</dynamicinstance>
<dynamicinstance>
<motion type="delta">
<filename>motion/sumo_car_0.1.mov</filename>
</motion>
</dynamicinstance>
...
This list of instances can then be injected as the instances into a GLIST
file using the XML xi::include
feature:
traffic.glist
file.<geometrylist>
<object>
<basegeometry>
<box>
<matid>car</matid>
<lowerextent>
<point><x>-0.9</x><y>-2.5</y><z>+0.0</z></point>
</lowerextent>
<upperextent>
<point><x>+0.9</x><y>+2.5</y><z>+1.4</z></point>
</upperextent>
</box>
</basegeometry>
<xi:include href="geometry/sumo.instances"/>
</object>
</geometrylist>
Setup
Single-Frame (Still) Simulation
To run the single-frame simulation, perform the following steps:
-
Run the DIRSIG
single_frame.sim
file -
Load the resulting
demo-t0000-c0000.img
file in the image viewer.
Multi-Scene, Single-Frame (Still) Simulation
There is also a variant of the single-frame simulation that splits the scene into a pair of scenes:
-
A scene containing only the ground (see
ground_only.scene
) and -
A scene contraining only the traffic (see
traffic_only.scene
).
The point of this variant configuration is show how a baseline (background) scene can be combined with different scenes that isolate dynamic scene content. For example, different traffic simulations could be captured as different "traffic only" scene files and the choice of which traffic to combine with the standard scene could made at run time.
To run the multi-scene, single-frame simulation, perform the following steps:
-
Run the DIRSIG
multi_scene.jsim
file -
Load the resulting
demo-t0000-c0000.img
file in the image viewer.
Multi-Frame (video) Simulation
To run the multi-frame simulation, perform the following steps:
-
Run the DIRSIG
multi_frame.sim
file -
Load the resulting
demo-t0000-c0000.img
,demo-t0000-c0001.img
, etc. files in the image viewer.
Results
Single-Frame (Still) Simulation
The single-frame simulation produces a single image acquired approximately half way through the traffice simulation:

Multi-Scene, Single-Frame (Still) Simulation
The multi-scene, single-frame simulation should produce the same output as the single-frame simulation:

Multi-Frame (video) Simulation
The imaging instrument is setup to use the "file per capture" output schedule. As a result, the simulation produces 241 separate image files for the 241 captures. The video below was created from these 241 frames.