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

HKG: Car Port for Hyundai Palisade and Kia Telluride 2023-24 (non-HDA2) #27478

Closed
wants to merge 101 commits into from
Closed
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
d634ddf
HKG: Car Port for Hyundai Palisade 2023 and Kia Telluride 2023 (non-H…
sunnyhaibin Mar 2, 2023
4356862
don't forget dbc
sunnyhaibin Mar 2, 2023
95bee73
Don't forward
sunnyhaibin Mar 2, 2023
19bd540
Revert "Don't forward"
sunnyhaibin Mar 2, 2023
0eda669
try not modifying checksum
sunnyhaibin Mar 2, 2023
0f7c065
forward counters
sunnyhaibin Mar 2, 2023
c98ba3c
try this?
sunnyhaibin Mar 3, 2023
640786d
fill it up
sunnyhaibin Mar 3, 2023
8115513
limit it
sunnyhaibin Mar 3, 2023
dcd952f
bump opendbc
sunnyhaibin Mar 3, 2023
faa6c42
try this out
sunnyhaibin Mar 3, 2023
fc3678b
bump opendbc
sunnyhaibin Mar 3, 2023
b5016f7
pass through everything from cs
sunnyhaibin Mar 3, 2023
7abebcf
don't use
sunnyhaibin Mar 3, 2023
a2a651f
only modify these
sunnyhaibin Mar 3, 2023
ca9bad0
wait, we weren't sending this?!
sunnyhaibin Mar 3, 2023
5722959
Send LFA on this one too!
sunnyhaibin Mar 3, 2023
71b51c7
bump opendbc
sunnyhaibin Mar 3, 2023
fdac94b
bump panda
sunnyhaibin Mar 3, 2023
7521b9c
pass through LFAHDA_MPC and some modified
sunnyhaibin Mar 3, 2023
a16ad58
try sending these values now
sunnyhaibin Mar 3, 2023
dc62540
don't send this
sunnyhaibin Mar 3, 2023
aeeb9b9
stop changing
sunnyhaibin Mar 3, 2023
a99f8b4
try sending checksum and counter this way
sunnyhaibin Mar 3, 2023
ede8075
some cleanup
sunnyhaibin Mar 3, 2023
4d88dbd
more cleanup
sunnyhaibin Mar 3, 2023
38e5bdd
6b checksum
sunnyhaibin Mar 4, 2023
c9a0208
should be byte 1-7
sunnyhaibin Mar 4, 2023
eb35f6c
try this checksum
sunnyhaibin Mar 4, 2023
c97875a
hmm
sunnyhaibin Mar 4, 2023
78a79a7
try the old one
sunnyhaibin Mar 4, 2023
3644a3c
suppress cluster error
sunnyhaibin Mar 4, 2023
a6d087c
bump opendbc
sunnyhaibin Mar 4, 2023
a7f17ce
match stock
sunnyhaibin Mar 4, 2023
549f51e
small cleanup
sunnyhaibin Mar 4, 2023
0ae5ac4
lower delta up/down
sunnyhaibin Mar 4, 2023
44f141a
some cleanup
sunnyhaibin Mar 4, 2023
01ed053
add test route
sunnyhaibin Mar 4, 2023
5dd3927
merge rx checks
sunnyhaibin Mar 4, 2023
cf86db4
bump panda
sunnyhaibin Mar 4, 2023
f211b32
Merge remote-tracking branch 'upstream/master' into palisade-2023-port-2
sunnyhaibin Mar 4, 2023
71e151c
fix understeer
sunnyhaibin Mar 6, 2023
c9fb5e5
Revert "fix understeer"
sunnyhaibin Mar 6, 2023
ab8b5b4
less oversteer
sunnyhaibin Mar 6, 2023
db3c22f
bump opendbc
sunnyhaibin Mar 6, 2023
45538cb
lower friction to test torqued
sunnyhaibin Mar 8, 2023
08f6958
default values worked best
sunnyhaibin Mar 8, 2023
61000d9
Revert "default values worked best"
sunnyhaibin Mar 8, 2023
6ae76fe
higher factor at init
sunnyhaibin Mar 8, 2023
21743b1
add more FW
sunnyhaibin Mar 12, 2023
208e780
Revert "add more FW"
sunnyhaibin Mar 12, 2023
4f0ac09
add more FW (mbbarnestn)
sunnyhaibin Mar 18, 2023
da0ed5e
Merge remote-tracking branch 'upstream/master' into palisade-2023-port-2
sunnyhaibin Mar 27, 2023
ca843fa
bump opendbc
sunnyhaibin Mar 27, 2023
d3f0ec4
bump panda
sunnyhaibin Mar 27, 2023
cdb227b
Merge branch 'upstream/openpilot/master' into palisade-2023-port-2
sunnyhaibin Jun 4, 2023
8aa2fa6
fix
sunnyhaibin Aug 11, 2023
5241883
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Aug 11, 2023
ac4f430
Update CARS.md
sunnyhaibin Aug 11, 2023
6e944e6
Fix
sunnyhaibin Aug 11, 2023
5fd43d1
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Aug 18, 2023
a887df0
Sync with CanBus helper
sunnyhaibin Aug 25, 2023
6e72d77
bump opendbc
sunnyhaibin Aug 25, 2023
8c20f19
Use generated DBC for common messages
sunnyhaibin Aug 27, 2023
ef63743
bump opendbc
sunnyhaibin Aug 27, 2023
ac208d7
bump opendbc
sunnyhaibin Aug 27, 2023
d776505
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Aug 27, 2023
3b5d63a
Cleanup and fixes
sunnyhaibin Aug 27, 2023
cf1ae51
Should be here
sunnyhaibin Aug 27, 2023
aca2330
consolidate in method
sunnyhaibin Aug 27, 2023
5a34070
Gate the list
sunnyhaibin Aug 27, 2023
ee34c6e
Gate it by default
sunnyhaibin Aug 27, 2023
f324df0
Update docs
sunnyhaibin Aug 27, 2023
51781a2
Revert for now
sunnyhaibin Aug 28, 2023
3abafb0
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Aug 28, 2023
c38ac76
bump opendbc
sunnyhaibin Aug 28, 2023
0cf6c5f
Fix button method
sunnyhaibin Aug 29, 2023
64cb137
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Aug 29, 2023
5cbeeed
try this
sunnyhaibin Aug 29, 2023
d2bad37
flipped safety mode :p
sunnyhaibin Aug 29, 2023
9c16023
H7 reset
sunnyhaibin Aug 29, 2023
2ee2bf0
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Aug 30, 2023
54e5f13
This platform is radar SCC
sunnyhaibin Aug 30, 2023
2384a52
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Aug 30, 2023
c0955a2
fix
sunnyhaibin Aug 30, 2023
e14c5ba
bump safety param
sunnyhaibin Aug 31, 2023
61a8219
Merge remote-tracking branch 'upstream/master' into palisade-2023-port-2
sshane Sep 7, 2023
f1aebe5
lower lateral limits
sshane Sep 7, 2023
e5c6e22
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Nov 16, 2023
ab0a211
fix checksum arg
sunnyhaibin Nov 16, 2023
b8074cf
remove unused
sunnyhaibin Nov 16, 2023
a0d1d04
sync dbc with generator
sunnyhaibin Nov 16, 2023
1792e9a
Add more FW versions
sunnyhaibin Feb 8, 2024
ff6f687
Merge remote-tracking branch 'commaai/openpilot/master' into palisade…
sunnyhaibin Jun 17, 2024
c596a50
Missed
sunnyhaibin Jun 17, 2024
c311b6c
Update docs
sunnyhaibin Jun 17, 2024
0f66f91
Update RELEASES.md
sunnyhaibin Jun 17, 2024
ae15252
Add back fingerprints from sync
sunnyhaibin Jun 17, 2024
6b8daf4
Fix typo
sunnyhaibin Jun 17, 2024
d54f695
More
sunnyhaibin Jun 17, 2024
a49d4b9
Driver torque mismatch fix
sunnyhaibin Jun 17, 2024
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
2 changes: 2 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Version 0.9.2 (2023-03-XX)
========================
* Draw MPC path instead of model predicted path, this is a more accurate representation of what the car will do.
* Buick LaCrosse 2017-19 support thanks to koch-cf!
* Hyundai Palisade (without HDA II) 2023 support thanks to sunnyhaibin!
* Kia Telluride (without HDA II) 2023 support thanks to sunnyhaibin!
* Škoda Fabia 2022-23 support thanks to jyoung8607!

Version 0.9.1 (2023-02-28)
Expand Down
2 changes: 2 additions & 0 deletions docs/CARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ A supported vehicle is one that just works when you install a comma three. All s
|Hyundai|Kona Electric 2022|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Hyundai&model=Kona Electric 2022">Hyundai O</a>||
|Hyundai|Kona Hybrid 2020|Smart Cruise Control (SCC)|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Hyundai&model=Kona Hybrid 2020">Hyundai I</a>|<a href="https://youtu.be/0dwpAHiZgFo" target="_blank"><img height="18px" src="assets/icon-youtube.svg"></img></a>|
|Hyundai|Palisade 2020-22|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Hyundai&model=Palisade 2020-22">Hyundai H</a>|<a href="https://youtu.be/TAnDqjF4fDY?t=456" target="_blank"><img height="18px" src="assets/icon-youtube.svg"></img></a>|
|Hyundai|Palisade (without HDA II) 2023[<sup>5</sup>](#footnotes)|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Hyundai&model=Palisade (without HDA II) 2023">Hyundai A</a>||
|Hyundai|Santa Cruz 2022-23[<sup>5</sup>](#footnotes)|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Hyundai&model=Santa Cruz 2022-23">Hyundai N</a>||
|Hyundai|Santa Fe 2019-20|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Hyundai&model=Santa Fe 2019-20">Hyundai D</a>||
|Hyundai|Santa Fe 2021-22|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Hyundai&model=Santa Fe 2021-22">Hyundai L</a>|<a href="https://youtu.be/VnHzSTygTS4" target="_blank"><img height="18px" src="assets/icon-youtube.svg"></img></a>|
Expand Down Expand Up @@ -124,6 +125,7 @@ A supported vehicle is one that just works when you install a comma three. All s
|Kia|Stinger 2018-20|Smart Cruise Control (SCC)|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Kia&model=Stinger 2018-20">Hyundai C</a>|<a href="https://www.youtube.com/watch?v=MJ94qoofYw0" target="_blank"><img height="18px" src="assets/icon-youtube.svg"></img></a>|
|Kia|Stinger 2022|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Kia&model=Stinger 2022">Hyundai K</a>||
|Kia|Telluride 2020-22|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Kia&model=Telluride 2020-22">Hyundai H</a>||
|Kia|Telluride (without HDA II) 2023[<sup>5</sup>](#footnotes)|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Kia&model=Telluride (without HDA II) 2023">Hyundai L</a>||
|Lexus|CT Hybrid 2017-18|Lexus Safety System+|openpilot available[<sup>2</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Lexus&model=CT Hybrid 2017-18">Toyota</a>||
|Lexus|ES 2019-22|All|openpilot|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Lexus&model=ES 2019-22">Toyota</a>||
|Lexus|ES Hybrid 2017-18|All|openpilot available[<sup>2</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<a href="https://comma.ai/shop/comma-three.html?make=Lexus&model=ES Hybrid 2017-18">Toyota</a>||
Expand Down
2 changes: 1 addition & 1 deletion opendbc
Submodule opendbc updated 1 files
+1,088 −0 hyundai_palisade_2023.dbc
2 changes: 1 addition & 1 deletion panda
1 change: 1 addition & 0 deletions release/files_common
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ opendbc/honda_civic_ex_2022_can_generated.dbc

opendbc/hyundai_canfd.dbc
opendbc/hyundai_kia_generic.dbc
opendbc/hyundai_palisade_2023.dbc
opendbc/hyundai_kia_mando_front_radar_generated.dbc

opendbc/mazda_2017.dbc
Expand Down
13 changes: 7 additions & 6 deletions selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, dbc_name, CP, VM):
self.apply_steer_last = 0
self.car_fingerprint = CP.carFingerprint
self.last_button_frame = 0
self.lkas11_cnt = -1

def update(self, CC, CS, now_nanos):
actuators = CC.actuators
Expand Down Expand Up @@ -157,18 +158,18 @@ def update(self, CC, CS, now_nanos):
self.last_button_frame = self.frame
else:
can_sends.append(hyundaican.create_lkas11(self.packer, self.frame, self.car_fingerprint, apply_steer, lat_active,
torque_fault, CS.lkas11, sys_warning, sys_state, CC.enabled,
hud_control.leftLaneVisible, hud_control.rightLaneVisible,
left_lane_warning, right_lane_warning))
torque_fault, CS.lkas11, sys_warning, sys_state, CC.enabled,
hud_control.leftLaneVisible, hud_control.rightLaneVisible,
left_lane_warning, right_lane_warning, self.CP))

if not self.CP.openpilotLongitudinalControl:
if CC.cruiseControl.cancel:
can_sends.append(hyundaican.create_clu11(self.packer, self.frame, CS.clu11, Buttons.CANCEL, self.CP.carFingerprint))
can_sends.append(hyundaican.create_clu11(self.packer, self.frame, CS.clu11, Buttons.CANCEL, self.CP))
elif CC.cruiseControl.resume:
# send resume at a max freq of 10Hz
if (self.frame - self.last_button_frame) * DT_CTRL > 0.1:
# send 25 messages at a time to increases the likelihood of resume being accepted
can_sends.extend([hyundaican.create_clu11(self.packer, self.frame, CS.clu11, Buttons.RES_ACCEL, self.CP.carFingerprint)] * 25)
can_sends.extend([hyundaican.create_clu11(self.packer, self.frame, CS.clu11, Buttons.RES_ACCEL, self.CP)] * 25)
if (self.frame - self.last_button_frame) * DT_CTRL >= 0.15:
self.last_button_frame = self.frame

Expand All @@ -180,7 +181,7 @@ def update(self, CC, CS, now_nanos):

# 20 Hz LFA MFA message
if self.frame % 5 == 0 and self.CP.flags & HyundaiFlags.SEND_LFA.value:
can_sends.append(hyundaican.create_lfahda_mfc(self.packer, CC.enabled))
can_sends.append(hyundaican.create_lfahda_mfc(self.packer, self.frame, CC.enabled, self.CP))

# 5 Hz ACC options
if self.frame % 20 == 0 and self.CP.openpilotLongitudinalControl:
Expand Down
74 changes: 54 additions & 20 deletions selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ def update(self, cp, cp_cam):
ret.cruiseState.enabled = cp.vl["TCS13"]["ACC_REQ"] == 1
ret.cruiseState.standstill = False
else:
ret.cruiseState.available = cp_cruise.vl["SCC11"]["MainMode_ACC"] == 1
scc_bus = "SCC12" if self.CP.flags & HyundaiFlags.CAN_CANFD.value else "SCC11"
ret.cruiseState.available = cp_cruise.vl[scc_bus]["MainMode_ACC"] == 1
ret.cruiseState.enabled = cp_cruise.vl["SCC12"]["ACCMode"] != 0
ret.cruiseState.standstill = cp_cruise.vl["SCC11"]["SCCInfoDisplay"] == 4.
ret.cruiseState.speed = cp_cruise.vl["SCC11"]["VSetDis"] * speed_conv
ret.cruiseState.standstill = cp_cruise.vl[scc_bus]["SCCInfoDisplay"] == 4.
ret.cruiseState.speed = cp_cruise.vl[scc_bus]["VSetDis"] * speed_conv

# TODO: Find brake pressure
ret.brake = 0
Expand Down Expand Up @@ -134,7 +135,7 @@ def update(self, cp, cp_cam):

ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear))

if not self.CP.openpilotLongitudinalControl:
if not self.CP.openpilotLongitudinalControl and not (self.CP.flags & HyundaiFlags.CAN_CANFD.value):
aeb_src = "FCA11" if self.CP.flags & HyundaiFlags.USE_FCA.value else "SCC12"
aeb_sig = "FCA_CmdAct" if self.CP.flags & HyundaiFlags.USE_FCA.value else "AEB_CmdAct"
aeb_warning = cp_cruise.vl[aeb_src]["CF_VSM_Warn"] != 0
Expand Down Expand Up @@ -291,7 +292,6 @@ def get_can_parser(CP):
]
checks = [
# address, frequency
("MDPS12", 50),
("TCS13", 50),
("TCS15", 10),
("CLU11", 50),
Expand All @@ -303,8 +303,10 @@ def get_can_parser(CP):
("WHL_SPD11", 50),
("SAS11", 100),
]
freq_mdps12 = 100 if CP.flags & HyundaiFlags.CAN_CANFD.value else 50
checks.append(("MDPS12", freq_mdps12))

