From e0a109374509c6786d229b995016da9f4da78513 Mon Sep 17 00:00:00 2001 From: Jason Shuler Date: Mon, 20 Jun 2022 00:36:37 -0400 Subject: [PATCH] ctrl: limit sends by config --- selfdrive/car/gm/carcontroller.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index ae2a188e3f6787..bbd1773e42f61e 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -8,6 +8,7 @@ from selfdrive.car.gm.values import DBC, CanBus, CarControllerParams VisualAlert = car.CarControl.HUDControl.VisualAlert +NetworkLocation = car.CarParams.NetworkLocation class CarController: @@ -61,7 +62,7 @@ def update(self, CC, CS): can_sends.append(gmcan.create_steering_control(self.packer_pt, CanBus.POWERTRAIN, apply_steer, idx, lkas_enabled)) # Gas/regen and brakes - all at 25Hz - if (self.frame % 4) == 0: + if CS.CP.openpilotLongitudinalControl and ((self.frame % 4) == 0): if not CC.longActive: # Stock ECU sends max regen when not enabled self.apply_gas = self.params.MAX_ACC_REGEN @@ -79,7 +80,7 @@ def update(self, CC, CS): can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, CanBus.CHASSIS, self.apply_brake, idx, near_stop, at_full_stop)) # Send dashboard UI commands (ACC status), 25hz - if (self.frame % 4) == 0: + if CS.CP.openpilotLongitudinalControl and ((self.frame % 4) == 0): send_fcw = hud_alert == VisualAlert.fcw can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, CanBus.POWERTRAIN, CC.enabled, hud_v_cruise * CV.MS_TO_KPH, hud_control.leadVisible, send_fcw)) @@ -89,18 +90,18 @@ def update(self, CC, CS): time_and_headlights_step = 10 tt = self.frame * DT_CTRL - if self.frame % time_and_headlights_step == 0: + if CS.CP.openpilotLongitudinalControl and (not CS.CP.radarOffCan) and ((self.frame % time_and_headlights_step) == 0): idx = (self.frame // time_and_headlights_step) % 4 can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx)) can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE)) speed_and_accelerometer_step = 2 - if self.frame % speed_and_accelerometer_step == 0: + if CS.CP.openpilotLongitudinalControl and (not CS.CP.radarOffCan) and ((self.frame % speed_and_accelerometer_step) == 0): idx = (self.frame // speed_and_accelerometer_step) % 4 can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx)) can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx)) - if self.frame % self.params.ADAS_KEEPALIVE_STEP == 0: + if CS.CP.openpilotLongitudinalControl and CS.CP.networkLocation == NetworkLocation.gateway and ((self.frame % self.params.ADAS_KEEPALIVE_STEP) == 0): can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN) # Show green icon when LKA torque is applied, and @@ -110,7 +111,7 @@ def update(self, CC, CS): lka_active = CS.lkas_status == 1 lka_critical = lka_active and abs(actuators.steer) > 0.9 lka_icon_status = (lka_active, lka_critical) - if self.frame % self.params.CAMERA_KEEPALIVE_STEP == 0 or lka_icon_status != self.lka_icon_status_last: + if CS.CP.networkLocation != NetworkLocation.fwdCamera and ((self.frame % self.params.CAMERA_KEEPALIVE_STEP) == 0 or lka_icon_status != self.lka_icon_status_last): steer_alert = hud_alert in (VisualAlert.steerRequired, VisualAlert.ldw) can_sends.append(gmcan.create_lka_icon_command(CanBus.SW_GMLAN, lka_active, lka_critical, steer_alert)) self.lka_icon_status_last = lka_icon_status