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

Junction "turn filters" (partially enter blocked junction if turning) #46

Open
originalfoo opened this issue Feb 8, 2019 · 19 comments
Open
Labels
feature A new distinct feature JUNCTION RESTRICTIONS Feature: Junction restrictions TRAFFIC LIGHTS Feature: Traffic lights - toggle, timed, etc

Comments

@originalfoo
Copy link
Member

originalfoo commented Feb 8, 2019

This relates to PR: #25

Partially enter junction

But also check out this mod, specifically how the vehicles can part-enter the junction to wait for left/right turn:

EDIT: Mod linked above no longer exists, and there's nothing in web archive. Can't find source code. Mod was by pcfantasy, called "Advanced Junction Rule":

Traffic in UK does same sort of thing, only in opposite (vehicles drive on left in UK). Would be freaking awesome if this functionality could be merged in too :) It's common in Europe too.

See also: VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition#62

@originalfoo
Copy link
Member Author

originalfoo commented Feb 8, 2019

Filter left/right signs

There's a "green filter" or "green arrow" rule that's common in many countries

From: VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition#31

Not quite. The green arrow is like a Stop sign for right turns. You habe to stop first, then obey yield rules and only then you are allowed to turn right at a red traffic light.

See also: http://transblawg.eu/2004/02/03/green-arrow-in-german-traffic-gruner-pfeil-als-verkehrsschild/ (Germany and UK)

Depending on country:

  • Driver must stop and check there is no pedestrians/traffic in the way before turning
  • Driver must yield to any pedestrians/traffic
  • Driver can only turn when the filter sign is active

@pcfantasy
Copy link
Contributor

@FireController1847 @aubergine10

Yes, those functions are very similar as left waiting rules which is widely used in China or Japan. It is very useful if junction is large, left turn traffic can enter juction a lot first to wait for real turn.

You can check my source code to help add this function into TMPE, I detour some methods in CarAI.cs to implement this.

https://github.com/pcfantasy/AdvancedJunctionRule

@originalfoo
Copy link
Member Author

For vehicles part-entering junction, would it not be easier to simply extend the relevant lanes out in to the junction so the cars yield normally to oncoming traffic?

@krzychu124 krzychu124 added the feature A new distinct feature label Feb 9, 2019
@originalfoo originalfoo changed the title On red light: Turn and/or enter junction Junction "turn filters" (partially enter blocked junction if turning) Feb 10, 2019
@originalfoo
Copy link
Member Author

Can everyone following this issue please review my notes on unprotected turns vs. turn on red here: #63 (comment)

@originalfoo
Copy link
Member Author

Found a workshop traffic lights asset pack that includes the yellow arrow thing: https://steamcommunity.com/sharedfiles/filedetails/?id=1535107168

I've asked the author of the asset to take a look at this thread and hopefully provide additional input.

@originalfoo
Copy link
Member Author

originalfoo commented Feb 11, 2019

I've found some arrow props which could be useful for converting some types of traffic light assets in to more advanced forms (would need definition files for the base traffic light assets to work out where exactly to place these props - an extension to #49).

Take a look at the props to see what I mean (I wonder if he can do yellow versions too?):

https://steamcommunity.com/sharedfiles/filedetails/?id=917459841

Now imagine what we could do to UK traffic lights (specifically those with "no left/right turn" signs) by adding the arrow props:

uk lights

Source of UK traffic lights shown above: https://steamcommunity.com/sharedfiles/filedetails/?id=1406118102

@originalfoo
Copy link
Member Author

originalfoo commented Feb 11, 2019

Summarising what I know so far:

Green arrow sign

  • Where: Germany, ...?
  • Looks like:
    green arrow

This sign means that, regardless of state of the traffic lights (at least in Germany), you can turn in the direction of the arrow so long as you yield to any other traffic/pedestrians. This would be an "unprotected turn", as their is risk of collision.

LOL! A traffic light that stayed red for 28 years!

Green arrow light

  • Where: Most countries
  • Looks like:
    green arrow

