This model shows how to test a closed-loop ADAS (advanced driver assistance system) algorithm in Simulink®. In a closed-loop ADAS algorithm, the ego vehicle is controlled by changes in its scenario environment as the simulation advances.
To test the scenario, you use a driving scenario that was saved from the Driving Scenario Designer app. In this model, you read in a scenario using a Scenario Reader block, and then visually verify the performance of the algorithm, an autonomous emergency braking (AEB) system, on the Bird's-Eye Scope.
This example uses a driving scenario that is based on one of the prebuilt Euro NCAP test protocol scenarios that you can access through the Driving Scenario Designer app. For more details on these scenarios, see Euro NCAP Driving Scenarios in Driving Scenario Designer.
Open the scenario file in the app.
Click Run to simulate the scenario. In this scenario, the ego vehicle collides with a pedestrian child who is crossing the street.
In the model used in this example, you use an AEB sensor fusion algorithm to detect the pedestrian child and test whether the ego vehicle brakes in time to avoid a collision.
The model implements the AEB algorithm described in the Autonomous Emergency Braking with Sensor Fusion example and is configured to simulate a pedestrian collision scenario. Open the model.
A Scenario Reader block reads the non-ego actors and roads from the specified scenario file and outputs the non-ego actors. The ego vehicle is passed into the block through an input port.
The Scenario Reader block is located in the Vehicle Environment > Actors and Sensor Simulation subsystem. Open this subsystem.
open_system('AEBTestBenchExample/Vehicle and Environment/Actors and Sensor Simulation')
In the Scenario Reader block, the Driving Scenario Designer 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. Alternatively, you can specify a
object by setting Source of driving scenario to
From workspace and then setting MATLAB or model workspace variable name to the name of a valid
drivingScenario object workspace variable. In closed-loop simulations, specifying the
drivingScenario object is useful because it enables you finer control over specifying the initial position of the ego vehicle in your model.
The Scenario Reader block outputs the poses of the non-ego actors in the scenario. These poses are passed to vision and radar sensors, whose detections are used to determine the behavior of the AEB controller.
The actor poses are output 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.
Although this scenario includes a predefined ego vehicle, the Scenario Reader block is configured to ignore this ego vehicle definition. Instead, the ego vehicle is defined in the model and specified as an input to the Scenario Reader block (the Source of ego vehicle parameter is set to
Input port). As the simulation advances, the AEB algorithm determines the pose and trajectory of the ego vehicle. If you are developing an open-loop algorithm, where the ego vehicle is predefined in the driving scenario, set the Source of ego vehicle parameter to
Scenario. For an example, see Test Open-Loop ADAS Algorithm Using Driving Scenario.
To visualize the scenario, use the Bird's-Eye Scope. From the Simulink toolstrip, under Review Results, click Bird's-Eye Scope. Then, in the scope, click Find Signals and run the simulation. With the AEB algorithm, the ego vehicle brakes in time to avoid a collision.