Main Content

Add Sensors to RoadRunner Scenario Using Simulink

Define sensor models in Simulink®, and add them to vehicle actors in a RoadRunner Scenario. Then, obtain ground truth measurements from RoadRunner Scenario, process them into detections in Simulink for visualization.

In this example you add a radar, a vision sensor, and a lidar to a vehicle in a RoadRunner scenario.

Set Up RoadRunner Scenario — Simulink Interface

Configure your RoadRunner installation and project folder properties. Open the RoadRunner app.

rrInstallationPath = "C:\Program Files\RoadRunner R2023b\bin\win64";
rrProjectPath = "D:\RR\TestProjects";

s = settings;
s.roadrunner.application.InstallationFolder.PersonalValue = rrInstallationPath;
rrApp = roadrunner(rrProjectPath);

To open the scenario this example uses, you must add these files from the example folder to your RoadRunner project folder:

  1. straightCurvedFourLaneRoad.rrscene — RoadRunner scene file that describes the four lane highway.

  2. SensorDerectionSimulation.rrscenario — RoadRunner scenario file that describes actors and their trajectories on the four lane highway scene.

  3. SensorIntegration.rrbehavior.rrmeta — Behavior file that associates the sensor detection processing and visualization behavior using Simulink, to the ego vehicle in the RoadRunner scenario.

copyfile("straightCurvedFourLaneRoad.rrscene",fullfile(rrProjectPath,"Scenes/"));
copyfile("SensorDetectionSimulation.rrscenario",fullfile(rrProjectPath,"Scenarios/"))
copyfile("SensorIntegration.rrbehavior.rrmeta",fullfile(rrProjectPath,"Assets","Behaviors/"))

Open the scenario and create a ScenarioSimulation object to connect Simulink with the RoadRunner Scenario.

openScenario(rrApp,"SensorDetectionSimulation")
rrSim = createSimulation(rrApp);
Connection status: 1
Connected to RoadRunner Scenario server on localhost:55322, with client id {1b96b35c-bb9a-4141-ba14-d0a583451ee0}

Specify the step size for the RoadRunner scenario simulation. The Simulink model also uses the same step size. Units are in seconds.

simStepSize = 0.1;
set(rrSim,"StepSize",simStepSize);

Inspect Simulink Model and Simulate Scenario

The Simulink model rrScenarioSimWithSensors configures sensor models for the vision, radar and lidar sensors using the Vision Detection Generator, Driving Radar Data Generator and Lidar Point Cloud Generator blocks respectively. The model reads ground truth data from the scenario and processes that into detections and visualizes the detections. It also reads the path defined for the ego vehicle from the RoadRunner Scenario, implements the path follower logic and controls the ego vehicle motion along the path.

Load the bus definitions and open the model. Note that the lidar sensor model block does not require any ground-truth target pose inputs.

load("busDefinitionsForRRSim.mat")
modelName = 'rrScenarioSimWithSensors';
open_system(modelName)

To visualize the scenario and sensor detections, use the Bird'sEye Scope app. On the Simulink toolstrip, under Review Results, click Bird's-Eye Scope.

Start the scenario Simulation. The model visualizes the 3D point cloud using the Point Cloud Viewer block during the simulation. In Bird's-Eye Scope, you can visualize the 2D point cloud, object detections and lane detections alongside ground truth values.

set(rrSim,"SimulationCommand","Start")

See Also

Apps

Blocks

Functions

Objects

Related Topics