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

Median detection #503

Closed
originalfoo opened this issue Aug 25, 2019 · 10 comments
Closed

Median detection #503

originalfoo opened this issue Aug 25, 2019 · 10 comments
Labels
DLS Dynamic Lane Selection PATHFINDER Pathfinding tweaks or issues Pedestiran Crossing

Comments

@originalfoo
Copy link
Member

This is closely related to #89 but there is no issue that details the requirement, hence this issue.

The game does not have any concept of medians. They are purely visual, generated by the road prefab mesh. In other cases, it's not even the mesh that depicts the median, but the road texture (think striped line lane in middle of road).

This poses issues for both pathfinding and DLS. Vehicles should not be able to cross medians; medians should be treated as barriers.

In #243, the proposed solution is to identify medians based on distance between adjacent vehicle lanes.

Note that a road could have median between lanes in same direction. Some examples and illustrations are shown in #89.

What is required:

  • Agree on how to identify medians
    • We should document this as it's important for asset creators
  • Scan road prefabs on startup to work out which have medians (and where)
    • This should be cached, and needs to be available to pathfinder, DLS, parking AI, etc
  • We might need some sort of "fudge list" to deal with unusual roads
    • Some roads might look like they have medians, but don't have medians
    • Others might appear not to have medians, but they actually do (how to specify where?)
  • Pathfinder, DLS, Parking AI and and anything else which must respect medians (eg. reckless driver AI?) will need updating
  • As AIs will be using it, it needs to be very high performance (do not assume viability of moving all the AIs to different threads)
  • Some roads have "toggleable medians" at junctions (see Medians #89). Usually the toggle is traffic lights; the median is shown unless the junction has traffic lights.
    • Would need a list of workshop ids (and specific prefabs in that asset) to determine which roads are applicable
    • Different elevations, Elevated, Bridge, Slope, Tunnel, might behave differently than Ground elevation
  • Several tools would need updating to handle medians properly - in particular lane arrows/connector and timed traffic lights, but possibly also others.
@originalfoo originalfoo added PATHFINDER Pathfinding tweaks or issues DLS Dynamic Lane Selection labels Aug 25, 2019
@originalfoo
Copy link
Member Author

Just looking through code of the PR referenced above:

A median is defined as:

  • Gap of 1 meter or more between adjacent lanes
  • Lane of different vehicle type (although bear in mind things like trams, and also on some crazy roads even trains!)

Also, it can affect much more than just path finder, for example:

  • Routing manager
  • Lane connector
  • etc...

@originalfoo
Copy link
Member Author

Tagging #89

@victoriacity
Copy link

victoriacity commented Feb 9, 2020

  • Gap of 1 meter or more between adjacent lanes

I am wondering how this 1-meter threshold was determined.

Below were based my incorrect calculation of lane gaps. The correct way to calculate the spacing is directly (lane separation - lane width). This gives 0.75 m gap between lanes in CSUR so the 1 m threshold already suffices.

All of new CSUR, old CSUR, and part of CSUE roads have lane widths of 3 m while their lanes are separated by 3.75 m. This gives a 1.5 m gap between adjacent lanes. If the 1 m median threshold were implemented, lane changing in all CSUR roads (old/new) and some CSUE roads will be entirely forbidden. For compatibility with these existing assets on the Workshop, I would suggest increasing the median threshold to 1.5 or 2 meters.

If there is indeed a strong reason against using a larger threshold than 1 m, we may make the new CSUR compatible with the future TM:PE version by either rebuilding all road assets or a hot fix after loading the game. However the 1-meter median detection will likely make all of the old CSUR roads unusable.

@originalfoo
Copy link
Member Author

The 1m gap thing came from #243 I think (author of NExt2). It's not set in stone, it's just what was propposed by that PR. If there is a better value we'll use that.

This is the main problem with medians; we have no freaking clue how to reliably identify them (other than something crazy like building a massive list of road asset IDs and manually defining the medians on them all).

There are some potential indicators (I guess, I don't really know that much about road assets) - things like spotting a prop/tree lane (I assume those exist?) or a pedestrian lane could indicate median between road lanes. But in many cases central medians on avenue roads are just empty spaces between lanes.

Maybe for the empty spaces we could look at median gap between road lanes and anything bigger than that treat as a median?

Any info you could provide that could help us narrow down a reliable way to identify medians in general for any road would be much appreciated. Also if there's any way to determine if a median allows crossing at a junction or whether it's a "hard median" (eg. a barrier across it as seen with some workshop roads) that would be extemely useful for guiding bulk junction policy applicators that are currently being developed.

@originalfoo
Copy link
Member Author

I see you already posted some info that can help with continuous median detection: #649 (comment)

@kianzarrin this might be useful for the stuff you're working on?

@victoriacity
Copy link

victoriacity commented Feb 10, 2020

I'm not very familiar with roads outside CSUR, so these are my general ideas about road assets based on how CSUR was made. Let's just assume that most road asset creators are responsible and don't randomly mess with parameters in their roads, such as a 4 m wide lane next to a 3 m wide lane.

Median detection using lane spacing

Starting with vanilla roads, the lane separation is about 3 m in regular (non-highway) vanilla roads and about 4 m in vanilla highways, and these lanes are correspondingly 3 m wide in regular roads and 4 m wide in highways. Then, a car lane in a road asset is likely 3 m wide if it used a regular road as template and is likely 4 m wide if it used the highway as template. For skinnier highway assets, like the SHUTO expressway, the lane width is likely decreased from the 4 m default.

Among road assets using regular roads as template, CSUR likely has the largest lane separation of 3.75 m. The narrowest hard median in CSUR is 1.875 m separating local and express roadways in a road, giving a 2.625 m spacing between two non-cross-able lanes. Solely based on compatibility with CSUR (old and new), a threshold between 0.75 m and 2.625 m can be used to detect medians.

For roads without dedicated bus or tram lanes, case in #89 would be much rarer, and the major concern of median detection is to prevent cars from crossing between local and express roadways in roads with "planting strip" medians. As far as I know, there are very few roads with separated local and express lanes outside CSUR. Typically, the local/express median would be narrower than central medians, which also justified that 0.75 -- 2.625 m is a reasonable range for the median detection threshold.

Median detection using additional lanes

In vanilla 4-lane roads with medians, there is a prop lane at 0 position for road light and trees with laneType None and vehicleType None. The lane at 0 position is also used by Network Skins 2 to customize trees on the median. If an asset creator makes a road from the 4-lane road template, it is very likely that they keeps the median lane in the road asset. Therefore, a non-traffic lane between two opposite car lanes is a very strong indicator of the existence of a median.

Hard medians at intersections

CSUR extensively implements continuous medians at intersections when a divided road intersects another road (see #649). Solely for the CSUR case, when the traffic lights are turned off for an intersection with at least 2 roads with medians, traffic should not cross any median (both central median across incoming traffic and local-express median) when passing the intersection. The same logic may be applicable to any road asset with medians and traffic lights on by default, because continuous medians only make sense when traffic lights are off. (For vanilla roads one may manually plop a median across a non-trafficlight intersection to achieve this effect) A more robust way is to just apply this to roads with continuous medians. This can be done by searching for a direct connect node with TrafficLights in its m_flagsForbidden property. For highways with continuous medians, the direct connect node may always exist regardless of traffic lights on/off, but the median crossing problem can be probably fixed by just applying the highway rule.

@originalfoo
Copy link
Member Author

originalfoo commented Feb 10, 2020

Just a random note for anyone who works on this: Beware decorative networks that are flagged as vehicle roads but don't have vehicle lanes - See #510 and #513

@kianzarrin
Copy link
Collaborator

My direct connect mods can change median connection at junctions based in TMPE rules. so there is median if There are no criss crossing lanes at junctions.

@originalfoo
Copy link
Member Author

Given Kian's mods, can this issue #503 now be closed?

Also, a bunch of other median-related stuff is now being tracked in #1223 (any remaining node-specific stuff will be added to #1223 too).

@originalfoo
Copy link
Member Author

Closing this as it's now all tracked in #1223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DLS Dynamic Lane Selection PATHFINDER Pathfinding tweaks or issues Pedestiran Crossing
Projects
None yet
Development

No branches or pull requests

3 participants