主要内容

Traffic Light Negotiation

此示例显示了如何设计和测试决策逻辑,以在交叉路口协商交通信号灯。

Introduction

谈判交通信号灯的决策逻辑是自动驾驶应用程序的基本组成部分。决策逻辑必须对交通信号灯和周围车辆状态等输入的反应。然后,决策逻辑为控制器提供所需的速度和路径。由于交通信号灯交叉点对测试很危险,因此模拟此类驾驶场景可以洞悉决策逻辑和控制器的相互作用。

This example shows how to design and test the decision logic for negotiating a traffic light. The decision logic in this example reacts to the state of the traffic light, distance to the traffic light, and distance to the closest vehicle ahead. In this example, you will:

  1. 探索测试工作台模型: The model contains the traffic light sensors and environment, traffic light decision logic, controls, and vehicle dynamics.

  2. Model the traffic light decision logic: The traffic light decision logic arbitrates between a lead vehicle and an upcoming traffic light. It also provides a reference path for the ego vehicle to follow at an intersection in the absence of lanes.

  3. Simulate a left turn with traffic light and a lead vehicle:该模型被配置为测试交通信号灯决策逻辑与自我车辆的控制之间的相互作用,同时在存在铅车的情况下接近交叉路口。

  4. Simulate a left turn with traffic light and cross traffic: The model is configured to test the interactions between the traffic light decision logic and controls of the ego vehicle when there is cross traffic at the intersection.

  5. Explore other scenarios: These scenarios test the system under additional conditions.

您可以应用本示例中使用的建模模式来测试自己的决策逻辑和控件以协商交通信号灯。

Explore Test Bench Model

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('TrafficLightNegotiation.zip','workDir', pwd);

要探索交通信号灯协商系统的行为,请打开系统的仿真测试基准模型。

open_system(“交通灯”);

Opening this model runs thehelperSLTrafficLightNegotiationSetupscript that initializes the road scenario using thedrivingScenario基本工作区中的对象。它运行默认测试方案,方案_02_tln_left_turn_with_cross_over_vehicle, that contains an ego vehicle and two other vehicles. This setup script also configures the controller design parameters, vehicle model parameters, and Simulink® bus signals required for defining the inputs and outputs for the交通点式测试台模型。

测试工作台模型包含以下子系统:

  1. 传感器和环境:建模交通灯传感器,道路网络,车辆以及用于仿真的相机和雷达传感器。

  2. Traffic Light Decision Logic:在交叉路口的交通信号灯和其他铅车辆或交叉车辆之间进行仲裁。

  3. 泳道跟随控制器: Generates longitudinal and lateral controls.

  4. 车辆动力学:使用A模型自我车辆Bicycle Model使用从Lane Following Controller子系统。

  5. Visualization: Plots the world coordinate view of the road network, vehicles, and the traffic light state during simulation.

TheLane Following Controller参考模型和车辆动力学子系统从高速公路车道跟随example. This example focuses on the传感器和环境andTraffic Light Decision Logic子系统。

The传感器和环境subsystem configures the road network, defines target vehicle trajectories, and synthesizes sensors. Open the传感器和环境子系统。

open_system(“交通点燃的测试箱/传感器和环境”);

The scenario and sensors on the ego vehicle are specified by the following parts of the subsystem:

  • TheScenario Readerblock is configured to take in ego vehicle information to perform a closed-loop simulation. It outputs ground truth information of lanes and actors in ego vehicle coordinates. This block reads thedrivingScenarioobject variable,设想, from the base workspace, which contains a road network compatible with the交通点式测试台模型。

Plot the road network provided by the scenario.

hfigscenario =图('位置',[1 1 800 600]);情节(场景,'Parent', axes(hFigScenario));

This default scenario has one intersection with an ego vehicle, one lead vehicle, and one cross-traffic vehicle.

关闭图。

关闭(hfigscenario);

TheTracking and Sensor Fusion子系统融合了从Driving Radar Data Generatorand视觉检测发生器blocks by using a多对象跟踪器块提供对象跟踪周围的the ego vehicle.

视觉检测发生器块还提供了有关自我车辆的车道检测,该车辆有助于识别自我车道中存在的车辆。

The交通灯传感器子系统模拟交通信号灯。它被配置为支持在交叉路口的四个交通灯传感万博1manbetx器,TL传感器1,TL传感器2,TL传感器3, andTL传感器4

Plot the scenario with traffic light sensors.

hfigscenario = helpplotscenariowithtrafficlights();

观察到这是与以前相同的情况,只有添加了交通灯传感器。这些传感器在交叉路口的红色圆圈表示,表明红色的交通信号灯。交通信号灯的标签1,2,3,4correspond toTL传感器1,TL传感器2,TL传感器3, andTL传感器4, respectively.

