From ca1ce9bcc93fe4afc6b44cdc8f5c5249191df8b2 Mon Sep 17 00:00:00 2001 From: discountchubbs Date: Tue, 28 Oct 2025 06:27:51 -0700 Subject: [PATCH 1/2] Clear route cache more gracefully to allow we based route connection to happen quick ish --- sunnypilot/navd/navigationd.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sunnypilot/navd/navigationd.py b/sunnypilot/navd/navigationd.py index 73d41c0152..8eb11f037b 100755 --- a/sunnypilot/navd/navigationd.py +++ b/sunnypilot/navd/navigationd.py @@ -59,10 +59,10 @@ class Navigationd: self.reroute_counter = 0 if self.cancel_route_counter == 30: - self.nav_instructions.clear_route_cache() - self.params.put('MapboxSettings', {"navData": {"current": {}, "route": {}}}) - self.route = None + self.cancel_route_counter = 0 self.destination = None + self.nav_instructions.clear_route_cache() + self.route = None self.valid = self.route is not None From 5f5e3668ebd582d9043bd78deca8e2ef2e8f3315 Mon Sep 17 00:00:00 2001 From: discountchubbs Date: Tue, 28 Oct 2025 06:43:00 -0700 Subject: [PATCH 2/2] Add steering pressed and torque to desire for non blindspot cars, and a note! --- sunnypilot/navd/navigation_desires/navigation_desires.py | 9 +++++++-- .../navigation_desires/tests/test_navigation_desires.py | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sunnypilot/navd/navigation_desires/navigation_desires.py b/sunnypilot/navd/navigation_desires/navigation_desires.py index c68cf6ca59..51f4325843 100644 --- a/sunnypilot/navd/navigation_desires/navigation_desires.py +++ b/sunnypilot/navd/navigation_desires/navigation_desires.py @@ -35,10 +35,15 @@ class NavigationDesires: self.desire = log.Desire.keepLeft elif upcoming == 'slightRight' and (not CS.rightBlindspot or CS.vEgo < self._turn_speed_limit): self.desire = log.Desire.keepRight - elif upcoming == 'left' and not CS.rightBlinker and not CS.leftBlindspot and CS.vEgo < self._turn_speed_limit: + elif (upcoming == 'left' and CS.steeringPressed and CS.steeringTorque > 0 and not CS.rightBlinker + and not CS.leftBlindspot and CS.vEgo < self._turn_speed_limit): self.desire = log.Desire.turnLeft - elif upcoming == 'right' and not CS.leftBlinker and not CS.rightBlindspot and CS.vEgo < self._turn_speed_limit: + elif (upcoming == 'right' and CS.steeringPressed and CS.steeringTorque < 0 and not CS.leftBlinker + and not CS.rightBlindspot and CS.vEgo < self._turn_speed_limit): self.desire = log.Desire.turnRight + # Note to reviewers: This change to require steering pressed (nudge basically) is intentional to prevent unwanted turns + # for those who don't have blind spot detection. + def get_desire(self) -> log.Desire: return self.desire diff --git a/sunnypilot/navd/navigation_desires/tests/test_navigation_desires.py b/sunnypilot/navd/navigation_desires/tests/test_navigation_desires.py index c87e75798a..c2150558fe 100644 --- a/sunnypilot/navd/navigation_desires/tests/test_navigation_desires.py +++ b/sunnypilot/navd/navigation_desires/tests/test_navigation_desires.py @@ -26,9 +26,9 @@ NAVIGATION_PARAMS: list[tuple] = [ ('slightRight', make_car(), log.Desire.keepRight), ('slightLeft', make_car(vEgo=9, leftBlindspot=True), log.Desire.none), ('slightRight', make_car(vEgo=9, rightBlindspot=True), log.Desire.none), - ('left', make_car(vEgo=5, leftBlinker=True, rightBlinker=False, leftBlindspot=False), log.Desire.turnLeft), + ('left', make_car(vEgo=5, leftBlinker=True, rightBlinker=False, leftBlindspot=False, steeringPressed=True, steeringTorque=1), log.Desire.turnLeft), ('left', make_car(vEgo=5, leftBlinker=False, rightBlinker=True), log.Desire.none), - ('right', make_car(vEgo=6, rightBlinker=True, leftBlindspot=False), log.Desire.turnRight), + ('right', make_car(vEgo=6, rightBlinker=True, leftBlindspot=False, steeringPressed=True, steeringTorque=-1), log.Desire.turnRight), ('right', make_car(vEgo=6, rightBlinker=True, rightBlindspot=True), log.Desire.none), ('left', make_car(vEgo=9, leftBlinker=True), log.Desire.none), ] @@ -75,7 +75,7 @@ def test_update(mock_submaster, mocker): mock_submaster.__getitem__ = mocker.Mock(return_value=make_nav_msg(valid=True, upcoming='left')) nav_desires = NavigationDesires() - nav_desires.update(make_car(leftBlinker=True), True) + nav_desires.update(make_car(leftBlinker=True, steeringPressed=True, steeringTorque=1), True) assert nav_desires.get_desire() == log.Desire.turnLeft params_setter(False)