diff --git a/opendbc_repo/opendbc/car/gm/interface.py b/opendbc_repo/opendbc/car/gm/interface.py index be27e24a8..673097ee3 100755 --- a/opendbc_repo/opendbc/car/gm/interface.py +++ b/opendbc_repo/opendbc/car/gm/interface.py @@ -59,11 +59,6 @@ NON_LINEAR_TORQUE_PARAMS = { "right": [3.8, 0.81, 0.24, 0.0465122], }, } -SILVERADO_TRAILER_MODE_TESTING_GROUND_ID = testing_ground.id_6 -SILVERADO_TRAILER_NON_LINEAR_TORQUE_PARAMS = { - "left": [4.1, 0.84, 0.262, 0.0465122], - "right": [3.8, 0.81, 0.24, 0.0465122], -} PEDAL_MSG = 0x201 CAM_MSG = 0x320 @@ -106,16 +101,6 @@ BOLT_GEN1_CANCEL_PERSONALITY_CARS = { CANCEL_REMAP_DISTANCE_CARS = BOLT_GEN1_CANCEL_PERSONALITY_CARS -def silverado_trailer_mode_active() -> bool: - return testing_ground.use(SILVERADO_TRAILER_MODE_TESTING_GROUND_ID) - - -def get_non_linear_torque_params(candidate: str): - if candidate == CAR.CHEVROLET_SILVERADO and silverado_trailer_mode_active(): - return SILVERADO_TRAILER_NON_LINEAR_TORQUE_PARAMS - return NON_LINEAR_TORQUE_PARAMS.get(candidate) - - class CarInterface(CarInterfaceBase): CarState = CarState CarController = CarController @@ -156,7 +141,7 @@ class CarInterface(CarInterfaceBase): # The "lat_accel vs torque" relationship is assumed to be the sum of "sigmoid + linear" curves # An important thing to consider is that the slope at 0 should be > 0 (ideally >1) # This has big effect on the stability about 0 (noise when going straight) - non_linear_torque_params = get_non_linear_torque_params(self.CP.carFingerprint) + non_linear_torque_params = NON_LINEAR_TORQUE_PARAMS.get(self.CP.carFingerprint) assert non_linear_torque_params, "The params are not defined" if isinstance(non_linear_torque_params, dict): side_key = "left" if lateral_acceleration >= 0 else "right" @@ -174,7 +159,7 @@ class CarInterface(CarInterfaceBase): return torque_values, lataccel_values def torque_from_lateral_accel(self) -> TorqueFromLateralAccelCallbackType: - if get_non_linear_torque_params(self.CP.carFingerprint) is not None: + if self.CP.carFingerprint in NON_LINEAR_TORQUE_PARAMS: torque_values, lataccel_values = self.get_lataccel_torque_siglin() def torque_from_lateral_accel_siglin(lateral_acceleration: float, torque_params: structs.CarParams.LateralTorqueTuning): @@ -184,7 +169,7 @@ class CarInterface(CarInterfaceBase): return self.torque_from_lateral_accel_linear def lateral_accel_from_torque(self) -> LateralAccelFromTorqueCallbackType: - if get_non_linear_torque_params(self.CP.carFingerprint) is not None: + if self.CP.carFingerprint in NON_LINEAR_TORQUE_PARAMS: torque_values, lataccel_values = self.get_lataccel_torque_siglin() def lateral_accel_from_torque_siglin(torque: float, torque_params: structs.CarParams.LateralTorqueTuning): diff --git a/opendbc_repo/opendbc/car/gm/tests/test_gm.py b/opendbc_repo/opendbc/car/gm/tests/test_gm.py index d767b8c17..1e71a4b5e 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_gm.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_gm.py @@ -63,27 +63,16 @@ class TestGMInterface: fingerprint[0][0x201] = 8 # pedal detected fingerprint[0][0x2FF] = 8 # SASCM detected - monkeypatch.setattr(gm_interface, "testing_ground", SimpleNamespace(use_2=True)) + monkeypatch.setattr(gm_interface.testing_ground, "use_2", True, raising=False) car_params = CarInterface.get_params(CAR.CHEVROLET_VOLT_ASCM, fingerprint, [], alpha_long=False, is_release=False, docs=False, starpilot_toggles=_test_starpilot_toggles()) - assert list(car_params.longitudinalTuning.kpV) == pytest.approx([0.10, 0.072, 0.05, 0.04]) - assert list(car_params.longitudinalTuning.kiV) == pytest.approx([0.025, 0.03, 0.04, 0.055]) + assert list(car_params.longitudinalTuning.kpV) == [0.10, 0.072, 0.05, 0.04] + assert list(car_params.longitudinalTuning.kiV) == [0.025, 0.03, 0.04, 0.055] assert car_params.startingState assert car_params.startAccel == pytest.approx(1.15) - def test_silverado_testing_ground_uses_left_biased_non_linear_torque_params(self, monkeypatch): - stock_params = gm_interface.get_non_linear_torque_params(CAR.CHEVROLET_SILVERADO) - - monkeypatch.setattr(gm_interface, "silverado_trailer_mode_active", lambda: True) - tuned_params = gm_interface.get_non_linear_torque_params(CAR.CHEVROLET_SILVERADO) - - assert tuned_params["left"][0] > stock_params["left"][0] - assert tuned_params["left"][1] > stock_params["left"][1] - assert tuned_params["left"][2] > stock_params["left"][2] - assert tuned_params["right"] == stock_params["right"] - class TestGMCarController: def test_dash_speed_spoof_respects_live_stock_acc_toggles(self): diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index 8fcbe83e7..9fe4be959 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -384,6 +384,7 @@ class LatControlTorque(LatControl): self.is_bolt_2022_2023 = CP.carFingerprint in BOLT_2022_2023_CARS self.is_bolt_2018_2021 = CP.carFingerprint in BOLT_2018_2021_CARS self.is_bolt_2017 = CP.carFingerprint in BOLT_2017_CARS + self.is_silverado = CP.carFingerprint == GM_CAR.CHEVROLET_SILVERADO self.use_bolt_ff_scaling = self.is_bolt_2022_2023 or self.is_bolt_2018_2021 or self.is_bolt_2017 self.use_bolt_ki_multiplier = self.use_bolt_ff_scaling self.torque_ff_scale_pos = 1.0 diff --git a/selfdrive/controls/tests/test_latcontrol.py b/selfdrive/controls/tests/test_latcontrol.py index d53c3e6a4..76d422944 100644 --- a/selfdrive/controls/tests/test_latcontrol.py +++ b/selfdrive/controls/tests/test_latcontrol.py @@ -144,13 +144,6 @@ class TestLatControl: assert lac_log.active - def test_silverado_default_update_path(self): - controller, VM, CS, params, starpilot_toggles = self._build_torque_controller(GM.CHEVROLET_SILVERADO) - - _, _, lac_log = controller.update(True, CS, VM, params, False, 0.0025, False, 0.2, None, None, starpilot_toggles) - - assert lac_log.active - @parameterized.expand([(HONDA.HONDA_CIVIC, LatControlPID), (TOYOTA.TOYOTA_RAV4, LatControlTorque), (NISSAN.NISSAN_LEAF, LatControlAngle), (GM.CHEVROLET_BOLT_ACC_2022_2023, LatControlTorque)]) def test_saturation(self, car_name, controller): diff --git a/starpilot/common/testing_grounds.py b/starpilot/common/testing_grounds.py index 88f109d67..c37f4c636 100644 --- a/starpilot/common/testing_grounds.py +++ b/starpilot/common/testing_grounds.py @@ -65,10 +65,9 @@ TESTING_GROUNDS_SLOT_DEFINITIONS = ( }, { "id": TESTING_GROUND_6, - "name": "Silverado Trailer Mode", - "description": "Silverado/Sierra lateral A/B sandbox for trailer-related hugging and turn-in response.", - "aLabel": "A - Installed tune", - "bLabel": "B - Trailer assist tune", + "name": "Unused", + "description": "", + "aLabel": "A", }, { "id": TESTING_GROUND_7, diff --git a/starpilot/common/tests/test_testing_grounds.py b/starpilot/common/tests/test_testing_grounds.py index ddc7ae2e5..23f165721 100644 --- a/starpilot/common/tests/test_testing_grounds.py +++ b/starpilot/common/tests/test_testing_grounds.py @@ -1,13 +1,16 @@ import json +import pytest + from openpilot.starpilot.common import testing_grounds as tg -def test_hidden_testing_ground_selection_is_migrated(tmp_path, monkeypatch): +@pytest.mark.parametrize("hidden_slot_id", [tg.TESTING_GROUND_3, tg.TESTING_GROUND_6]) +def test_hidden_testing_ground_selection_is_migrated(tmp_path, monkeypatch, hidden_slot_id): state_path = tmp_path / "slots.json" state_path.write_text(json.dumps({ "schemaVersion": tg.TESTING_GROUNDS_SCHEMA_VERSION, - "activeSlot": tg.TESTING_GROUND_3, + "activeSlot": hidden_slot_id, "activeVariant": tg.TESTING_GROUND_TEST_VARIANT, }), encoding="utf-8")