Skip to content

Commit

Permalink
GM pcmCruise: cancel more reliably (commaai#25454)
Browse files Browse the repository at this point in the history
* Cancel more reliably

* Apply suggestions from code review

* Try sending multiple

* Apply suggestions from code review

* Apply suggestions from code review

* Update selfdrive/car/gm/carcontroller.py

* lower rate a bit

* try this

* Update selfdrive/car/gm/carcontroller.py
  • Loading branch information
sshane authored Aug 19, 2022
1 parent 03b0744 commit fe509e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def update(self, CC, CS):

else:
# Stock longitudinal, integrated at camera
if (self.frame - self.last_button_frame) * DT_CTRL > 0.1:
if (self.frame - self.last_button_frame) * DT_CTRL > 0.04:
if CC.cruiseControl.cancel:
self.last_button_frame = self.frame
can_sends.append(gmcan.create_buttons(self.packer_pt, CanBus.CAMERA, CruiseButtons.CANCEL))
can_sends.append(gmcan.create_buttons(self.packer_pt, CanBus.CAMERA, CS.buttons_counter, CruiseButtons.CANCEL))

# Show green icon when LKA torque is applied, and
# alarming orange icon when approaching torque limit.
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/car/gm/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ def __init__(self, CP):
can_define = CANDefine(DBC[CP.carFingerprint]["pt"])
self.shifter_values = can_define.dv["ECMPRDNL2"]["PRNDL2"]
self.lka_steering_cmd_counter = 0
self.buttons_counter = 0

def update(self, pt_cp, cam_cp, loopback_cp):
ret = car.CarState.new_message()

self.prev_cruise_buttons = self.cruise_buttons
self.cruise_buttons = pt_cp.vl["ASCMSteeringButton"]["ACCButtons"]
self.buttons_counter = pt_cp.vl["ASCMSteeringButton"]["RollingCounter"]

ret.wheelSpeeds = self.get_wheel_speeds(
pt_cp.vl["EBCMWheelSpdFront"]["FLWheelSpd"],
Expand Down Expand Up @@ -109,6 +111,7 @@ def get_can_parser(CP):
("AcceleratorPedal2", "AcceleratorPedal2"),
("CruiseState", "AcceleratorPedal2"),
("ACCButtons", "ASCMSteeringButton"),
("RollingCounter", "ASCMSteeringButton"),
("SteeringWheelAngle", "PSCMSteeringAngle"),
("SteeringWheelRate", "PSCMSteeringAngle"),
("FLWheelSpd", "EBCMWheelSpdFront"),
Expand Down
7 changes: 5 additions & 2 deletions selfdrive/car/gm/gmcan.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from selfdrive.car import make_can_msg

def create_buttons(packer, bus, button):
values = {"ACCButtons": button}
def create_buttons(packer, bus, idx, button):
values = {
"ACCButtons": button,
"RollingCounter": idx,
}
return packer.make_can_msg("ASCMSteeringButton", bus, values)

def create_steering_control(packer, bus, apply_steer, idx, lkas_active):
Expand Down

0 comments on commit fe509e0

Please sign in to comment.