Main Content

Simulate RoadRunner Scenarios with MATLAB and Simulink

Develop MATLAB® and Simulink® behaviors, publish actor behavior, simulate behaviors in RoadRunner Scenario simulation, control simulation, and access simulation parameters

Automated Driving Toolbox™ provides a flexible framework for simulating scenarios RoadRunner scenarios with actors modeled in MATLAB and Simulink. In this framework, you can configure actors, define their behaviors, or create observers for scenario-level analysis:

  • Actors represent dynamic entities in a RoadRunner scenario, such as vehicles or pedestrians.

  • Behaviors define the logic that controls how an actor moves or reacts during simulation. You can author behaviors using MATLAB System objects or Simulink models.

  • Observers are special scenario-level analysis components which can read scenario states without modifying them during simulation. Unlike behaviors, observers exist only within MATLAB or Simulink and are not recognized by RoadRunner. The purpose of observers is to allow for custom computations, for example, visualization and runtime analysis of simulation data, such as detecting when vehicles exceed a speed threshold or get too close to each other.

This table outlines the roles of behaviors and observers, its purpose, workflow steps and implementation options:

Simulation RolePurpose and Workflow StepsGetting Started Examples
Observer

Use observers to only read scenario simulation states without modifying them and then perform runtime analysis of simulation data in MATLAB and Simulink

  • Author MATLAB System objects or Simulink models to define observers.

  • Add observers to the scenario.

Simulate RoadRunner Scenarios with Observers Modeled in MATLAB or Simulink

Behavior

Use actor behaviors to control actors during the simulation and also read the simulation states.

  • Author MATLAB System objects or Simulink models to define actor behavior.

  • Associate actor behavior in RoadRunner.

  • Optionally, publish the actor behavior.

  • Tune parameters defined in MATLAB or Simulink for RoadRunner simulations.

After setting up either an observer or an actor behavior, you can simulate the scenario using the RoadRunner user interface, or control simulations programmatically from MATLAB.

If you are using actor behaviors to cosimulate a scenario, you can log simulation data, inspect simulation results from the log, and replay the scenario simulation using the saved simulation log.

You can also store the scenario simulation data in ASAM Open Simulation Interface (OSI)® file format.

For an overview of cosimulating RoadRunner scenarios using MATLAB and Simulink, see Overview of Simulating RoadRunner Scenarios with MATLAB and Simulink.

Functions

expand all

ScenarioSimulationCreate, access, and control RoadRunner Scenario simulations from MATLAB (Since R2022a)
addActionAdd user-defined action in MATLAB actor interface (Since R2023a)
addEventAdd user-defined event in MATLAB actor interface (Since R2023a)
getGet value of scenario simulation parameter (Since R2022a)
loadLoad saved simulation log (Since R2023a)
reportDiagnostic Report information, warning, or error message during scenario simulation (Since R2022a)
saveSave simulation log to file for later use (Since R2023a)
setSet value of scenario simulation parameter (Since R2022a)
Simulink.ScenarioSimulation.findReturn scenario simulations or actors in current MATLAB session (Since R2022a)
addObserverAdd observer to scenario simulation (Since R2022a)
removeObserverRemove observer from scenario simulation (Since R2022a)
ActorSimulationAccess and modify runtime specifications of RoadRunner Scenario actor in MATLAB (Since R2022a)
ActorModelView static specifications of RoadRunner Scenario actor in MATLAB (Since R2022a)
sendEventSend event to scenario (Since R2022b)
receiveEventReceive event from scenario (Since R2023a)
convertToStructConvert actor to MATLAB structure (Since R2022a)
getGet scenario or static attribute of actor (Since R2022a)
getActionGet actions associated with actor (Since R2022a)
getAttributeGet run-time attribute of actor (Since R2022a)
setAttributeSet run-time attribute of actor (Since R2022a)
getAttribute Return static attribute of actor (Since R2022a)
reportDiagnostic Report information, warning, or error message during scenario simulation (Since R2022a)
Simulink.ActorSimulation.createMATLABStructCreate MATLAB structure for bus object for RoadRunner (Since R2024a)
Simulink.ActorSimulation.loadLoad built-in RoadRunner bus definitions into MATLAB workspace (Since R2024a)
SensorSimulationAdd sensors and access sensor data from RoadRunner Scenario simulation (Since R2023a)
addSensorsAdd sensors to vehicle actors in RoadRunner scenario (Since R2023a)
targetPosesGet positions and orientations of targets in sensor range from RoadRunner Scenario (Since R2023a)
laneBoundariesGet lane boundaries relative to host vehicle from RoadRunner Scenario (Since R2023a)
publishActorGenerate package for actor simulation (Since R2022a)
publishActorBehaviorGenerate proto file for actor simulation (Since R2022a)
publishCustomActionGenerate asset file for user-defined action (Since R2022b)
publishCustomEventGenerate asset file for user-defined event (Since R2023a)
ScenarioLogView RoadRunner Scenario simulation outcomes in MATLAB at any time step (Since R2022a)
getGet logged scenario simulation data (Since R2022a)
viewView logged scenario simulation data (Since R2024a)
openSimulationInterfaceStore RoadRunner Scenario simulation data in ASAM Open Simulation Interface (OSI) format (Since R2024b)
groundTruthAreaGround truth area centered at ego vehicle origin (Since R2025a)
startRoadRunnerSimulationStart RoadRunner Scenario simulation (Since R2024b)
writeWrite OSI data to binary file (Since R2024b)
getProtoMessageGet OSI protocol buffer (protobuf) message at each simulation step (Since R2024b)
sim3d.scenario.ActorBehaviorDefine RoadRunner actors that use Unreal Engine viewer visualization (Since R2023b)
onSimulationStartSpecify code to run at start of simulation (Since R2023b)
onSimulationStopSpecify code to run at end of simulation (Since R2023b)
onSimulationStep Specify code to run at each time step (Since R2023b)
matrix2transformConvert 4-by-4 pose matrix to translation, rotation, and scale vectors (Since R2023b)
transform2matrixConvert translation, rotation, and scale vectors to 4-by-4 pose matrix (Since R2023b)
ScenarioServicesPerform calculations on scene elements of RoadRunner Scenario in MATLAB (Since R2024b)
getGet calculations on scene elements of RoadRunner Scenario in MATLAB (Since R2024b)

Blocks

RoadRunner ScenarioDefine interface for Simulink actor model (Since R2022a)
RoadRunner Scenario ReaderReads selected topic from RoadRunner scenario (Since R2022a)
RoadRunner Scenario WriterWrite selected topic to RoadRunner scenario (Since R2022a)

Apps

Bird's-Eye ScopeVisualize sensor coverages, detections, and tracks

Topics

Set Up MATLAB Interface for Scenario Simulation

Add Observers to Scenario Simulation

Model Actor Behaviors for Scenario Simulation

Add Sensors to Scenario Simulation

Publish Actor Behavior, Custom Action and Events

Visualize Scenario in Unreal Engine 3D Viewer

Featured Examples