Traffic Light Negotiation Using Vehicle-to-Everything Communication
This example shows how to model and simulate a traffic light negotiation application using vehicle-to-everything (V2X) communication. This example uses the vehicle-to-vehicle (V2V) and vehicle-to-infrastructure (V2I) modes of V2X communication.
A traffic light negotiation system makes an appropriate decision at an intersection based on the current state of the traffic light and the status of other surrounding vehicles. V2V and V2I are wireless communication technologies that transmit essential information about the states of other vehicles and the state of a traffic light signal to an ego vehicle. The V2V and V2I technologies improve the perceptual ability of vehicles, enabling them to effectively manage traffic light negotiation. The information received through the V2V and V2I systems is used by the decision logic component of an automated driving application. The decision logic component reacts to this information regarding the state of the traffic light and surrounding vehicles and provides necessary inputs to the controller to guide the vehicle safely.
This example builds on the Traffic Light Negotiation example. The traffic light negotiation example shows how to design and test decision logic for negotiating a traffic light at an intersection using probabilistic vision and radar sensors. This example shows how to design and test decision logic, using V2V and V2I communication, for negotiating a traffic light while preventing collisions at intersections.
In this example, you:
Explore the test bench model — The model contains components for the traffic light sensors and environment, V2V communication, V2I communication, tracker, decision logic, controls, and vehicle dynamics.
Model V2V and V2I communication — The model uses V2V mode to communicate basic safety messages (BSMs) from non-ego vehicles to the ego vehicle. V2I mode communicates signal phase and timing (SPAT) messages from the traffic signal to the ego vehicle. For more details on V2V communication, see Intersection Movement Assist Using Vehicle-to-Vehicle Communication.
Model the decision logic — The decision logic identifies the most important object (MIO) and the state of the traffic signal of interest and arbitrates between them. It provides a reference path for the ego vehicle to follow at an intersection in the absence of lane markings. The decision logic subsystem also differentiates between a lead vehicle and a crossover vehicle, to provide crossover vehicle alert.
Simulate interactions with traffic light — Configure the model to test the interactions between the decision logic and controls of the ego vehicle while approaching a signalized intersection in the presence of a lead vehicle.
Simulate the interactions with a crossover vehicle and traffic light — Configure the model to test the interactions between the traffic light decision logic and controls of the ego vehicle when there is cross traffic at the intersection.
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.
To explore the behavior of the traffic light negotiation system, open the simulation test bench model for the system.
Opening this model runs the
helperSLTrafficLightNegotiationWithV2XSetup function that initializes the scenario using the
drivingScenario object in the base workspace. The function runs the default scenario,
scenario_03_TLNWithV2X_Straight_With_Lead_and_CrossOver, which contains an ego vehicle with a lead vehicle and crossover vehicle. This function also loads the
V2XChannelInfo.mat file, provided by this example, to save the precomputed channel characteristics to the base workspace for the range specified. The setup function configures the controller design parameters, vehicle model parameters, and Simulink® bus signals required for defining the inputs and outputs for the
The test bench model contains these subsystems:
Sensors and Environment— Models the traffic light sensors, road network, vehicles, and the camera and radar sensors used for simulation.
V2V Simulator— Models the vehicle-to-vehicle (V2V) communication system.
V2I Simulator— Models the vehicle-to-infrastructure (V2I) communication system.
Tracker— Converts received BSMs into detections, and tracks each detection using a Multi-Object Tracker.
Decision Logic— Arbitrates between the traffic light and other lead vehicles or crossover vehicles at the intersection.
Lane Following Controller— Generates longitudinal and lateral controls.
Vehicle Dynamics— Models the ego vehicle using a Bicycle Model block, and updates its state using commands received from the
Lane Following Controllerreference model.
Visualization— Plots the world coordinate view of the road network, vehicles, and the traffic light state during simulation.
This example reuses the
Lane Following Controller reference model and the
Vehicle Dynamics subsystem from the Highway Lane Following example. This example focuses on the
V2V Simulator and
V2I Simulator subsystems and
Decision Logic reference model.
Sensors and Environment subsystem configures the road network, defines target vehicle trajectories, and provides scenario-related information. Open the
Sensors and Environment subsystem.
open_system("TrafficLightNegotiationWithV2XTestBench/Sensors and Environment");
Sensors and Environment subsystem consists of these sections:
Scenario and Actors— Configures the scenario and actors. The Scenario Reader block takes the ego vehicle information as input to perform closed-loop simulation. It outputs ground truth information for the lanes and actors in ego vehicle coordinates. This block reads the
scenario, which contains a road network compatible with the
TrafficLightNegotiationWithV2XTestBenchmodel, from the base workspace. This section also converts the actor poses from the coordinates of the ego vehicle to world coordinates using a Vehicle To World block.
Traffic Light Sensor Simulation— Simulates the traffic lights using four traffic light sensors at an intersection. For more information, see the Traffic Light Negotiation example.
Scenario Information— Provides scenario-related information such as reference path, scene origin, approaching intersection, signal name, set velocity for the ego vehicle, and intersection center information.
Model V2V and V2I Communication
V2V Simulator represents the message-based communication between vehicles present in the scenario. Each vehicle transmits essential information about its state in the form of BSMs. The
V2I Simulator represents the message-based communication between the ego vehicle and infrastructure. In this example, the infrastructure is a traffic light sensor that transmits SPAT messages.
V2V Simulator subsystem consists of the
V2V Transmitter and
V2V Receiver subsystems.
V2V Simulator subsystem.
V2V Transmitter subsystem implements the transmitters of all target vehicles in the scenario using the
HelperV2VTransmitter object and uses the actor information and the scene origin information to generate BSMs. First, the subsystem passes the input actor information through an inertial navigation system (INS) and global navigation satellite system (GNSS) to apply noise to the input data. Then, it converts the target vehicle poses from Cartesian coordinates to geographic coordinates to generate the BSMs. To convert the generated BSMs to Simulink messages, the subsystem uses a Send block.
A generated BSM contains these attributes for each vehicle:
MsgCount— Sequence number for a stream of messages.
TemporaryId— Random device identifier.
DSecond— Time at which the position was determined.
Latitude— Geographic latitude of the vehicle.
Longitude— Geographic longitude of the vehicle.
Elevation— Geographic position of the vehicle above or below the reference ellipsoid.
PositionalAccuracy— Accuracy of the positional determination.
TransmissionState— The current state of the vehicle transmission.
Speed— Speed of the vehicle.
Heading— Current heading of the vehicle, in degrees clockwise from north.
SteeringWheelAngle— Angle of the steering wheel of the vehicle.
AccelerationSet4Way— Acceleration of the vehicle along three directions, and the yaw rotation rate.
BrakeSystemStatus— Current brake and system control status.
VehicleSize— Length and width of the vehicle.
V2V Receiver subsystem, a Receive block converts the BSMs back to a signal. The
V2V Receiver subsystem implements the receiver behavior for the ego vehicle using the
HelperV2VReceiver object, and takes the BSM, ego information, and scene origin as input. The
V2V Receiver uses precomputed channel characteristics to receive the message. The channel characteristics provide the throughput percentage for a given distance between the transmitter and receiver. If the throughput percentage is greater than the generated random number, then the subsystem receives the BSM and appends it to the output bus
BSMOut. For more details on channel characteristics, see Intersection Movement Assist Using Vehicle-to-Vehicle Communication.
V2I Simulator subsystem consists of the
V2I Transmitter and
V2I Receiver subsystems.
V2I Simulator subsystem.
V2I Transmitter subsystem implements the transmitter of a traffic light sensor using the
HelperV2ITransmitter object, and generates the SPAT message for the traffic light sensor. The SPAT message conveys the current status of one or more signalized intersections in a region. To convert the generated SPATs to a Simulink messages, the subsystem uses a Send block.
A generated SPAT contains these attributes:
TimeStamp— Minute of the year.
Name— Region name.
Intersection— Traffic signal information for each intersection in a region.
V2I Receiver subsystem, a Receive block converts the SPAT messages back to a signal. The
V2I Receiver subsystem implements the receiver behavior for the ego vehicle using the
HelperV2IReceiver object. The
V2I Receiver uses precomputed channel characteristics. For a specified distance between the transmitter and receiver, if the throughput is greater than the preset threshold, the receiver receives the SPAT message sent by the transmitter.
Model Decision Logic
Decision Logic reference model arbitrates between the lead vehicle, a crossover vehicle, and the traffic light. It also calculates the lane center information using either lanes from the scenario reader or a predefined path.
Decision Logic reference model.
Find MIO MATLAB Function block finds the MIO from the input object tracks. The MIO can be a lead car in the current lane, or it can be a crossover vehicle that can possibly collide with the ego vehicle. The block provides the relative distance and relative velocity of the ego vehicle, with respect to the MIO. For crossover vehicles, the relative distance is the distance between the ego vehicle and the estimated collision point. The relative velocity is the ego velocity towards the estimated collision point. When no MIO is present, this block sets both the relative velocity and relative distance to infinity.
Arbitration Logic block, which arbitrates between the MIO and the traffic light, and the
Lane Center Decision Logic block, which computes lane center, are reused from the
Traffic Light Decision Logic reference model in the Traffic Light Negotiation example.
Simulate Interactions with Traffic Light
Configure the model to use the
To reduce Command Window output, turn off the model predictive control (MPC) update messages.
In this test scenario, a lead vehicle travels in the ego lane and crosses the intersection while the traffic light is green. Then, the traffic light turns red forcing the ego vehicle to wait. The ego vehicle is expected to follow the lead vehicle, negotiate the traffic light, and make a left turn.
Simulate the test bench model.
You can plot the results using the
Traffic light state - TL Sensor 1plot shows the traffic light sensor states of
TL Sensor 1. It changes from green to yellow, then from yellow to red, and then repeats this behavior.
Number of V2V Detectionsplots shows the number of vehicles detected using V2V communication. Observe that the only non-ego vehicle present in the scenario is detected most of the time.
MIOplot shows the type of MIO at each time instant. Notice that the MIO is initially the lead vehicle, and after the ego vehicle takes the left turn, there is no MIO as there is no lead vehicle or crossover vehicle.
Ego accelerationplot shows the acceleration profile from the
Lane Following Controller. Notice that the ego vehicle decelerates slightly more than 4 seconds into the simulation, to react to the red state of the traffic light. When the traffic light turns green, slightly more than 9 seconds into the simulation, the ego vehicle accelerates.
Ego yaw angleplot shows the yaw angle profile of the ego vehicle. Notice that the yaw angle is close to 0 degrees up to 12 seconds into the simulation because the ego vehicle travels straight while approaching the intersection. When the ego vehicle takes a left turn through the intersection, slightly more than 12 seconds into the simulation, the ego yaw angle shows significant variation.
Simulate Interactions with Crossover Vehicle and Traffic Light
Configure the model to use the
This test scenario configures the model to test the interactions between the decision logic and controls of the ego vehicle when both a lead vehicle and a cross-traffic vehicle are present at the intersection. The ego vehicle is expected to follow the lead vehicle, wait for the crossover vehicle to clear the intersection, and negotiate the traffic light.
Simulate the test bench model.
Plot the results.
The ego begins to decelerate slightly more than 4 seconds into the simulation, in response to detecting the red traffic light. The ego vehicle halts at the intersection. While waiting at the intersection, the crossover vehicle approaches the intersection and becomes the MIO, as shown in the MIO plot, slightly more than 6 seconds into the simulation. Though the light turns green slightly more than 9 seconds into the simulation, the ego vehicle does not accelerate until the crossover vehicle moves out of the intersection. After 10 seconds, the ego vehicle starts accelerating and moves through the intersection. Because the ego vehicle drives straight throughout the simulation, the ego yaw angle does not change.
Explore Other Scenarios
The example provides these additional scenarios that are compatible with the
For more details on each scenario, view the comments in its file. You can configure the Simulink model and workspace to simulate these scenarios using the
Enable the MPC update messages once again.
 SAE International. Dedicated Short Range Communications (DSRC) Message Set Dictionary . J2735_201603. SAE International, issued September 2015; revised March 2016. https://www.sae.org/standards/content/j2735_201603/.