if not CP.openpilotLongitudinalControl and CP.carFingerprint not in CAMERA_SCC_CAR:
if not CP.openpilotLongitudinalControl and CP.carFingerprint not in CAMERA_SCC_CAR and not (CP.flags & HyundaiFlags.CAN_CANFD.value):
signals += [
("MainMode_ACC", "SCC11"),
("VSetDis", "SCC11"),
Expand All @@ -330,13 +332,25 @@ def get_can_parser(CP):
("CF_VSM_Warn", "SCC12"),
("CF_VSM_DecCmdAct", "SCC12"),
]
elif CP.flags & HyundaiFlags.CAN_CANFD.value:
signals += [
("MainMode_ACC", "SCC12"),
("VSetDis", "SCC12"),
("SCCInfoDisplay", "SCC12"),
("ACC_ObjDist", "SCC12"),
("ACCMode", "SCC12"),
]
checks += [
("SCC12", 50),
]

if CP.enableBsm:
signals += [
("CF_Lca_IndLeft", "LCA11"),
("CF_Lca_IndRight", "LCA11"),
]
checks.append(("LCA11", 50))
freq_lca11 = 20 if CP.flags & HyundaiFlags.CAN_CANFD.value else 50
checks.append(("LCA11", freq_lca11))

if CP.carFingerprint in (HYBRID_CAR | EV_CAR):
if CP.carFingerprint in HYBRID_CAR:
Expand Down Expand Up @@ -366,7 +380,8 @@ def get_can_parser(CP):
signals.append(("CF_Lvr_Gear", "LVR12"))
checks.append(("LVR12", 100))

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0)
bus = 4 if CP.flags & HyundaiFlags.CAN_CANFD.value else 0
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, bus)

