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

Allow u-turns only at dead ends #2883

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

Allow u-turns only at dead ends #2883

wants to merge 34 commits into from

Conversation

easbar
Copy link
Member

@easbar easbar commented Sep 13, 2023

This is based on #2882.

So far we allowed u-turns at every junction, which in some cases yields suboptimal routes. The number of suggested u-turns can be reduced by increasing the u-turn costs, but it is still debatable if suggesting a u-turn at any junction is useful. The better default might be to only allow u-turns at dead-ends, where they are required when curbside or heading parameters are used. In this PR I added a new turn cost encoded value that marks dead ends and adjusted the turn weighting such that u-turns are only allowed at these dead ends.

# Conflicts:
#	core/src/main/java/com/graphhopper/routing/util/VehicleEncodedValues.java
# Conflicts:
#	core/src/main/java/com/graphhopper/routing/util/VehicleEncodedValues.java
#	core/src/main/java/com/graphhopper/routing/weighting/SpeedWeighting.java
# Conflicts:
#	core/src/main/java/com/graphhopper/routing/DefaultWeightingFactory.java
#	core/src/main/java/com/graphhopper/routing/weighting/DefaultTurnCostProvider.java
@easbar easbar marked this pull request as draft September 13, 2023 16:58

import static com.graphhopper.routing.util.EncodingManager.getKey;

public class DeadEnd {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case there will be u-turns other than dead-ends that we want to explicitly allow in the future, maybe we should use a more general name(?).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Information. Sorry as (non dev) GPS user I have to describe it less technically.

U-turns are sure very useful.
In the Kurviger and Cruiser app 180° u-turns are very usefully used.
See example in the image and attached gpx navigation track.
By Notepad++ or gpx editor, find turn instructions in trackpoints.

Cruiser_GraphHopper planning.

  • This 180° u-turn example here is indeed correctly placed and you indeed are expected to make a -u turn at this location. A such 180° U-turn NOT defined to be a Left nor a Right u-turn command.
  • U-turns are shown as a red Icons in the Cruiser turnlist.
  • U-turns can usefully be used as alert signal that a shaping or via point may have been falsely placed onto a side road in the planner and causes false annoying turn commands immediate than to be corrected by an 180° u-turn.

Cruiser_Brouter planning.
Same as above but with an extra.
A "correct misplaced via points" tool can presumably thus automatically prevent false out and return track glitches with 180° u-turn commands. The correction distance is adjustable between 0 and 100m (default 40m).
Provided additional shaping point, a 180° u-turn can still be enforced even in this correction range.

Cruiser_Brouter navigation.
If you ignore the u-turn command during navigation, the system does not insist on a 180° u-turn but suggests a forward alternative (large diversions if necessary). As a person, you can of course still turn back.

RouteYou website planner. (osrm router).
Sure allows 180° U-turns. In addition, there is a "correct misplaced via points" tool. The correction distance at which the tool intervenes is 100m. Track glitches shorter than 100m are so automatically prevented.
Usefull u-turn example
Usefull u-turn navtrack.gpx.txt

# Conflicts:
#	core/src/main/java/com/graphhopper/routing/ch/CHPreparationGraph.java
@easbar easbar temporarily deployed to benchmarks September 18, 2023 10:29 — with GitHub Actions Inactive
Base automatically changed from turn_restriction_enc to master September 25, 2023 08:47
# Conflicts:
#	core/src/main/java/com/graphhopper/routing/DefaultWeightingFactory.java
#	core/src/main/java/com/graphhopper/routing/util/VehicleEncodedValues.java
#	core/src/main/java/com/graphhopper/routing/weighting/DefaultTurnCostProvider.java
#	core/src/test/java/com/graphhopper/routing/weighting/FastestWeightingTest.java
#	core/src/test/java/com/graphhopper/routing/weighting/custom/CustomWeightingTest.java
@easbar easbar temporarily deployed to benchmarks September 25, 2023 09:17 — with GitHub Actions Inactive
@easbar easbar temporarily deployed to benchmarks September 25, 2023 15:34 — with GitHub Actions Inactive
@easbar easbar marked this pull request as ready for review September 25, 2023 16:55
@easbar easbar temporarily deployed to benchmarks September 25, 2023 17:14 — with GitHub Actions Inactive
@easbar easbar temporarily deployed to benchmarks September 25, 2023 17:15 — with GitHub Actions Inactive
@easbar easbar temporarily deployed to benchmarks September 25, 2023 17:17 — with GitHub Actions Inactive
@karussell karussell temporarily deployed to benchmarks September 26, 2023 08:32 — with GitHub Actions Inactive
@karussell karussell temporarily deployed to benchmarks September 26, 2023 09:42 — with GitHub Actions Inactive
@easbar easbar temporarily deployed to benchmarks October 4, 2023 08:12 — with GitHub Actions Inactive
@easbar easbar temporarily deployed to benchmarks October 19, 2023 05:23 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants