From d1bee2c971b3dfa83e7e9159b02b2fe3a4998fb2 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:39:30 -0700 Subject: [PATCH] Add GM BSM Co-Authored-By: garrettpall <76917194+garrettpall@users.noreply.github.com> --- opendbc/gm_global_a_powertrain_generated.dbc | 4 ++++ selfdrive/car/gm/carstate.py | 4 ++++ selfdrive/car/gm/interface.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/opendbc/gm_global_a_powertrain_generated.dbc b/opendbc/gm_global_a_powertrain_generated.dbc index 5165a40..f75b38b 100644 --- a/opendbc/gm_global_a_powertrain_generated.dbc +++ b/opendbc/gm_global_a_powertrain_generated.dbc @@ -125,6 +125,10 @@ BO_ 320 BCMTurnSignals: 3 K9_BCM SG_ HighBeamsActive : 7|1@0+ (1,0) [0|1] "" XXX SG_ HighBeamsTemporary : 5|1@0+ (1,0) [0|1] "" XXX +BO_ 322 BCMBSM: 7 K9_BCM + SG_ Left_BSM : 6|1@0+ (1,0) [0|1] "" XXX + SG_ Right_BSM : 7|1@0+ (1,0) [0|1] "" XXX + BO_ 328 PSCM_148: 1 K43_PSCM BO_ 381 ESPStatus: 6 K20_ECM diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index 562cfeb..14817e4 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -35,6 +35,10 @@ class CarState(CarStateBase): self.pscm_status = copy.copy(pt_cp.vl["PSCMStatus"]) self.moving_backward = pt_cp.vl["EBCMWheelSpdRear"]["MovingBackward"] != 0 + if self.CP.enableBsm: + ret.leftBlindspot = pt_cp.vl["BCMBSM"]["Left_BSM"] == 1 + ret.rightBlindspot = pt_cp.vl["BCMBSM"]["Right_BSM"] == 1 + # Variables used for avoiding LKAS faults self.loopback_lka_steering_cmd_updated = len(loopback_cp.vl_all["ASCMLKASteeringCmd"]["RollingCounter"]) > 0 if self.loopback_lka_steering_cmd_updated: diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index a774ae9..0ea2d0e 100644 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -21,6 +21,7 @@ BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.D CruiseButtons.MAIN: ButtonType.altButton3, CruiseButtons.CANCEL: ButtonType.cancel} ACCELERATOR_POS_MSG = 0xbe +BSM_MSG = 0x142 NON_LINEAR_TORQUE_PARAMS = { CAR.BOLT_EUV: [2.6531724862969748, 1.0, 0.1919764879840985, 0.009054123646805178], @@ -299,6 +300,9 @@ class CarInterface(CarInterfaceBase): if ACCELERATOR_POS_MSG not in fingerprint[CanBus.POWERTRAIN]: ret.flags |= GMFlags.NO_ACCELERATOR_POS_MSG.value + # Detect if BSM message is present + ret.enableBsm = BSM_MSG in fingerprint[CanBus.POWERTRAIN] + return ret # returns a car.CarState