From 589e33f66597b77b6cec36b147617cd84585d9c1 Mon Sep 17 00:00:00 2001 From: discountchubbs Date: Thu, 23 Oct 2025 17:20:23 -0700 Subject: [PATCH] sum red diff --- .../navd/navigation_helpers/nav_instructions.py | 14 +------------- .../navd/navigation_helpers/tests/test_mapbox.py | 7 +------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/sunnypilot/navd/navigation_helpers/nav_instructions.py b/sunnypilot/navd/navigation_helpers/nav_instructions.py index a2e9148f41..6550cfb843 100644 --- a/sunnypilot/navd/navigation_helpers/nav_instructions.py +++ b/sunnypilot/navd/navigation_helpers/nav_instructions.py @@ -31,18 +31,11 @@ class NavigationInstructions: # The next turn is the next step relative to our cumulative index next_turn_idx = current_step_idx + 1 next_turn = route['steps'][next_turn_idx] if 0 <= next_turn_idx < len(route['steps']) else None - next_turn_distance = max(0, next_turn['cumulative_distance'] - closest_cumulative) if next_turn else None current_maxspeed = current_step['maxspeed'] distance_to_end_of_step = max(0, current_step['distance'] - (closest_cumulative - current_step['cumulative_distance'])) - # Calculate total remaining distance and time - total_distance_remaining: float = max(0, route['total_distance'] - closest_cumulative) - progress_in_step = (closest_cumulative - current_step['cumulative_distance']) / current_step['distance'] - time_left_in_step = (1 - progress_in_step) * current_step['duration'] - total_time_remaining: float = time_left_in_step + sum(step['duration'] for step in route['steps'][current_step_idx + 1 :]) - all_maneuvers: list = [] max_maneuvers = 2 for idx in range(current_step_idx, min(current_step_idx + max_maneuvers, len(route['steps']))): @@ -55,17 +48,12 @@ class NavigationInstructions: return { 'distance_from_route': min_distance, - 'route_position_cumulative': closest_cumulative, 'current_step': current_step, 'next_turn': next_turn, - 'distance_to_next_turn': next_turn_distance, - 'route_progress_percent': (closest_cumulative / max(1, route['total_distance'])) * 100, 'current_maxspeed': current_maxspeed, - 'distance_to_end_of_step': distance_to_end_of_step, - 'total_distance_remaining': total_distance_remaining, - 'total_time_remaining': total_time_remaining, 'all_maneuvers': all_maneuvers, 'current_step_idx': current_step_idx, + 'distance_to_end_of_step': distance_to_end_of_step, } def get_current_route(self): diff --git a/sunnypilot/navd/navigation_helpers/tests/test_mapbox.py b/sunnypilot/navd/navigation_helpers/tests/test_mapbox.py index 4ba70ac5bb..c45814f7a8 100644 --- a/sunnypilot/navd/navigation_helpers/tests/test_mapbox.py +++ b/sunnypilot/navd/navigation_helpers/tests/test_mapbox.py @@ -68,15 +68,10 @@ class TestMapbox: assert progress is not None assert 'distance_from_route' in progress assert 'next_turn' in progress - assert 'route_progress_percent' in progress assert 'current_maxspeed' in progress - assert 'total_distance_remaining' in progress - assert 'total_time_remaining' in progress assert 'all_maneuvers' in progress + assert 'distance_to_end_of_step' in progress assert progress['distance_from_route'] >= 0 - assert 0 <= progress['route_progress_percent'] <= 100 - assert progress['total_distance_remaining'] >= 0 - assert progress['total_time_remaining'] >= 0 assert isinstance(progress['all_maneuvers'], list) speed_limit_metric = self.nav.get_current_speed_limit_from_progress(progress, True)