From 26a45ca18d8c84edc24ab7be2b8b7112a32f2de4 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 10 Nov 2023 23:50:22 -0800 Subject: [PATCH] remove get_decel_allowed --- board/safety.h | 14 +++----------- board/safety_declarations.h | 1 - tests/libpanda/safety_helpers.py | 4 ++-- tests/safety/common.py | 18 +++++++++--------- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/board/safety.h b/board/safety.h index 7a1128802..6ba196255 100644 --- a/board/safety.h +++ b/board/safety.h @@ -86,16 +86,8 @@ bool get_longitudinal_allowed(void) { return controls_allowed && !gas_pressed_prev; } - - -bool get_decel_allowed(void) { - // No longitudinal control when overriding with gas. Only brake is allowed when pre-enabling at a standstill - return controls_allowed && !gas_pressed_prev; -} - bool get_accel_allowed(void) { - // No positive acceleration/gas command while pre-enabled at a stop with brake -// return get_decel_allowed() && !brake_pressed_prev && !regen_braking_prev; + // No gas while pre-enabled at a stop with brake return get_longitudinal_allowed() && !brake_pressed_prev && !regen_braking_prev; } @@ -527,7 +519,7 @@ bool longitudinal_accel_checks(int desired_accel, const LongitudinalLimits limit } bool longitudinal_speed_checks(int desired_speed, const LongitudinalLimits limits) { - return !get_decel_allowed() && (desired_speed != limits.inactive_speed); + return !get_longitudinal_allowed() && (desired_speed != limits.inactive_speed); } bool longitudinal_transmission_rpm_checks(int desired_transmission_rpm, const LongitudinalLimits limits) { @@ -544,7 +536,7 @@ bool longitudinal_gas_checks(int desired_gas, const LongitudinalLimits limits) { bool longitudinal_brake_checks(int desired_brake, const LongitudinalLimits limits) { bool violation = false; - violation |= !get_decel_allowed() && (desired_brake != 0); + violation |= !get_longitudinal_allowed() && (desired_brake != 0); violation |= desired_brake > limits.max_brake; return violation; } diff --git a/board/safety_declarations.h b/board/safety_declarations.h index 9ac9bd977..85cfef35a 100644 --- a/board/safety_declarations.h +++ b/board/safety_declarations.h @@ -149,7 +149,6 @@ bool driver_limit_check(int val, int val_last, struct sample_t *val_driver, const int MAX, const int MAX_RATE_UP, const int MAX_RATE_DOWN, const int MAX_ALLOWANCE, const int DRIVER_FACTOR); bool get_longitudinal_allowed(void); -bool get_decel_allowed(void); bool get_accel_allowed(void); bool rt_rate_limit_check(int val, int val_last, const int MAX_RT_DELTA); float interpolate(struct lookup_t xy, float x); diff --git a/tests/libpanda/safety_helpers.py b/tests/libpanda/safety_helpers.py index 4bf4a9021..da1169220 100644 --- a/tests/libpanda/safety_helpers.py +++ b/tests/libpanda/safety_helpers.py @@ -5,7 +5,7 @@ def setup_safety_helpers(ffi): ffi.cdef(""" void set_controls_allowed(bool c); bool get_controls_allowed(void); - bool get_decel_allowed(void); + bool get_longitudinal_allowed(void); bool get_accel_allowed(void); void set_alternative_experience(int mode); int get_alternative_experience(void); @@ -57,7 +57,7 @@ def setup_safety_helpers(ffi): class PandaSafety(Protocol): def set_controls_allowed(self, c: bool) -> None: ... def get_controls_allowed(self) -> bool: ... - def get_decel_allowed(self) -> bool: ... + def get_longitudinal_allowed(self) -> bool: ... def get_accel_allowed(self) -> bool: ... def set_alternative_experience(self, mode: int) -> None: ... def get_alternative_experience(self) -> int: ... diff --git a/tests/safety/common.py b/tests/safety/common.py index 576ad79d7..45e94b48f 100644 --- a/tests/safety/common.py +++ b/tests/safety/common.py @@ -165,11 +165,11 @@ class InterceptorSafetyTest(PandaSafetyTestBase): 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_decel_allowed()) + self.assertEqual(g <= self.INTERCEPTOR_THRESHOLD, self.safety.get_longitudinal_allowed()) self.assertEqual(g <= self.INTERCEPTOR_THRESHOLD, self.safety.get_accel_allowed()) # Make sure we can re-gain longitudinal actuation self._rx(self._interceptor_user_gas(0)) - self.assertTrue(self.safety.get_decel_allowed()) + self.assertTrue(self.safety.get_longitudinal_allowed()) self.assertTrue(self.safety.get_accel_allowed()) def test_allow_engage_with_gas_interceptor_pressed(self): @@ -1010,11 +1010,11 @@ class PandaCarSafetyTest(PandaSafetyTest): self._rx(self._user_gas_msg(self.GAS_PRESSED_THRESHOLD + 1)) # Test we allow lateral, but not longitudinal self.assertTrue(self.safety.get_controls_allowed()) - self.assertFalse(self.safety.get_decel_allowed()) + self.assertFalse(self.safety.get_longitudinal_allowed()) self.assertFalse(self.safety.get_accel_allowed()) # Make sure we can re-gain longitudinal actuation self._rx(self._user_gas_msg(0)) - self.assertTrue(self.safety.get_decel_allowed()) + self.assertTrue(self.safety.get_longitudinal_allowed()) self.assertTrue(self.safety.get_accel_allowed()) def test_prev_user_brake(self, _user_brake_msg=None, get_brake_pressed_prev=None): @@ -1057,16 +1057,16 @@ class PandaCarSafetyTest(PandaSafetyTest): self.safety.set_controls_allowed(1) self._rx(_user_brake_msg(1)) self.assertTrue(self.safety.get_controls_allowed()) - self.assertTrue(self.safety.get_decel_allowed()) + self.assertTrue(self.safety.get_longitudinal_allowed()) self.assertFalse(self.safety.get_accel_allowed()) self._rx(_user_brake_msg(0)) self.assertTrue(self.safety.get_controls_allowed()) - self.assertTrue(self.safety.get_decel_allowed()) + self.assertTrue(self.safety.get_longitudinal_allowed()) self.assertTrue(self.safety.get_accel_allowed()) # rising edge of brake should disengage self._rx(_user_brake_msg(1)) self.assertFalse(self.safety.get_controls_allowed()) - self.assertFalse(self.safety.get_decel_allowed()) + self.assertFalse(self.safety.get_longitudinal_allowed()) self.assertFalse(self.safety.get_accel_allowed()) self._rx(_user_brake_msg(0)) # reset no brakes @@ -1080,12 +1080,12 @@ class PandaCarSafetyTest(PandaSafetyTest): self._rx(self._vehicle_moving_msg(self.STANDSTILL_THRESHOLD)) self._rx(_user_brake_msg(1)) self.assertTrue(self.safety.get_controls_allowed()) - self.assertTrue(self.safety.get_decel_allowed()) + self.assertTrue(self.safety.get_longitudinal_allowed()) self.assertFalse(self.safety.get_accel_allowed()) self._rx(self._vehicle_moving_msg(self.STANDSTILL_THRESHOLD + 1)) self._rx(_user_brake_msg(1)) self.assertFalse(self.safety.get_controls_allowed()) - self.assertFalse(self.safety.get_decel_allowed()) + self.assertFalse(self.safety.get_longitudinal_allowed()) self.assertFalse(self.safety.get_accel_allowed()) self._rx(self._vehicle_moving_msg(0))