From bc582c57872cf5be7b4cdf4e5e0da57134bf0b9b Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 18 Mar 2022 14:54:20 -0700 Subject: [PATCH] Hyundai: send driver override state when gas is pressed (#23745) * send pre-enable state when gas is pressed formatting and it's out forgot one allow gas press show toggle revert changes revert changes * revert change --- selfdrive/car/hyundai/carcontroller.py | 3 ++- selfdrive/car/hyundai/hyundaican.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 6b2cbd422d0da0..54ff0ad19bd90c 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -97,7 +97,8 @@ def update(self, c, CS, frame, actuators, pcm_cancel_cmd, visual_alert, hud_spee stopping = (actuators.longControlState == LongCtrlState.stopping) set_speed_in_units = hud_speed * (CV.MS_TO_MPH if CS.clu11["CF_Clu_SPEED_UNIT"] == 1 else CV.MS_TO_KPH) - can_sends.extend(create_acc_commands(self.packer, c.enabled, accel, jerk, int(frame / 2), lead_visible, set_speed_in_units, stopping)) + can_sends.extend(create_acc_commands(self.packer, c.enabled, accel, jerk, int(frame / 2), lead_visible, + set_speed_in_units, stopping, CS.out.gasPressed)) self.accel = accel # 20 Hz LFA MFA message diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index fd3fc78e88cc8c..ba2e3277f0e967 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -78,7 +78,7 @@ def create_lfahda_mfc(packer, enabled, hda_set_speed=0): } return packer.make_can_msg("LFAHDA_MFC", 0, values) -def create_acc_commands(packer, enabled, accel, jerk, idx, lead_visible, set_speed, stopping): +def create_acc_commands(packer, enabled, accel, jerk, idx, lead_visible, set_speed, stopping, gas_pressed): commands = [] scc11_values = { @@ -95,7 +95,7 @@ def create_acc_commands(packer, enabled, accel, jerk, idx, lead_visible, set_spe commands.append(packer.make_can_msg("SCC11", 0, scc11_values)) scc12_values = { - "ACCMode": 1 if enabled else 0, + "ACCMode": 2 if enabled and gas_pressed else 1 if enabled else 0, "StopReq": 1 if enabled and stopping else 0, "aReqRaw": accel if enabled else 0, "aReqValue": accel if enabled else 0, # stock ramps up and down respecting jerk limit until it reaches aReqRaw @@ -111,7 +111,7 @@ def create_acc_commands(packer, enabled, accel, jerk, idx, lead_visible, set_spe "ComfortBandLower": 0.0, # stock usually is 0 but sometimes uses higher values "JerkUpperLimit": max(jerk, 1.0) if (enabled and not stopping) else 0, # stock usually is 1.0 but sometimes uses higher values "JerkLowerLimit": max(-jerk, 1.0) if enabled else 0, # stock usually is 0.5 but sometimes uses higher values - "ACCMode": 1 if enabled else 4, # stock will always be 4 instead of 0 after first disengage + "ACCMode": 2 if enabled and gas_pressed else 1 if enabled else 4, # stock will always be 4 instead of 0 after first disengage "ObjGap": 2 if lead_visible else 0, # 5: >30, m, 4: 25-30 m, 3: 20-25 m, 2: < 20 m, 0: no lead } commands.append(packer.make_can_msg("SCC14", 0, scc14_values))