From 567dbfe6d86ddda6d803da371942603c6dbe36c8 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 17 Mar 2024 22:22:46 -0700 Subject: [PATCH] remove comma pedal (#1902) --- board/safety.h | 6 --- board/safety/safety_honda.h | 69 ++++---------------------- board/safety/safety_toyota.h | 73 ++------------------------- board/safety_declarations.h | 3 -- python/__init__.py | 2 - tests/libpanda/safety_helpers.h | 4 -- tests/libpanda/safety_helpers.py | 2 - tests/safety/common.py | 85 -------------------------------- tests/safety/test_honda.py | 44 ----------------- tests/safety/test_toyota.py | 39 --------------- 10 files changed, 13 insertions(+), 314 deletions(-) diff --git a/board/safety.h b/board/safety.h index 1e95244099..048d7cca48 100644 --- a/board/safety.h +++ b/board/safety.h @@ -327,8 +327,6 @@ int set_safety_hooks(uint16_t mode, uint16_t param) { // reset state set by safety mode safety_mode_cnt = 0U; relay_malfunction = false; - enable_gas_interceptor = false; - gas_interceptor_prev = 0; gas_pressed = false; gas_pressed_prev = false; brake_pressed = false; @@ -543,10 +541,6 @@ bool longitudinal_brake_checks(int desired_brake, const LongitudinalLimits limit return violation; } -bool longitudinal_interceptor_checks(const CANPacket_t *to_send) { - return !get_longitudinal_allowed() && (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)); -} - // Safety checks for torque-based steering commands bool steer_torque_cmd_checks(int desired_torque, int steer_req, const SteeringLimits limits) { bool violation = false; diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 78bbb7f0bf..3c93ab9d10 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -1,16 +1,9 @@ const CanMsg HONDA_N_TX_MSGS[] = {{0xE4, 0, 5}, {0x194, 0, 4}, {0x1FA, 0, 8}, {0x30C, 0, 8}, {0x33D, 0, 5}}; -const CanMsg HONDA_N_INTERCEPTOR_TX_MSGS[] = {{0xE4, 0, 5}, {0x194, 0, 4}, {0x1FA, 0, 8}, {0x200, 0, 6}, {0x30C, 0, 8}, {0x33D, 0, 5}}; const CanMsg HONDA_BOSCH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}, {0x33DA, 0, 5}, {0x33DB, 0, 8}}; // Bosch const CanMsg HONDA_BOSCH_LONG_TX_MSGS[] = {{0xE4, 1, 5}, {0x1DF, 1, 8}, {0x1EF, 1, 8}, {0x1FA, 1, 8}, {0x30C, 1, 8}, {0x33D, 1, 5}, {0x33DA, 1, 5}, {0x33DB, 1, 8}, {0x39F, 1, 8}, {0x18DAB0F1, 1, 8}}; // Bosch w/ gas and brakes const CanMsg HONDA_RADARLESS_TX_MSGS[] = {{0xE4, 0, 5}, {0x296, 2, 4}, {0x33D, 0, 8}}; // Bosch radarless const CanMsg HONDA_RADARLESS_LONG_TX_MSGS[] = {{0xE4, 0, 5}, {0x33D, 0, 8}, {0x1C8, 0, 8}, {0x30C, 0, 8}}; // Bosch radarless w/ gas and brakes -// panda interceptor threshold needs to be equivalent to openpilot threshold to avoid controls mismatches -// If thresholds are mismatched then it is possible for panda to see the gas fall and rise while openpilot is in the pre-enabled state -// Threshold calculated from DBC gains: round(((83.3 / 0.253984064) + (83.3 / 0.126992032)) / 2) = 492 -const int HONDA_GAS_INTERCEPTOR_THRESHOLD = 492; -#define HONDA_GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + (GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2U) // avg between 2 tracks - const LongitudinalLimits HONDA_BOSCH_LONG_LIMITS = { .max_accel = 200, // accel is used for brakes .min_accel = -350, @@ -47,11 +40,6 @@ RxCheck honda_common_rx_checks[] = { HONDA_COMMON_RX_CHECKS(0) }; -RxCheck honda_common_interceptor_rx_checks[] = { - HONDA_COMMON_RX_CHECKS(0) - {.msg = {{0x201, 0, 6, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, -}; - RxCheck honda_common_alt_brake_rx_checks[] = { HONDA_COMMON_RX_CHECKS(0) HONDA_ALT_BRAKE_ADDR_CHECK(0) @@ -62,11 +50,6 @@ RxCheck honda_nidec_alt_rx_checks[] = { HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(0) }; -RxCheck honda_nidec_alt_interceptor_rx_checks[] = { - HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(0) - {.msg = {{0x201, 0, 6, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, -}; - // Bosch has pt on bus 1, verified 0x1A6 does not exist RxCheck honda_bosch_rx_checks[] = { HONDA_COMMON_RX_CHECKS(1) @@ -81,7 +64,6 @@ const uint16_t HONDA_PARAM_ALT_BRAKE = 1; const uint16_t HONDA_PARAM_BOSCH_LONG = 2; const uint16_t HONDA_PARAM_NIDEC_ALT = 4; const uint16_t HONDA_PARAM_RADARLESS = 8; -const uint16_t HONDA_PARAM_GAS_INTERCEPTOR = 16; enum { HONDA_BTN_NONE = 0, @@ -127,26 +109,15 @@ static uint32_t honda_compute_checksum(const CANPacket_t *to_push) { } static uint8_t honda_get_counter(const CANPacket_t *to_push) { - int addr = GET_ADDR(to_push); - - uint8_t cnt = 0U; - if (addr == 0x201) { - // Signal: COUNTER_PEDAL - cnt = GET_BYTE(to_push, 4) & 0x0FU; - } else { - int counter_byte = GET_LEN(to_push) - 1U; - cnt = (GET_BYTE(to_push, counter_byte) >> 4U) & 0x3U; - } - return cnt; + int counter_byte = GET_LEN(to_push) - 1U; + return (GET_BYTE(to_push, counter_byte) >> 4U) & 0x3U; } static void honda_rx_hook(const CANPacket_t *to_push) { - const bool pcm_cruise = ((honda_hw == HONDA_BOSCH) && !honda_bosch_long) || \ - ((honda_hw == HONDA_NIDEC) && !enable_gas_interceptor); + const bool pcm_cruise = ((honda_hw == HONDA_BOSCH) && !honda_bosch_long) || (honda_hw == HONDA_NIDEC); int pt_bus = honda_get_pt_bus(); int addr = GET_ADDR(to_push); - int len = GET_LEN(to_push); int bus = GET_BUS(to_push); // sample speed @@ -218,17 +189,8 @@ static void honda_rx_hook(const CANPacket_t *to_push) { } } - // length check because bosch hardware also uses this id (0x201 w/ len = 8) - if ((addr == 0x201) && (len == 6) && enable_gas_interceptor) { - int gas_interceptor = HONDA_GET_INTERCEPTOR(to_push); - gas_pressed = gas_interceptor > HONDA_GAS_INTERCEPTOR_THRESHOLD; - gas_interceptor_prev = gas_interceptor; - } - - if (!enable_gas_interceptor) { - if (addr == 0x17C) { - gas_pressed = GET_BYTE(to_push, 0) != 0U; - } + if (addr == 0x17C) { + gas_pressed = GET_BYTE(to_push, 0) != 0U; } // disable stock Honda AEB in alternative experience @@ -346,13 +308,6 @@ static bool honda_tx_hook(const CANPacket_t *to_send) { } } - // GAS: safety check (interceptor) - if (addr == 0x200) { - if (longitudinal_interceptor_checks(to_send)) { - tx = false; - } - } - // FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW // ensuring that only the cancel button press is sent (VAL 2) when controls are off. // This avoids unintended engagements while still allowing resume spam @@ -380,24 +335,18 @@ static safety_config honda_nidec_init(uint16_t param) { honda_alt_brake_msg = false; honda_bosch_long = false; honda_bosch_radarless = false; - enable_gas_interceptor = GET_FLAG(param, HONDA_PARAM_GAS_INTERCEPTOR); safety_config ret; bool enable_nidec_alt = GET_FLAG(param, HONDA_PARAM_NIDEC_ALT); + if (enable_nidec_alt) { - enable_gas_interceptor ? SET_RX_CHECKS(honda_nidec_alt_interceptor_rx_checks, ret) : \ - SET_RX_CHECKS(honda_nidec_alt_rx_checks, ret); + SET_RX_CHECKS(honda_nidec_alt_rx_checks, ret); } else { - enable_gas_interceptor ? SET_RX_CHECKS(honda_common_interceptor_rx_checks, ret) : \ - SET_RX_CHECKS(honda_common_rx_checks, ret); + SET_RX_CHECKS(honda_common_rx_checks, ret); } + SET_TX_MSGS(HONDA_N_TX_MSGS, ret); - if (enable_gas_interceptor) { - SET_TX_MSGS(HONDA_N_INTERCEPTOR_TX_MSGS, ret); - } else { - SET_TX_MSGS(HONDA_N_TX_MSGS, ret); - } return ret; } diff --git a/board/safety/safety_toyota.h b/board/safety/safety_toyota.h index 50c00b38a8..05f84e4604 100644 --- a/board/safety/safety_toyota.h +++ b/board/safety/safety_toyota.h @@ -37,12 +37,6 @@ const LongitudinalLimits TOYOTA_LONG_LIMITS = { .min_accel = -3500, // -3.5 m/s2 }; -// panda interceptor threshold needs to be equivalent to openpilot threshold to avoid controls mismatches -// If thresholds are mismatched then it is possible for panda to see the gas fall and rise while openpilot is in the pre-enabled state -// Threshold calculated from DBC gains: round((((15 + 75.555) / 0.159375) + ((15 + 151.111) / 0.159375)) / 2) = 805 -const int TOYOTA_GAS_INTERCEPTOR_THRSLD = 805; -#define TOYOTA_GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + (GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2U) // avg between 2 tracks - // Stock longitudinal #define TOYOTA_COMMON_TX_MSGS \ {0x2E4, 0, 5}, {0x191, 0, 8}, {0x412, 0, 8}, {0x343, 0, 8}, {0x1D2, 0, 8}, /* LKAS + LTA + ACC & PCM cancel cmds */ \ @@ -62,11 +56,6 @@ const CanMsg TOYOTA_LONG_TX_MSGS[] = { TOYOTA_COMMON_LONG_TX_MSGS }; -const CanMsg TOYOTA_INTERCEPTOR_TX_MSGS[] = { - TOYOTA_COMMON_LONG_TX_MSGS - {0x200, 0, 6}, // gas interceptor -}; - #define TOYOTA_COMMON_RX_CHECKS(lta) \ {.msg = {{ 0xaa, 0, 8, .check_checksum = false, .frequency = 83U}, { 0 }, { 0 }}}, \ {.msg = {{0x260, 0, 8, .check_checksum = true, .quality_flag = (lta), .frequency = 50U}, { 0 }, { 0 }}}, \ @@ -78,21 +67,11 @@ RxCheck toyota_lka_rx_checks[] = { TOYOTA_COMMON_RX_CHECKS(false) }; -RxCheck toyota_lka_interceptor_rx_checks[] = { - TOYOTA_COMMON_RX_CHECKS(false) - {.msg = {{0x201, 0, 6, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, -}; - // Check the quality flag for angle measurement when using LTA, since it's not set on TSS-P cars RxCheck toyota_lta_rx_checks[] = { TOYOTA_COMMON_RX_CHECKS(true) }; -RxCheck toyota_lta_interceptor_rx_checks[] = { - TOYOTA_COMMON_RX_CHECKS(true) - {.msg = {{0x201, 0, 6, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, -}; - // safety param flags // first byte is for EPS factor, second is for flags const uint32_t TOYOTA_PARAM_OFFSET = 8U; @@ -100,7 +79,6 @@ const uint32_t TOYOTA_EPS_FACTOR = (1UL << TOYOTA_PARAM_OFFSET) - 1U; const uint32_t TOYOTA_PARAM_ALT_BRAKE = 1UL << TOYOTA_PARAM_OFFSET; const uint32_t TOYOTA_PARAM_STOCK_LONGITUDINAL = 2UL << TOYOTA_PARAM_OFFSET; const uint32_t TOYOTA_PARAM_LTA = 4UL << TOYOTA_PARAM_OFFSET; -const uint32_t TOYOTA_PARAM_GAS_INTERCEPTOR = 8UL << TOYOTA_PARAM_OFFSET; bool toyota_alt_brake = false; bool toyota_stock_longitudinal = false; @@ -122,17 +100,6 @@ static uint32_t toyota_get_checksum(const CANPacket_t *to_push) { return (uint8_t)(GET_BYTE(to_push, checksum_byte)); } -static uint8_t toyota_get_counter(const CANPacket_t *to_push) { - int addr = GET_ADDR(to_push); - - uint8_t cnt = 0U; - if (addr == 0x201) { - // Signal: COUNTER_PEDAL - cnt = GET_BYTE(to_push, 4) & 0x0FU; - } - return cnt; -} - static bool toyota_get_quality_flag_valid(const CANPacket_t *to_push) { int addr = GET_ADDR(to_push); @@ -185,9 +152,7 @@ static void toyota_rx_hook(const CANPacket_t *to_push) { pcm_cruise_check(cruise_engaged); // sample gas pedal - if (!enable_gas_interceptor) { - gas_pressed = !GET_BIT(to_push, 4U); - } + gas_pressed = !GET_BIT(to_push, 4U); } // sample speed @@ -210,15 +175,6 @@ static void toyota_rx_hook(const CANPacket_t *to_push) { brake_pressed = GET_BIT(to_push, bit); } - // sample gas interceptor - if ((addr == 0x201) && enable_gas_interceptor) { - int gas_interceptor = TOYOTA_GET_INTERCEPTOR(to_push); - gas_pressed = gas_interceptor > TOYOTA_GAS_INTERCEPTOR_THRSLD; - - // TODO: remove this, only left in for gas_interceptor_prev test - gas_interceptor_prev = gas_interceptor; - } - bool stock_ecu_detected = addr == 0x2E4; // STEERING_LKA if (!toyota_stock_longitudinal && (addr == 0x343)) { stock_ecu_detected = true; // ACC_CONTROL @@ -234,14 +190,6 @@ static bool toyota_tx_hook(const CANPacket_t *to_send) { // Check if msg is sent on BUS 0 if (bus == 0) { - - // GAS PEDAL: safety check - if (addr == 0x200) { - if (longitudinal_interceptor_checks(to_send)) { - tx = false; - } - } - // ACCEL: safety check on byte 1-2 if (addr == 0x343) { int desired_accel = (GET_BYTE(to_send, 0) << 8) | GET_BYTE(to_send, 1); @@ -357,29 +305,17 @@ static safety_config toyota_init(uint16_t param) { toyota_alt_brake = GET_FLAG(param, TOYOTA_PARAM_ALT_BRAKE); toyota_stock_longitudinal = GET_FLAG(param, TOYOTA_PARAM_STOCK_LONGITUDINAL); toyota_lta = GET_FLAG(param, TOYOTA_PARAM_LTA); - enable_gas_interceptor = GET_FLAG(param, TOYOTA_PARAM_GAS_INTERCEPTOR); toyota_dbc_eps_torque_factor = param & TOYOTA_EPS_FACTOR; - // Gas interceptor should not be used if openpilot is not controlling longitudinal - if (toyota_stock_longitudinal) { - enable_gas_interceptor = false; - } - safety_config ret; if (toyota_stock_longitudinal) { SET_TX_MSGS(TOYOTA_TX_MSGS, ret); } else { - enable_gas_interceptor ? SET_TX_MSGS(TOYOTA_INTERCEPTOR_TX_MSGS, ret) : \ - SET_TX_MSGS(TOYOTA_LONG_TX_MSGS, ret); + SET_TX_MSGS(TOYOTA_LONG_TX_MSGS, ret); } - if (enable_gas_interceptor) { - toyota_lta ? SET_RX_CHECKS(toyota_lta_interceptor_rx_checks, ret) : \ - SET_RX_CHECKS(toyota_lka_interceptor_rx_checks, ret); - } else { - toyota_lta ? SET_RX_CHECKS(toyota_lta_rx_checks, ret) : \ - SET_RX_CHECKS(toyota_lka_rx_checks, ret); - } + toyota_lta ? SET_RX_CHECKS(toyota_lta_rx_checks, ret) : \ + SET_RX_CHECKS(toyota_lka_rx_checks, ret); return ret; } @@ -413,6 +349,5 @@ const safety_hooks toyota_hooks = { .fwd = toyota_fwd_hook, .get_checksum = toyota_get_checksum, .compute_checksum = toyota_compute_checksum, - .get_counter = toyota_get_counter, .get_quality_flag_valid = toyota_get_quality_flag_valid, }; diff --git a/board/safety_declarations.h b/board/safety_declarations.h index 64b55f2033..4140f56e34 100644 --- a/board/safety_declarations.h +++ b/board/safety_declarations.h @@ -203,7 +203,6 @@ bool longitudinal_speed_checks(int desired_speed, const LongitudinalLimits limit bool longitudinal_gas_checks(int desired_gas, const LongitudinalLimits limits); bool longitudinal_transmission_rpm_checks(int desired_transmission_rpm, const LongitudinalLimits limits); bool longitudinal_brake_checks(int desired_brake, const LongitudinalLimits limits); -bool longitudinal_interceptor_checks(const CANPacket_t *to_send); void pcm_cruise_check(bool cruise_engaged); void safety_tick(const safety_config *safety_config); @@ -211,8 +210,6 @@ void safety_tick(const safety_config *safety_config); // This can be set by the safety hooks bool controls_allowed = false; bool relay_malfunction = false; -bool enable_gas_interceptor = false; -int gas_interceptor_prev = 0; bool gas_pressed = false; bool gas_pressed_prev = false; bool brake_pressed = false; diff --git a/python/__init__.py b/python/__init__.py index 063602f4d8..97c967f226 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -194,13 +194,11 @@ class Panda: FLAG_TOYOTA_ALT_BRAKE = (1 << 8) FLAG_TOYOTA_STOCK_LONGITUDINAL = (2 << 8) FLAG_TOYOTA_LTA = (4 << 8) - FLAG_TOYOTA_GAS_INTERCEPTOR = (8 << 8) FLAG_HONDA_ALT_BRAKE = 1 FLAG_HONDA_BOSCH_LONG = 2 FLAG_HONDA_NIDEC_ALT = 4 FLAG_HONDA_RADARLESS = 8 - FLAG_HONDA_GAS_INTERCEPTOR = 16 FLAG_HYUNDAI_EV_GAS = 1 FLAG_HYUNDAI_HYBRID_GAS = 2 diff --git a/tests/libpanda/safety_helpers.h b/tests/libpanda/safety_helpers.h index 074463d319..36887c8963 100644 --- a/tests/libpanda/safety_helpers.h +++ b/tests/libpanda/safety_helpers.h @@ -43,10 +43,6 @@ bool get_relay_malfunction(void){ return relay_malfunction; } -int get_gas_interceptor_prev(void){ - return gas_interceptor_prev; -} - bool get_gas_pressed_prev(void){ return gas_pressed_prev; } diff --git a/tests/libpanda/safety_helpers.py b/tests/libpanda/safety_helpers.py index 28f3349dc6..ea41264ae0 100644 --- a/tests/libpanda/safety_helpers.py +++ b/tests/libpanda/safety_helpers.py @@ -10,7 +10,6 @@ def setup_safety_helpers(ffi): int get_alternative_experience(void); void set_relay_malfunction(bool c); bool get_relay_malfunction(void); - int get_gas_interceptor_prev(void); bool get_gas_pressed_prev(void); bool get_brake_pressed_prev(void); bool get_regen_braking_prev(void); @@ -61,7 +60,6 @@ def set_alternative_experience(self, mode: int) -> None: ... def get_alternative_experience(self) -> int: ... def set_relay_malfunction(self, c: bool) -> None: ... def get_relay_malfunction(self) -> bool: ... - def get_gas_interceptor_prev(self) -> int: ... def get_gas_pressed_prev(self) -> bool: ... def get_brake_pressed_prev(self) -> bool: ... def get_regen_braking_prev(self) -> bool: ... diff --git a/tests/safety/common.py b/tests/safety/common.py index a3c22dffb9..8179cff1f6 100644 --- a/tests/safety/common.py +++ b/tests/safety/common.py @@ -118,91 +118,6 @@ def _common_measurement_test(self, msg_func: Callable, min_value: float, max_val self.assertEqual(meas_max_func(), 0) -class GasInterceptorSafetyTest(PandaSafetyTestBase): - - INTERCEPTOR_THRESHOLD = 0 - - cnt_gas_cmd = 0 - cnt_user_gas = 0 - - packer: CANPackerPanda - - @classmethod - def setUpClass(cls): - if cls.__name__ == "GasInterceptorSafetyTest" or cls.__name__.endswith("Base"): - cls.safety = None - raise unittest.SkipTest - - def _interceptor_gas_cmd(self, gas: int): - values: dict[str, float | int] = {"COUNTER_PEDAL": self.__class__.cnt_gas_cmd & 0xF} - if gas > 0: - values["GAS_COMMAND"] = gas * 255. - values["GAS_COMMAND2"] = gas * 255. - self.__class__.cnt_gas_cmd += 1 - return self.packer.make_can_msg_panda("GAS_COMMAND", 0, values) - - def _interceptor_user_gas(self, gas: int): - values = {"INTERCEPTOR_GAS": gas, "INTERCEPTOR_GAS2": gas, - "COUNTER_PEDAL": self.__class__.cnt_user_gas} - self.__class__.cnt_user_gas += 1 - return self.packer.make_can_msg_panda("GAS_SENSOR", 0, values) - - # Skip non-interceptor user gas tests - def test_prev_gas(self): - pass - - def test_disengage_on_gas(self): - pass - - def test_alternative_experience_no_disengage_on_gas(self): - pass - - def test_prev_gas_interceptor(self): - self._rx(self._interceptor_user_gas(0x0)) - self.assertFalse(self.safety.get_gas_interceptor_prev()) - self._rx(self._interceptor_user_gas(0x1000)) - self.assertTrue(self.safety.get_gas_interceptor_prev()) - self._rx(self._interceptor_user_gas(0x0)) - - def test_disengage_on_gas_interceptor(self): - for g in range(0x1000): - self._rx(self._interceptor_user_gas(0)) - self.safety.set_controls_allowed(True) - self._rx(self._interceptor_user_gas(g)) - remain_enabled = g <= self.INTERCEPTOR_THRESHOLD - self.assertEqual(remain_enabled, self.safety.get_controls_allowed()) - self._rx(self._interceptor_user_gas(0)) - - def test_alternative_experience_no_disengage_on_gas_interceptor(self): - self.safety.set_controls_allowed(True) - self.safety.set_alternative_experience(ALTERNATIVE_EXPERIENCE.DISABLE_DISENGAGE_ON_GAS) - for g in range(0x1000): - self._rx(self._interceptor_user_gas(g)) - # Test we allow lateral, but not longitudinal - self.assertTrue(self.safety.get_controls_allowed()) - self.assertEqual(g <= self.INTERCEPTOR_THRESHOLD, self.safety.get_longitudinal_allowed()) - # Make sure we can re-gain longitudinal actuation - self._rx(self._interceptor_user_gas(0)) - self.assertTrue(self.safety.get_longitudinal_allowed()) - - def test_allow_engage_with_gas_interceptor_pressed(self): - self._rx(self._interceptor_user_gas(0x1000)) - self.safety.set_controls_allowed(1) - self._rx(self._interceptor_user_gas(0x1000)) - self.assertTrue(self.safety.get_controls_allowed()) - self._rx(self._interceptor_user_gas(0)) - - def test_gas_interceptor_safety_check(self): - for gas in np.arange(0, 4000, 100): - for controls_allowed in [True, False]: - self.safety.set_controls_allowed(controls_allowed) - if controls_allowed: - send = True - else: - send = gas == 0 - self.assertEqual(send, self._tx(self._interceptor_gas_cmd(gas))) - - class LongitudinalAccelSafetyTest(PandaSafetyTestBase, abc.ABC): MAX_ACCEL: float = 2.0 diff --git a/tests/safety/test_honda.py b/tests/safety/test_honda.py index 45f190c36a..082199c02b 100755 --- a/tests/safety/test_honda.py +++ b/tests/safety/test_honda.py @@ -24,8 +24,6 @@ class Btn: # * Nidec # * normal (PCM-enable) # * alt SCM messages (PCM-enable) -# * gas interceptor (button-enable) -# * gas interceptor with alt SCM messages (button-enable) # * Bosch # * Bosch with Longitudinal Support # * Bosch Radarless @@ -352,21 +350,6 @@ def test_disable_control_allowed_from_cruise(self): pass -class TestHondaNidecGasInterceptorSafety(common.GasInterceptorSafetyTest, HondaButtonEnableBase, TestHondaNidecSafetyBase): - """ - Covers the Honda Nidec safety mode with a gas interceptor, switches to a button-enable car - """ - - TX_MSGS = HONDA_N_COMMON_TX_MSGS + [[0x200, 0]] - INTERCEPTOR_THRESHOLD = 492 - - def setUp(self): - self.packer = CANPackerPanda("honda_civic_touring_2016_can_generated") - self.safety = libpanda_py.libpanda - self.safety.set_safety_hooks(Panda.SAFETY_HONDA_NIDEC, Panda.FLAG_HONDA_GAS_INTERCEPTOR) - self.safety.init_tests() - - class TestHondaNidecPcmAltSafety(TestHondaNidecPcmSafety): """ Covers the Honda Nidec safety mode with alt SCM messages @@ -389,33 +372,6 @@ def _button_msg(self, buttons, main_on=False, bus=None): return self.packer.make_can_msg_panda("SCM_BUTTONS", bus, values) -class TestHondaNidecAltGasInterceptorSafety(common.GasInterceptorSafetyTest, HondaButtonEnableBase, TestHondaNidecSafetyBase): - """ - Covers the Honda Nidec safety mode with alt SCM messages and gas interceptor, switches to a button-enable car - """ - - TX_MSGS = HONDA_N_COMMON_TX_MSGS + [[0x200, 0]] - INTERCEPTOR_THRESHOLD = 492 - - def setUp(self): - self.packer = CANPackerPanda("acura_ilx_2016_can_generated") - self.safety = libpanda_py.libpanda - self.safety.set_safety_hooks(Panda.SAFETY_HONDA_NIDEC, Panda.FLAG_HONDA_NIDEC_ALT | Panda.FLAG_HONDA_GAS_INTERCEPTOR) - self.safety.init_tests() - - def _acc_state_msg(self, main_on): - values = {"MAIN_ON": main_on, "COUNTER": self.cnt_acc_state % 4} - self.__class__.cnt_acc_state += 1 - return self.packer.make_can_msg_panda("SCM_BUTTONS", self.PT_BUS, values) - - def _button_msg(self, buttons, main_on=False, bus=None): - bus = self.PT_BUS if bus is None else bus - values = {"CRUISE_BUTTONS": buttons, "MAIN_ON": main_on, "COUNTER": self.cnt_button % 4} - self.__class__.cnt_button += 1 - return self.packer.make_can_msg_panda("SCM_BUTTONS", bus, values) - - - # ********************* Honda Bosch ********************** diff --git a/tests/safety/test_toyota.py b/tests/safety/test_toyota.py index 0743c67e83..80bf9ce9a1 100755 --- a/tests/safety/test_toyota.py +++ b/tests/safety/test_toyota.py @@ -14,7 +14,6 @@ [0x128, 1], [0x141, 1], [0x160, 1], [0x161, 1], [0x470, 1], # DSU bus 1 [0x411, 0], # PCS_HUD [0x750, 0]] # radar diagnostic address -GAS_INTERCEPTOR_TX_MSGS = [[0x200, 0]] class TestToyotaSafetyBase(common.PandaCarSafetyTest, common.LongitudinalAccelSafetyTest): @@ -127,32 +126,6 @@ def test_rx_hook(self): self.assertFalse(self.safety.get_controls_allowed()) -class TestToyotaSafetyGasInterceptorBase(common.GasInterceptorSafetyTest, TestToyotaSafetyBase): - - TX_MSGS = TOYOTA_COMMON_TX_MSGS + TOYOTA_COMMON_LONG_TX_MSGS + GAS_INTERCEPTOR_TX_MSGS - INTERCEPTOR_THRESHOLD = 805 - - def setUp(self): - super().setUp() - self.safety.set_safety_hooks(Panda.SAFETY_TOYOTA, self.safety.get_current_safety_param() | - Panda.FLAG_TOYOTA_GAS_INTERCEPTOR) - self.safety.init_tests() - - def test_stock_longitudinal(self): - # If stock longitudinal is set, the gas interceptor safety param should not be respected - self.safety.set_safety_hooks(Panda.SAFETY_TOYOTA, self.safety.get_current_safety_param() | - Panda.FLAG_TOYOTA_STOCK_LONGITUDINAL) - self.safety.init_tests() - - # Spot check a few gas interceptor tests: (1) reading interceptor, - # (2) behavior around interceptor, and (3) txing interceptor msgs - for test in (self.test_prev_gas_interceptor, self.test_disengage_on_gas_interceptor, - self.test_gas_interceptor_safety_check): - with self.subTest(test=test.__name__): - with self.assertRaises(AssertionError): - test() - - class TestToyotaSafetyTorque(TestToyotaSafetyBase, common.MotorTorqueSteeringSafetyTest, common.SteerRequestCutSafetyTest): MAX_RATE_UP = 15 @@ -175,10 +148,6 @@ def setUp(self): self.safety.init_tests() -class TestToyotaSafetyTorqueGasInterceptor(TestToyotaSafetyGasInterceptorBase, TestToyotaSafetyTorque): - pass - - class TestToyotaSafetyAngle(TestToyotaSafetyBase, common.AngleSteeringSafetyTest): # Angle control limits @@ -292,10 +261,6 @@ def test_angle_measurements(self): self.assertEqual(self.safety.get_angle_meas_max(), 0) -class TestToyotaSafetyAngleGasInterceptor(TestToyotaSafetyGasInterceptorBase, TestToyotaSafetyAngle): - pass - - class TestToyotaAltBrakeSafety(TestToyotaSafetyTorque): def setUp(self): @@ -313,10 +278,6 @@ def test_lta_steer_cmd(self): pass -class TestToyotaAltBrakeSafetyGasInterceptor(TestToyotaSafetyGasInterceptorBase, TestToyotaAltBrakeSafety): - pass - - class TestToyotaStockLongitudinalBase(TestToyotaSafetyBase): TX_MSGS = TOYOTA_COMMON_TX_MSGS