Test Open-Loop ADAS Algorithm Using Driving Scenario

This example shows how to test an open-loop ADAS (advanced driver assistance system) algorithm in Simulink®. To test the scenario, you use a driving scenario that was saved from the Driving Scenario Designer app. In this example, you read in a scenario using a Scenario Reader block, and then visually verify the performance of a simple sensor fusion algorithm on the Bird's-Eye Scope.

Before beginning this example, add the example file folder to the MATLAB® search path.


Inspect Driving Scenario

This example uses a driving scenario that is based on one of the prebuilt scenarios that you can access through the Driving Scenario Designer app. For more details on these scenarios, see Generate Synthetic Detections from a Prebuilt Driving Scenario.

Open the scenario file in the app.


Click Run to simulate the scenario. In this scenario, the ego vehicle travels north and goes straight through an intersection. Meanwhile, a vehicle coming from the left side of the intersection turns left and ends up in front of the ego vehicle.

In the model used in this example, you generate detections of the other vehicle and the lane boundaries of the ego vehicle. Although this scenario includes a vision sensor defined in the app, the Scenario Reader block does not support reading sensor data from scenarios. Therefore, sensors must be defined in the model. If you read a scenario file containing sensor data, the block ignores this sensor data.

Inspect Model

In the model, a Scenario Reader block reads the actors and roads from the scenario file and outputs the non-ego actors and lane boundaries. Open the model.


In the Scenario Reader block, the Driving scenario file name parameter specifies the name of the scenario file. You can specify a scenario file that is on the MATLAB search path, such as the scenario file used in this example, or the full path to a scenario file.

The Scenario Reader block outputs the poses of the non-ego actors in the scenario and the left-lane and right-lane boundaries of the ego vehicle. To output all lane boundaries of the road on which the ego vehicle is traveling, select the corresponding option for the Lane boundaries to output parameter.

The actors are passed to a Radar Detection Generator and a Vision Detection Generator block, and the lane boundaries are passed to the Vision Detection Generator block. These sensor blocks produce synthetic detections from the scenario. The outputs are in vehicle coordinates, where:

  • The X-axis points forward from the ego vehicle.

  • The Y-axis points to the left of the ego vehicle.

  • The origin is located at the center of the rear axle of the ego vehicle.

If a scenario has multiple ego vehicles, in the Scenario Reader block, set the Coordinate system of outputs parameter to World coordinates instead of Vehicle Coordinates. In the world coordinate system, the actors and lane boundaries are in the world coordinates of the driving scenario. The Bird's-Eye Scope does not support visualization of world coordinates.

In this model, the Scenario Reader block reads the ego vehicle from the scenario file (the Source of ego vehicle parameter is set to Scenario file). Because this algorithm is open-loop, the ego vehicle behavior does not change as the simulation advances. Therefore, the Source of ego vehicle parameter is set to Scenario file, and the block reads the predefined ego vehicle pose and trajectory from the scenario. For vehicle controllers and other closed-loop algorithms, set the Source of ego vehicle parameter to Input port. With this option, you specify an ego vehicle that is defined in the model as an input to the Scenario Reader block. For an example, see Test Closed-Loop ADAS Algorithm Using Driving Scenario.

Visually Verify Algorithm

To visualize the scenario and the object and lane boundary detections, use the Bird's-Eye Scope. From the Simulink model toolbar, click the Bird's-Eye Scope button. Then, click Find Signals, and run the simulation. The vision sensor correctly generates detections for the non-ego actor and the lane boundaries.

Update Simulation Settings

This model uses the default simulation stop time of 10 seconds. However, because the scenario is only about 5 seconds long, the simulation continues to run in the Bird's-Eye Scope even after the scenario has ended. To synchronize the simulation and scenario stop times, in the Simulink model toolbar, set the simulation stop time to 5.2 seconds, which is the exact stop time of the app scenario. After you run the simulation, the app displays this value in the bottom-right corner of the scenario canvas.

If the simulation runs too fast in the Bird's-Eye Scope, you can slow down the simulation by using simulation pacing. From the Simulink model toolbar, select Simulation > Pacing Options. Select the Enable pacing to slow down simulation check box and decrease the simulation time to slightly less than 1 second per wall-clock second, such as 0.8 seconds. Then, rerun the simulation in the Bird's-Eye Scope.

When you are done with this example, remove the example file folder from the MATLAB search path.


See Also

| | | |

Related Topics