主要内容

roadrunner.hdmap.Phase

R2026b

Create signal phase at junction in RoadRunner HD Map

Since R2025a

    Description

    A roadrunner.hdmap.Phase object enables you to create a signal phase at a junction in a RoadRunner HD Map scene model. To learn how to create a complete T-junction with roads, maneuver lanes, and traffic signal phases including bulb-level signal control, see Build Signalized Junction Using RoadRunner HD Map.

    Creation

    Description

    signalPhase = roadrunner.hdmap.Phase creates an empty phase.

    signalPhase = roadrunner.hdmap.Phase(PropertyName=Value) sets the properties of the phase using one or more name-value arguments. For example, ID="Phase1" specifies the ID of the phase element as "Phase1".

    example

    Properties

    expand all

    ID of the phase element, specified as a character vector or string scalar.

    Data Types: char | string

    Name of the phase element, specified as a character vector or string scalar.

    Data Types: char | string

    Duration of the phase state in seconds, specified as a real valued scalar.

    Data Types: uint32

    Junction lanes that can be traversed during the phase, specified as an array of roadrunner.hdmap.JunctionLaneState objects.

    Signal type and signal state references, specified as an array of roadrunner.hdmap.SignalStateReference objects. Each signal state reference associates a signal type with one of its supported signal states to specify the state of the signal during the phase.

    Examples

    collapse all

    Create signal state references by creating a signal type definition with a complete bulb configuration for a traffic light, then add the signal state references to a phase to control traffic signal behavior during that phase interval.

    Create a bulb representing the green light of a traffic signal.

    bulbGreen = roadrunner.hdmap.Bulb(ID="BulbGreen",Name="Green Light");

    Create a bulb state that sets the green bulb to "On".

    bulbStateGreen = roadrunner.hdmap.BulbState(BulbRef=roadrunner.hdmap.Reference(ID="BulbGreen"),State="On");

    Create a signal state representing the green signal configuration. This signal state defines the bulb state for the green bulb.

    signalStateGreen = roadrunner.hdmap.SignalState(ID="Green",StateName="Green",BulbStates=bulbStateGreen);

    Create a signal type that includes the bulb and signal state.

    signalType = roadrunner.hdmap.SignalType(ID="TrafficLight",Bulbs=bulbGreen,SignalStates=signalStateGreen);

    Create a phase in which east–west traffic has green lights.

    ewGreen = roadrunner.hdmap.Phase(ID="ewGreen",Name="East-West Green",Time=20);

    Create signal state references for the three signals at the junction.

    signalStateRefWest = roadrunner.hdmap.SignalStateReference(SignalTypeRef=roadrunner.hdmap.Reference(ID="TrafficLight"), ...
        SignalStateRef=roadrunner.hdmap.Reference(ID="Green"));
    signalStateRefEast = roadrunner.hdmap.SignalStateReference(SignalTypeRef=roadrunner.hdmap.Reference(ID="TrafficLight"), ...
        SignalStateRef=roadrunner.hdmap.Reference(ID="Green"));
    signalStateRefSouth = roadrunner.hdmap.SignalStateReference(SignalTypeRef=roadrunner.hdmap.Reference(ID="TrafficLight"), ...
        SignalStateRef=roadrunner.hdmap.Reference(ID="Red"));

    Add the signal state references to the phase.

    ewGreen.SignalStateReferences(end+1) = signalStateRefWest;
    ewGreen.SignalStateReferences(end+1) = signalStateRefEast;
    ewGreen.SignalStateReferences(end+1) = signalStateRefSouth;

    Display the phase containing signal state references.

    disp(ewGreen)
      Phase with properties:
    
                           ID: "ewGreen"
                         Name: "East-West Green"
                         Time: 20
           JunctionLaneStates: [0×1 roadrunner.hdmap.JunctionLaneState]
        SignalStateReferences: [3×1 roadrunner.hdmap.SignalStateReference]
    

    Version History

    Introduced in R2025a

    expand all