Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for stock AEB message checks #825

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tests/safety/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest
import importlib
import numpy as np
from typing import Optional, List, Dict
from typing import Optional, List, Dict, Tuple
from opendbc.can.packer import CANPacker # pylint: disable=import-error
from panda import LEN_TO_DLC
from panda.tests.safety import libpandasafety_py
Expand Down Expand Up @@ -253,6 +253,7 @@ class PandaSafetyTest(PandaSafetyTestBase):
RELAY_MALFUNCTION_BUS: Optional[int] = None
FWD_BLACKLISTED_ADDRS: Dict[int, List[int]] = {} # {bus: [addr]}
FWD_BUS_LOOKUP: Dict[int, int] = {}
STOCK_AEB_MSGS: Optional[List[Tuple[int, int, Optional[int]]]] = None

@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -307,6 +308,14 @@ def test_spam_can_buses(self):
if all(addr != m[0] or bus != m[1] for m in self.TX_MSGS):
self.assertFalse(self._tx(make_msg(bus, addr, 8)))

def test_block_aeb(self):
if self.STOCK_AEB_MSGS is None:
raise unittest.SkipTest("no stock AEB messages found")
for addr, target_bus, fwd_source_bus in self.STOCK_AEB_MSGS:
self.assertFalse(self._tx(make_msg(target_bus, addr, 8)))
if fwd_source_bus is not None:
self.assertEqual(target_bus, self.safety.safety_fwd_hook(fwd_source_bus, make_msg(fwd_source_bus, addr, 8)))

def test_default_controls_not_allowed(self):
self.assertFalse(self.safety.get_controls_allowed())

Expand Down
2 changes: 2 additions & 0 deletions tests/safety/test_volkswagen_mqb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
MSG_ESP_19 = 0xB2 # RX from ABS, for wheel speeds
MSG_LH_EPS_03 = 0x9F # RX from EPS, for driver steering torque
MSG_ESP_05 = 0x106 # RX from ABS, for brake light state
MSG_ACC_10 = 0x117 # TX by stock radar, automated emergency braking
MSG_TSK_06 = 0x120 # RX from ECU, for ACC status from drivetrain coordinator
MSG_MOTOR_20 = 0x121 # RX from ECU, for driver throttle input
MSG_HCA_01 = 0x126 # TX by OP, Heading Control Assist steering torque
Expand All @@ -36,6 +37,7 @@ class TestVolkswagenMqbSafety(common.PandaSafetyTest):
STANDSTILL_THRESHOLD = 1
RELAY_MALFUNCTION_ADDR = MSG_HCA_01
RELAY_MALFUNCTION_BUS = 0
STOCK_AEB_MSGS = [(MSG_ACC_10, 0, 2)]

@classmethod
def setUpClass(cls):
Expand Down
2 changes: 2 additions & 0 deletions tests/safety/test_volkswagen_pq.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
MSG_LENKHILFE_3 = 0x0D0 # RX from EPS, for steering angle and driver steering torque
MSG_HCA_1 = 0x0D2 # TX by OP, Heading Control Assist steering torque
MSG_MOTOR_2 = 0x288 # RX from ECU, for CC state and brake switch state
MSG_AWV = 0x366 # TX by stock radar, automated emergency braking
MSG_MOTOR_3 = 0x380 # RX from ECU, for driver throttle input
MSG_GRA_NEU = 0x38A # TX by OP, ACC control buttons for cancel/resume
MSG_BREMSE_1 = 0x1A0 # RX from ABS, for ego speed
Expand All @@ -44,6 +45,7 @@ class TestVolkswagenPqSafety(common.PandaSafetyTest):
STANDSTILL_THRESHOLD = 1
RELAY_MALFUNCTION_ADDR = MSG_HCA_1
RELAY_MALFUNCTION_BUS = 0
STOCK_AEB_MSGS = [(MSG_AWV, 0, 2)]
FWD_BLACKLISTED_ADDRS = {2: [MSG_HCA_1, MSG_LDW_1]}
FWD_BUS_LOOKUP = {0: 2, 2: 0}

Expand Down