@staticmethod
def get_cam_can_parser(CP):
Expand All @@ -376,21 +391,39 @@ def get_cam_can_parser(CP):
signals = [
# signal_name, signal_address
("CF_Lkas_LdwsActivemode", "LKAS11"),
("CF_Lkas_LdwsSysState", "LKAS11"),
("CF_Lkas_SysWarning", "LKAS11"),
("CF_Lkas_LdwsLHWarning", "LKAS11"),
("CF_Lkas_LdwsRHWarning", "LKAS11"),
("CF_Lkas_HbaLamp", "LKAS11"),
("CF_Lkas_FcwBasReq", "LKAS11"),
("CF_Lkas_HbaSysState", "LKAS11"),
("CF_Lkas_FcwOpt", "LKAS11"),
("CF_Lkas_HbaOpt", "LKAS11"),
("CF_Lkas_FcwSysState", "LKAS11"),
("CF_Lkas_FcwCollisionWarning", "LKAS11"),
("CF_Lkas_FusionState", "LKAS11"),
("CF_Lkas_FcwOpt_USM", "LKAS11"),
("CF_Lkas_LdwsOpt_USM", "LKAS11"),
]
if CP.flags & HyundaiFlags.CAN_CANFD.value:
signals += [
("CF_Lkas_ActToi", "LKAS11"),
("CF_Lkas_Chksum", "LKAS11"),
("CF_Lkas_MsgCount", "LKAS11"),
("CF_Lkas_ToiFlt", "LKAS11"),
("CR_Lkas_StrToqReq", "LKAS11"),
("NEW_SIGNAL_1", "LKAS11"),
("NEW_SIGNAL_2", "LKAS11"),
("NEW_SIGNAL_3", "LKAS11"),
("NEW_SIGNAL_4", "LKAS11"),
("NEW_SIGNAL_5", "LKAS11"),
("NEW_SIGNAL_6", "LKAS11"),
("NEW_SIGNAL_7", "LKAS11"),
]
else:
signals += [
("CF_Lkas_LdwsSysState", "LKAS11"),
("CF_Lkas_SysWarning", "LKAS11"),
("CF_Lkas_HbaLamp", "LKAS11"),
("CF_Lkas_FcwBasReq", "LKAS11"),
("CF_Lkas_HbaSysState", "LKAS11"),
("CF_Lkas_FcwOpt", "LKAS11"),
("CF_Lkas_HbaOpt", "LKAS11"),
("CF_Lkas_FcwSysState", "LKAS11"),
("CF_Lkas_FcwCollisionWarning", "LKAS11"),
("CF_Lkas_FusionState", "LKAS11"),
("CF_Lkas_LdwsOpt_USM", "LKAS11"),
]
checks = [
("LKAS11", 100)
]
Expand Down Expand Up @@ -422,7 +455,8 @@ def get_cam_can_parser(CP):
("CF_VSM_DecCmdAct", "SCC12"),
]

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2)
bus = 6 if CP.flags & HyundaiFlags.CAN_CANFD else 2
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, bus)

