Skip to content

Comments

Improve slight turn completion heuristic#378

Merged
bsudekum merged 2 commits intomasterfrom
slight-maneuver-completion
Jul 13, 2017
Merged

Improve slight turn completion heuristic#378
bsudekum merged 2 commits intomasterfrom
slight-maneuver-completion

Conversation

@bsudekum
Copy link
Contributor

Turn completion boils down to two different heuristics:

  • is within x meters of maneuver radius
  • user course is with x degrees of the exit heading

For slight turns like on/off ramps, this falls apart quickly since the user's course is easily within x degrees of the exit heading.

This PR looks at the difference between the initial and exit heading. If their difference is less than x degrees, then don't rely on the exit heading check. Instead, rely on their snapped distance from the maneuver location. Once the user is at or moving away from the maneuver location, their snapped distance will always be zero. If it's zero, increment the step.

/cc @1ec5 @frederoni @ericrwolfe

@bsudekum bsudekum requested review from 1ec5 and frederoni July 12, 2017 22:53
@bsudekum bsudekum force-pushed the slight-maneuver-completion branch from bfa3b4e to 7858d53 Compare July 12, 2017 22:54
@bsudekum
Copy link
Contributor Author

Also, if we find we want even more time/distance, we can check for their absolute distance as well. Once this is over x meters and their snapped distance is zero, increment.

@1ec5 1ec5 added this to the v0.6.0 milestone Jul 13, 2017
1ec5
1ec5 previously requested changes Jul 13, 2017
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

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

I don’t think this approach will yield the expected results. In fact, I think it’ll tend to cause sharp turns to be missed.

let finalHeadingNormalized = wrap(finalHeading, min: 0, max: 360)
let userHeadingNormalized = wrap(location.course, min: 0, max: 360)
courseMatchesManeuverFinalHeading = differenceBetweenAngles(finalHeadingNormalized, userHeadingNormalized) <= RouteControllerMaximumAllowedDegreeOffsetForTurnCompletion
let differenceBetweenInitialAndFinalHeading = differenceBetweenAngles(initialHeadingNormalized, finalHeadingNormalized)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about a shorter name like expectedTurningAngle?

// We can do this by looking at their snapped distance from the maneuver.
// Once this distance is zero, they are at more moving away from the maneuver location
if differenceBetweenInitialAndFinalHeading <= RouteControllerMaximumAllowedDegreeOffsetForTurnCompletion {
courseMatchesManeuverFinalHeading = userSnapToStepDistanceFromManeuver == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Intersections in OpenStreetMap are somewhat idealized. What if a sharp left is modeled like this:

sharp-left

The user’s location never snaps to the precisely the end of the road. Do we have a provision for preceding to the next step if the user is closer to the next step geometry than the current step geometry?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I missed that this check only occurs for slight turns.

@1ec5 1ec5 dismissed their stale review July 13, 2017 02:10

Sharp turns are unaffected.

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

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

In the case of a slight turn, we never consider the user’s change in heading at all. So this means we may erroneously call a slight turn complete when in fact the user has missed the slight turn. That’s still preferable to getting stuck on that step and rerouting when the user performed the original maneuver correctly. If the user does miss the turn, the SDK will recover by rerouting a short distance after the junction anyways.

@bsudekum
Copy link
Contributor Author

In the case of a slight turn, we never consider the user’s change in heading at all.

I'm not certain this is true. My understanding is prior to this PR we always looked at the user's course and compared it to the exit heading. In slight turn cases, the difference in angle was always very small causing turn completion to happen at the first location update when entering the maneuver radius.

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.

2 participants