All Implemented Interfaces:
EventListener, nl.tudelft.simulation.dsol.animation.Locatable, Identifiable, EventListener, EventProducer, OtsShape, LocatedObject, LaneBasedObject

public final class Conflict extends AbstractLaneBasedObject implements EventListener
Conflicts deal with traffic on different links/roads that need to consider each other as their paths may be in conflict spatially. A single Conflict represents the one-sided consideration of a conflicting situation. I.e., what is considered a single conflict in traffic theory, is represented by two Conflicts, one on each of the conflicting Lanes.

This class provides easy access to upstream and downstream GTUs through PerceptionIterables using methods getUpstreamGtus and getDownstreamGtus. These methods are efficient in that they reuse underlying data structures if the GTUs are requested at the same time by another GTU.

Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Method Details

    • init

      protected void init() throws NetworkException
      Overrides:
      init in class AbstractLaneBasedObject
      Throws:
      NetworkException
    • getUpstreamGtus

      public PerceptionCollectable<PerceivedGtu,LaneBasedGtu> getUpstreamGtus(LaneBasedGtu perceivingGtu, PerceivedGtuType perceivedGtuType, Length visibility)
      Provides the upstream GTUs.
      Parameters:
      perceivingGtu - perceiving GTU
      perceivedGtuType - perceived GTU type to use
      visibility - distance over which GTU's are provided
      Returns:
      iterable over the upstream GTUs
    • getDownstreamGtus

      public PerceptionCollectable<PerceivedGtu,LaneBasedGtu> getDownstreamGtus(LaneBasedGtu perceivingGtu, PerceivedGtuType perceivedGtuType, Length visibility)
      Provides the downstream GTUs.
      Parameters:
      perceivingGtu - perceiving GTU
      perceivedGtuType - perceived GTU type to use
      visibility - distance over which GTU's are provided
      Returns:
      iterable over the downstream GTUs
    • notify

      public void notify(Event event)
      Specified by:
      notify in interface EventListener
    • getConflictType

      public ConflictType getConflictType()
      Returns the conflict type.
      Returns:
      conflictType.
    • getConflictRule

      public ConflictRule getConflictRule()
      Returns the conflict rule.
      Returns:
      conflictRule.
    • conflictPriority

      public ConflictPriority conflictPriority()
      Returns the conflict priority.
      Returns:
      conflictPriority.
    • getLength

      public Length getLength()
      Description copied from interface: LaneBasedObject
      Returns the length of the object. The default value is zero.
      Specified by:
      getLength in interface LaneBasedObject
      Returns:
      length of the object
    • getOtherConflict

      public Conflict getOtherConflict()
      Returns the other conflict.
      Returns:
      otherConflict.
    • isPermitted

      public boolean isPermitted()
      If permitted, traffic upstream of traffic lights may not be ignored, as these can have green light.
      Returns:
      permitted.
    • getTrafficLightDistance

      public Length getTrafficLightDistance(Length maxDistance)
      Returns the distance to an upstream traffic light.
      Parameters:
      maxDistance - maximum distance of traffic light
      Returns:
      distance to upstream traffic light, infinite if beyond maximum distance
    • generateConflictPair

      public static void generateConflictPair(ConflictType conflictType, ConflictRule conflictRule, boolean permitted, Lane lane1, Length longitudinalPosition1, Length length1, Polygon2d geometry1, Lane lane2, Length longitudinalPosition2, Length length2, Polygon2d geometry2, OtsSimulatorInterface simulator) throws NetworkException
      Creates a pair of conflicts.
      Parameters:
      conflictType - conflict type, i.e. crossing, merge or split
      conflictRule - conflict rule
      permitted - whether the conflict is permitted in traffic light control
      lane1 - lane of conflict 1
      longitudinalPosition1 - longitudinal position of conflict 1
      length1 - Length of conflict 1
      geometry1 - geometry of conflict 1
      lane2 - lane of conflict 2
      longitudinalPosition2 - longitudinal position of conflict 2
      length2 - Length of conflict 2
      geometry2 - geometry of conflict 2
      simulator - the simulator for animation and timed events
      Throws:
      NetworkException - if the combination of conflict type and both conflict rules is not correct
    • toString

      public String toString()
      Overrides:
      toString in class AbstractLaneBasedObject