关闭图。

关闭(hfigscenario);

The test scenarios in交通点式测试台are configured such that the ego vehicle negotiates withTL传感器1。There are three modes in which you can configure this交通灯传感器subsystem:

  1. Steady Red:TL传感器1andTL传感器3总是在一个红色的状态。其他两个交通lights are always in a green state.

  2. Steady Green:TL传感器1andTL传感器3总是处于绿色状态。其他两个交通信号灯总是处于红色状态。

  3. 循环[默认]:TL传感器1andTL传感器3遵循循环图案:绿色黄色,并带有预定义的时间。其他交通信号灯也遵循循环模式:红绿色黄色,带有预定义的时间,以补充TL传感器1andTL传感器3

您可以使用交通灯传感器模式mask parameter.

Open the交通灯传感器子系统。

open_system('TrafficLightNegotiationTestBench/Sensors and Environment/Traffic Light Sensor','力量');

TheTraffic Light Switching LogicStateflow® chart implements the traffic light state change logic for the four traffic light sensors. The initial state for all the traffic lights is set to red. Transition to a different mode is based on a trigger condition defined by distance of the ego vehicle to theTL传感器1traffic light. This distance is defined by the variabledistanceToTrafficLight。Traffic light transition is triggered if this distance is less than交通灯 - statetriggerThreshold。This threshold is currently set to 60 meters and can be changed in thehelperSLTrafficLightNegotiationSetupscript.

The Compute Distance To Traffic Light block calculatesdistanceToTrafficLightusing the traffic light position ofTL传感器1, defined by the variable交通聚光度。这是从交通信号灯位置蒙版参数交通灯传感器子系统。掩码参数的值设置为IntersectionInfo.tlSensor1 position, a variable set in the base workspace by thehelperSLTrafficLightNegotiationSetupscript.intersectionInfo结构是来自HelpergetTrafficlightscenefunction. This function is used to create the test scenarios that are compatible with the交通点式测试台模型。

流量灯决策逻辑和控制器需要以下输入来实施其功能:

  • 参考Pathinfoprovides a predefined reference trajectory that can be used by the ego vehicle for navigation in absence of lane information. The ego vehicle can go straight, take a left turn, or a right turn at the intersection based on the reference path. This reference path is obtained usingreferencePathInfo, an output fromHelpergetTrafficlightscene。This function takes an input argument to specify the direction of travel at the intersection. The possible values are:Straight,, andRight

  • 相交中心在场景中提供了道路网络交叉点中心的位置。这是使用intersectionInfo, an output fromHelpergetTrafficlightscene

  • 设置速度定义控制器的用户集速度。

Model Traffic Light Decision Logic

TheTraffic Light Decision Logicreference model arbitrates between the lead car and the traffic light. It also calculates the lane center information as required by the controller either using the detected lanes or a predefined path. Open theTraffic Light Decision Logicreference model.

open_system(“交通lightdecisionLogic”);

TheFind Lead Carsubsystem finds the lead car in the current lane from input object tracks. It provides relative distance,relativeDistToLeadCar和相对速度,相对级别的曲线,关于领先工具。如果没有铅车,则该块认为铅车在无限距离处存在。

The仲裁逻辑Stateflow chart uses the lead car information and implements the logic required to arbitrate between the traffic light and the lead vehicle at the intersection. Open the仲裁逻辑状态流图。

open_system(“交通lightdecisionLogic/仲裁逻辑”);

The仲裁逻辑Stateflow chart consists of two states,OnentryandOnRedAndYellowLightDetection。如果交通信号灯状态是绿色的,或者没有交通信号灯检测,则该状态仍在Onentrystate. If the traffic light state is red or yellow, then the state transitions to theOnRedAndYellowLightDetectionstate. The control flow switches between these states based ontrafficLightDetectionanddistanceToTrafficLight变量。在每个状态中,计算相对于最重要的对象(MIO)的相对距离和相对速度。领先的车辆和红色交通信号灯被认为是元人。

Onentry:

relativeDistance = relativeDistToLeadCar;

relativeVelocity = relativeVelocityOfLeadCar;

OnRedAndYellowLightDetection:

相对主义= min(perativeStoladcar,distancetRafficlight);

相对速度=最小(相对级别的曲线,纵向级别);

The纵向级别代表自我车辆的纵向速度。

与当前自我位置相交中心的距离计算距离距离相交中心的距离。由于交叉路口没有车道,因此自我车辆使用此距离落回交叉路口的预定义参考路径。

The车道中心决策逻辑子系统根据要求计算车道中心信息Path Following Control System(Model Predictive Control Toolbox)。Open the车道中心决策逻辑子系统。

open_system(“交通灯/车道中心决策逻辑”);

