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

feat: separate waypoint logic #457

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

Archdoog
Copy link
Collaborator

  • Separates waypoint advance logic out of step advance fn. This reduces the conditional burden required to advance a waypoint. It also enables flexible waypoint advance logic.

common/ferrostar/src/navigation_controller/models.rs Outdated Show resolved Hide resolved
common/ferrostar/src/navigation_controller/mod.rs Outdated Show resolved Hide resolved
Comment on lines +338 to +348
if let Some(waypoint) = remaining_waypoints.first() {
let current_location: Point = snapped_user_location.coordinates.into();
let next_waypoint: Point = waypoint.coordinate.into();
match self.config.waypoint_advance {
WaypointAdvanceMode::WaypointWithinRange(range) => {
Haversine::distance(current_location, next_waypoint) < range
}
}
} else {
false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice work! I think you can make this even more compact with the is_some_and like this:

remaining_waypoints.first().is_some_and(|waypoint| {
    // Rest of the inner code
}

Then you can drop the whole if/else wrapper and it's a single expression inside :)

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