autonomous emergency braking with sensor fusion -凯发k8网页登录
this example shows how to implement autonomous emergency braking (aeb) using a sensor fusion algorithm.
introduction
autonomous emergency braking is an advanced active safety system that helps drivers avoid or mitigate collisions with other vehicles.
the european new car assessment programme (euro ncap®) has included the aeb city and interurban systems in its safety rating since 2014. the euro ncap continues to promote aeb systems for protecting vulnerable road users, such as pedestrians and cyclists.
today, aeb systems mostly use radar and vision sensors to identify potential collision partners ahead of the ego vehicle. these systems often require multiple sensors to obtain accurate, reliable, and robust detections while minimizing false positives. to combine the data from various sensors, multiple sensor aeb systems use sensor fusion technology. this example shows how to implement aeb using a sensor fusion algorithm. in this example, you:
explore the test bench model — the model contains the sensors and environment, sensor fusion and tracking, decision logic, controls, and vehicle dynamics.
model the aeb controller — use simulink® and stateflow® to integrate a braking controller for braking control and a nonlinear model predictive controller (nlmpc) for acceleration and steering controls.
simulate the test bench model — you can configure the test bench model for different scenarios based on euro ncap test protocols.
generate c code — generate c code and test the software-in-the-loop(sil) simulation for the sensor fusion, decision logic, and control algorithms.
explore additional scenarios — these scenarios test the system under additional conditions.
explore test bench model
in this example, you use a system-level simulation test bench model to explore the behavior of the controller for an aeb system.
to explore the test bench model, open a working copy of the project example files. matlab® copies the files to an example folder so that you can edit them.
addpath(fullfile(matlabroot,"toolbox","driving","drivingdemos")) helperdrivingprojectsetup("autonomousemergencybraking.zip",workdir=pwd);
to reduce command window output, turn off model predictive controller (mpc) update messages.
mpcverbosity("off");
open the system-level simulation test bench model.
open_system("aebtestbench");
opening this model runs the helperslaebsetup
helper function, which initializes the scenario using the drivingscenario
object in the base workspace. it runs the default test scenario, scenario_25_aeb_pedestrianturning_nearside_10kph
, that contains an ego vehicle and a pedestrian. this setup function also configures the controller design parameters, vehicle model parameters, and simulink bus signals required for defining the inputs and outputs for the aebtestbench
model.
the test bench model contains these modules:
sensors and environment
— subsystem that specifies the road, actors, camera, and radar sensor used for simulation.sensor fusion and tracking
— algorithm model that fuses vehicle detections from the camera to those from the radar sensor.aeb decision logic
— algorithm model that specifies the lateral and longitudinal decision logic that provides most important object (mio) related information and ego vehicle reference path information to the controller.aeb controller
— algorithm model that specifies the steering angle and acceleration controls.vehicle dynamics
— subsystem that specifies the dynamic model of the ego vehicle.metrics assessment
— subsystem that assesses system-level behavior.
the vehicle dynamics
subsystem models the ego vehicle using a bicycle model, and updates its state using commands received from the aeb controller
model. for more details on the vehicle dynamics
subsystem, see the highway lane following example.
to plot synthetic sensor detections, tracked objects, and ground truth data, use the . the bird's-eye scope is a model-level visualization tool that you can open from the simulink model toolbar. on the simulation tab, under review results, click bird's-eye scope. after opening the scope, click update signals to set up the signals. the dashboard panel displays these ego vehicle parameters: velocity, acceleration, aeb status, forward collision warning (fcw) status, and safety status.
the sensors and environment
subsystem configures the road network, defines target actor trajectories, and synthesizes sensors. open the sensors and environment
subsystem.
open_system("aebtestbench/sensors and environment")
the subsystem specifies the scenario and sensors of the ego vehicle using these blocks:
the block reads the
drivingscenario
object from the base workspace, and then reads the actor data from that object. the block uses the ego vehicle information to perform a closed-loop simulation, and then outputs the ground truth information of the scenario actors and their trajectories in ego vehicle coordinates.
the block generates radar sensor data from a driving scenario.
the block generates detections and measurements from a camera mounted on the ego vehicle.
the
reference path info
block provides a predefined reference trajectory for ego vehicle navigation. the reference path in the block is created by using thehelperegorefpathcreator
helper function.
the sensor fusion and tracking
algorithm model processes vision and radar detections and generates the position and velocity of the tracks relative to the ego vehicle. open the aebsensorfusion
algorithm model.
open_system("aebsensorfusion");
the aebsensorfusion
model contains these blocks:
detection concatenation — combines the vision and radar detections onto a single output bus.
multi-object tracker — performs sensor fusion and outputs the tracks of stationary and moving objects. these tracks are updated at prediction time, specified by a digital clock block in the
sensors and environment
subsystem.
the aebdecisionlogic
algorithm model specifies lateral and longitudinal decisions based on the predefined ego reference path and tracks. open the aebdecisionlogic
algorithm model.
open_system("aebdecisionlogic");
the aeb decision logic
algorithm model contains these blocks:
ego reference path generator
— estimates the curvature, relative yaw angle, and lateral deviation of the ego vehicle using the current ego position and the reference path information fromsensors and environment
subsystem. the block also determines if the ego vehicle reached its goal.
find lead car
— finds the lead car, which is the mio in front of the ego vehicle in the same lane. this block outputs the relative distance and relative velocity between the ego vehicle and the mio.
model aeb controller
the aebcontroller
algorithm model implements the main algorithm to specify the longitudinal and lateral controls. open the aebcontroller
algorithm model.
open_system("aebcontroller");
the aebcontroller
model contains these subsystems:
controller mode selector
— releases the vehicle accelerator when aeb is activated.
nlmpc controller
— reads the ego longitudinal velocity, curvature sequence, relative yaw angle, and lateral deviation, and then outputs the steering angle and acceleration for the ego vehicle. open thenlmpc controller
referenced subsystem.
open_system("aebcontroller/nlmpc controller")
this example uses a nonlinear mpc controller with a prediction model that has seven states, three output variables, and two manipulated variables.
states
lateral velocity
yaw rate
longitudinal velocity
longitudinal acceleration
lateral deviation
relative yaw angle
output disturbance of relative yaw angle
output variables
longitudinal velocity
lateral deviation
sum of the yaw angle and yaw angle output disturbance
manipulated variables
acceleration
steering
the controller models the product of the road curvature and the longitudinal velocity as a measured disturbance. the prediction horizon and control horizon are specified by the helperslaebsetup
function. the state function for the nonlinear plant model and its jacobian are specified by helpernlmpcstatefcn
function and helpernlmpcstatejacfcn
function, respectively. the continuous-time prediction model for the nlmpc controller uses the output equation defined in the helpernlmpcoutputfcn
function. the constraints for the manipulated variables, and the weights in the standard mpc cost function are defined in the helperslaebsetup
function when it creates the nlmpc
object. in this example, the nlmpc controller does not support zero initial velocity for the ego vehicle.
in this example, an extended kalman filter (ekf) provides state estimation for the seven states. the state transition function for the ekf is defined in the helperekfstatefcn
function, and the measurement function is defined in helperekfmeasfcn
function. for more details on designing a nonlinear mpc controller, see (model predictive control toolbox).
the braking controller
subsystem implements the fcw and aeb control algorithm based on a stopping time calculation approach.
stopping time refers to the time from when the ego vehicle first applies its brakes, , to when it comes to a complete stop. you can find stopping time by using this equation:
,
where is the velocity of the ego vehicle.
the fcw system alerts the driver about an imminent collision with a lead vehicle. the driver is expected to react to the alert and apply the brake with a delay time, .
the total travel time of the ego vehicle before colliding with the lead vehicle can be expressed as:
when the time-to-collision (ttc) with the lead vehicle is less than , the fcw alert activates.
if the driver fails to apply the brake in time, such as due to distraction, the aeb system acts independently of the driver to avoid or mitigate the collision. the aeb systems typically apply cascaded braking, which consists of multi-stage partial braking followed by full braking [1].
open the braking controller
subsystem.
open_system("aebcontroller/braking controller")
the braking controller
subsystem contains these blocks:
ttccalculation
— calculates the ttc using the relative distance and velocity of the lead vehicle.stoppingtimecalculation
— calculates stopping times for the fcw, first- and second-stage partial braking (pb), and full braking (fb).aeblogic
— state machine that compares the ttc with the calculated stopping times to determine the fcw and aeb activations.
aeb controller
outputs the steering angle and acceleration commands that determine whether to accelerate or decelerate.
explore metrics assessment
the metrics assessment
subsystem enables system-level metric evaluations using the ground truth information from the scenario. open the metrics assessment
subsystem.
open_system("aebtestbench/metrics assessment");
in this example, you can assess the aeb system using these metrics:
check collision
— verifies whether the ego vehicle collide with the target actor at any point during the simulation.check safety
— verifies that the ego vehicle is within the prescribed thresholdsafetygoal
throughout the simulation. use thehelperaebsetup
post-load callback function to definesafetygoal
.
simulate aeb model
simulate the test bench model with scenarios based on euro ncap test protocols. euro ncap offers a series of test protocols that test the performance of aeb systems in car-to-car rear (ccr) [2] and vulnerable road user (vru) [3] scenarios.
this example uses a closed-loop simulation of these two scenarios. you then analyze the results.
scenario_23_aeb_pedestrianchild_nearside_50width
scenario_25_aeb_pedestrianturning_nearside_10kph
simulate scenario_23_aeb_pedestrianchild_nearside_50width
configure the aebtestbench
model for the scenario_23_aeb_pedestrianchild_nearside_50width
scenario. in this scenario, a child pedestrian is crossing from the right side of the road to the left. the ego vehicle, which is traveling forward, collides with the child pedestrian. at collision time, the pedestrian is 50% of the way across the width of the ego vehicle.
helperslaebsetup(scenariofcnname="scenario_23_aeb_pedestrianchild_nearside_50width");
the test bench model reads the drivingscenario
object and runs a simulation.
simulate the model for 0.1 seconds.
sim("aebtestbench",stoptime="0.1"); % simulate for 0.1 seconds
the bird's-eye scope shows the ground truth data of the vehicles and child pedestrian. it also shows radar detections, vision detections, and objects tracked by the multi-object tracker. at a simulation time of 0.1 seconds, the camera and radar sensor do not detect the child pedestrian, as other the vehicles obstruct their line of sight.
simulate the model for 2.8 seconds.
sim("aebtestbench",stoptime="2.8"); % simulate for 2.8 seconds
update the bird's-eye scope. notice that the sensor fusion and tracking algorithm detects the child pedestrian as the mio, and that the aeb system applies the brake to avoid a collision.
the dashboard panel shows that the aeb system applies cascaded brake to stop the ego vehicle before the collision point. the color of the aeb indicator specifies the level of aeb activation.
gray — aeb is not activated.
yellow — first stage partial brake is activated.
orange — second stage partial brake is activated.
red — full brake is activated.
simulate the scenario to the end. then, plot the results by using the helperplotaebresults
helper function.
sim("aebtestbench"); % simulate to end of scenario helperplotaebresults(logsout,scenariofcnname);
ttc vs. stopping time — compares the time-to-collision and the stopping times for the fcw, first stage partial brake, second stage partial brake, and full brake, respectively.
fcw and aeb status — displays the fcw and aeb activation status based on the comparison results from the first plot.
ego car acceleration — shows the acceleration of the ego vehicle.
ego car yaw and yaw rate — shows the yaw and yaw rate of the ego vehicle.
ego car velocity — shows the velocity of the ego vehicle.
headway — shows the headway between the ego vehicle and the mio.
in the first 2 seconds, the ego vehicle speeds up to reach its specified velocity. at 2.3 seconds, the sensors first detect the child pedestrian. immediately after the detection, the fcw system activates.
at 2.4 seconds, the aeb system applies the first stage of the partial brake, and the ego vehicle starts to slow down.
when the ego vehicle comes to a complete stop at 4.1 seconds, the headway between the ego vehicle and the child pedestrian is about 2.1 meters. the aeb system fully avoids a collision in this scenario.
simulate with scenario_25_aeb_pedestrianturning_nearside_10kph
configure the aebtestbench
model for the scenario_25_aeb_pedestrianturning_nearside_10kph
scenario. in this scenario, the ego vehicle makes a right turn at an intersection, and collides with an adult pedestrian crossing the road from the opposite side of the intersection. at the time of collision, the pedestrian is 50% of the way across the width of the frontal structure of the ego vehicle.
helperslaebsetup(scenariofcnname="scenario_25_aeb_pedestrianturning_nearside_10kph");
simulate the model and plot the results.
sim("aebtestbench");
helperplotaebresults(logsout,scenariofcnname);
for the first 9.5 seconds, the ego vehicle travels at its specified velocity. at 9.5 seconds, the sensors first detect the pedestrian in the intersection, after the ego vehicle has turned right. despite the short headway between the ego vehicle and the pedestrian, the aeb system applies only the first partial brake due to the low velocity of the ego vehicle.
generate c code
if you have the licenses for simulink coder™ and embedded coder™, you can generate ready-to-deploy code for algorithm models such as aeb sensor fusion, aeb decision logic, and aeb controller for an embedded real-time (ert) target.
you can verify that the compiled c code behaves as expected using software-in-the-loop simulation. to simulate the referenced models in sil mode, enter these commands.
set_param("aebtestbench/sensor fusion and tracking", ... simulationmode="software-in-the-loop (sil)") set_param("aebtestbench/aeb decision logic", ... simulationmode="software-in-the-loop (sil)") set_param("aebtestbench/aeb controller", ... simulationmode="software-in-the-loop (sil)")
when you run the aebtestbench
model, code is generated, compiled, and executed for the aebsensorfusion
, aebdecisionlogic
and aebcontroller
models. this enables you to test the behavior of the compiled code through simulation.
explore additional scenarios
in this example, you have explored the system behavior for the scenario_25_aeb_pedestrianturning_nearside_10kph
and scenario_23_aeb_pedestrianchild_nearside_50width
scenarios. this example provides additional scenarios that are compatible with the aebtestbench
model:
scenario_01_aeb_bicyclist_longitudinal_25width
scenario_02_aeb_bicyclist_longitudinal_50width
scenario_03_aeb_bicyclist_longitudinal_75width
scenario_04_aeb_ccrb_2_initialgap_12m
scenario_05_aeb_ccrb_2_initialgap_40m
scenario_06_aeb_ccrb_6_initialgap_12m
scenario_07_aeb_ccrb_6_initialgap_40m
scenario_08_aeb_ccrm_50overlap
scenario_09_aeb_ccrm__50overlap
scenario_10_aeb_ccrm_75overlap
scenario_11_aeb_ccrm__75overlap
scenario_12_aeb_ccrm_100overlap
scenario_13_aeb_ccrs_50overlap
scenario_14_aeb_ccrs__50overlap
scenario_15_aeb_ccrs_75overlap
scenario_16_aeb_ccrs__75overlap
scenario_17_aeb_ccrs_100overlap
scenario_18_aeb_pedestrian_farside_50width
scenario_19_aeb_pedestrian_longitudinal_25width
scenario_20_aeb_pedestrian_longitudinal_50width
scenario_21_aeb_pedestrian_nearside_25width
scenario_22_aeb_pedestrian_nearside_75width
scenario_23_aeb_pedestrianchild_nearside_50width
scenario_24_aeb_pedestrianturning_farside_10kph
scenario_25_aeb_pedestrianturning_nearside_10kph
[default]scenario_26_aeb_ccftap_vut_10kph_gvt_30kph
these scenarios have been created using the driving scenario designer app, and then exported to scenario files. you can configure the aebtestbench
model and workspace to simulate these scenarios using the helperslaebsetup
function. for example, to configure the simulation for the scenario_01_aeb_bicyclist_longitudinal_25width
scenario, enter this command.
helperslaebsetup(scenariofcnname="scenario_01_aeb_bicyclist_longitudinal_25width");
when you are finished with this example, enable mpc update messages once again.
mpcverbosity("on");
references
[1] hulshof, wesley, iain knight, alix edwards, matthew avery, and colin grover. "autonomous emergency braking test results." in proceedings of the 23rd international technical conference on the enhanced safety of vehicles (esv) , paper number 13-0168. seoul, korea: esv conference, 2013.
[2] european new car assessment programme (euro ncap). test protocol – _aeb systems . version 2.0.1. euro ncap, november, 2017.
[3] european new car assessment programme (euro ncap). test protocol – aeb vru systems. version 2.0.2. euro ncap, november, 2017.
see also
apps
blocks
- (vehicle dynamics blockset) | |
objects
- |