From ab52d2a3c0d431d2ba72b39740b5bb1937fa1b7a Mon Sep 17 00:00:00 2001 From: garrettpall <76917194+garrettpall@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:24:18 -0400 Subject: [PATCH] GM: Car Port for XT4 2023 --- opendbc/car/docs_definitions.py | 2 ++ opendbc/car/gm/carstate.py | 10 +++++++--- opendbc/car/gm/fingerprints.py | 5 +++++ opendbc/car/gm/interface.py | 13 +++++++++---- opendbc/car/gm/values.py | 20 ++++++++++++++++++-- opendbc/car/tests/routes.py | 1 + opendbc/car/torque_data/override.toml | 1 + 7 files changed, 43 insertions(+), 9 deletions(-) diff --git a/opendbc/car/docs_definitions.py b/opendbc/car/docs_definitions.py index db022f9143..5e0fa28a00 100644 --- a/opendbc/car/docs_definitions.py +++ b/opendbc/car/docs_definitions.py @@ -114,6 +114,8 @@ class CarHarness(EnumBase): custom = BaseCarHarness("Developer connector") obd_ii = BaseCarHarness("OBD-II connector", parts=[Cable.long_obdc_cable, Cable.long_obdc_cable], has_connector=False) gm = BaseCarHarness("GM connector", parts=[Accessory.harness_box]) + gmsdgm = BaseCarHarness("GM SDGM connector", parts=[Accessory.harness_box, Cable.rj45_cable_7ft, Cable.long_obdc_cable, + Cable.usbc_coupler, Accessory.comma_power_v2]) nissan_a = BaseCarHarness("Nissan A connector", parts=[Accessory.harness_box, Cable.rj45_cable_7ft, Cable.long_obdc_cable, Cable.usbc_coupler]) nissan_b = BaseCarHarness("Nissan B connector", parts=[Accessory.harness_box, Cable.rj45_cable_7ft, Cable.long_obdc_cable, Cable.usbc_coupler]) mazda = BaseCarHarness("Mazda connector") diff --git a/opendbc/car/gm/carstate.py b/opendbc/car/gm/carstate.py index cd30639787..318646bbe2 100644 --- a/opendbc/car/gm/carstate.py +++ b/opendbc/car/gm/carstate.py @@ -5,7 +5,7 @@ from opendbc.car.common.conversions import Conversions as CV from opendbc.car.common.numpy_fast import mean from opendbc.car.interfaces import CarStateBase -from opendbc.car.gm.values import DBC, AccState, CanBus, CruiseButtons, STEER_THRESHOLD +from opendbc.car.gm.values import DBC, AccState, CanBus, CruiseButtons, STEER_THRESHOLD, SDGM_CAR ButtonType = structs.CarState.ButtonEvent.Type TransmissionType = structs.CarParams.TransmissionType @@ -119,7 +119,8 @@ def update(self, pt_cp, cam_cp, _, __, loopback_cp) -> structs.CarState: ret.cruiseState.standstill = pt_cp.vl["AcceleratorPedal2"]["CruiseState"] == AccState.STANDSTILL if self.CP.networkLocation == NetworkLocation.fwdCamera: ret.cruiseState.speed = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCSpeedSetpoint"] * CV.KPH_TO_MS - ret.stockAeb = cam_cp.vl["AEBCmd"]["AEBCmdActive"] != 0 + if self.CP.carFingerprint not in SDGM_CAR: + ret.stockAeb = cam_cp.vl["AEBCmd"]["AEBCmdActive"] != 0 # openpilot controls nonAdaptive when not pcmCruise if self.CP.pcmCruise: ret.cruiseState.nonAdaptive = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCCruiseState"] not in (2, 3) @@ -144,10 +145,13 @@ def get_cam_can_parser(CP): messages = [] if CP.networkLocation == NetworkLocation.fwdCamera: messages += [ - ("AEBCmd", 10), ("ASCMLKASteeringCmd", 10), ("ASCMActiveCruiseControlStatus", 25), ] + if CP.carFingerprint not in SDGM_CAR: + messages += [ + ("AEBCmd", 10), + ] return CANParser(DBC[CP.carFingerprint]["pt"], messages, CanBus.CAMERA) diff --git a/opendbc/car/gm/fingerprints.py b/opendbc/car/gm/fingerprints.py index 57dbff41b6..039c05b344 100644 --- a/opendbc/car/gm/fingerprints.py +++ b/opendbc/car/gm/fingerprints.py @@ -57,6 +57,11 @@ { 190: 6, 201: 8, 211: 2, 717: 5, 241: 6, 451: 8, 298: 8, 452: 8, 453: 6, 479: 3, 485: 8, 249: 8, 500: 6, 587: 8, 1611: 8, 289: 8, 481: 7, 193: 8, 197: 8, 209: 7, 455: 7, 489: 8, 309: 8, 413: 8, 501: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 311: 8, 510: 8, 528: 5, 532: 6, 715: 8, 560: 8, 562: 8, 707: 8, 789: 5, 869: 4, 880: 6, 761: 7, 840: 5, 842: 5, 844: 8, 313: 8, 381: 8, 386: 8, 810: 8, 322: 7, 384: 4, 800: 6, 1033: 7, 1034: 7, 1296: 4, 753: 5, 388: 8, 288: 5, 497: 8, 463: 3, 304: 3, 977: 8, 1001: 8, 1280: 4, 320: 4, 352: 5, 563: 5, 565: 5, 1221: 5, 1011: 6, 1017: 8, 1020: 8, 1249: 8, 1300: 8, 328: 1, 1217: 8, 1233: 8, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1930: 7, 1271: 8 }], + CAR.CADILLAC_XT4: [ + # Cadillac XT4 w/ ACC 2023 + { + 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 257: 8, 288: 5, 289: 8, 292: 2, 298: 8, 304: 3, 309: 8, 313: 8, 320: 4, 322: 7, 328: 1, 331: 3, 352: 5, 353: 3, 368: 3, 381: 8, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 401: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 455: 7, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 719: 5, 761: 7, 806: 1, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 872: 1, 880: 6, 961: 8, 969: 8, 975: 2, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 5, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1037: 5, 1105: 5, 1187: 5, 1195: 3, 1217: 8, 1221: 5, 1223: 2, 1225: 7, 1233: 8, 1236: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1268: 2, 1271: 8, 1273: 3, 1276: 2, 1277: 7, 1278: 4, 1279: 4, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1345: 8, 1417: 8, 1512: 8, 1517: 8, 1601: 8, 1609: 8, 1613: 8, 1649: 8, 1792: 8, 1793: 8, 1798: 8, 1824: 8, 1825: 8, 1840: 8, 1842: 8, 1858: 8, 1860: 8, 1863: 8, 1872: 8, 1875: 8, 1882: 8, 1888: 8, 1889: 8, 1892: 8, 1906: 7, 1907: 7, 1912: 7, 1919: 7, 1920: 8, 1924: 8, 1930: 7, 1937: 8, 1953: 8, 1968: 8, 1969: 8, 1971: 8, 1975: 8, 1984: 8, 1988: 8, 2000: 8, 2001: 8, 2002: 8, 2016: 8, 2017: 8, 2018: 8, 2020: 8, 2021: 8, 2024: 8, 2026: 8 + }], } FW_VERSIONS: dict[str, dict[tuple, list[bytes]]] = { diff --git a/opendbc/car/gm/interface.py b/opendbc/car/gm/interface.py index 3910ec64a1..1f302ea6c1 100755 --- a/opendbc/car/gm/interface.py +++ b/opendbc/car/gm/interface.py @@ -7,7 +7,7 @@ from opendbc.car.common.basedir import BASEDIR from opendbc.car.common.conversions import Conversions as CV from opendbc.car.gm.radar_interface import RADAR_HEADER_MSG -from opendbc.car.gm.values import CAR, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, CanBus +from opendbc.car.gm.values import CAR, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, SDGM_CAR, CanBus from opendbc.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD, LatControlInputs, NanoFFModel TransmissionType = structs.CarParams.TransmissionType @@ -93,13 +93,13 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime ret.longitudinalTuning.kiBP = [5., 35.] - if candidate in CAMERA_ACC_CAR: - ret.experimentalLongitudinalAvailable = True + if candidate in (CAMERA_ACC_CAR | SDGM_CAR): + ret.experimentalLongitudinalAvailable = candidate not in SDGM_CAR ret.networkLocation = NetworkLocation.fwdCamera ret.radarUnavailable = True # no radar ret.pcmCruise = True ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_HW_CAM - ret.minEnableSpeed = 5 * CV.KPH_TO_MS + ret.minEnableSpeed = -1 if candidate in SDGM_CAR else 5 * CV.KPH_TO_MS ret.minSteerSpeed = 10 * CV.KPH_TO_MS # Tuning for experimental long @@ -190,5 +190,10 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime elif candidate == CAR.CHEVROLET_TRAILBLAZER: ret.steerActuatorDelay = 0.2 CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) + + elif candidate == CAR.CADILLAC_XT4: + ret.steerActuatorDelay = 0.2 + ret.minSteerSpeed = 30 * CV.MPH_TO_MS + CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) return ret diff --git a/opendbc/car/gm/values.py b/opendbc/car/gm/values.py index 1fbee8c256..620a4ce33c 100644 --- a/opendbc/car/gm/values.py +++ b/opendbc/car/gm/values.py @@ -36,7 +36,7 @@ def __init__(self, CP): self.ZERO_GAS = 2048 # Coasting self.MAX_BRAKE = 400 # ~ -4.0 m/s^2 with regen - if CP.carFingerprint in CAMERA_ACC_CAR: + if CP.carFingerprint in (CAMERA_ACC_CAR | SDGM_CAR): self.MAX_GAS = 3400 self.MAX_ACC_REGEN = 1514 self.INACTIVE_REGEN = 1554 @@ -65,7 +65,10 @@ class GMCarDocs(CarDocs): def init_make(self, CP: CarParams): if CP.networkLocation == CarParams.NetworkLocation.fwdCamera: - self.car_parts = CarParts.common([CarHarness.gm]) + if CP.carFingerprint in SDGM_CAR: + self.car_parts = CarParts.common([CarHarness.gmsdgm]) + else: + self.car_parts = CarParts.common([CarHarness.gm]) else: self.car_parts = CarParts.common([CarHarness.obd_ii]) @@ -86,6 +89,12 @@ def init(self): # ASCM is supported, but due to a janky install and hardware configuration, we are not showing in the car docs self.car_docs = [] +@dataclass +class GMSDGMPlatformConfig(GMPlatformConfig): + def init(self): + # SDGM is supported, but due to harness not being sold by comma, we are not showing in the car docs + self.car_docs = [] + class CAR(Platforms): HOLDEN_ASTRA = GMASCMPlatformConfig( @@ -150,6 +159,10 @@ class CAR(Platforms): [GMCarDocs("Chevrolet Trailblazer 2021-22")], GMCarSpecs(mass=1345, wheelbase=2.64, steerRatio=16.8, centerToFrontRatio=0.4, tireStiffnessFactor=1.0), ) + CADILLAC_XT4 = GMSDGMPlatformConfig( + [GMCarDocs("Cadillac XT4 2023", "Driver Assist Package")], + CarSpecs(mass=1660, wheelbase=2.78, steerRatio=14.4, centerToFrontRatio=0.4), + ) class CruiseButtons: @@ -229,6 +242,9 @@ class CanBus: # We're integrated at the camera with VOACC on these cars (instead of ASCM w/ OBD-II harness) CAMERA_ACC_CAR = {CAR.CHEVROLET_BOLT_EUV, CAR.CHEVROLET_SILVERADO, CAR.CHEVROLET_EQUINOX, CAR.CHEVROLET_TRAILBLAZER} +# We're integrated at the Safety Data Gateway Module on these cars +SDGM_CAR = {CAR.CADILLAC_XT4} + STEER_THRESHOLD = 1.0 DBC = CAR.create_dbc_map() diff --git a/opendbc/car/tests/routes.py b/opendbc/car/tests/routes.py index dac197642b..6695b4cbc2 100644 --- a/opendbc/car/tests/routes.py +++ b/opendbc/car/tests/routes.py @@ -70,6 +70,7 @@ class CarTestRoute(NamedTuple): CarTestRoute("555d4087cf86aa91|2022-12-02--12-15-07", GM.CHEVROLET_BOLT_EUV, segment=14), # Bolt EV CarTestRoute("38aa7da107d5d252|2022-08-15--16-01-12", GM.CHEVROLET_SILVERADO), CarTestRoute("5085c761395d1fe6|2023-04-07--18-20-06", GM.CHEVROLET_TRAILBLAZER), + CarTestRoute("162796f1469f2f1b/00000005--6f334eda14", GM.CADILLAC_XT4), CarTestRoute("0e7a2ba168465df5|2020-10-18--14-14-22", HONDA.ACURA_RDX_3G), CarTestRoute("a74b011b32b51b56|2020-07-26--17-09-36", HONDA.HONDA_CIVIC), diff --git a/opendbc/car/torque_data/override.toml b/opendbc/car/torque_data/override.toml index a4fc2a479f..f4142ba1df 100644 --- a/opendbc/car/torque_data/override.toml +++ b/opendbc/car/torque_data/override.toml @@ -36,6 +36,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "SUBARU_OUTBACK" = [2.0, 1.5, 0.2] "CADILLAC_ESCALADE" = [1.899999976158142, 1.842270016670227, 0.1120000034570694] "CADILLAC_ESCALADE_ESV_2019" = [1.15, 1.3, 0.2] +"CADILLAC_XT4" = [1.45, 1.6, 0.2] "CHEVROLET_BOLT_EUV" = [2.0, 2.0, 0.05] "CHEVROLET_SILVERADO" = [1.9, 1.9, 0.112] "CHEVROLET_TRAILBLAZER" = [1.33, 1.9, 0.16]