Skip to content

Commit

Permalink
Hyundai: send driver override state when gas is pressed (#23745)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sshane authored Mar 18, 2022
1 parent 3d8537a commit 6c7d178
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/car/hyundai/hyundaican.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit 6c7d178

Please sign in to comment.