Fix controls mismatch on button enable cars + test against panda safety (#23975)
* test models: check button enable cars against panda safety * gm too * cleanuppull/23978/head
parent
5fe00fb773
commit
20db4525a2
2
panda
2
panda
|
@ -1 +1 @@
|
|||
Subproject commit e6722c7f99b8f7b9f81bb0216edb88cc2e5ad7c0
|
||||
Subproject commit ba10911dbc0a6f2c5c04886ca793f6ac38400cd3
|
|
@ -403,9 +403,9 @@ class CarInterface(CarInterfaceBase):
|
|||
for b in ret.buttonEvents:
|
||||
|
||||
# do enable on both accel and decel buttons
|
||||
if b.type in (ButtonType.accelCruise, ButtonType.decelCruise) and not b.pressed:
|
||||
if not self.CP.pcmCruise:
|
||||
events.add(EventName.buttonEnable)
|
||||
if not self.CP.pcmCruise:
|
||||
if b.type in (ButtonType.accelCruise, ButtonType.decelCruise) and not b.pressed:
|
||||
events.add(EventName.buttonEnable)
|
||||
|
||||
# do disable on button down
|
||||
if b.type == ButtonType.cancel and b.pressed:
|
||||
|
|
|
@ -50,9 +50,6 @@ class TestCarModel(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
#if cls.car_model != "HONDA RIDGELINE 2017":
|
||||
# raise unittest.SkipTest
|
||||
|
||||
if cls.route is None:
|
||||
if cls.car_model in non_tested_cars:
|
||||
print(f"Skipping tests for {cls.car_model}: missing route")
|
||||
|
@ -63,11 +60,6 @@ class TestCarModel(unittest.TestCase):
|
|||
params.clear_all()
|
||||
|
||||
for seg in (2, 1, 0):
|
||||
#from tools.lib.route import Route
|
||||
#from tools.lib.logreader import MultiLogIterator
|
||||
#r = Route("97bbe58ea225ad1d|2022-03-08--12-54-42")
|
||||
#lr = MultiLogIterator(r.log_paths()[3:4])
|
||||
|
||||
try:
|
||||
lr = LogReader(get_url(cls.route, seg))
|
||||
except Exception:
|
||||
|
@ -104,7 +96,7 @@ class TestCarModel(unittest.TestCase):
|
|||
# TODO: check safetyModel is in release panda build
|
||||
self.safety = libpandasafety_py.libpandasafety
|
||||
set_status = self.safety.set_safety_hooks(self.CP.safetyConfigs[0].safetyModel.raw, self.CP.safetyConfigs[0].safetyParam)
|
||||
self.assertEqual(0, set_status, f"failed to set safetyModel {self.CP.safetyConfigs[0].safetyModel}")
|
||||
self.assertEqual(0, set_status, f"failed to set safetyModel {self.CP.safetyConfigs}")
|
||||
self.safety.init_tests()
|
||||
|
||||
def test_car_params(self):
|
||||
|
@ -197,6 +189,10 @@ class TestCarModel(unittest.TestCase):
|
|||
self.safety.safety_rx_hook(to_send)
|
||||
self.CI.update(CC, (can_list_to_can_capnp([msg, ]), ))
|
||||
|
||||
if not self.CP.pcmCruise:
|
||||
self.safety.set_controls_allowed(0)
|
||||
|
||||
controls_allowed_prev = False
|
||||
CS_prev = car.CarState.new_message()
|
||||
checks = defaultdict(lambda: 0)
|
||||
for can in self.can_msgs:
|
||||
|
@ -235,6 +231,14 @@ class TestCarModel(unittest.TestCase):
|
|||
checks['controlsAllowed'] += not self.safety.get_controls_allowed()
|
||||
else:
|
||||
checks['controlsAllowed'] += not CS.cruiseState.enabled and self.safety.get_controls_allowed()
|
||||
else:
|
||||
# Check for enable events on rising edge of controls allowed
|
||||
button_enable = any(evt.enable for evt in CS.events)
|
||||
mismatch = button_enable != (self.safety.get_controls_allowed() and not controls_allowed_prev)
|
||||
checks['controlsAllowed'] += mismatch
|
||||
controls_allowed_prev = self.safety.get_controls_allowed()
|
||||
if button_enable and not mismatch:
|
||||
self.safety.set_controls_allowed(False)
|
||||
|
||||
if self.CP.carName == "honda":
|
||||
checks['mainOn'] += CS.cruiseState.available != self.safety.get_acc_main_on()
|
||||
|
@ -245,10 +249,6 @@ class TestCarModel(unittest.TestCase):
|
|||
if self.CP.carFingerprint == TOYOTA.SIENNA and checks['brakePressed'] < 25:
|
||||
checks['brakePressed'] = 0
|
||||
|
||||
# Honda Nidec uses button enable in panda, but pcm enable in openpilot
|
||||
if self.CP.carName == "honda" and self.CP.carFingerprint not in HONDA_BOSCH and checks['controlsAllowed'] < 25:
|
||||
checks['controlsAllowed'] = 0
|
||||
|
||||
failed_checks = {k: v for k, v in checks.items() if v > 0}
|
||||
self.assertFalse(len(failed_checks), f"panda safety doesn't agree with openpilot: {failed_checks}")
|
||||
|
||||
|
|
Loading…
Reference in New Issue