@staticmethod
def get_can_parser_canfd(CP):
Expand Down
56 changes: 41 additions & 15 deletions selfdrive/car/hyundai/hyundaican.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
import crcmod
from selfdrive.car.hyundai.values import CAR, CHECKSUM, CAMERA_SCC_CAR
from selfdrive.car.hyundai.values import HyundaiFlags, CAR, CHECKSUM, CAMERA_SCC_CAR

hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf)

def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req,
torque_fault, lkas11, sys_warning, sys_state, enabled,
left_lane, right_lane,
left_lane_depart, right_lane_depart):
left_lane_depart, right_lane_depart, CP):
can_canfd = CP.flags & HyundaiFlags.CAN_CANFD
bus = 4 if can_canfd else 0

values = lkas11
values["CF_Lkas_LdwsSysState"] = sys_state
values["CF_Lkas_SysWarning"] = 3 if sys_warning else 0
values["CF_Lkas_LdwsLHWarning"] = left_lane_depart
values["CF_Lkas_LdwsRHWarning"] = right_lane_depart
values["CR_Lkas_StrToqReq"] = apply_steer
values["CF_Lkas_ActToi"] = steer_req
values["CF_Lkas_ToiFlt"] = torque_fault # seems to allow actuation on CR_Lkas_StrToqReq
values["CF_Lkas_MsgCount"] = frame % 0x10
values["CF_Lkas_MsgCount"] = frame % (0xF if can_canfd else 0x10)

