Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaced lane support in traffic light simulation #1392

Open
13 of 25 tasks
Elesbaan70 opened this issue Feb 11, 2022 · 14 comments
Open
13 of 25 tasks

Displaced lane support in traffic light simulation #1392

Elesbaan70 opened this issue Feb 11, 2022 · 14 comments
Assignees
Labels
feature A new distinct feature TRAFFIC LIGHTS Feature: Traffic lights - toggle, timed, etc

Comments

@Elesbaan70
Copy link
Contributor

Elesbaan70 commented Feb 11, 2022

Note - This issue has been completely rewritten, and so some comments before 27-March-2022 may be outdated and irrelevant. A more extensive discussion of this issue can be found at #1428

Description

Detect lanes that run in a nonstandard direction, and use them as a basis for traffic light grouping.

There are three use cases already identified for displaced lanes: Continuous Flow Intersections and Turnaround Lanes (both pictured below), and also Contraflow Interchanges. Diverging Diamond Interchanges are not an example of displaced lanes, because they involve only lane reversal, not a complex mixture of lane directions.

Entry into and exit from displaced lanes needs separate traffic light regulation for these scenarios:

  • In advance of a Continuous Flow Intersection, traffic crossing over into the displaced far turn lane needs separate control from traffic remaining in standard lanes. This divides forward-moving traffic among multiple lights.
  • After a Continuous Flow Intersection, traffic going straight starts out displaced and crosses back to the standard side, for which it needs separate control from the near-turn slip lane. This divides forward-moving traffic among multiple lights.
  • At an intersection with a turnaround lane, the turns into and out of the displaced (turnaround) lane need separate control from the standard far turns. This divides "far"-turning traffic among multiple lights.

A theoretical condition exists where near-turning traffic turns into or out of a displaced lane. However, there seem to be no real-world use cases for this, so it is being omitted to avoid strange traffic light groupings that would be difficult to represent clearly in the UI.

Definitions

Forward Lane - A lane for which the value of Lane.m_direction is Forward, Both, or AvoidBackward. This is represented in the asset editor by the Direction field.

Backward Lane - A lane for which the value of Lane.m_direction is Backward, Both, or AvoidForward. This is represented in the asset editor by the Direction field.

Standard Road - A road that is either one-way or that has exactly two sets of lanes, one forward and the other backward. Forward and backward may be reversed, and for the purposes of lane displacement that is still a standard road.

Complex Road - A road that has three or more sets of lanes in alternating directions.

Standard Lane - Any lane on a Standard Road. On a complex road, any lane that exists in the standard position in relation to opposing traffic. If there is only one set of lanes going in a given direction, they are always Standard lanes.

Displaced Lane - On a complex road, any lane that exists in a nonstandard position in relation to opposing traffic, when other lanes going the same direction are in the standard position. If there is only one set of lanes going in a given direction, they are never Displaced Lanes.

Cross Left - A traffic light lane grouping for forward-moving traffic that crosses into a displaced lane (out of a displaced lane in LHT).

Cross Right - A traffic light lane grouping for forward-moving traffic that crosses out of a displaced lane (into a displaced lane in LHT).

Forward Displaced - A traffic light lane grouping for forward-moving traffic that is in a displaced lane both before and after the node.

Turn Into Displaced - A traffic light lane grouping for far-turning traffic that enters a displaced lane.

Turn Out of Displaced -- A traffic light lane grouping for far-turning traffic that leaves a displaced lane.

Examples

Continuous Flow Intersection

Sometimes called a Displaced Left Turn
image

Turnaround Lane

A slip lane that connects pairs of one-way roads to facilitate U-turns
image

Displaced Lane Identification

Conceptually, lane displacement is based on identifying sets of lanes that run in opposing directions, and that is how they are described here and covered in unit tests. The implementation will be mathematical.

One-way and simple two-way roads

If only one or two sets of lanes exist, they are always Standard Lanes, even if they are reversed as in the case of a Diverging Diamond Interchange.

Roads with three sets of lanes in alternating directions

