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.

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.


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

rrSim = createSimulation(rrApp);

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;

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.

modelName = 'rrScenarioSimWithSensors';

Create a SensorSimulation object. Specify the block paths for the radar, vision and lidar sensors in the model.

sensorSim = get(rrSim,"SensorSimulation");
visionSensorBlkPath = [modelName,'/Vision Detection Generator'];
radarSensorBlkPath = [modelName,'/Driving Radar Data Generator'];
lidarSensorBlkPath = [modelName,'/Lidar Point Cloud Generator'];

Add the three sensors to the ego vehicle using the addSensors function.

egoVehicleId = 1;

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. Then in the scope, click Find Signals to establish connection with the RoadRunner scenario and populate the signals to visualize.

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.


See Also





Related Topics