Skip to content

Configuring a traffic lights system

Kamil Świat edited this page Jan 12, 2024 · 3 revisions

1) Prepare Space Data in Space Manager (XvpWorld)

In this step, we set the light cycle configuration, which determines how long and which lights will be in what state (green, red, etc.)

Step 2

  1. Find in the "Outliner" window the XvpWorld blueprint instance (Note: Editor mode must be set to default: "Selection Mode")
  2. Open "Details" window
  3. Select "Space Manager"
  4. Expand "Space Data"
  5. Choose "Traffic Signal Phase" (Three or four signal phased)
  6. In list "Traffic Signal Configs", add new list items (these will correspond to traffic light cycles)
  7. For each added Traffic Signal Config, enter the number of phases that will be in the cycle into the "Count" field
  8. Enter the times of individual phases in fields P0, P1, P2, etc. (e.g. if "Count" is equal to 2, then fill in only P0 and P1)

If all the traffic lights operate in the same cycles (go through the loop at the same time), then one config is enough. Changing the initial phase allows you to shift the state in which a given light will be (usually 0 for vehicles, 1 for pedestrians).

2) Set traffic lights in AI space

This step allows AI vehicles to know which road segments are affected by the lights

Step 1

  1. Select "XAI Space Editor" mode in editor
  2. Select the segment to which you will add the signal barrier
  3. In "XAI Space Editor" window, select "Paths" tab
  4. Below, in "Signal barrier" section press "Add signal barrier"
  5. Configure Traffic signal ID and Phase. Traffic Signaler Id is the Traffic Signal Configs index (see "Prepare Space Data in Space Manager" step). Phase determines the starting phase of the selected signal barriers.
  6. Press "Apply" button
  7. You should notice the traffic lights gizmos if gizmos are enabled in the editor. If the gizmos is red, it means that the Traffic signal Id is outside the range of the Traffic Signal Configs table (see "Prepare Space Data in Space Manager" step)

3) Set up model blueprint (traffic lights model)

In order for the traffic light models to be synchronized with the AI system supporting traffic lights, it is necessary to add the XvpEntity components to the traffic light blueprint: XaiTrafficSignalerPresentationConfig and XaiTrafficSignalerPresentationState and then configure them

Step 3

  1. Open blueprint containing the traffic lights model
  2. Add XvpEntity component, then as its children add XaiTrafficSignalerPresentationConfig and XaiTrafficSignalerPresentationState components
  3. Select XaiTrafficSignalerPresentationConfig component, open "Details" window
  4. Enter Static Mesh Name - the name of the mesh containing the material that is to change the appearance of the lights, then in the "Dynamic Material Instance Index" enter the index of this material (e.g. 0 if it has only one material)
  5. Enter Light Param Names in Visuals Config tab - These are the material instance parameters that will be modified (as values 0 or 1) depending on the system state
  6. For each blueprint instance on the map (not a general blueprint), enter Traffic Signaler Type (Vehicle or Pedestrian), Traffic Signal Id and start phase (usually 0 for vehicles, 1 for pedestrians). Traffic Signaler Id is the Traffic Signal Configs index (see "Prepare Space Data in Space Manager" step).