In this scenario, one direction will have two sets of lanes, and the other direction will have only one. In the direction with two sets of lanes, the set that is in a nonstandard position in relation to opposing traffic are considered displaced lanes.

Roads with four sets of lanes in alternating directions.

In this scenario, each direction has two distinct sets of lanes. They may be configured in one of two ways:

  • If the outer lanes run in the standard direction (i.e., in the asset editor the leftmost lane is backward and the rightmost lane is forward), then the two inner sets of lanes are displaced. This is the configuration for a standard Continuous Flow Intersection.
  • If the outer lanes run in the reverse direction (i.e., in the asset editor the leftmost lane is forward and the rightmost lane is backward), then the two outer sets of lanes are displaced. This is the configuration for Turnaround Lanes.

More than four sets of lanes

This implementation will not support more than four sets of lanes on a single prefab.

Traffic Light Grouping

Traffic light grouping for displaced lanes will be based on the Lane Connector tool. This is based on the assumption that this type of intersection always involves the intentional assignment of lane connections. In the future, we could explore basing these lane groupings on the traffic AI's default behavior in the absence of explicit lane connections.

The traffic light simulation will attempt to eliminate groupings based on displaced lanes when they do not represent a distinct movement. For example, at the central node of a Continuous Flow Intersection, the left turns are Turn Out of Displaced, but since this applies to all of the left-turning lanes on a segment, the distinct grouping would not add functionality but would only make the UI more confusing.

Lane Transitions

At a node where the Lane Connector tool has not been used, lane transitions between displaced and non-displaced lanes will be disallowed for all vehicle types when the node has only two segments AND the segments have matching displaced lane layouts. The number of lanes does not have to match, only the overall pattern of standard and displaced lanes.

Graphics

CrossLeft, CrossRight
image image

TurnOutOfDisplaced (RHT, LHT)
image image

TurnIntoDisplaced (RHT, LHT)
image image

ForwardDisplaced (RHT, LHT)
image image

Tasks

  • NetInfo extensions
    • Displaced lane detection
  • LaneConnectionManager
    • Raise an event when connections on a lane end change.
    • Raise an event when the lane connection feature is enabled/disabled.
  • Identification and flagging of lane connections involving displaced lanes, in LaneEndManager.
    Also listens for LaneConnectionManager events to reset its cached data.
  • Removal of unmaintainable and unused public traffic light API.
    This needs a rollout plan in case there are unknown/surprise dependencies.
  • CustomSegmentLights groups lights by both ExtVehicleInfo and NetLaneFlags.
    Displacement-based groupings are folded into the main group if they don't conflict.
  • Tool enhancements:
    • Show infosigns for displaced lane connections
    • When displaced lane lights have the same vehicle types as the main light, hide the vehicle type infosigns.
  • Persistence
    • Merge from xml-persistence branch
    • Rework CustomSegmentLightModel to include NetLaneFlags
  • LaneConnectionManager
    • Allow LaneConnectionManager to be queried during load regardless of enabled state
  • TTL Copy/Paste
  • RoutingManager
    • Enter Displaced Lane Configuration
    • Leave Displaced Lane Configuration
    • Within Displaced Lane Configuration
      • Junctions
        • Forward transitions to same lane type only
        • Turns favor transition to same lane type
        • Do not mix outgoing lane types
      • Middle and Bend Nodes
        • Disallow lane transitions of any type into and out of displaced lanes at middle and bend nodes.
    • Use RoutingManager instead of LaneConnectionManager for TTL lane groupings
  • Lane Connector stay-in-lane
    • Try to be smart about crossovers
  • TTL Quick Setup
    • Continuous Flow Intersection
      • Two-way node with inner displaced lanes on one segment
      • Three- or four-way node with inner displaced lanes on one or more segments
    • Contraflow Interchange
      • To be addressed separately
    • Diamond Interchange with Turnaround Lane
      • To be addressed separately
@Elesbaan70 Elesbaan70 added feature A new distinct feature triage Awaiting issue categorisation labels Feb 11, 2022
@originalfoo originalfoo added the TRAFFIC LIGHTS Feature: Traffic lights - toggle, timed, etc label Feb 12, 2022
@Elesbaan70
Copy link
Contributor Author

