|
4 | 4 | import unittest |
5 | 5 | import itertools |
6 | 6 |
|
7 | | -from panda import Panda, ALTERNATIVE_EXPERIENCE |
| 7 | +from panda import Panda |
8 | 8 | from panda.tests.libpanda import libpanda_py |
9 | 9 | import panda.tests.safety.common as common |
10 | 10 | from panda.tests.safety.common import CANPackerPanda |
@@ -366,24 +366,16 @@ def _accel_2_msg(self, accel, cancel_req=0): |
366 | 366 | values = {"ACCEL_CMD": accel} |
367 | 367 | return self.packer.make_can_msg_panda("ACC_CONTROL_2", 0, values) |
368 | 368 |
|
369 | | - # FIXME: Replaces common test, refactor common tests to handle this situation better? |
| 369 | + # On a SecOC vehicle, we still transmit ACC_CONTROL but the accel value moves to ACC_CONTROL_2 |
| 370 | + # Verify that all non-idle accel values in ACC_CONTROL are rejected, verify ACC_CONTROL_2 accel normally |
| 371 | + def _should_tx_1(self, controls_allowed: bool, stock_longitudinal: bool, accel: float, min_accel: float, max_accel: float): |
| 372 | + return accel == self.INACTIVE_ACCEL |
| 373 | + |
| 374 | + def _should_tx_2(self, controls_allowed: bool, stock_longitudinal: bool, accel: float, min_accel: float, max_accel: float): |
| 375 | + return (controls_allowed and min_accel <= accel <= max_accel) or accel == self.INACTIVE_ACCEL |
| 376 | + |
370 | 377 | def test_accel_actuation_limits(self, stock_longitudinal=False): |
371 | | - limits = ((self.MIN_ACCEL, self.MAX_ACCEL, ALTERNATIVE_EXPERIENCE.DEFAULT), |
372 | | - (self.MIN_ACCEL, self.MAX_ACCEL, ALTERNATIVE_EXPERIENCE.RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX)) |
373 | | - |
374 | | - for min_accel, max_accel, alternative_experience in limits: |
375 | | - # enforce we don't skip over 0 or inactive accel |
376 | | - for accel in np.concatenate((np.arange(min_accel - 1, max_accel + 1, 0.05), [0, self.INACTIVE_ACCEL])): |
377 | | - accel = round(accel, 2) # floats might not hit exact boundary conditions without rounding |
378 | | - for controls_allowed in [True, False]: |
379 | | - self.safety.set_controls_allowed(controls_allowed) |
380 | | - self.safety.set_alternative_experience(alternative_experience) |
381 | | - # On a SecOC vehicle, we still transmit ACC_CONTROL but the accel value moves to ACC_CONTROL_2 |
382 | | - # Verify that all non-idle accel values in ACC_CONTROL are rejected, verify ACC_CONTROL_2 accel normally |
383 | | - should_tx_1 = accel == self.INACTIVE_ACCEL |
384 | | - should_tx_2 = (controls_allowed and min_accel <= accel <= max_accel) or accel == self.INACTIVE_ACCEL |
385 | | - self.assertEqual(should_tx_1, self._tx(self._accel_msg(accel))) |
386 | | - self.assertEqual(should_tx_2, self._tx(self._accel_2_msg(accel))) |
| 378 | + super().test_accel_actuation_limits(stock_longitudinal=stock_longitudinal) |
387 | 379 |
|
388 | 380 |
|
389 | 381 | if __name__ == "__main__": |
|
0 commit comments