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

Obvious Turn Handling, code transfer from #4426 #4867

Merged
merged 3 commits into from
Mar 20, 2018
Merged

Conversation

oxidase
Copy link
Contributor

@oxidase oxidase commented Feb 9, 2018

Issue

PR #4426 has an initial implementation of the obvious turn detection restructuring.

This PR rebases parts of the branch https://github.com/Project-OSRM/osrm-backend/tree/fix/obvious-2
0001-Don-t-show-time-by-default-in-osrm-runner.patch.txt
to the current master:

  • obvious-turn-discovery.feature
  • include/extractor/guidance/road_classification.hpp
  • findObviousTurn -> findObviousTurnNew
  • src/extractor/guidance/motorway_handler.cpp
  • src/extractor/guidance/turn_handler.cpp
  • src/engine/guidance/collapse_scenario_detection.cpp
  • src/extractor/scripting_environment_lua.cpp and changes in Lua scripts

Tasklist

  • Finish implementation of findObviousTurnNew -> no failing cucumber tests
  • Revisit cases, open points and related issues in Restructure Obvious Turn Handling #4426
  • review
  • adjust for comments
  • cherry pick to release branch

Additional cases to check

Requirements / Relations

Related #3105, #4426, #4414

@oxidase oxidase mentioned this pull request Feb 9, 2018
16 tasks
@oxidase oxidase self-assigned this Feb 9, 2018
@oxidase oxidase force-pushed the guidance/obvious-turn branch 7 times, most recently from c156b84 to c74ad95 Compare February 19, 2018 16:03
@oxidase oxidase force-pushed the guidance/obvious-turn branch 4 times, most recently from 4c289ba to 22cdc06 Compare February 23, 2018 16:10
@oxidase
Copy link
Contributor Author

oxidase commented Feb 23, 2018

Finished initial code transfer from #4426 and prepared PR for the first review iteration

The PR extends RoadPriorityClass and adds priority groups.

findObviousTurn makes the following checks:

  1. Detect the straight-most road that has the same or higher priority and does not require a name announcement. Return the road index if such road exists and the road is distinct from other roads

  2. Detect the straight-most road that has the same or higher priority. Return the road index if such road exists and the road is distinct from other roads.

  3. Detect the straight-most valid road. If such road does not exist then return no obvious turn.

  4. Handle special cases

IsDistinctTurn returns true if an intersection has no roads similar to the candidate road.

For SF-area comparison of the branch with 5.16 release shows 2447 modified turns out of 812570 (0.3%)
http://bl.ocks.org/d/8ac513b7cfa8739726649628031093ad

@oxidase oxidase force-pushed the guidance/obvious-turn branch 5 times, most recently from 5177947 to 2ca9b11 Compare February 28, 2018 15:22
Copy link
Member

@TheMarex TheMarex left a comment

Choose a reason for hiding this comment

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

Looks good! I have a few questions regarding some test cases and I think there might be some debugging code left.

@@ -1010,7 +1010,7 @@ Feature: Collapse
| f,j | hohe,hohe | depart,arrive | f,j |
| a,t | hohe,a100,a100 | depart,on ramp right,arrive | a,b,t |
| f,e | | | |
| q,j | a100,hohe,hohe | depart,turn right,arrive | q,p,j |
| q,j | a100,hohe,hohe | depart,turn right,arrive | q,i,j |
Copy link
Member

Choose a reason for hiding this comment

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

Did the turn location logic also change, or is this a side-effect of an obvious turn change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

location logic was not changed, but obvious turn changed at node p

@@ -108,7 +108,7 @@ Feature: Continue Instructions
When I route I should get
| waypoints | route | turns |
| a,c | abc,abc,abc | depart,continue right,arrive |
| a,d | abc,bd,bd | depart,turn straight,arrive |
| a,d | abc,bd | depart,arrive |
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this expectation is right? I would expect a turn instruction since you are not following the street abc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have adjusted conditions. Now the expectation is again depart,turn straight,arrive.

| a,d | left,circle,circle,right,right | true:90;false:90 true:120 false:270;true:60 true:180 false:300;true:90 false:240 true:270;true:270 |
| g,d | bottom,circle,right,right | true:0;true:60 false:180 false:300;true:90 false:240 true:270;true:270 |
| waypoints | route | intersections |
| a,d | left,right,right | true:90,false:90 true:120 false:270;true:60 true:180 false:300,true:90 false:240 true:270;true:270 |
Copy link
Member

