Ford safety: prevent disable AEB (#1428)

* Ford AEB safety

* whoops

* working tests

* debugging

* clean up

* stock aeb test

* split up test

* rm

* cmt

* rm

* just test stateless sigs for simple branch

* clean up

* rm

* just test this bit

* it's signed now

* cmt

* cmt

* clean up

* ohh
This commit is contained in:
Shane Smiskol 2023-05-18 14:14:26 -07:00 committed by GitHub
parent 622106d7d4
commit 2a53833753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -264,11 +264,16 @@ static int ford_tx_hook(CANPacket_t *to_send) {
int gas = ((GET_BYTE(to_send, 6) & 0x3U) << 8) | GET_BYTE(to_send, 7);
// Signal: AccBrkTot_A_Rq
int accel = ((GET_BYTE(to_send, 0) & 0x1FU) << 8) | GET_BYTE(to_send, 1);
// Signal: CmbbDeny_B_Actl
int cmbb_deny = GET_BIT(to_send, 37U);
bool violation = false;
violation |= longitudinal_accel_checks(accel, FORD_LONG_LIMITS);
violation |= longitudinal_gas_checks(gas, FORD_LONG_LIMITS);
// Safety check for stock AEB
violation |= cmbb_deny != 0; // do not prevent stock AEB actuation
if (violation) {
tx = 0;
}

View File

@ -373,13 +373,24 @@ class TestFordLongitudinalSafety(TestFordSafetyBase):
self.safety.init_tests()
# ACC command
def _acc_command_msg(self, gas: float, brake: float):
def _acc_command_msg(self, gas: float, brake: float, cmbb_deny: bool = False):
values = {
"AccPrpl_A_Rq": gas, # [-5|5.23] m/s^2
"AccBrkTot_A_Rq": brake, # [-20|11.9449] m/s^2
"CmbbDeny_B_Actl": 1 if cmbb_deny else 0, # [0|1] deny AEB actuation
}
return self.packer.make_can_msg_panda("ACCDATA", 0, values)
def test_stock_aeb(self):
# Test that CmbbDeny_B_Actl is never 1, it prevents the ABS module from actuating AEB requests from ACCDATA_2
for controls_allowed in (True, False):
self.safety.set_controls_allowed(controls_allowed)
for cmbb_deny in (True, False):
should_tx = not cmbb_deny
self.assertEqual(should_tx, self._tx(self._acc_command_msg(self.INACTIVE_GAS, self.INACTIVE_ACCEL, cmbb_deny)))
should_tx = controls_allowed and not cmbb_deny
self.assertEqual(should_tx, self._tx(self._acc_command_msg(self.MAX_GAS, self.MAX_ACCEL, cmbb_deny)))
def test_gas_safety_check(self):
for controls_allowed in (True, False):
self.safety.set_controls_allowed(controls_allowed)