averbraeck / opentrafficsim

Open Source Multi-Level Traffic Simulator
BSD 3-Clause "New" or "Revised" License
28 stars 8 forks source link

Turn right on red #96

Closed WJSchakel closed 6 months ago

WJSchakel commented 6 months ago

There currently is a ConflictPriority named 'TURN_ON_RED', and a CrossSectionLink.Priority named TURN_ON_RED. The link property is used to set priority on a conflict. However, the turn-right-on-red rule is about crossing the traffic light. The conflict itself could have any priority (usually yield for traffic passing the red traffic light).

These priority values will be removed, and instead information will be added to a traffic light.

WJSchakel commented 6 months ago
WJSchakel commented 6 months ago

Turn-on-red information can be defined in XML and through the editor (see org.opentrafficsim.editor.RunEditor in ots-editor). The information is located at: Ots.Network.Link.TrafficLight.TurnOnRed, and contains a node value regarding the node id that can be turned to through red at the traffic light. For example:

<ots:Ots ...>
  <ots:Definitions>
    ...
  </ots:Definitions>
  <ots:Network>
    ...
    <ots:Link Id="AS-ASI" NodeEnd="ASI" NodeStart="AS" Type="URBAN">
      <ots:Straight/>
      <ots:DefinedLayout>2lane</ots:DefinedLayout>
      <ots:TrafficLight Id="A1" Lane="lane1" Position="275m"/>
      <ots:TrafficLight Id="A2" Lane="lane2" Position="275m">
        <ots:TurnOnRed>DWI</ots:TurnOnRed>
      </ots:TrafficLight>
    </ots:Link>
    ...

Here, GTU's towards node DWI will not stop for the traffic light A2 on lane lane2 on link AS-ASI, even when its red.

WJSchakel commented 6 months ago

A demo has been created to showcase the turn-on-red feature. This simulation is defined in TurnOnRed.xml which can be found in the resources of ots-demo. This file can be loaded in the editor, after which is can be run by hitting play in the top right corner of the screen. Alternatively one can run org.opentrafficsim.demo.loadfromxml.LoadXml and point to the xml file.

At the moment, conflicts have been turned off in the demo. GTUs will merge abruptly. Intersection behavior when conflicts and traffic lights are combined, causes GTUs to stop on the intersection beyond the traffic lights, with all other traffic waiting behind red traffic lights. This needs to be further investigated.

WJSchakel commented 6 months ago

A few more tweaks:

The demo now shows fully functional turn-on-red behavior.