if can_canfd:
values["CF_Lkas_LdwsActivemode"] = int(left_lane) + (int(right_lane) << 1)
values["CF_Lkas_FcwOpt_USM"] = 2 if enabled else 1
values["NEW_SIGNAL_1"] = 0
values["NEW_SIGNAL_5"] = 100
else:
values["CF_Lkas_LdwsSysState"] = sys_state
values["CF_Lkas_SysWarning"] = 3 if sys_warning else 0

if car_fingerprint in (CAR.SONATA, CAR.PALISADE, CAR.KIA_NIRO_EV, CAR.KIA_NIRO_HEV_2021, CAR.SANTA_FE,
CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KIA_SELTOS, CAR.ELANTRA_2021, CAR.GENESIS_G70_2020,
Expand Down Expand Up @@ -60,11 +70,11 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req,
# Genesis and Optima fault when forwarding while engaged
values["CF_Lkas_LdwsActivemode"] = 2

dat = packer.make_can_msg("LKAS11", 0, values)[2]
dat = packer.make_can_msg("LKAS11", bus, values)[2]

if car_fingerprint in CHECKSUM["crc8"]:
# CRC Checksum as seen on 2019 Hyundai Santa Fe
dat = dat[:6] + dat[7:8]
dat = dat[1:8] if can_canfd else dat[:6] + dat[7:8]
checksum = hyundai_checksum(dat)
elif car_fingerprint in CHECKSUM["6B"]:
# Checksum of first 6 Bytes, as seen on 2018 Kia Sorento
Expand All @@ -75,26 +85,42 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req,

values["CF_Lkas_Chksum"] = checksum

return packer.make_can_msg("LKAS11", 0, values)
return packer.make_can_msg("LKAS11", bus, values)


def create_clu11(packer, frame, clu11, button, car_fingerprint):
def create_clu11(packer, frame, clu11, button, CP):
values = clu11
values["CF_Clu_CruiseSwState"] = button
values["CF_Clu_AliveCnt1"] = frame % 0x10
# send buttons to camera on camera-scc based cars
bus = 2 if car_fingerprint in CAMERA_SCC_CAR else 0
bus = 2 if CP.carFingerprint in CAMERA_SCC_CAR else 4 if CP.flags & HyundaiFlags.CAN_CANFD else 0
return packer.make_can_msg("CLU11", bus, values)


def create_lfahda_mfc(packer, enabled, hda_set_speed=0):
def create_lfahda_mfc(packer, frame, enabled, CP):
can_canfd = CP.flags & HyundaiFlags.CAN_CANFD
bus = 4 if can_canfd else 0

values = {
"LFA_Icon_State": 2 if enabled else 0,
"HDA_Active": 1 if hda_set_speed else 0,
"HDA_Icon_State": 2 if hda_set_speed else 0,
"HDA_VSetReq": hda_set_speed,
"HDA_Icon_State": 2 if enabled else 0,
}
return packer.make_can_msg("LFAHDA_MFC", 0, values)

if can_canfd:
values.update({
"COUNTER": frame % 0xF
})

dat = packer.make_can_msg("LFAHDA_MFC", bus, values)[2]

# CRC Checksum
checksum = hyundai_checksum(dat[1:8])

values.update({
"CHECKSUM": checksum,
})

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

def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, set_speed, stopping, long_override):
commands = []
Expand Down
18 changes: 14 additions & 4 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long):
if candidate not in CANFD_RADAR_SCC_CAR:
ret.flags |= HyundaiFlags.CANFD_CAMERA_SCC.value
else:
# detect non-HDA2 with CAN and CAN-FD definitions
sunnyhaibin marked this conversation as resolved.
Show resolved Hide resolved
if 0x2a4 in fingerprint[5]:
ret.flags |= HyundaiFlags.CAN_CANFD.value

