Scenario Studio

The Scenario Studio of SMARTS is a stand alone package (sstudio) that supports flexible and expressive scenario specification. If you have access to sstudio you can use it to generate traffic with different traffic vehicle numbers and routes, and agent missions.

Generate traffic

traffic_actor = TrafficActor(name="car", speed=Distribution(sigma=0.2, mean=0.8),)

# add 10 social vehicles with random routes.
traffic = Traffic(
        # generate flows last for 10 hours
        Flow(route=RandomRoute(), begin=0, end=10 * 60 * 60, rate=25, actors={traffic_actor: 1},)
        for i in range(10)

gen_traffic(scenario_path, traffic, name="all", output_dir=scenario_path, seed=seed_, overwrite=True)

traffic_actor is used as a spec for traffic actors (e.g. Vehicles, Pedestrians, etc). The defaults provided are for a car. You can specify acceleration, deceleration, speed distribution, imperfection distribution and other configs for social cars. See more config for TrafficActor in smarts.sstudio.types.

Flow can be used to generate repeated vehicle runs on the same route, you can config vehicle route and depart rate here.

After the gen_traffic function is run, a dir named “traffic” containing vehicle config xmls will be created under output_dir.

This a short file example of how it works:

from pathlib import Path

from smarts.sstudio import types as t
from smarts.sstudio import gen_traffic, gen_bubbles, gen_missions

scenario = str(Path(__file__).parent)

# Definition of a traffic flow
traffic = t.Traffic(
                begin=("west", lane_idx, 10),
                end=("east", lane_idx, -10),
                t.TrafficActor("car"): 1,
        for lane_idx in range(3)

# The call to generate traffic
gen_traffic(scenario, traffic, name="basic")

        t.Mission(t.Route(begin=("west", 0, 0), end=("east", 0, "max"))),

We just run a file as a regular Python script to generate scenarios:

python3 scenario/

IMPORTANT: if you want to train model on one scenario, remember to set the end time of flow larger or equal to your expected training time, since SMARTS will continue the flow after each reset call. However, if there are multiple scenarios to train for one worker, you can relax this restriction since after the scenario change, the flow will also be reset to the beginning time.

Generate missions

The Scenario Studio of SMARTS also allows generation of missions for ego agents and social agents. These missions are similar to routes for social vehicles. When we run gen_missions, “missions.rou.xml” file will be created under the output dir:

# agent missions
    missions=[Mission(Route(begin=("edge0", 0, "random"), end=("edge1", 0, "max"),)),],

Generate friction map

The Scenario Studio of SMARTS also allows generation of friction map which consists of a list of surface patches for ego agents and social agents. These surface patches are using PositionalZone as in the case of bubbles. When we run gen_friction_map, “friction_map.pkl” file will be created under the output dir:

# friction map
    surface_patches=[RoadSurfacePatch(PositionalZone(pos=(153, -100), size=(2000, 6000)),

Edit SUMO maps

To enrich your training datasets, you can edit your own map through [SUMO’s NETEDIT]( and export it in a format. And if you have an additional file you wish to turn into a map you can use the conversion utility like this:

python3 -m smarts.sstudio.sumo2mesh dataset_public/2lane_sharp/ dataset_public/2lane_sharp/map.glb --format=glb
python3 -m smarts.sstudio.sumo2mesh dataset_public/2lane_sharp/ dataset_public/2lane_sharp/map.egg --format=egg

Create map

First, to start netedit, run the following on terminal:


On the top left bar, “file” -> “new network” to create a new map.

Use shortcut key “e” to change to edge mode. Click “chain” and “two-way” icons located on the far right of top tool bar, shown in the image below:


Then click on map to start creating new edges and lanes.

Edit existing map

“file” -> “Open Network…” to open an existing map.

Click on the inspect icon to enable inspect mode


Click on any edge to inspect detail and modify properties.


The selected block is an edge with id “gneE72”. It contains 3 lanes with lane index 0, 1, 2.

To modify the properties, for example change the number of lanes to 2 lanes by changing 3 to 2 on the “numLanes” field, and press “enter” to make the change. Then press “ctrl+s” to save. Finally, make sure to rebuild the scenario.

scl scenario build --clean <path-to-scenario-folder>

To create custom connections between edges, first click the following icon on top bar:


The first lane you select would be the source lane, highlighted in blue. Then select other lanes as target lanes to connect to.


Create traffic routes

For example, using the following Route definition:

Route(begin=("gneE72", 0, "random"), end=("edge2", 1, "max"),)

begin=(“gneE72”, 0, “random”) defines the route to start on edge with id gneE72 and at lane index 0, which is the same lane as the selected lane in the figure above. “random” here specifies the amount of offset on the lane to start the route.