This light means traffic can move in the direction of the arrow, regardless of what the other lights are doing. This would be a "protected turn", with no danger of collision from other traffic/pedestrians.

Yellow flashing arrow

  • Where: USA, Spain, ...?
  • Looks like:
    flashing yellow

This light, while flashing, means traffic can move in the direction of the arrow, but must yield to any other traffic/pedestrians. This would be an "unprotected turn", as there is risk of collision.

Summary of arrow lights

There are sometimes other stages of arrow lights:

  • Red = stop in that direction
  • Yellow = prepare to go, but don't yet go
  • Flashing yellow = go, but yield to other traffic
  • Green = go, you have right of way

@pcfantasy
Copy link
Contributor

@aubergine10

So I think this function is not exactly like "left waiting" rule in East Asia country.

Summary of left waiting rule in China:

(1)Left Red & Straight Red = Left Car stay in that direction
(2)Left Red & Straight Green = Left Car partially enter junction(which is left waiting area)
(3)Left Green & Straight Red = Left Car turn

You see, even in (2), this will be no risk of collision, because left Car will not real turn, just enter a waiting area, if juction is very large, this will very helpfull.

@originalfoo
Copy link
Member Author

In China cars drive on the right side of road?

I'm not sure how to deal with that situation you describe.

I'm thinking basically there's combination of options that we can work with:

  • Turn on red setting
  • Enter blocked junction setting
  • Priority signs (stop, yield, priority)

I'm trying to think of ways that we can handle all these situations, ideally, without adding any more UI elements....?

@RDTG
Copy link

RDTG commented Feb 12, 2019

Found a workshop traffic lights asset pack that includes the yellow arrow thing: https://steamcommunity.com/sharedfiles/filedetails/?id=1535107168

I've asked the author of the asset to take a look at this thread and hopefully provide additional input.

Welp i'm here. OK so, I did some extensive digging into this way back before my first SSD died and my health took a crap. So, it'd be entirely possible to have the traffic light flash a yellow arrow (with whatever parameters wanted like time of day or what not) BUT it would take a better coder than I to do it.. You could play with looping the traffic light shader on yellow, but that'd make all of the lights on the signal yellow (for instance if it has a turn arrow and a non-directional signal that'd look weird). Or you could take a crack at making a new shader and overhaul the traffic signals completely. :\ Both of these would require extensive work, to be honest, it'd be much much easier just to rewrite the traffic rules and leave the animated signal stuff be for now, however if someone does get around to implementing it I would be more than happy to rig up some test assets for it.

@originalfoo
Copy link
Member Author

originalfoo commented Feb 12, 2019

@RDTG: As there is code that knows what state a traffic light needs to be in (based on TMPE settings for junction, traffic lights, etc) it should be possible to plop a prop in the right location (see this comment for rough idea).

So the base traffic light model would have the bit where the yellow arrow would go, only it wouldn't contain a light or anything. When the traffic light prop is added to the road, the code would add in a "turned off" prop for the flashing yellow bit, aligned and positioned relative to the traffic light. Then, when time comes to flash the yellow arrow, the code places a different prop (one with flashing arrow) and removes the previous prop (the unlit one). So that gets around having to mess with shaders, etc.

The prop swapping could be constrained to what's in camera view to reduce number of props being swapped in and out.

There might be better ways to do it, but I don't know about asset creation. For example, is a traffic light "prop" just a single solid thing, or can it be a collection of props? If it could be a collection of props then we could just toggle some on and off. Maybe submeshes could be used or variation percentages? Like I say, I don't really know what is possible 'within' a prop asset.

@FireController1847
Copy link
Collaborator

FireController1847 commented Feb 12, 2019

This sounds very cool and I look forward to seeing it implemented. However, what is the plan for different regions of the world? Driving can be very, very different all the time, and as we've seen here, this "yellow flashing" or "left yield" or whatever seems to act differently in different parts of the world. How would we know how to implement this if we don't have truly one thing to implement it on? Will we end up implementing every different version of this and make it an option?

@originalfoo
Copy link
Member Author