lfa_bus = 6 if ret.flags & HyundaiFlags.CAN_CANFD else 2
# Send LFA message on cars with HDA
if 0x485 in fingerprint[2]:
if 0x485 in fingerprint[lfa_bus]:
ret.flags |= HyundaiFlags.SEND_LFA.value

# These cars use the FCA11 message for the AEB and FCW signals, all others use SCC12
Expand All @@ -73,7 +78,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long):
ret.mass = 4497. * CV.LB_TO_KG
ret.wheelbase = 2.804
ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable
elif candidate == CAR.PALISADE:
elif candidate in (CAR.PALISADE, CAR.PALISADE_2023):
ret.mass = 1999. + STD_CARGO_KG
ret.wheelbase = 2.90
ret.steerRatio = 15.6 * 1.15
Expand Down Expand Up @@ -235,7 +240,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long):
else:
ret.longitudinalTuning.kpV = [0.5]
ret.longitudinalTuning.kiV = [0.0]
ret.experimentalLongitudinalAvailable = candidate not in (LEGACY_SAFETY_MODE_CAR | CAMERA_SCC_CAR)
ret.experimentalLongitudinalAvailable = candidate not in (LEGACY_SAFETY_MODE_CAR | CAMERA_SCC_CAR) and not (ret.flags & HyundaiFlags.CAN_CANFD)
ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable
ret.pcmCruise = not ret.openpilotLongitudinalControl

Expand All @@ -250,7 +255,8 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long):
if candidate in CANFD_CAR:
ret.enableBsm = 0x1e5 in fingerprint[get_e_can_bus(ret)]
else:
ret.enableBsm = 0x58b in fingerprint[0]
bus = 4 if ret.flags & HyundaiFlags.CAN_CANFD else 0
ret.enableBsm = 0x58b in fingerprint[bus]

# *** panda safety config ***
if candidate in CANFD_CAR:
Expand All @@ -267,6 +273,10 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long):
if candidate in LEGACY_SAFETY_MODE_CAR:
# these cars require a special panda safety mode due to missing counters and checksums in the messages
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundaiLegacy)]
elif ret.flags & HyundaiFlags.CAN_CANFD:
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.noOutput),
get_safety_config(car.CarParams.SafetyModel.hyundai)]
ret.safetyConfigs[1].safetyParam |= Panda.FLAG_HYUNDAI_CAN_CANFD
else:
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)]

Expand Down
Loading