Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyundai-Kia-Genesis (HKG) #1362

Merged
merged 28 commits into from
Apr 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup dash
pd0wm committed Apr 16, 2020
commit 2a1ee6350618eb16037a310d7b61b89b887cb07e
2 changes: 1 addition & 1 deletion opendbc
2 changes: 1 addition & 1 deletion panda
11 changes: 8 additions & 3 deletions selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cereal import car
from selfdrive.car import apply_std_steer_torque_limits
from selfdrive.car.hyundai.hyundaican import create_lkas11, create_clu11
from selfdrive.car.hyundai.hyundaican import create_lkas11, create_clu11, create_lfa_mfa
from selfdrive.car.hyundai.values import Buttons, SteerLimitParams, CAR
from opendbc.can.packer import CANPacker

@@ -69,7 +69,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert,

can_sends = []
can_sends.append(create_lkas11(self.packer, frame, self.car_fingerprint, apply_steer, lkas_active,
CS.lkas11, sys_warning, sys_state,
CS.lkas11, sys_warning, sys_state, enabled,
left_lane, right_lane,
left_lane_warning, right_lane_warning))

@@ -84,7 +84,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert,
self.resume_cnt = 0
# when lead car starts moving, create 6 RES msgs
elif CS.lead_distance != self.last_lead_distance and (frame - self.last_resume_frame) > 5:
can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.RES_ACCEL))
can_sends.append(create_clu11(self.packer, frame, CS.clu11, Buttons.RES_ACCEL))
self.resume_cnt += 1
# interval after 6 msgs
if self.resume_cnt > 5:
@@ -95,4 +95,9 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert,
self.last_lead_distance = 0


# 20 Hz LFA MFA message
if frame % 5 == 0 and self.car_fingerprint == CAR.SONATA:
can_sends.append(create_lfa_mfa(self.packer, frame, enabled))


return can_sends
27 changes: 22 additions & 5 deletions selfdrive/car/hyundai/hyundaican.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req,
lkas11, sys_warning, sys_state,
lkas11, sys_warning, sys_state, enabled,
left_lane, right_lane,
left_lane_depart, right_lane_depart):
values = lkas11
@@ -29,16 +29,13 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req,
# FcwOpt_USM 2 = Green car + lanes
# FcwOpt_USM 1 = White car + lanes
# FcwOpt_USM 0 = No car + lanes
values["CF_Lkas_FcwOpt_USM"] = 2 if steer_req else 0
values["CF_Lkas_FcwOpt_USM"] = 2 if enabled else 0

# 4 is keep hands on wheel
# 5 is keep hands on wheel (red)
# 6 is keep hands on wheel (red) + beep
values["CF_Lkas_SysWarning"] = 4 if sys_warning else 0

# TODO: LFA stuff (steering wheel) is in 0x485
# Make sure there is no dash error when pressing LFA button on wheel

elif car_fingerprint == CAR.HYUNDAI_GENESIS:
# This field is actually LdwsActivemode
# Genesis and Optima fault when forwarding while engaged
@@ -69,3 +66,23 @@ def create_clu11(packer, frame, clu11, button):
values["CF_Clu_CruiseSwState"] = button
values["CF_Clu_CruiseSwState"] = frame % 0x10
return packer.make_can_msg("CLU11", 0, values)


def create_lfa_mfa(packer, frame, enabled):
values = {
"LFA_ACTIVE": enabled,
}

# ACTIVE 1 = Green steering wheel icon

# LFA_USM 2 & 3 = LFA cancelled, fast loud beeping
# LFA_USM 0 & 1 = No mesage

# LFA_SysWarning 1 = "Switching to HDA", short beep
# LFA_SysWarning 2 = "Switching to Smart Cruise control", short beep
# LFA_SysWarning 3 = LFA error

# ACTIVE2: nothing
# HDA_USM: nothing

return packer.make_can_msg("LFAHDA_MFC", 0, values)