@krzychu124, I've thought about this more based on our conversation on Discord, reexamined my use cases, and had a good look at the code.

Controlling traffic lights by lane would be really cool, but it's not realistic since the existing code treats it as a directional problem. But in reality, crossovers are a directional problem anyway, and reexamining my use cases confirms that. I could offer you some great use cases for traffic light control by lane, but this is not one of them.

A crossover is, in terms of traffic control, almost exactly the same thing as a far turn, and it should be treated as such. Both movements conflict with oncoming traffic, which is why they require a separate traffic light phase.

I will rewrite this feature request based on these findings.

@originalfoo
Copy link
Member

Regarding lane traffic crossing in the junction causing conflict points: #4

@Elesbaan70 Elesbaan70 changed the title Option to program timed traffic lights by lane instead of direction Displaced lane support in traffic light simulation Feb 13, 2022
@Elesbaan70
Copy link
Contributor Author

If this is implemented, Adaptive Networks should probably be given some related flag support. Not needed for this enhancement, but useful for asset creators.

@originalfoo
Copy link
Member

Could you clarify the terminology here:

  • It is a forward lane whose position is greater than that of all backward lanes.
  • It is a backward lane whose position is less than that of all forward lanes.

Is foward/backward lane in relation to the final lane direction in relation to the segment containing that lane, or relative to the main junction ahead? What is meant by position?

@Elesbaan70
Copy link
Contributor Author

"Position" means the value of the Position field in the editor. "Forward" and "Backward" are the directions as indicated in the editor.

@originalfoo originalfoo removed the triage Awaiting issue categorisation label Feb 13, 2022
@Elesbaan70
Copy link
Contributor Author

I have added definitions for Position, Forward Lane, and Backward Lane.

@originalfoo
Copy link
Member

I'm wondering if this feature could also provide a good opportunity to experiment with new traffic light editing UI?

Rather than using the floating traffic light icons, would it be better to 'highlight lanes' on the map, showing red/green (plus some other visual cue, such as fill or border style, for color blind users)? Toggling traffic light state for the lane would involve simply clicking the lane and would give immediate on-lane feedback (eg. the 'lane highlight' would change colour/etc)...?

@krzychu124
Copy link
Member

I would create at least simplified version of overlaymanager mentioned in other issue. Btw, I've been experimenting with animated shader texture (scrollable texture that follows shape of path) to display custom animated thingy as we see entering into traffic routes view (or via Traffic Report mod)

@originalfoo
Copy link
Member

Btw, I've been experimenting with animated shader texture (scrollable texture that follows shape of path) to display custom animated thingy as we see entering into traffic routes view (or via Traffic Report mod)

Yesssss :) The arrows would start flowing when the light goes green. Want!

@Elesbaan70
Copy link
Contributor Author

I'm wondering if this feature could also provide a good opportunity to experiment with new traffic light editing UI?

Seems like a good idea on the one hand. On the other hand, maybe best not to needlessly link two features of significant effort that could exist independently of each other?

@Elesbaan70
Copy link
Contributor Author

Elesbaan70 commented Feb 16, 2022

This feature is being implemented here:

https://github.com/Elesbaan70/TMPE/tree/lane-grouping

@Elesbaan70
Copy link
Contributor Author

An additional requirement has been added this issue's main description, for the RoutingManager to prevent lane changes across oncoming traffic.

@kianzarrin
Copy link
Collaborator

kianzarrin commented Apr 10, 2022

I don't see it.
image

RoutingManager to prevent lane changes across oncoming traffic.

Only on nodes with two segments.

@Elesbaan70
Copy link
Contributor Author

The date shown is when it was originally posted. If you click on "edited" it will show the edit history.

The change is under the "Lane Transitions" heading and states that it only applies on nodes with two segments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new distinct feature TRAFFIC LIGHTS Feature: Traffic lights - toggle, timed, etc
Projects
None yet
Development

No branches or pull requests

4 participants