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

navd: fix hysteresis when reaching destination #29032

Merged
merged 2 commits into from Jul 25, 2023
Merged

Conversation

sshane
Copy link
Contributor

@sshane sshane commented Jul 19, 2023

Noticed this when reading the code to start refactoring. Basically, the desired behavior (from the comments) is that you reach your destination, stop, but nothing is cleared until you start driving away:

cloudlog.warning("Destination reached")
Params().remove("NavDestination")
# Clear route if driving away from destination
dist = self.nav_destination.distance_to(self.last_position)
if dist > REROUTE_DISTANCE:
self.clear_route()

However since we clear the parameter first, we clear the route anyway on the next loop:

new_destination = coordinate_from_param("NavDestination", self.params)
if new_destination is None:
self.clear_route()
return

We can avoid clearing the param until we clear the route and don't need to worry about re-routing due to this check here:

# Don't recompute in last segment, assume destination is reached
if self.step_idx == len(self.route) - 1:
return False

@sshane
Copy link
Contributor Author

sshane commented Jul 19, 2023

However this is odd behavior to show all zeros for the ETA, maybe we should remove this broken code altogether. @adeebshihadeh have any preference? actually we handle this! we can merge this then. I'll post a comparison

@sshane sshane changed the title fix destination hysteresis when reaching destination navd: fix hysteresis when reaching destination Jul 19, 2023
@sshane
Copy link
Contributor Author

sshane commented Jul 19, 2023

This is the fixed behavior, before this, it would briefly show that you've arrived, then disappear. Includes fixed nav banner instructions from #29034 in the video

you.have.arrived.fixed.2.mp4

Copy link
Contributor

@adeebshihadeh adeebshihadeh left a comment

Choose a reason for hiding this comment

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

Remove the distance in the top banner too?


# Clear route if driving away from destination
dist = self.nav_destination.distance_to(self.last_position)
if dist > REROUTE_DISTANCE:
self.params.remove("NavDestination")
Copy link
Contributor

Choose a reason for hiding this comment

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

move this to clear route instead?

Copy link
Contributor Author

@sshane sshane Jul 19, 2023

Choose a reason for hiding this comment

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

Can't, it's used to temporarily hide the route on errors as well. It's intentional there's still a NavDestination but no route

@sshane
Copy link
Contributor Author

sshane commented Jul 25, 2023

nav.arrived.and.left.mp4

@sshane sshane merged commit 431a254 into master Jul 25, 2023
38 of 39 checks passed
@sshane sshane deleted the navd-fix-destination-hyst branch July 25, 2023 08:43
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.

None yet

2 participants