this makes it 2x more reliable, but messyyy

pull/27164/head
Shane Smiskol 2 years ago
parent 1be5479422
commit 03401dc4a7
  1. 6
      selfdrive/car/gm/carcontroller.py
  2. 2
      selfdrive/car/gm/carstate.py

@ -26,6 +26,7 @@ class CarController:
self.last_steer_frame = 0 self.last_steer_frame = 0
self.last_button_frame = 0 self.last_button_frame = 0
self.cancel_counter = 0 self.cancel_counter = 0
self.send_on_frame = 0
self.lka_steering_cmd_counter = 0 self.lka_steering_cmd_counter = 0
self.sent_lka_steering_cmd = False self.sent_lka_steering_cmd = False
@ -53,8 +54,11 @@ class CarController:
init_lka_counter = not self.sent_lka_steering_cmd and self.CP.networkLocation == NetworkLocation.fwdCamera init_lka_counter = not self.sent_lka_steering_cmd and self.CP.networkLocation == NetworkLocation.fwdCamera
# Send at 50Hz until we're sending right before camera sends LKAS message # Send at 50Hz until we're sending right before camera sends LKAS message
out_of_sync = self.lka_steering_cmd_counter % 4 != (CS.camera_lka_steering_cmd_counter + 1) % 4 out_of_sync = self.lka_steering_cmd_counter % 4 != (CS.camera_lka_steering_cmd_counter + 1) % 4
cam_updated = CS.camera_lka_steering_cmd_updated
if cam_updated:
self.send_on_frame = self.frame + 9 # this allows for 2x more restarts (~60) without faulting
steer_step = self.params.INACTIVE_STEER_STEP steer_step = self.params.INACTIVE_STEER_STEP
if CC.latActive or init_lka_counter or out_of_sync: if CC.latActive or init_lka_counter or out_of_sync or self.send_on_frame == self.frame:
steer_step = self.params.STEER_STEP steer_step = self.params.STEER_STEP
# Avoid GM EPS faults when transmitting messages too close together: skip this transmit if we just received the # Avoid GM EPS faults when transmitting messages too close together: skip this transmit if we just received the

@ -18,6 +18,7 @@ class CarState(CarStateBase):
can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) can_define = CANDefine(DBC[CP.carFingerprint]["pt"])
self.shifter_values = can_define.dv["ECMPRDNL2"]["PRNDL2"] self.shifter_values = can_define.dv["ECMPRDNL2"]["PRNDL2"]
self.loopback_lka_steering_cmd_updated = False self.loopback_lka_steering_cmd_updated = False
self.camera_lka_steering_cmd_updated = False
self.pt_lka_steering_cmd_counter = 0 self.pt_lka_steering_cmd_counter = 0
self.camera_lka_steering_cmd_counter = 0 self.camera_lka_steering_cmd_counter = 0
self.buttons_counter = 0 self.buttons_counter = 0
@ -33,6 +34,7 @@ class CarState(CarStateBase):
# Variables used for avoiding LKAS faults # Variables used for avoiding LKAS faults
self.loopback_lka_steering_cmd_updated = len(loopback_cp.vl_all["ASCMLKASteeringCmd"]["RollingCounter"]) > 0 self.loopback_lka_steering_cmd_updated = len(loopback_cp.vl_all["ASCMLKASteeringCmd"]["RollingCounter"]) > 0
self.camera_lka_steering_cmd_updated = len(cam_cp.vl_all["ASCMLKASteeringCmd"]["RollingCounter"]) > 0
if self.CP.networkLocation == NetworkLocation.fwdCamera: if self.CP.networkLocation == NetworkLocation.fwdCamera:
self.pt_lka_steering_cmd_counter = pt_cp.vl["ASCMLKASteeringCmd"]["RollingCounter"] self.pt_lka_steering_cmd_counter = pt_cp.vl["ASCMLKASteeringCmd"]["RollingCounter"]
self.camera_lka_steering_cmd_counter = cam_cp.vl["ASCMLKASteeringCmd"]["RollingCounter"] self.camera_lka_steering_cmd_counter = cam_cp.vl["ASCMLKASteeringCmd"]["RollingCounter"]

Loading…
Cancel
Save