Choose a reason for hiding this comment

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

The functional change here is that going straight is an obvious turn, even though the street name changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adjusted detection conditions to expectations:

            | a,d       | left,circle,right,right   | true:90,false:90 true:120 false:270;true:60 true:180 false:300;true:90 false:240 true:270;true:270 |
            | g,d       | bottom,circle,right,right | true:0;true:60 false:180 false:300;true:90 false:240 true:270;true:270                             |



# https://www.openstreetmap.org/#map=19/37.63829/-122.46345
@todo
Copy link
Member

Choose a reason for hiding this comment

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

This one is marked as todo, maybe we should add a comment what is missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have reviewed new test cases and marked as @todo in the following cases:

  • tests fail due to geometry conditions compare_road_deviation_is_distinct and compare_road_deviation_is_slightly_distinct. I would keep ratios 2 and 1.4 in these conditions as was proposed in the original PR
  • additional post-processing logic is required to collapse instructions.



# https://www.openstreetmap.org/#map=18/48.99155/8.43520
@todo
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

// Find the most obvious turn to follow. The function returns an index into the intersection
// determining whether there is a road that can be seen as obvious turn in the presence of many
// other possible turns. The function will consider road categories and other inputs like the
// turn angles.
template <typename IntersectionType> // works with Intersection and IntersectionView
std::size_t findObviousTurn(const EdgeID via_edge, const IntersectionType &intersection) const;

template <typename IntersectionType> // works with Intersection and IntersectionView
std::size_t findObviousTurnOld(const EdgeID via_edge,
Copy link
Member

Choose a reason for hiding this comment

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

These two declarations seem to be leftover from debugging?

// indicate that a low priority road is obvious
if (IsLowPriority(best_option_edge) &&
best_option_edge.flags.road_classification != in_way_edge.flags.road_classification)
if (candidate_deviation < GROUP_ANGLE)
Copy link
Member

Choose a reason for hiding this comment

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

Nit pick: It might make sense to split this function into two sub-functions each for handling a case of this if block. The function is quite huge.

return best_continue;
// Special case handling for roads splitting up, all the same name (exactly the same)
if (intersection.size() == 3 &&
std::all_of(intersection.begin(),
Copy link
Member

Choose a reason for hiding this comment

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

This function call should be moved out of the if head for readability.

if data.is_forward_oneway then
forward = forward or common
end
if data.is_reverse_oneway then
Copy link
Member

Choose a reason for hiding this comment

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

Is this an added bug fix for the profile? It might make sense to capture that separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found some bugs and will open a separate PR for review, namely here is a fix for double counting of lanes in case of oneways.

@@ -185,7 +185,7 @@ util::Coordinate CoordinateExtractor::ExtractRepresentativeCoordinate(
*/
const bool first_coordinate_is_far_away = [&first_distance, considered_lanes]() {
const auto required_distance =
considered_lanes * 0.5 * ASSUMED_LANE_WIDTH + LOOKAHEAD_DISTANCE_WITHOUT_LANES;
Copy link
Member

Choose a reason for hiding this comment

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

Any background why we removed the magic parameter here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i don't know exactly where 0.5 comes from, but assume that it is needed to reduce number of considered_lanes by factor 2 due to double counting.

@oxidase oxidase mentioned this pull request Mar 2, 2018
6 tasks
@oxidase oxidase force-pushed the guidance/obvious-turn branch 4 times, most recently from 3726dae to 82241ed Compare March 4, 2018 13:53
@oxidase
Copy link
Contributor Author

oxidase commented Mar 4, 2018

The current state of PR:

@oxidase oxidase force-pushed the guidance/obvious-turn branch from 09b5564 to 3f5ff84 Compare March 20, 2018 06:31
@oxidase oxidase force-pushed the guidance/obvious-turn branch from 3f5ff84 to f4a9f1f Compare March 20, 2018 14:18
@oxidase oxidase merged commit b56a757 into master Mar 20, 2018
@oxidase oxidase deleted the guidance/obvious-turn branch March 20, 2018 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants