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

safety: common gas/brake tests #1416

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
remove gm gas test
  • Loading branch information
sshane committed May 17, 2023
commit c4bb6a581e8b8e1e8ab145fce06d0f220f48dfb0
7 changes: 4 additions & 3 deletions tests/safety/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ def test_gas_actuation_limits(self):
did_tx = self._tx(self._send_gas_msg(gas))
print("gas: ", gas, "controls_allowed: ", controls_allowed, "should_tx: ", controls_allowed and self.MIN_GAS <= gas <= self.MAX_GAS, "did_tx: ", did_tx)
# test that gas command is within min gas and max gas when controls are allowed, but also allow gas if it's inactive at any time
should_tx = (controls_allowed and self.MIN_GAS <= gas <= self.MAX_GAS) or gas == self.INACTIVE_GAS
self.assertEqual(should_tx, did_tx)
should_tx = ((controls_allowed and self.MIN_GAS <= gas <= self.MAX_GAS) or
(not controls_allowed and gas == self.INACTIVE_GAS))
self.assertEqual(should_tx, self._tx(self._send_gas_msg(gas)))

# TODO: test stock longitudinal
def test_brake_actuation_limits(self):
Expand All @@ -229,7 +230,7 @@ def test_brake_actuation_limits(self):
did_tx = self._tx(self._send_brake_msg(brake))
print("brake: ", brake, "controls_allowed: ", controls_allowed, "should_tx: ", (controls_allowed and 0 <= brake <= self.MAX_BRAKE) or brake == 0, "did_tx: ", did_tx)
# test that brake command is within min brake and max brake when controls are allowed, or 0 if controls are not allowed
self.assertEqual(should_tx, did_tx)
self.assertEqual(should_tx, self._tx(self._send_brake_msg(brake)))


class TorqueSteeringSafetyTestBase(PandaSafetyTestBase, abc.ABC):
Expand Down
12 changes: 0 additions & 12 deletions tests/safety/test_gm.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,6 @@ def _button_msg(self, buttons):
values = {"ACCButtons": buttons}
return self.packer.make_can_msg_panda("ASCMSteeringButton", self.BUTTONS_BUS, values)

def test_gas_safety_check(self):
# Block if enabled and out of actuation range, disabled and not inactive regen, or if stock longitudinal
for enabled in [0, 1]:
for gas_regen in range(0, 2 ** 12 - 1):
self.safety.set_controls_allowed(enabled)
should_tx = ((enabled and self.MIN_GAS <= gas_regen <= self.MAX_GAS) or
(not enabled and gas_regen == self.INACTIVE_GAS))
self.assertEqual(should_tx, self._tx(self._send_gas_msg(gas_regen)), (enabled, gas_regen))


class TestGmAscmSafety(GmLongitudinalBase, TestGmSafetyBase):
TX_MSGS = [[384, 0], [1033, 0], [1034, 0], [715, 0], [880, 0], # pt bus
Expand Down Expand Up @@ -213,9 +204,6 @@ def test_buttons(self):
self.assertEqual(enabled, self._tx(self._button_msg(Buttons.CANCEL)))

# GM Cam safety mode does not allow longitudinal messages
def test_gas_safety_check(self):
pass

def test_gas_brake_limits_correct(self):
pass

Expand Down