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

Better Hyundai and Genesis Support, Better future model scaling #485

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0fba33b
Merge pull request #120 from commaai/devel
espes Jul 29, 2017
b111277
Merge pull request #121 from commaai/devel
espes Jul 31, 2017
cd25fac
Merge pull request #123 from commaai/devel
espes Aug 11, 2017
606c21b
Merge pull request #126 from commaai/devel
espes Aug 17, 2017
577608b
Merge pull request #137 from commaai/devel
espes Oct 4, 2017
5864323
Merge pull request #146 from commaai/devel
espes Nov 4, 2017
5ae7119
Merge pull request #154 from commaai/devel
geohot Dec 8, 2017
c2e120c
Merge pull request #165 from commaai/devel
espes Jan 17, 2018
675d9fe
Merge pull request #176 from commaai/devel
geohot Jan 22, 2018
10cb834
Merge pull request #183 from commaai/devel
geohot Feb 2, 2018
89605ed
Merge pull request #184 from commaai/devel
geohot Feb 3, 2018
e343c95
Update fingerprints.py
ErichMoraga Feb 3, 2018
affc00d
Merge pull request #188 from commaai/devel
geohot Feb 9, 2018
640ab12
openpilot 0.4.3.1 (#220)
geohot Mar 23, 2018
f550656
Revert "openpilot 0.4.3.1 (#220)"
geohot Mar 26, 2018
3e49143
Merge pull request #226 from commaai/revert-220-devel
geohot Mar 26, 2018
88d1dd2
Merge pull request #239 from commaai/devel
geohot May 2, 2018
afdda0e
Merge pull request #256 from commaai/devel
geohot May 30, 2018
30b72e4
Merge pull request #267 from commaai/devel
geohot Jun 19, 2018
27c7425
Merge pull request #277 from commaai/devel
geohot Jun 28, 2018
0ea21f3
Merge pull request #293 from commaai/devel
geohot Jul 14, 2018
8f22f52
openpilot v0.5.1 release (#315)
Aug 4, 2018
63adcfc
Merge pull request #329 from commaai/devel
rbiasini Aug 27, 2018
999edf2
Merge pull request #359 from commaai/devel
rbiasini Sep 11, 2018
ed69575
Merge pull request #379 from commaai/devel
rbiasini Sep 28, 2018
a488442
Revert the changes to GM in 0.5.4 (#380) (#386)
pd0wm Oct 3, 2018
1880165
Merge pull request #405 from commaai/devel
rbiasini Oct 26, 2018
7c0202a
Merge pull request #410 from commaai/devel
rbiasini Oct 27, 2018
9a42f2f
Merge pull request #434 from commaai/devel
rbiasini Nov 14, 2018
9398a28
Merge pull request #448 from commaai/devel
rbiasini Nov 30, 2018
9ce3045
Merge pull request #470 from commaai/devel
rbiasini Dec 18, 2018
20fa0cb
Cleanup
emmertex Dec 23, 2018
59593cb
no unecessary comments
emmertex Dec 26, 2018
3cf477d
Match dbc to opendbc
emmertex Dec 26, 2018
7331604
Better Vehicle Compatability and Better Scaling
emmertex Dec 26, 2018
0b4c015
Merge branch 'devel' of github.com:commaai/openpilot into comma_relea…
rbiasini Dec 27, 2018
24b9674
PR Updates as requested
emmertex Dec 27, 2018
a53a34e
Merge branch 'comma_release2_b' of https://github.com/emmertex/openpi…
emmertex Dec 27, 2018
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: 1 addition & 1 deletion selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from selfdrive.car.hyundai.hyundaican import create_lkas11, create_lkas12, \
create_1191, create_1156, \
create_clu11
from selfdrive.car.hyundai.values import Buttons
from selfdrive.car.hyundai.values import Buttons, CAR, LKAS_FEATURES
from selfdrive.can.packer import CANPacker


Expand Down
28 changes: 16 additions & 12 deletions selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def get_can_parser(CP):

("YAW_RATE", "ESP12", 0),

("CF_Gway_DrvSeatBeltInd", "CGW4", 1),

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused

("CF_Gway_DrvSeatBeltSw", "CGW1", 0),
("CF_Gway_TSigLHSw", "CGW1", 0),
("CF_Gway_TurnSigLh", "CGW1", 0),
Expand Down Expand Up @@ -60,15 +58,20 @@ def get_can_parser(CP):

("CF_Lvr_GearInf", "LVR11", 0), #Transmission Gear (0 = N or P, 1-8 = Fwd, 14 = Rev)

("CR_Mdps_DrvTq", "MDPS11", 0),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MDPS11 is not active (present, but always 0) on some older Hyundai.
As such, they cannot detect a user touching the wheel.
This message is also in MDPS12, and is present on all vehicles.


("CR_Mdps_StrColTq", "MDPS12", 0),
("CF_Mdps_Def", "MDPS12", 0),
("CF_Mdps_ToiActive", "MDPS12", 0),
("CF_Mdps_ToiUnavail", "MDPS12", 0),
("CF_Mdps_MsgCount2", "MDPS12", 0),
("CF_Mdps_Chksum2", "MDPS12", 0),
("CF_Mdps_ToiFlt", "MDPS12", 0),
("CF_Mdps_SErr", "MDPS12", 0),
("CR_Mdps_StrTq", "MDPS12", 0),
("CF_Mdps_FailStat", "MDPS12", 0),
("CR_Mdps_OutTq", "MDPS12", 0),

("VSetDis", "SCC11", 0),
("MainMode_ACC", "SCC11", 0),
("SCCInfoDisplay", "SCC11", 0),
("ACCMode", "SCC12", 1),

Expand All @@ -79,14 +82,12 @@ def get_can_parser(CP):
checks = [
# address, frequency
("MDPS12", 50),
("MDPS11", 100),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used

("TCS15", 10),
("TCS13", 50),
("CLU11", 50),
("ESP12", 100),
("EMS12", 100),
("CGW1", 10),
("CGW4", 5),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

("WHL_SPD11", 50),
("SCC11", 50),
("SCC12", 50),
Expand All @@ -99,6 +100,7 @@ def get_camera_parser(CP):

signals = [
# sig_name, sig_address, default
("CF_Lkas_Icon", "LKAS11", 0),
("CF_Lkas_LdwsSysState", "LKAS11", 0),
("CF_Lkas_SysWarning", "LKAS11", 0),
("CF_Lkas_LdwsLHWarning", "LKAS11", 0),
Expand All @@ -113,7 +115,9 @@ def get_camera_parser(CP):
("CF_Lkas_FcwCollisionWarning", "LKAS11", 0),
("CF_Lkas_FusionState", "LKAS11", 0),
("CF_Lkas_FcwOpt_USM", "LKAS11", 0),
("CF_Lkas_LdwsOpt_USM", "LKAS11", 0)
("CF_Lkas_LdwsOpt_USM", "LKAS11", 0),
("CF_Lkas_ActToi", "LKAS11", 0),
("CR_Lkas_StrToqReq", "LKAS11", 0)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used for better camera forwarding

]

checks = []
Expand Down Expand Up @@ -166,7 +170,7 @@ def update(self, cp, cp_cam):
self.v_wheel_fr = cp.vl["WHL_SPD11"]['WHL_SPD_FR'] * CV.KPH_TO_MS
self.v_wheel_rl = cp.vl["WHL_SPD11"]['WHL_SPD_RL'] * CV.KPH_TO_MS
self.v_wheel_rr = cp.vl["WHL_SPD11"]['WHL_SPD_RR'] * CV.KPH_TO_MS
self.v_wheel = (self.v_wheel_fl + self.v_wheel_fr + self.v_wheel_rl + self.v_wheel_rr) / 4.
self.v_wheel = 1.035 * (self.v_wheel_fl + self.v_wheel_fr + self.v_wheel_rl + self.v_wheel_rr) / 4.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stock speed is about 3.8% out, as such, this 3.5% increase makes speedo, speed limit, and cruise speed match.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for now, would be better to put this in values.py (see honda/values.py)


self.low_speed_lockout = self.v_wheel < 1.0

Expand All @@ -191,17 +195,16 @@ def update(self, cp, cp_cam):
self.left_blinker_flash = cp.vl["CGW1"]['CF_Gway_TurnSigLh']
self.right_blinker_on = cp.vl["CGW1"]['CF_Gway_TSigRHSw']
self.right_blinker_flash = cp.vl["CGW1"]['CF_Gway_TurnSigRh']
self.steer_override = abs(cp.vl["MDPS11"]['CR_Mdps_DrvTq']) > 100.
self.steer_override = abs(cp.vl["MDPS12"]['CR_Mdps_StrColTq']) > 1.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StrColTq is a scaled value, so the threshold of touching the wheel also needed changing

Copy link
Contributor

@rbiasini rbiasini Dec 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is CR_Mdps_StrColTq the same as CR_Mdps_DrvTq (except for scaling)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical
screenshot-20181227183632-988x1166

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] #0 NOT ACTIVE, 1 ACTIVE
self.steer_error = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail']
self.brake_error = 0
self.steer_torque_driver = cp.vl["MDPS11"]['CR_Mdps_DrvTq']
self.steer_torque_driver = cp.vl["MDPS12"]['CR_Mdps_StrColTq']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, this change requires a change to panda safety as well. I think this should be in its own PR.

self.steer_torque_motor = cp.vl["MDPS12"]['CR_Mdps_OutTq']
self.stopped = cp.vl["SCC11"]['SCCInfoDisplay'] == 4.

self.user_brake = 0

self.brake_pressed = cp.vl["TCS13"]['DriverBraking']
self.brake_lights = bool(self.brake_pressed)
if (cp.vl["TCS13"]["DriverOverride"] == 0 and cp.vl["TCS13"]['ACC_REQ'] == 1):
self.pedal_gas = 0
Expand Down Expand Up @@ -234,6 +237,7 @@ def update(self, cp, cp_cam):
else:
self.gear_shifter_cluster = "unknown"

# save the entire LKAS11 and CLU11
# save the entire LKAS11, CLU11 and MDPS12
self.lkas11 = cp_cam.vl["LKAS11"]
self.clu11 = cp.vl["CLU11"]
self.mdps12 = cp.vl["MDPS12"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future PR requirement

12 changes: 6 additions & 6 deletions selfdrive/car/hyundai/hyundaican.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import crcmod
from selfdrive.car.hyundai.values import CHECKSUM
from selfdrive.car.hyundai.values import LKAS_FEATURES

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

Expand All @@ -8,7 +8,7 @@ def make_can_msg(addr, dat, alt):

def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock=False):
values = {
"CF_Lkas_Icon": 3 if enabled else 0,
"CF_Lkas_Icon": 2 if (car_fingerprint in LKAS_FEATURES["icon_basic"]) else (3 if enabled else 0),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Genesis fault when anything other than 2 is sent,

"CF_Lkas_LdwsSysState": 3 if steer_req else 1,
"CF_Lkas_SysWarning": hud_alert,
"CF_Lkas_LdwsLHWarning": lkas11["CF_Lkas_LdwsLHWarning"] if keep_stock else 0,
Expand All @@ -26,21 +26,21 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled,
"CF_Lkas_FcwCollisionWarning": lkas11["CF_Lkas_FcwCollisionWarning"] if keep_stock else 0,
"CF_Lkas_FusionState": lkas11["CF_Lkas_FusionState"] if keep_stock else 0,
"CF_Lkas_Chksum": 0,
"CF_Lkas_FcwOpt_USM": 2 if enabled else 1,
"CF_Lkas_FcwOpt_USM": lkas11["CF_Lkas_FcwOpt_USM"] if keep_stock else (2 if enabled else 1),
"CF_Lkas_LdwsOpt_USM": lkas11["CF_Lkas_LdwsOpt_USM"] if keep_stock else 3,
}

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

if car_fingerprint in CHECKSUM["crc8"]:
if car_fingerprint in LKAS_FEATURES["crc8"]:
# CRC Checksum as seen on 2019 Hyundai Santa Fe
dat = dat[:6] + dat[7]
checksum = hyundai_checksum(dat)
elif car_fingerprint in CHECKSUM["6B"]:
elif car_fingerprint in LKAS_FEATURES["6B"]:
# Checksum of first 6 Bytes, as seen on 2018 Kia Sorento
dat = [ord(i) for i in dat]
checksum = sum(dat[:6]) % 256
elif car_fingerprint in CHECKSUM["7B"]:
elif car_fingerprint in LKAS_FEATURES["7B"]:
# Checksum of first 6 Bytes and last Byte as seen on 2018 Kia Stinger
dat = [ord(i) for i in dat]
checksum = (sum(dat[:6]) + dat[7]) % 256
Expand Down
10 changes: 6 additions & 4 deletions selfdrive/car/hyundai/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ class Buttons:

CAMERA_MSGS = [832, 1156, 1191, 1342]

CHECKSUM = {
"crc8": [CAR.SANTA_FE],
"6B": [CAR.KIA_SORENTO, CAR.GENESIS],
"7B": [CAR.KIA_STINGER, CAR.ELANTRA],
# Lane Keep Assist related Features and Limitations
LKAS_FEATURES = {
"6B": [CAR.KIA_SORENTO, CAR.GENESIS], # 6 Bytes used in Checksum
"7B": [CAR.KIA_STINGER, CAR.ELANTRA], # 7 Bytes used in Checksum
"crc8": [CAR.SANTA_FE], # CRC Checksum
"icon_basic": [CAR.GENESIS], # Anything but 2 for LKAS_Icon causes MDPS Fault
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems unused. Why not keeping this CHECKSUM specific?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used, hyundaican line 11.
As for the soft disable, this usage may need to be in its own PR as it may be .... rejected.
I'll remove it for this PR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can keep it checksum specific and make one for vehicle limitations seperate if preferred?
I am wishing to remove any vehicle specific code out of everything except values and interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, icon_basic has nothing to do with the algorithm used for CHECKSUM computation. I would prefer to use 2 different params.

}

DBC = {
Expand Down