Main Content

Generate V2X MAP Message from RoadRunner

Since R2024a

This example shows how to generate a MAP message per the China Society of Automotive Engineers (CSAE) standards [1] and model a roadside unit (RSU) for vehicle-to-everything (V2X) communication.


In vehicle-to-everything (V2X) communication, a connected vehicle interacts with roadside units (RSUs) to obtain vital information about road infrastructure. These RSUs transmit MAP messages, which contain detailed geographic road information. Each MAP message includes essential data about lane geometry and lane connectivity at intersections. This information aids in navigation and critical decision-making within interconnected road networks. When combined with basic safety messages (BSMs), the MAP messages significantly enhance the accuracy of localization and tracking of target vehicles at intersections, thereby contributing to improved safety on the roads.

This example explores MAP messages, RSU modeling, and shows how to generate MAP messages in compliance with CSAE standards using RoadRunner HD Map. In this example, you:

  • Set Up Environment — Configure MATLAB® to interact with RoadRunner Scenario.

  • Explore Scene and Scenario — Explore the RoadRunner scene and scenario, which defines actions for the ego vehicle and other actors.

  • Generate MAP Message — Generate a MAP message for a scene using the RoadRunner HD Map.

  • Explore Test Bench Model — Explore the Simulink® model configured for cosimulation with RoadRunner. The test bench includes RoadRunner interfaces, an RSU for transmitting MAP messages, and a visualization system for observing the MAP messages.

  • Model Road Side Unit — Model an RSU that transmits local geographic information to the vehicles within its range.

  • Simulate and Visualize MAP Message — Simulate the test scenario, and visualize the MAP messages transmitted from the RSU.

Set Up Environment

This section shows how to set up the environment to cosimulate with RoadRunner Scenario.

Start the RoadRunner application interactively by using the roadrunnerSetup function. When the function opens a dialog box, specify the RoadRunner Project Folder and RoadRunner Installation Folder locations.

rrApp = roadrunnerSetup;

The rrApp RoadRunner object enables you to interact with RoadRunner from the MATLAB workspace. You can open the scenario and update scenario variables using this object. For more information on this object, see roadrunner.

This example uses these files, which you must add to the RoadRunner project.

  • GenerateMapMessage.rrscenario — Scenario file based on the USCityBlockBidirectional.rrscene scene included with the RoadRunner Asset Library.

  • GenerateMapMessage.rrbehavior.rrmeta — Behavior file to associate with the ego vehicle in RoadRunner Scenario, implemented using the Simulink model.

Copy these files to the RoadRunner project.


Explore RoadRunner Scene and Scenario

The scene is a 3D representation of a compact city block with 15 intersections. All roads in the scene are two-way roads with four lanes.

Open the scene.


Open the scenario.


The scenario contains an ego vehicle that follows the specified path with a constant velocity.

Connect to the RoadRunner Scenario server for cosimulation by using the createSimulation function, and enable data logging.

rrSim = createSimulation(rrApp);

rrSim is a ScenarioSimulation object. Use this object to set variables and to read scenario-related information. Set the simulation to run at a step size of 0.1.

Ts = 0.1;

Generate MAP Message

This example generates MAP messages per the CSAE standard. Each message contains these elements:

  • Node — A node is the fundamental unit of a map. it can represent an intersection or an endpoint of a road segment. Node attributes include name, ID, location, and the set of upstream links connected to it.

  • Link — A link represents a connection between two nodes, starting from an upstream node and ending at a downstream node.

  • Lane — Each link consists of multiple lanes. Each lane contains information about lane maneuver, speed limit, lane width, and connections with other lanes.

Get the RoadRunner HD Map, which contains detailed information about lanes, lane boundaries, and intersections.

rrHDMap = get(rrSim,"Map");

Plot the RoadRunner HD Map


Define the geographic scene origin, specified as a three-element vector of the form [ latitude longitude altitude].

sceneOrigin = [42.3648 -71.0214 10.0];

Generate a V2X MAP message per the CSAE standard by using the helperGenerateV2XMap helper function.

v2xMapMsg = helperGenerateV2XMap(rrHDMap,sceneOrigin);

Visualize the MAP message using the helperPlotV2XMap function.


Explore Test Bench Model

Open the test bench model.


The test bench model contains RoadRunner Scenario blocks, which configure, read from, and write to RoadRunner Scenario, as well as these modules:

  • Road Side Unit — System object™ that implements an RSU, which transmits MAP messages containing the road geometry of the upcoming intersection.

  • Ego Vehicle Path Following — This subsystem enables the ego vehicle to follow the path specified in the RoadRunner scenario. It takes the ego pose and the path as input and writes back the updated ego pose to RoadRunner.

  • Visualization — Visualizes the scenario along with the MAP message received from the RSU.

The RoadRunner Scenario blocks consist of:

  • RoadRunner Scenario — Defines the interface for an actor model.

  • Path Action — RoadRunner Scenario Reader block that reads the path of the ego vehicle.

  • Ego Vehicle Runtime — RoadRunner Scenario Reader block that reads ego vehicle runtime information.

  • RoadRunner Scenario Writer — Writes the ego vehicle runtime information to RoadRunner Scenario.

Model Road Side Unit

RSUs are critical components of modern intelligent transportation systems. These units are installed along roadways and infrastructure to enable communication between vehicles, infrastructure, and other entities. The HelperRoadSideUnit System object models the RSU transmitting the map information of its region. The block receives the ego vehicle position as input and, based on that, outputs the MAP message for the region in which the ego vehicle is present, simulating an actual RSU transmitting map information for its region. The System object converts the MAP message structure into a serialized format by using jsonencode function, which returns a character vector. Then, the System object converts character vector to a numeric double representation. This sequence of numbers represent the MAP message.

Open the Road Side Unit subsystem.

open_system("GenerateMapMessage/Road Side Unit")

Simulate Scenario and Visualize MAP Message

Simulate the scenario and visualize the MAP message received from the RSU, as well as the ego vehicle position.

while strcmp(get(rrSim,"SimulationStatus"),"Running")


[1] T/CSAE 53-2020. Cooperative Intelligent Transportation SystemVehicular Communication Application Layer Specification and Data Exchange Standard (Phase I). China Society of Automotive Engineers, 2020.

See Also



Related Topics