Improve slight turn completion heuristic#378
Conversation
bfa3b4e to
7858d53
Compare
|
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
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Intersections in OpenStreetMap are somewhat idealized. What if a sharp left is modeled like this:
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?
There was a problem hiding this comment.
Oh, I missed that this check only occurs for slight turns.
1ec5
left a comment
There was a problem hiding this comment.
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.
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. |

Turn completion boils down to two different heuristics:
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