Traffic Simulation in CARLA

Traffic simulation is integral to the accurate and efficient training and testing of autonomous driving stacks. CARLA provides a number of different options to simulate traffic and specific traffic scenarios. This section is an overview of the options available to help decide which is the best fit for your use case.


Scenario Runner and OpenScenario

Scenario Runner provides predefined traffic scenarios out of the box and also allows users to define their own scenarios using either Python or the OpenSCENARIO 1.0 standard.

The primary use of OpenSCENARIO is the description of complex maneuvers that involve multiple vehicles. Users can see which features of OpenSCENARIO are supported by Scenario Runner here. These features include Maneuvers, Actions, Conditions, Stories and the Storyboard.

Scenario Runner has to be installed separately from the main CARLA package.

Useful for:

  • Creating complex traffic scenarios and routes to prepare AD agents for evaluation in the CARLA leaderboard.
  • Defining bespoke metrics that can be run against recordings of the scenario simulation, foregoing the need to run simulations repeatedly.

Traffic Manager

Traffic Manager is a module within CARLA that controls certain vehicles in a simulation from the client side. Vehicles are registered to Traffic Manager via the carla.Vehicle.set_autopilot method or command.SetAutopilot class. Control of each vehicle is managed through a cycle of distinct stages which each run on a different thread.

Useful for:

  • Populating a simulation with realistic urban traffic conditions.
  • Customizing traffic behaviours to set specific learning circumstances.
  • Developing phase-related functionalities and data structures while improving computational efficiency.

Scenic

Scenic is a domain-specific probabilistic programming language for modeling the environments of cyber-physical systems like robots and autonomous cars. Scenic provides an specialized domain to facilitate execution of Scenic scripts on the CARLA simulator.

Scenic scenario definitions are easy to read and construct. A tutorial to create a simple scenario is provided here.

Useful for:

  • Generating multiple, diverse scenarios with a single scenario definition.
  • Defining probabilistic policies for dynamic agents to take actions over time in response to the state of the world.

SUMO

SUMO is an open source, microscopic, multi-modal traffic simulation. In SUMO, each vehicle is modelled explicitly, has its own route, and moves individually through the network. Simulations are deterministic by default but there are various options for introducing randomness.

CARLA provides a co-simulation feature with SUMO that allows distribution of tasks between the two simulators. Vehicles can be spawned in CARLA through SUMO, and managed by SUMO much as the Traffic Manager would do.

Useful for:

  • Exploitation of the capabilities of both CARLA and SUMO in one package.

If you have any doubts about the different options available to simulate traffic in CARLA, feel free to post in the forum or in Discord.