mirror of
https://github.com/infiniteCable2/opendbc.git
synced 2026-02-18 13:03:52 +08:00
Revert "Toyota: SecOC Longitudinal Control (#126)"
This reverts commit d2002787f6.
This commit is contained in:
@@ -8,7 +8,6 @@ import itertools
|
||||
from opendbc.car.toyota.values import ToyotaSafetyFlags
|
||||
from opendbc.sunnypilot.car.toyota.values import ToyotaSafetyFlagsSP
|
||||
from opendbc.car.structs import CarParams
|
||||
from opendbc.safety import ALTERNATIVE_EXPERIENCE
|
||||
from opendbc.safety.tests.libsafety import libsafety_py
|
||||
import opendbc.safety.tests.common as common
|
||||
from opendbc.safety.tests.common import CANPackerSafety
|
||||
@@ -491,52 +490,5 @@ class TestToyotaSecOcSafety(TestToyotaSecOcSafetyBase):
|
||||
self.assertEqual(should_tx, self._tx(self._accel_msg_343(accel, cancel_req=1)))
|
||||
|
||||
|
||||
class TestToyotaSecOcSafetyStockLongitudinal(TestToyotaSecOcSafetyBase, TestToyotaStockLongitudinalBase):
|
||||
|
||||
def setUp(self):
|
||||
self.packer = CANPackerPanda("toyota_secoc_pt_generated")
|
||||
self.safety = libsafety_py.libsafety
|
||||
self.safety.set_safety_hooks(CarParams.SafetyModel.toyota,
|
||||
self.EPS_SCALE | ToyotaSafetyFlags.STOCK_LONGITUDINAL | ToyotaSafetyFlags.SECOC)
|
||||
self.safety.init_tests()
|
||||
|
||||
def test_diagnostics(self, stock_longitudinal: bool = True, ecu_disabled: bool = False):
|
||||
super().test_diagnostics(stock_longitudinal=stock_longitudinal, ecu_disabled=ecu_disabled)
|
||||
|
||||
|
||||
class TestToyotaSecOcSafety(TestToyotaSecOcSafetyBase):
|
||||
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (0x2E4, 0x343, 0x183, 0x191, 0x412, 0x131)}
|
||||
FWD_BLACKLISTED_ADDRS = {2: [0x2E4, 0x191, 0x412, 0x131, 0x343, 0x183]}
|
||||
|
||||
def setUp(self):
|
||||
self.packer = CANPackerPanda("toyota_secoc_pt_generated")
|
||||
self.safety = libsafety_py.libsafety
|
||||
self.safety.set_safety_hooks(CarParams.SafetyModel.toyota, self.EPS_SCALE | ToyotaSafetyFlags.SECOC)
|
||||
self.safety.init_tests()
|
||||
|
||||
def _accel_msg_2(self, accel):
|
||||
values = {"ACCEL_CMD": accel}
|
||||
return self.packer.make_can_msg_panda("ACC_CONTROL_2", 0, values)
|
||||
|
||||
def test_accel_actuation_limits(self, stock_longitudinal=False):
|
||||
limits = ((self.MIN_ACCEL, self.MAX_ACCEL, ALTERNATIVE_EXPERIENCE.DEFAULT),
|
||||
(self.MIN_ACCEL, self.MAX_ACCEL, ALTERNATIVE_EXPERIENCE.RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX))
|
||||
|
||||
for min_accel, max_accel, alternative_experience in limits:
|
||||
# enforce we don't skip over 0 or inactive accel
|
||||
for accel in np.concatenate((np.arange(min_accel - 1, max_accel + 1, 0.05), [0, self.INACTIVE_ACCEL])):
|
||||
accel = round(accel, 2) # floats might not hit exact boundary conditions without rounding
|
||||
for controls_allowed in [True, False]:
|
||||
self.safety.set_controls_allowed(controls_allowed)
|
||||
self.safety.set_alternative_experience(alternative_experience)
|
||||
# On a SecOC vehicle, we still transmit ACC_CONTROL but the accel value moves to ACC_CONTROL_2
|
||||
# Verify that all non-idle accel values in ACC_CONTROL are rejected, verify ACC_CONTROL_2 accel normally
|
||||
should_tx_1 = accel == self.INACTIVE_ACCEL
|
||||
should_tx_2 = (controls_allowed and min_accel <= accel <= max_accel) or accel == self.INACTIVE_ACCEL
|
||||
self.assertEqual(should_tx_1, self._tx(self._accel_msg(accel)))
|
||||
self.assertEqual(should_tx_2, self._tx(self._accel_msg_2(accel)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user