originalfoo commented Feb 12, 2019

@FireController1847 : I was thinking of a combination of existing settings could cover most cases.

To elaborate on an earlier comment:

  • Turn on red setting
    • This handles "near-side turns" (where vehicle doesn't need to cross path of other traffic from same source segment)
    • Turn on red is always a "yield" situation (correct me if I'm wrong)
  • Enter blocked junction setting
    • This could control "far-side turns" (where vehicle crosses opposite direction lanes for its source segment)
    • Priority sign (see below) determines how this plays out.
  • Priority signs (stop, yield, priority)
    • This could affect the type of far-side turn...
    • Stop = you can't do far-side turn until light goes green
    • Yield = you can enter junction a bit, but wait for green light before continuing (situations: China)
    • Priority = you can enter the junction a bit, and continue as soon as there's a gap in oncoming traffic (situations: green arrow sign, green arrow, yellow flashing arrow)

If we knew where conflict points are, we could further refine the 'priority' state (eg. if no conflict points for current traffic signal state, cars would not need to yeild maybe)?

Those are just very rough ideas.

BTW, for China situation, I don't even know if it's possible to get both green and red lights active (for a single traffic light prop) at the same time?

@originalfoo
Copy link
Member Author

originalfoo commented Feb 12, 2019

Another approach would be, assuming we make a much better UI for timed traffic lights, to be able to add 'flags' (as in tags) to traffic light states, and somehow have those influence things?

@pcfantasy
Copy link
Contributor

@aubergine10

Agree with your setting.

In China, if there is only single traffic light prop, left waiting rule is not allowed in that junction.

And what`s more, Left waiting function is done by me in this mod based on TMPE
https://steamcommunity.com/sharedfiles/filedetails/?id=1647686914
https://github.com/pcfantasy/AdvancedJunctionRule

  1. I detour TMPE MayChangeSegment method to get traffic light states
  2. When left is red, straight is green, let left car go and save some data to get (current stop position and the first position after left turn)
  3. Detour CarAI.SimulationStep to make left car stop again inside junction, (about 1/3 bettween current stop position and the first position after left turn)
  4. When left is green, let car go again.

This is for your reference, maybe there is a better way to implement this.

@originalfoo
Copy link
Member Author

originalfoo commented Feb 12, 2019

Currently Enter blocked junction has only 2 states: on / off

We could add third state: on / partial / off

The partial would define whether vehicles can part-enter junction when doing far-side turns.

EDIT: So it would become:

  • On = enter junction, proceed when there is a gap
  • Partial = enter junction, but wait for green light before continue
  • Off = wait for green light before enter junction

And the stop/yield/priority signs defines how traffic from different segments gets prioritised in race conditions.

@originalfoo
Copy link
Member Author

If #3 is implemented, which in turn allows #4, we could automatically determine how far in to a junction cars can move to wait to turn.

This wouldn't require the visualisation aspects of #4, just some of the collision detection code:

  • Make a list of lanes that are currently allowed to enter the junction (green light, yellow flashing arrow, etc)
  • For lanes that are making "far side" turns (FS Lanes), find any other lanes that collide with them
  • The closest collision point to the FS lane would become the reference point
  • From there, subtract width of a vehicle (probably value defined in global config file) and that gets us the 'stop/yield line' position in the junction (a point along the arc the FS lane takes in to the junction)

This would mean that we could work out the in-junction stop/yield point for any FS lane. Also, if we find there is no conflict point (due to user making good traffic light settings), they won't even need to yield/stop. It would work on any road, even small roads (on small roads they only pull in to junction by tiny amount).

@originalfoo
Copy link
Member Author

List of "yellow traps": https://midimagic.sgc-hosting.com/yeltrp.htm

Lots of info on left-turns (from perspective of vehicles driving on right): https://midimagic.sgc-hosting.com/lagdef.htm

Not entirely related to this topic, but a huge list of road design fallacies that will be useful for future reference: https://midimagic.sgc-hosting.com/trafalcy.htm

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

No branches or pull requests

5 participants