mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-19 01:33:52 +08:00
Hyundai: support 90deg angle limit bypass (#1091)
* h90d safety * quicker rate * update comment * support multi frames? * stash * stash * might work? * stash * clean up * revert that * add test * fixup tests * clean up * remove test * try to combine tests * Revert "try to combine tests" This reverts commit f147955b94119eca0abd1b605844ab5002fb0305. * seems simpler * more explicit * shouldn't be needed * comment * fix that test
This commit is contained in:
@@ -9,6 +9,13 @@ const SteeringLimits HYUNDAI_STEERING_LIMITS = {
|
||||
.driver_torque_allowance = 50,
|
||||
.driver_torque_factor = 2,
|
||||
.type = TorqueDriverLimited,
|
||||
|
||||
// the EPS faults when the steering angle is above a certain threshold for too long. to prevent this,
|
||||
// we allow setting CF_Lkas_ActToi bit to 0 while maintaining the requested torque value for two consecutive frames
|
||||
.min_valid_request_frames = 89,
|
||||
.max_invalid_request_frames = 2,
|
||||
.min_valid_request_rt_interval = 810000, // 810ms; a ~10% buffer on cutting every 90 frames
|
||||
.has_steer_req_tolerance = true,
|
||||
};
|
||||
|
||||
const int HYUNDAI_MAX_ACCEL = 200; // 1/100 m/s2
|
||||
|
||||
@@ -245,10 +245,12 @@ class TorqueSteeringSafetyTestBase(PandaSafetyTestBase):
|
||||
self.assertTrue(self._tx(self._torque_cmd_msg(self.MAX_TORQUE, steer_req=1)))
|
||||
|
||||
# Send partial amount of allowed invalid frames
|
||||
for _ in range(max_invalid_steer_frames):
|
||||
self.assertTrue(self._tx(self._torque_cmd_msg(self.MAX_TORQUE, steer_req=0)))
|
||||
for idx in range(max_invalid_steer_frames):
|
||||
should_tx = idx < self.MAX_INVALID_STEERING_FRAMES
|
||||
self.assertEqual(should_tx, self._tx(self._torque_cmd_msg(self.MAX_TORQUE, steer_req=0)))
|
||||
|
||||
# Send one valid frame, and subsequent invalid should now be blocked
|
||||
self._set_prev_torque(self.MAX_TORQUE)
|
||||
self.assertTrue(self._tx(self._torque_cmd_msg(self.MAX_TORQUE, steer_req=1)))
|
||||
for _ in range(self.MIN_VALID_STEERING_FRAMES + 1):
|
||||
self.assertFalse(self._tx(self._torque_cmd_msg(self.MAX_TORQUE, steer_req=0)))
|
||||
|
||||
@@ -76,6 +76,11 @@ class TestHyundaiSafety(HyundaiButtonBase, common.PandaSafetyTest, common.Driver
|
||||
DRIVER_TORQUE_ALLOWANCE = 50
|
||||
DRIVER_TORQUE_FACTOR = 2
|
||||
|
||||
# Safety around steering req bit
|
||||
MIN_VALID_STEERING_FRAMES = 89
|
||||
MAX_INVALID_STEERING_FRAMES = 2
|
||||
MIN_VALID_STEERING_RT_INTERVAL = 810000 # a ~10% buffer, can send steer up to 110Hz
|
||||
|
||||
cnt_gas = 0
|
||||
cnt_speed = 0
|
||||
cnt_brake = 0
|
||||
@@ -125,22 +130,6 @@ class TestHyundaiSafety(HyundaiButtonBase, common.PandaSafetyTest, common.Driver
|
||||
values = {"CR_Lkas_StrToqReq": torque, "CF_Lkas_ActToi": steer_req}
|
||||
return self.packer.make_can_msg_panda("LKAS11", 0, values)
|
||||
|
||||
def test_steer_req_bit(self):
|
||||
"""
|
||||
On Hyundai, you can ramp up torque and then set the CF_Lkas_ActToi bit and the
|
||||
EPS will ramp up faster than the effective panda safety limits. This tests:
|
||||
- Nothing is sent when cutting torque
|
||||
- Nothing is blocked when sending torque normally
|
||||
"""
|
||||
self.safety.set_controls_allowed(True)
|
||||
for _ in range(100):
|
||||
self._set_prev_torque(self.MAX_TORQUE)
|
||||
self.assertFalse(self._tx(self._torque_cmd_msg(self.MAX_TORQUE, steer_req=0)))
|
||||
|
||||
self._set_prev_torque(self.MAX_TORQUE)
|
||||
for _ in range(100):
|
||||
self.assertTrue(self._tx(self._torque_cmd_msg(self.MAX_TORQUE, steer_req=1)))
|
||||
|
||||
|
||||
class TestHyundaiSafetyCameraSCC(TestHyundaiSafety):
|
||||
BUTTONS_BUS = 2 # tx on 2, rx on 0
|
||||
|
||||
Reference in New Issue
Block a user