The车道中心决策逻辑子系统主要依赖于车道检测视觉检测发生器块到估计巷中心的信息,例如曲率,曲率导数,侧向偏移和标题角。但是,在交叉路口没有泳道标记可检测。在这种情况下,可以从预定义的参考路径中估算车道中心信息。

TheReference Path Lane Centersubsystem computes lane center information based on the current ego pose and predefined reference path. A switch is configured to useLANECENTERFROMREFERNECHETH什么时候伸缩式调查小于referencePathSwitchThreshold。此阈值当前设置为20米,可以在helperSLTrafficLightNegotiationSetupscript.

用交通信号灯和领先的车辆模拟左转弯

In this test scenario, a lead vehicle travels in the ego lane and crosses the intersection. The traffic light state keeps green for the lead vehicle and turns red for the ego vehicle. The ego vehicle is expected to follow the lead vehicle, negotiate the traffic light, and make a left turn.

配置交通点式测试台model to use the设想_03_TLN_left_turn_with_lead_vehicle设想。

helperSLTrafficLightNegotiationSetup("scenario_03_TLN_left_turn_with_lead_vehicle");% To reduce command-window output, first turn off the MPC update messages.mpcverbosity('离开');%模拟模型。sim(“交通灯”);

绘制仿真结果。

hfigresults = helperplottrafficlightnogotiationResults(logSout);

检查结果。

  • The交通信号灯状态-TL传感器1情节显示了交通灯传感器的状态TL传感器1。它从绿色变为黄色,然后从黄色变为红色,然后重复循环mode.

  • TheRelative longitudinal distanceplot shows the relative distance between the ego vehicle and the MIO. Notice that the ego vehicle follows the lead vehicle from 0 to 4.2 seconds by maintaining a safe distance from it. You can also observe that from 4.2 to 9 seconds, this distance reduces because the red traffic light is detected as an MIO. Also notice the gaps representing infinite distance when there is no MIO after the lead vehicle exceeds the maximum distance allowed for an MIO.

  • The自我加速图显示了来自Lane Following Controller。请注意,对于将红色交通信号视为MIO的检测,对4.2秒至4.7秒的负加速度。您还可以观察到9秒后的加速度增加,以响应绿色交通信号灯。

  • The自我偏航角plot shows the yaw angle profile of the ego vehicle. Notice the variation in this profile after 12 seconds, in response to the ego vehicle taking a left turn.

关闭图。

close(hFigResults);

Simulate Left Turn with Traffic Light and Cross Traffic

This test scenario is an extension to the previous scenario. In addition to the previous conditions, in this scenario, a slow-moving cross-traffic vehicle is in the intersection when the traffic light is green for the ego vehicle. The ego vehicle is expected to wait for the cross-traffic vehicle to pass the intersection before taking the left turn.

配置交通点式测试台model to use the方案_02_tln_left_turn_with_cross_over_vehicle设想。

helperSLTrafficLightNegotiationSetup("scenario_02_TLN_left_turn_with_cross_over_vehicle");%模拟模型。sim(“交通灯”);

绘制仿真结果。

hfigresults = helperplottrafficlightnogotiationResults(logSout);

检查结果。

  • The交通信号灯状态-TL传感器1plot is same as the one from the previous simulation.

  • TheRelative longitudinal distanceplot diverges from the previous simulation run from 10.5 seconds onward. Notice the detection of the cross-traffic vehicle as the MIO at 10 seconds at around 10 meters.

  • The自我加速情节还迅速在10.6时响应跨流量的车辆。您可以注意到交叉路口的跨交通车辆的艰苦锻炼。

  • The自我偏航角plot shows that the ego vehicle initiates a left turn after 14 seconds, in response to the cross-traffic vehicle leaving the intersection.

关闭图。

close(hFigResults);

探索其他场景

在前面的部分中,您探索了系统行为设想_03_TLN_left_turn_with_lead_vehicleand方案_02_tln_left_turn_with_cross_over_vehicle方案。以下是兼容的方案列表交通点式测试台

设想_01_TLN_left_turn scenario_02_TLN_left_turn_with_cross_over_vehicle [Default] scenario_03_TLN_left_turn_with_lead_vehicle scenario_04_TLN_straight scenario_05_TLN_straight_with_lead_vehicle

使用这些其他场景进行分析交通点式测试台under different conditions. For example, while learning about the interactions between the traffic light decision logic and controls, it can be helpful to begin with a scenario that has an intersection with a traffic light but no vehicles. To configure the model and workspace for such a scenario, use this code:

helperSLTrafficLightNegotiationSetup("scenario_04_TLN_straight");

Enable the MPC update messages.

mpcverbosity('on');

Conclusion

在此示例中,您实现了交通信号灯协商的决策逻辑,并在闭环Simulink模型中使用Controller的车道进行了测试。万博1manbetx

Related Topics