Skip to content

Commit

Permalink
GM: move more longitudinal related function into class (commaai#1574)
Browse files Browse the repository at this point in the history
move these into the long test
  • Loading branch information
sshane authored Aug 11, 2023
1 parent 61590b6 commit 20b1e50
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions tests/safety/test_gm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ class GmLongitudinalBase(common.PandaSafetyTest):

PCM_CRUISE = False # openpilot can control the PCM state if longitudinal

def _send_brake_msg(self, brake):
values = {"FrictionBrakeCmd": -brake}
return self.packer_chassis.make_can_msg_panda("EBCMFrictionBrakeCmd", self.BRAKE_BUS, values)

def _send_gas_msg(self, gas):
values = {"GasRegenCmd": gas}
return self.packer.make_can_msg_panda("ASCMGasRegenCmd", 0, values)

# override these tests from PandaSafetyTest, GM longitudinal uses button enable
def _pcm_status_msg(self, enable):
raise NotImplementedError

def test_disable_control_allowed_from_cruise(self):
pass

def test_enable_control_allowed_from_cruise(self):
pass

def test_cruise_engaged_prev(self):
pass

def test_set_resume_buttons(self):
"""
SET and RESUME enter controls allowed on their falling and rising edges, respectively.
Expand Down Expand Up @@ -64,19 +85,6 @@ def test_gas_safety_check(self):
gas_regen == self.INACTIVE_REGEN)
self.assertEqual(should_tx, self._tx(self._send_gas_msg(gas_regen)), (enabled, gas_regen))

# override these tests from PandaSafetyTest, GM longitudinal uses button enable
def test_disable_control_allowed_from_cruise(self):
pass

def test_enable_control_allowed_from_cruise(self):
pass

def test_cruise_engaged_prev(self):
pass

def _pcm_status_msg(self, enable):
pass


class TestGmSafetyBase(common.PandaSafetyTest, common.DriverTorqueSteeringSafetyTest):
STANDSTILL_THRESHOLD = 10 * 0.0311
Expand Down Expand Up @@ -136,14 +144,6 @@ def _user_gas_msg(self, gas):
values["CruiseState"] = self.safety.get_controls_allowed()
return self.packer.make_can_msg_panda("AcceleratorPedal2", 0, values)

def _send_brake_msg(self, brake):
values = {"FrictionBrakeCmd": -brake}
return self.packer_chassis.make_can_msg_panda("EBCMFrictionBrakeCmd", self.BRAKE_BUS, values)

def _send_gas_msg(self, gas):
values = {"GasRegenCmd": gas}
return self.packer.make_can_msg_panda("ASCMGasRegenCmd", 0, values)

def _torque_driver_msg(self, torque):
values = {"LKADriverAppldTrq": torque}
return self.packer.make_can_msg_panda("PSCMStatus", 0, values)
Expand Down

0 comments on commit 20b1e50

Please sign in to comment.