GM: reduce LKAS faults while inactive (#26196)

* send at 10hz when inactive

* try to make it fine to switch rates

* fix rate

* todododo

* fine if we skip, we usually send too early

* clean up

* this may be required, 50Hz is not really needed to sync/initialize

* preserves previous behavior (not sure if this makes sense)

* Revert "preserves previous behavior (not sure if this makes sense)"

This reverts commit 3b297bca72.

* Revert "this may be required, 50Hz is not really needed to sync/initialize"

This reverts commit a6b4693814.

* rm com

* Update ref_commit

* gate behind GM Cam

* common logic

* bet

* update refs
old-commit-hash: 27e315e58f
taco
Shane Smiskol 3 years ago committed by GitHub
parent 89e6b69f05
commit ed9c040be9
  1. 16
      selfdrive/car/gm/carcontroller.py
  2. 3
      selfdrive/car/gm/values.py
  3. 2
      selfdrive/test/process_replay/ref_commit

@ -22,6 +22,7 @@ class CarController:
self.apply_gas = 0 self.apply_gas = 0
self.apply_brake = 0 self.apply_brake = 0
self.frame = 0 self.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
@ -46,15 +47,21 @@ class CarController:
# Send CAN commands. # Send CAN commands.
can_sends = [] can_sends = []
# Steering (50Hz) # Steering (Active: 50Hz, inactive: 10Hz)
# Attempt to sync with camera on startup at 50Hz, first few msgs are blocked
init_lka_counter = not self.sent_lka_steering_cmd and self.CP.networkLocation == NetworkLocation.fwdCamera
steer_step = self.params.INACTIVE_STEER_STEP
if CC.latActive or init_lka_counter:
steer_step = self.params.ACTIVE_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
# next Panda loopback confirmation in the current CS frame. # next Panda loopback confirmation in the current CS frame.
if CS.loopback_lka_steering_cmd_updated: if CS.loopback_lka_steering_cmd_updated:
self.lka_steering_cmd_counter += 1 self.lka_steering_cmd_counter += 1
self.sent_lka_steering_cmd = True self.sent_lka_steering_cmd = True
elif (self.frame % self.params.STEER_STEP) == 0: elif (self.frame - self.last_steer_frame) >= steer_step:
# Initialize ASCMLKASteeringCmd counter using the camera # Initialize ASCMLKASteeringCmd counter using the camera until we get a msg on the bus
if not self.sent_lka_steering_cmd and self.CP.networkLocation == NetworkLocation.fwdCamera: if init_lka_counter:
self.lka_steering_cmd_counter = CS.camera_lka_steering_cmd_counter + 1 self.lka_steering_cmd_counter = CS.camera_lka_steering_cmd_counter + 1
if CC.latActive: if CC.latActive:
@ -63,6 +70,7 @@ class CarController:
else: else:
apply_steer = 0 apply_steer = 0
self.last_steer_frame = self.frame
self.apply_steer_last = apply_steer self.apply_steer_last = apply_steer
idx = self.lka_steering_cmd_counter % 4 idx = self.lka_steering_cmd_counter % 4
can_sends.append(gmcan.create_steering_control(self.packer_pt, CanBus.POWERTRAIN, apply_steer, idx, CC.latActive)) can_sends.append(gmcan.create_steering_control(self.packer_pt, CanBus.POWERTRAIN, apply_steer, idx, CC.latActive))

@ -11,7 +11,8 @@ Ecu = car.CarParams.Ecu
class CarControllerParams: class CarControllerParams:
STEER_MAX = 300 # GM limit is 3Nm. Used by carcontroller to generate LKA output STEER_MAX = 300 # GM limit is 3Nm. Used by carcontroller to generate LKA output
STEER_STEP = 2 # Control frames per command (50hz) ACTIVE_STEER_STEP = 2 # Active control frames per command (50hz)
INACTIVE_STEER_STEP = 10 # Inactive control frames per command (10hz)
STEER_DELTA_UP = 7 # Delta rates require review due to observed EPS weakness STEER_DELTA_UP = 7 # Delta rates require review due to observed EPS weakness
STEER_DELTA_DOWN = 17 STEER_DELTA_DOWN = 17
STEER_DRIVER_ALLOWANCE = 50 STEER_DRIVER_ALLOWANCE = 50

@ -1 +1 @@
a5c77655fba5563e8128fb655f69b1bbd02198aa 9d042d06f61c8f48e8c7a4e30001630c14712272
Loading…
Cancel
Save