Skip to content

Commit

Permalink
GM CAM ACC Spam
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettpall committed Jan 27, 2024
1 parent e513d72 commit 7b7a918
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from opendbc.can.packer import CANPacker
from openpilot.selfdrive.car import apply_driver_steer_torque_limits, create_gas_interceptor_command
from openpilot.selfdrive.car.gm import gmcan
from openpilot.selfdrive.car.gm.values import DBC, CanBus, CarControllerParams, CruiseButtons, GMFlags, CC_ONLY_CAR, EV_CAR, SDGM_CAR
from openpilot.selfdrive.car.gm.values import DBC, CanBus, CarControllerParams, CruiseButtons, GMFlags, CC_ONLY_CAR, EV_CAR, SDGM_CAR, CAMERA_ACC_CAR
from openpilot.selfdrive.controls.lib.drive_helpers import apply_deadzone, V_CRUISE_MAX
from openpilot.selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY
from openpilot.common.params import Params
Expand Down Expand Up @@ -244,10 +244,11 @@ def update(self, CC, CS, now_nanos):
can_sends.append(gmcan.create_buttons(self.packer_pt, CanBus.CAMERA, CS.buttons_counter, CruiseButtons.CANCEL))

# ACC Spam
if self.CP.carFingerprint in SDGM_CAR and toggle_params.get_bool("CSLCEnabled"):
if (self.CP.carFingerprint in SDGM_CAR or self.CP.carFingerprint in CAMERA_ACC_CAR)and toggle_params.get_bool("CSLCEnabled"):
if CC.enabled and self.frame % 3 == 0 and CS.cruise_buttons == CruiseButtons.UNPRESS and not CS.out.gasPressed:
bus = CanBus.CAMERA if self.CP.carFingerprint in SDGM_CAR else CanBus.POWERTRAIN
slcSet = get_set_speed(self, hud_v_cruise)
can_sends.extend(gmcan.create_gm_acc_spam_command(self.packer_pt, self, CS, slcSet))
can_sends.extend(gmcan.create_gm_acc_spam_command(self.packer_pt, self, CS, slcSet, bus))

if self.CP.networkLocation == NetworkLocation.fwdCamera:
# Silence "Take Steering" alert sent by camera, forward PSCMStatus with HandsOffSWlDetectionStatus=1
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/gm/gmcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def create_gm_cc_spam_command(packer, controller, CS, actuators):
else:
return []

def create_gm_acc_spam_command(packer, controller, CS, slcSet):
def create_gm_acc_spam_command(packer, controller, CS, slcSet, bus):
cruiseBtn = CruiseButtons.INIT
byfive = 0
speedSetPoint = int(round(CS.out.cruiseState.speed * CV.MS_TO_MPH))
Expand All @@ -277,6 +277,6 @@ def create_gm_acc_spam_command(packer, controller, CS, slcSet):
if (cruiseBtn != CruiseButtons.INIT) and controller.frame % (FRAMES_ON + FRAMES_OFF) < FRAMES_ON:
controller.last_button_frame = controller.frame
idx = (CS.buttons_counter + 1) % 4
return [create_buttons_five(packer, CanBus.CAMERA, idx, cruiseBtn, byfive)]
return [create_buttons_five(packer, bus, idx, cruiseBtn, byfive)]
else:
return []

0 comments on commit 7b7a918

Please sign in to comment.