SE450: Project Description: Intersection Behavior [4/16] |
Each intersection has two traffic lights; one for each direction (NS=North/South, EW=East/West). The traffic lights of an intersection are coordinated by a light controller.
Light controllers have four state: GreenNS/RedEW, YellowNS/RedEW, RedNS/GreenEW, RedNS/YellowEW. The rate at which a light controller transitions between these states is determined by two attributes:
greenDurationNS // Duration of the North/South green phase (in seconds) yellowDurationNS // Duration of the North/South yellow phase (in seconds) greenDurationEW // Duration of the East/West green phase (in seconds) yellowDurationEW // Duration of the East/West yellow phase (in seconds)
Suppose a light controller has the following values for these attributes:
greenDurationNS = 55.0 yellowDurationNS = 5.0 greenDurationEW = 25.0 yellowDurationEW = 5.0
Then the light will make the following transitions:
time=0 state=GreenNS/RedEW time=55 state=YellowNS/RedEW time=60 state=RedNS/GreenEW time=85 state=RedNS/YellowEW time=90 state=GreenNS/RedEW time=145 state=YellowNS/RedEW time=150 state=RedNS/GreenEW time=175 state=RedNS/YellowEW time=180 state=GreenNS/RedEW
Intersections also have a length, and therefore may hold cars.
From the point of view of a car, an intersection is an obstacle if any of the following are true:
Thus, a car will ignore Yellow lights within it's brakeDistance.