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

Remove Location filter and check Location#getAccuracy #1157

Merged
merged 1 commit into from
Aug 6, 2018

Conversation

danesfeder
Copy link
Contributor

@danesfeder danesfeder commented Jul 25, 2018

We are seeing issues with what I think to have tracked down is the velocity check in the LocationValidator. I think it's best to roll back the filtering here in favor of the less aggressive filter we had prior.

Capturing some discussion with @Guardiola31337, this filter is not ideal as it can "build up" to eventually be accepting poor updates. We should continue to look into filtering out erroneous data for situations like urban canyons and such.

TODO:

  • Allow setting of accuracy threshold in MapboxNavigationOptions (default 100)

@danesfeder danesfeder added this to the 0.17.0 milestone Jul 25, 2018
@danesfeder danesfeder self-assigned this Jul 25, 2018
@danesfeder danesfeder changed the title Remove Location filter and check Location#getAccuracy [WIP] Remove Location filter and check Location#getAccuracy Jul 25, 2018
@danesfeder danesfeder changed the title [WIP] Remove Location filter and check Location#getAccuracy Remove Location filter and check Location#getAccuracy Jul 27, 2018
@danesfeder danesfeder added ✓ ready for review and removed ⚠️ DO NOT MERGE PR should not be merged! labels Jul 27, 2018
@dsilvera
Copy link

I test this update in real life and with simulator. It works fine and solve my problem.
The algorithm is really simpler.

@mclucky
Copy link

mclucky commented Jul 29, 2018

Hi @danesfeder

We're currently implementing a pilot based on this SDK.
While doing that, we've observed some weird behaviours regarding GPS location.

I personally investigated in the old source before your recent commit, and I've found it well thought, the only line which I doubt was:
LocationValidator.java LINE 120
return accuracyAcceptable || timeSinceLastValidUpdate > locationUpdateTimeInMillisThreshold;

That would mean, as long as there was enough time between updates the current location update would be valid regardless of the value of accuracyAcceptable.

Can you explain why you're doing such a radical change to LocationValidator.java with you recent commit, because all of what was well thought before would be gone.

Thank you,
Lukas

this.locationAccuracyPercentThreshold = locationAccuracyPercentThreshold;
this.locationUpdateTimeInMillisThreshold = locationUpdateTimeInMillisThreshold;
this.locationVelocityInMetersPerSecondThreshold = locationVelocityInMetersPerSecondThreshold;
public LocationValidator(int accuracyThreshold) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we ok here breaking SemVer?
If so, we should document this in the release notes.

@@ -51,12 +51,6 @@

public abstract int locationAcceptableAccuracyInMetersThreshold();

public abstract int locationAccuracyPercentThreshold();
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we ok here breaking SemVer?
If so, we should document this in the release notes.

@danesfeder
Copy link
Contributor Author

@mclucky we were noticing some problems with this logic and opted to remove it.

The first problem was the "percent threshold" rule for accuracy. This logic could potentially allow the Location accuracy to be X percent worse and let the acceptable accuracy grow to an actually unacceptable value:
https://github.com/mapbox/mapbox-navigation-android/pull/1157/files#diff-d7e02b2b6e966516d978dc02e8d89be6L85

The second problem was using the lastValidLocation for the velocity check. For example, if you went through a tunnel, your last valid location would be at the beginning of the tunnel. Once out of the tunnel, your velocity would continually be invalid because the distance from the last valid location to the current location would always be too far for a valid velocity:
https://github.com/mapbox/mapbox-navigation-android/pull/1157/files#diff-d7e02b2b6e966516d978dc02e8d89be6L101

We could potentially "band-aid" these issues, but we are going to remove the logic for now in favor of simple filter - and then will revisit with a more robust implementation. Thanks for your understanding!

@mclucky
Copy link

mclucky commented Aug 6, 2018

@danesfeder thank you for that in deep explanation, we understand!

@danesfeder danesfeder merged commit efd276f into master Aug 6, 2018
@danesfeder danesfeder deleted the dan-remove-filter branch August 6, 2018 12:27
@Guardiola31337
Copy link
Contributor

Hey @mclucky 👋
To add to what @danesfeder mentioned there's also another drawback wrt isValidLocation and locationUpdateTimeInMillisThreshold rule https://github.com/mapbox/mapbox-navigation-android/pull/1157/files#diff-d7e02b2b6e966516d978dc02e8d89be6L120

(numbers are location accuracies):
5, 10, 10, 10, 10, 10, 500, 500, 10, 10, 10
If you get a location every second, you'd skip all of the 10s, but then when 5 second timer expires for isValidLocation(), it will take 500 without regard to its accuracy, and then it will revert back to 10, which from the user point of view will look like two sudden location jumps, first from one with 5 to 500 (probably inaccurate) and then again back to 10.

But the proper thing with this sequence would be to ignore both 500 updates.

@mclucky
Copy link

mclucky commented Aug 6, 2018

Hi @Guardiola31337

Thank you for further explaining.
I guess what you wrote "... without regard to its accuracy" was what originally catched my eye in the source code.

But however, we'll test your latest changes and we'll give you feedback!!

@Guardiola31337
Copy link
Contributor

Yeah, not a problem anymore because we check against accuracyThreshold 👀

return checkLastValidLocation(location) || location.getAccuracy() < accuracyThreshold;
which developers can tweak in MapboxNavigationOptions#locationAcceptableAccuracyInMetersThreshold
public abstract Builder locationAcceptableAccuracyInMetersThreshold(int accuracyInMetersThreshold);
if the default value doesn't fit your needs.

@Guardiola31337 Guardiola31337 mentioned this pull request Aug 10, 2018
11 tasks
@Guardiola31337 Guardiola31337 added the backwards incompatible Requires a SEMVER major version change. label Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards incompatible Requires a SEMVER major version change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants