From 4ff8e7a5da62f1f4639e778ed39772f2f3eca24c Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:41:25 -0600 Subject: [PATCH] Keep Redneck Cruise SET pending until accelerator release --- .../starpilot/car/hyundai/redneck_cruise.py | 4 +-- .../speed_limits/tests/test_engagement.py | 30 +++++++++++-------- prebuilt.json | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/openpilot/starpilot/car/hyundai/redneck_cruise.py b/openpilot/starpilot/car/hyundai/redneck_cruise.py index cda6d908c1..1bf537de4f 100644 --- a/openpilot/starpilot/car/hyundai/redneck_cruise.py +++ b/openpilot/starpilot/car/hyundai/redneck_cruise.py @@ -289,7 +289,7 @@ class RedneckCruise: cc = card.sm['carControl'] if (not card.slc_match_on_engage or not card.slc_control_enabled or not cs.canValid or cs.canTimeout or not cs.cruiseState.available or cs.gearShifter != car.CarState.GearShifter.drive or - cs.standstill or cs.brakePressed or cs.gasPressed or cs.accFaulted): + cs.standstill or cs.brakePressed or cs.accFaulted): self.set_match_ns = 0 return if not self.set_match_ns and not cs.buttonEvents: @@ -306,7 +306,7 @@ class RedneckCruise: return helper = card.v_cruise_helper - if (not cc.enabled or not cs.cruiseState.enabled or not current(card.sm, 'carControl', now_ns) or + if (cs.gasPressed or not cc.enabled or not cs.cruiseState.enabled or not current(card.sm, 'carControl', now_ns) or not V_CRUISE_MIN <= helper.v_cruise_kph < V_CRUISE_UNSET): return self.set_match_ns = 0 diff --git a/openpilot/starpilot/speed_limits/tests/test_engagement.py b/openpilot/starpilot/speed_limits/tests/test_engagement.py index 3f987d0b62..f01fada204 100644 --- a/openpilot/starpilot/speed_limits/tests/test_engagement.py +++ b/openpilot/starpilot/speed_limits/tests/test_engagement.py @@ -83,15 +83,19 @@ def engage(instance, *, now=START + 10_000_000): return cs -@pytest.mark.parametrize('gesture,match,limit,delay,expected', [ - ('decelCruise', True, 50., 80_000_000, 50.), - ('decelCruise', False, 50., 80_000_000, 60.), - ('accelCruise', True, 50., 80_000_000, 60.), - ('decelCruise', True, 70., 80_000_000, 60.), - ('decelCruise', True, 20., 80_000_000, 60.), - ('decelCruise', True, 50., 550_000_000, 60.), +@pytest.mark.parametrize('gesture,match,limit,delay,gas_at_set,expected', [ + ('decelCruise', True, 50., 80_000_000, False, 50.), + ('decelCruise', False, 50., 80_000_000, False, 60.), + ('accelCruise', True, 50., 80_000_000, False, 60.), + ('decelCruise', True, 70., 80_000_000, False, 60.), + ('decelCruise', True, 20., 80_000_000, False, 60.), + ('decelCruise', True, 50., 550_000_000, False, 60.), + ('decelCruise', True, 50., 100_000_000, True, 50.), + ('decelCruise', True, 50., 550_000_000, True, 60.), + ('accelCruise', True, 50., 100_000_000, True, 60.), + ('decelCruise', True, 70., 100_000_000, True, 60.), ]) -def test_redneck_set_matching_preserves_the_stock_ceiling_and_resume(gesture, match, limit, delay, expected): +def test_redneck_set_matching_preserves_the_stock_ceiling_and_resume(gesture, match, limit, delay, gas_at_set, expected): from opendbc.car.hyundai.interface import CarInterface from opendbc.car.hyundai.software_cruise import prepare from opendbc.car.hyundai.values import CAR @@ -103,11 +107,11 @@ def test_redneck_set_matching_preserves_the_stock_ceiling_and_resume(gesture, ma instance.redneck_cruise = RedneckCruise(cp, SimpleNamespace(redneckCruiseAvailable=True, pcmCruiseSpeed=False)) sm.seen, sm.recv_time = dict(sm.valid), {} - def step(now, *, enabled, stock_speed, buttons=()): + def step(now, *, enabled, stock_speed, buttons=(), gas=False): sm.advance(now) sm.recv_time['carControl'] = now / 1e9 sm['carControl'].enabled = enabled - cs = car.CarState(canValid=True, vEgo=15., gearShifter='drive', buttonEvents=list(buttons), + cs = car.CarState(canValid=True, vEgo=15., gearShifter='drive', gasPressed=gas, buttonEvents=list(buttons), cruiseState={'available': True, 'enabled': enabled, 'speed': stock_speed / 3.6, 'speedCluster': stock_speed / 3.6}) with patch.object(card.time, 'monotonic_ns', return_value=now), patch.object(cruise, 'monotonic_ns', return_value=now): instance.update_cruise_speed(cs) @@ -115,8 +119,10 @@ def test_redneck_set_matching_preserves_the_stock_ceiling_and_resume(gesture, ma instance.CC_prev = car.CarControl(enabled=enabled) return instance.v_cruise_helper.v_cruise_kph - step(START, enabled=False, stock_speed=0., buttons=({'type': gesture, 'pressed': True},)) - assert step(START + 20_000_000, enabled=True, stock_speed=0.) == cruise.V_CRUISE_UNSET + step(START, enabled=False, stock_speed=0., gas=gas_at_set, buttons=({'type': gesture, 'pressed': True},)) + assert step(START + 20_000_000, enabled=True, stock_speed=0., gas=gas_at_set) == cruise.V_CRUISE_UNSET + if gas_at_set: + assert step(START + 40_000_000, enabled=True, stock_speed=60., gas=True) == pytest.approx(60.) assert step(START + delay, enabled=True, stock_speed=60.) == pytest.approx(expected) assert step(START + delay + 20_000_000, enabled=True, stock_speed=60.) == pytest.approx(expected) assert not sm['carControl'].longActive and not cp.openpilotLongitudinalControl diff --git a/prebuilt.json b/prebuilt.json index a0e788e5fb..af3d71c57e 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "54261fc0458a9c34864b113de3ac3c9ec08bebdbbcba6ef3de5458e1377bbc1c", "schema_version": 1} +{"protected_inventory_sha256": "1421ffc245d7e2bc4187bcab11dac0d5ae3fb8dc6797eaa10dced668730c2dea", "schema_version": 1}