mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 04:53:40 +08:00
Keep Redneck Cruise SET pending until accelerator release
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "54261fc0458a9c34864b113de3ac3c9ec08bebdbbcba6ef3de5458e1377bbc1c", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "1421ffc245d7e2bc4187bcab11dac0d5ae3fb8dc6797eaa10dced668730c2dea", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user