From e43fa32077e7d1dfd75dfdd9f18ab21525dde162 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:00:14 -0700 Subject: [PATCH 01/28] hkg --- panda | 2 +- selfdrive/car/hyundai/carcontroller.py | 85 ++++++++--- selfdrive/car/hyundai/carstate.py | 176 ++++++++++++++--------- selfdrive/car/hyundai/hyundaican.py | 31 ++-- selfdrive/car/hyundai/interface.py | 89 +++++++++--- selfdrive/car/hyundai/radar_interface.py | 74 +++++++++- selfdrive/car/hyundai/values.py | 109 +++++++++++--- 7 files changed, 433 insertions(+), 133 deletions(-) diff --git a/panda b/panda index bc90b60f973ddf..781f3dae97a325 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit bc90b60f973ddf422ea78ce8fb83fbf88448694f +Subproject commit 781f3dae97a3258b7bcc27dec5723e3d1b07c025 diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index efd8796e0840aa..5baa5e7281a0b5 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -1,47 +1,100 @@ +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.values import Buttons, SteerLimitParams +from selfdrive.car.hyundai.values import Buttons, SteerLimitParams, CAR from opendbc.can.packer import CANPacker +VisualAlert = car.CarControl.HUDControl.VisualAlert +def process_hud_alert(enabled, fingerprint, visual_alert, left_line, + right_line, left_lane_depart, right_lane_depart): + hud_alert = 0 + if visual_alert == VisualAlert.steerRequired: + hud_alert = 3 + + # initialize to no line visible + lane_visible = 1 + if left_line and right_line or hud_alert: #HUD alert only display when LKAS status is active + if enabled or hud_alert: + lane_visible = 3 + else: + lane_visible = 4 + elif left_line: + lane_visible = 5 + elif right_line: + lane_visible = 6 + + # initialize to no warnings + left_lane_warning = 0 + right_lane_warning = 0 + if left_lane_depart: + left_lane_warning = 1 if fingerprint in [CAR.GENESIS , CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 + if right_lane_depart: + right_lane_warning = 1 if fingerprint in [CAR.GENESIS , CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 + + return hud_alert, lane_visible, left_lane_warning, right_lane_warning class CarController(): def __init__(self, dbc_name, CP, VM): self.apply_steer_last = 0 self.car_fingerprint = CP.carFingerprint - self.lkas11_cnt = 0 - self.cnt = 0 - self.last_resume_cnt = 0 self.packer = CANPacker(dbc_name) self.steer_rate_limited = False + self.resume_cnt = 0 + self.last_resume_frame = 0 + self.last_lead_distance = 0 - def update(self, enabled, CS, actuators, pcm_cancel_cmd, hud_alert): + def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, + left_line, right_line, left_lane_depart, right_lane_depart): ### Steering Torque new_steer = actuators.steer * SteerLimitParams.STEER_MAX apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, SteerLimitParams) self.steer_rate_limited = new_steer != apply_steer - if not enabled: + # disable if steer angle reach 90 deg, otherwise mdps fault in some models + lkas_active = enabled and abs(CS.angle_steers) < 90. + # fix for Genesis hard fault at low speed + if CS.v_ego < 16.7 and self.car_fingerprint == CAR.GENESIS: + lkas_active = 0 + + if not lkas_active: apply_steer = 0 - steer_req = 1 if enabled else 0 + steer_req = 1 if apply_steer else 0 self.apply_steer_last = apply_steer + hud_alert, lane_visible, left_lane_warning, right_lane_warning =\ + process_hud_alert(enabled, self.car_fingerprint, visual_alert, + left_line, right_line,left_lane_depart, right_lane_depart) + can_sends = [] - self.lkas11_cnt = self.cnt % 0x10 - self.clu11_cnt = self.cnt % 0x10 + lkas11_cnt = frame % 0x10 + clu11_cnt = frame % 0x10 - can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, steer_req, self.lkas11_cnt, - enabled, CS.lkas11, hud_alert, keep_stock=True)) + can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, steer_req, lkas11_cnt, lkas_active, + CS.lkas11, hud_alert, lane_visible, left_lane_depart, right_lane_depart, keep_stock=True)) if pcm_cancel_cmd: - can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.CANCEL)) - elif CS.out.cruiseState.standstill and (self.cnt - self.last_resume_cnt) > 5: - self.last_resume_cnt = self.cnt - can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.RES_ACCEL)) + can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.CANCEL, clu11_cnt)) - self.cnt += 1 + elif CS.out.cruiseState.standstill: + # run only first time when the car stopped + if self.last_lead_distance == 0: + # get the lead distance from the Radar + self.last_lead_distance = CS.lead_distance + 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, clu11_cnt)) + self.resume_cnt += 1 + # interval after 6 msgs + if self.resume_cnt > 5: + self.last_resume_frame = frame + self.clu11_cnt = 0 + # reset lead distnce after the car starts moving + elif self.last_lead_distance != 0: + self.last_lead_distance = 0 return can_sends diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 59c825f44d6a90..5c31b6165adf18 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -11,7 +11,8 @@ class CarState(CarStateBase): def update(self, cp, cp_cam): ret = car.CarState.new_message() - ret.doorOpen = False # FIXME + ret.doorOpen = not any([cp.vl["CGW1"]['CF_Gway_DrvDrSw'],cp.vl["CGW1"]['CF_Gway_AstDrSw'], + cp.vl["CGW2"]['CF_Gway_RLDrSw'], cp.vl["CGW2"]['CF_Gway_RRDrSw']]) ret.seatbeltUnlatched = cp.vl["CGW1"]['CF_Gway_DrvSeatBeltSw'] == 0 ret.wheelSpeeds.fl = cp.vl["WHL_SPD11"]['WHL_SPD_FL'] * CV.KPH_TO_MS @@ -28,7 +29,7 @@ def update(self, cp, cp_cam): ret.yawRate = cp.vl["ESP12"]['YAW_RATE'] ret.leftBlinker = cp.vl["CGW1"]['CF_Gway_TSigLHSw'] != 0 ret.rightBlinker = cp.vl["CGW1"]['CF_Gway_TSigRHSw'] != 0 - ret.steeringTorque = cp.vl["MDPS11"]['CR_Mdps_DrvTq'] + ret.steeringTorque = cp.vl["MDPS12"]['CR_Mdps_StrColTq'] ret.steeringTorqueEps = cp.vl["MDPS12"]['CR_Mdps_OutTq'] ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD @@ -45,54 +46,64 @@ def update(self, cp, cp_cam): ret.brake = 0 # FIXME ret.brakePressed = cp.vl["TCS13"]['DriverBraking'] != 0 - ret.brakeLights = ret.brakePressed - ret.gas = cp.vl["EMS12"]['PV_AV_CAN'] / 100 - ret.gasPressed = cp.vl["EMS16"]["CF_Ems_AclAct"] != 0 - ret.espDisabled = cp.vl["TCS15"]['ESC_Off_Step'] != 0 - - # Gear Selecton - This is not compatible with all Kia/Hyundai's, But is the best way for those it is compatible with - gear = cp.vl["LVR12"]["CF_Lvr_Gear"] - if gear == 5: - gear_shifter = GearShifter.drive - elif gear == 6: - gear_shifter = GearShifter.neutral - elif gear == 0: - gear_shifter = GearShifter.park - elif gear == 7: - gear_shifter = GearShifter.reverse + ret.brakeLights = bool(cp.vl["TCS13"]['BrakeLight'] or self.brake_pressed) + if (cp.vl["TCS13"]["DriverOverride"] == 0 and cp.vl["TCS13"]['ACC_REQ'] == 1): + pedal_gas = 0 else: - gear_shifter = GearShifter.unknown + pedal_gas = cp.vl["EMS12"]['TPS'] + ret.gasPressed = pedal_gas > 1e-3 + ret.gas = cp.vl["EMS12"]['TPS'] + #TODO: find pedal signal for EV/HYBRID Cars # Gear Selection via Cluster - For those Kia/Hyundai which are not fully discovered, we can use the Cluster Indicator for Gear Selection, as this seems to be standard over all cars, but is not the preferred method. - if cp.vl["CLU15"]["CF_Clu_InhibitD"] == 1: - gear_shifter_cluster = GearShifter.drive - elif cp.vl["CLU15"]["CF_Clu_InhibitN"] == 1: - gear_shifter_cluster = GearShifter.neutral - elif cp.vl["CLU15"]["CF_Clu_InhibitP"] == 1: - gear_shifter_cluster = GearShifter.park - elif cp.vl["CLU15"]["CF_Clu_InhibitR"] == 1: - gear_shifter_cluster = GearShifter.reverse - else: - gear_shifter_cluster = GearShifter.unknown - - # Gear Selecton via TCU12 - gear2 = cp.vl["TCU12"]["CUR_GR"] - if gear2 == 0: - gear_tcu = GearShifter.park - elif gear2 == 14: - gear_tcu = GearShifter.reverse - elif gear2 > 0 and gear2 < 9: # unaware of anything over 8 currently - gear_tcu = GearShifter.drive - else: - gear_tcu = GearShifter.unknown - - # gear shifter if self.CP.carFingerprint in FEATURES["use_cluster_gears"]: - ret.gearShifter = gear_shifter_cluster + if cp.vl["CLU15"]["CF_Clu_InhibitD"] == 1: + ret.gearShifter = GearShifter.drive + elif cp.vl["CLU15"]["CF_Clu_InhibitN"] == 1: + ret.gearShifter = GearShifter.neutral + elif cp.vl["CLU15"]["CF_Clu_InhibitP"] == 1: + ret.gearShifter = GearShifter.park + elif cp.vl["CLU15"]["CF_Clu_InhibitR"] == 1: + ret.gearShifter = GearShifter.reverse + else: + ret.gearShifter = GearShifter.unknown + # Gear Selecton via TCU12 elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]: - ret.gearShifter = gear_tcu + gear = cp.vl["TCU12"]["CUR_GR"] + if gear == 0: + ret.gearShifter = GearShifter.park + elif gear == 14: + ret.gearShifter = GearShifter.reverse + elif gear > 0 and gear < 9: # unaware of anything over 8 currently + ret.gearShifter = GearShifter.drive + else: + ret.gearShifter = GearShifter.unknown + # Gear Selecton - This is only compatible with optima hybrid 2017 + elif self.CP.carFingerprint in FEATURES["use_elect_gears"]: + gear = cp.vl["ELECT_GEAR"]["Elect_Gear_Shifter"] + if gear in (5, 8): # 5: D, 8: sport mode + ret.gearShifter = GearShifter.drive + elif gear == 6: + ret.gearShifter = GearShifter.neutral + elif gear == 0: + ret.gearShifter = GearShifter.park + elif gear == 7: + ret.gearShifter = GearShifter.reverse + else: + ret.gearShifter = GearShifter.unknown + # Gear Selecton - This is not compatible with all Kia/Hyundai's, But is the best way for those it is compatible with else: - ret.gearShifter = gear_shifter + gear = cp.vl["LVR12"]["CF_Lvr_Gear"] + if gear in (5, 8): # 5: D, 8: sport mode + ret.gearShifter = GearShifter.drive + elif gear == 6: + ret.gearShifter = GearShifter.neutral + elif gear == 0: + ret.gearShifter = GearShifter.park + elif gear == 7: + ret.gearShifter = GearShifter.reverse + else: + ret.gearShifter = GearShifter.unknown # save the entire LKAS11 and CLU11 self.lkas11 = cp_cam.vl["LKAS11"] @@ -101,6 +112,7 @@ def update(self, cp, cp_cam): self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] #0 NOT ACTIVE, 1 ACTIVE self.steer_warning = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail'] self.brake_error = 0 + self.lead_distance = cp.vl["SCC11"]['ACC_ObjDist'] return ret @@ -119,16 +131,16 @@ def get_can_parser(CP): ("CF_Gway_DrvSeatBeltInd", "CGW4", 1), ("CF_Gway_DrvSeatBeltSw", "CGW1", 0), + ("CF_Gway_DrvDrSw", "CGW1", 0), # Driver Door + ("CF_Gway_AstDrSw", "CGW1", 0), # Passenger door + ("CF_Gway_RLDrSw", "CGW2", 0), # Rear reft door + ("CF_Gway_RRDrSw", "CGW2", 0), # Rear right door ("CF_Gway_TSigLHSw", "CGW1", 0), ("CF_Gway_TurnSigLh", "CGW1", 0), ("CF_Gway_TSigRHSw", "CGW1", 0), ("CF_Gway_TurnSigRh", "CGW1", 0), ("CF_Gway_ParkBrakeSw", "CGW1", 0), - ("BRAKE_ACT", "EMS12", 0), - ("PV_AV_CAN", "EMS12", 0), - ("CF_Ems_AclAct", "EMS16", 0), - ("CYL_PRES", "ESP12", 0), ("CF_Clu_CruiseSwState", "CLU11", 0), @@ -144,54 +156,85 @@ def get_can_parser(CP): ("CF_Clu_AmpInfo", "CLU11", 0), ("CF_Clu_AliveCnt1", "CLU11", 0), - ("CF_Clu_InhibitD", "CLU15", 0), - ("CF_Clu_InhibitP", "CLU15", 0), - ("CF_Clu_InhibitN", "CLU15", 0), - ("CF_Clu_InhibitR", "CLU15", 0), - - ("CF_Lvr_Gear", "LVR12",0), - ("CUR_GR", "TCU12",0), - ("ACCEnable", "TCS13", 0), + ("ACC_REQ", "TCS13", 0), + ("BrakeLight", "TCS13", 0), ("DriverBraking", "TCS13", 0), + ("DriverOverride", "TCS13", 0), ("ESC_Off_Step", "TCS15", 0), ("CF_Lvr_GearInf", "LVR11", 0), #Transmission Gear (0 = N or P, 1-8 = Fwd, 14 = Rev) - ("CR_Mdps_DrvTq", "MDPS11", 0), - ("CR_Mdps_StrColTq", "MDPS12", 0), ("CF_Mdps_ToiActive", "MDPS12", 0), ("CF_Mdps_ToiUnavail", "MDPS12", 0), ("CF_Mdps_FailStat", "MDPS12", 0), ("CR_Mdps_OutTq", "MDPS12", 0), + ("SAS_Angle", "SAS11", 0), + ("SAS_Speed", "SAS11", 0), + + ("MainMode_ACC", "SCC11", 0), ("VSetDis", "SCC11", 0), ("SCCInfoDisplay", "SCC11", 0), + ("ACC_ObjDist", "SCC11", 0), ("ACCMode", "SCC12", 1), - - ("SAS_Angle", "SAS11", 0), - ("SAS_Speed", "SAS11", 0), ] checks = [ # address, frequency ("MDPS12", 50), - ("MDPS11", 100), - ("TCS15", 10), ("TCS13", 50), + ("TCS15", 10), ("CLU11", 50), ("ESP12", 100), - ("EMS12", 100), - ("EMS16", 100), ("CGW1", 10), ("CGW4", 5), ("WHL_SPD11", 50), + ("SAS11", 100), ("SCC11", 50), ("SCC12", 50), - ("SAS11", 100) ] + if CP.carFingerprint in FEATURES["use_cluster_gears"]: + signals += [ + ("BRAKE_ACT", "EMS12", 0), + ("PV_AV_CAN", "EMS12", 0), + ("TPS", "EMS12", 0), + ("CF_Clu_InhibitD", "CLU15", 0), + ("CF_Clu_InhibitP", "CLU15", 0), + ("CF_Clu_InhibitN", "CLU15", 0), + ("CF_Clu_InhibitR", "CLU15", 0), + ] + checks += [ + ("EMS12", 100), + ("CLU15", 5) + ] + elif CP.carFingerprint in FEATURES["use_tcu_gears"]: + signals += [ + ("BRAKE_ACT", "EMS12", 0), + ("PV_AV_CAN", "EMS12", 0), + ("TPS", "EMS12", 0), + ("CUR_GR", "TCU12",0) + ] + checks += [ + ("EMS12", 100), + ("TCU12", 100) + ] + elif CP.carFingerprint in FEATURES["use_elect_gears"]: + signals += [("Elect_Gear_Shifter", "ELECT_GEAR", 0)] + checks += [("ELECT_GEAR", 20)] + else: + signals += [ + ("BRAKE_ACT", "EMS12", 0), + ("PV_AV_CAN", "EMS12", 0), + ("TPS", "EMS12", 0), + ("CF_Lvr_Gear","LVR12",0) + ] + checks += [ + ("EMS12", 100), + ("LVR12", 100) + ] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) @@ -200,6 +243,7 @@ def get_cam_can_parser(CP): signals = [ # sig_name, sig_address, default + ("CF_Lkas_Bca_R", "LKAS11", 0), ("CF_Lkas_LdwsSysState", "LKAS11", 0), ("CF_Lkas_SysWarning", "LKAS11", 0), ("CF_Lkas_LdwsLHWarning", "LKAS11", 0), diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 910e05ad7c7a4e..44c53e487d7692 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -1,15 +1,16 @@ import crcmod -from selfdrive.car.hyundai.values import CHECKSUM +from selfdrive.car.hyundai.values import CAR, CHECKSUM hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) -def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock=False): +def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, + lane_visible, left_lane_depart, right_lane_depart, keep_stock=False): values = { - "CF_Lkas_Bca_R": 3 if enabled else 0, - "CF_Lkas_LdwsSysState": 3 if steer_req else 1, + "CF_Lkas_Bca_R": lkas11["CF_Lkas_Bca_R"] if keep_stock else 3, + "CF_Lkas_LdwsSysState": lane_visible, "CF_Lkas_SysWarning": hud_alert, - "CF_Lkas_LdwsLHWarning": lkas11["CF_Lkas_LdwsLHWarning"] if keep_stock else 0, - "CF_Lkas_LdwsRHWarning": lkas11["CF_Lkas_LdwsRHWarning"] if keep_stock else 0, + "CF_Lkas_LdwsLHWarning": left_lane_depart, + "CF_Lkas_LdwsRHWarning": right_lane_depart, "CF_Lkas_HbaLamp": lkas11["CF_Lkas_HbaLamp"] if keep_stock else 0, "CF_Lkas_FcwBasReq": lkas11["CF_Lkas_FcwBasReq"] if keep_stock else 0, "CR_Lkas_StrToqReq": apply_steer, @@ -23,9 +24,19 @@ 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, "CF_Lkas_LdwsOpt_USM": lkas11["CF_Lkas_LdwsOpt_USM"] if keep_stock else 3, } + if car_fingerprint == CAR.GENESIS: + values["CF_Lkas_Bca_R"] = 2 + values["CF_Lkas_HbaSysState"] = lkas11["CF_Lkas_HbaSysState"] if keep_stock else 0 + values["CF_Lkas_HbaOpt"] = lkas11["CF_Lkas_HbaOpt"] if keep_stock else 1 + values["CF_Lkas_FcwOpt_USM"] = lkas11["CF_Lkas_FcwOpt_USM"] if keep_stock else 2 + values["CF_Lkas_LdwsOpt_USM"] = lkas11["CF_Lkas_LdwsOpt_USM"] if keep_stock else 0 + if car_fingerprint == CAR.KIA_OPTIMA: + values["CF_Lkas_Bca_R"] = 0 + values["CF_Lkas_HbaOpt"] = lkas11["CF_Lkas_HbaOpt"] if keep_stock else 1 + values["CF_Lkas_FcwOpt_USM"] = lkas11["CF_Lkas_FcwOpt_USM"] if keep_stock else 0 dat = packer.make_can_msg("LKAS11", 0, values)[2] @@ -36,7 +47,7 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, elif car_fingerprint in CHECKSUM["6B"]: # Checksum of first 6 Bytes, as seen on 2018 Kia Sorento checksum = sum(dat[:6]) % 256 - elif car_fingerprint in CHECKSUM["7B"]: + else: # Checksum of first 6 Bytes and last Byte as seen on 2018 Kia Stinger checksum = (sum(dat[:6]) + dat[7]) % 256 @@ -44,7 +55,7 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, return packer.make_can_msg("LKAS11", 0, values) -def create_clu11(packer, clu11, button): +def create_clu11(packer, clu11, button, cnt): values = { "CF_Clu_CruiseSwState": button, "CF_Clu_CruiseSwMain": clu11["CF_Clu_CruiseSwMain"], @@ -57,7 +68,7 @@ def create_clu11(packer, clu11, button): "CF_Clu_RheostatLevel": clu11["CF_Clu_RheostatLevel"], "CF_Clu_CluInfo": clu11["CF_Clu_CluInfo"], "CF_Clu_AmpInfo": clu11["CF_Clu_AmpInfo"], - "CF_Clu_AliveCnt1": 0, + "CF_Clu_AliveCnt1": cnt, } return packer.make_can_msg("CLU11", 0, values) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index c8246e124fcb68..32800e5455c90d 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -2,7 +2,7 @@ from cereal import car from selfdrive.config import Conversions as CV from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event -from selfdrive.car.hyundai.values import Ecu, ECU_FINGERPRINT, CAR, get_hud_alerts, FINGERPRINTS +from selfdrive.car.hyundai.values import Ecu, ECU_FINGERPRINT, CAR, FINGERPRINTS from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase @@ -20,9 +20,6 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, ret.safetyModel = car.CarParams.SafetyModel.hyundai ret.radarOffCan = True - # Hyundai port is a community feature, since we don't own one to test - ret.communityFeature = True - ret.steerActuatorDelay = 0.1 # Default delay ret.steerRateCost = 0.5 ret.steerLimitTimer = 0.4 @@ -32,11 +29,9 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.766 - # Values from optimizer ret.steerRatio = 16.55 # 13.8 is spec end-to-end tire_stiffness_factor = 0.82 - ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[9., 22.], [9., 22.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.35], [0.05, 0.09]] ret.minSteerSpeed = 0. @@ -48,7 +43,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] ret.minSteerSpeed = 0. - elif candidate == CAR.ELANTRA: + elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]: ret.lateralTuning.pid.kf = 0.00006 ret.mass = 1275. + STD_CARGO_KG ret.wheelbase = 2.7 @@ -57,15 +52,21 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] ret.minSteerSpeed = 32 * CV.MPH_TO_MS - elif candidate == CAR.GENESIS: + elif candidate == CAR.HYUNDAI_GENESIS: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 2060. + STD_CARGO_KG ret.wheelbase = 3.01 ret.steerRatio = 16.5 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]] - ret.minSteerSpeed = 35 * CV.MPH_TO_MS - elif candidate == CAR.KIA_OPTIMA: + ret.minSteerSpeed = 60 * CV.KPH_TO_MS + elif candidate in [CAR.GENESIS_G90, CAR.GENESIS_G80]: + ret.mass = 2200 + ret.wheelbase = 3.15 + ret.steerRatio = 12.069 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]] + elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H]: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3558. * CV.LB_TO_KG ret.wheelbase = 2.80 @@ -81,6 +82,49 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] ret.minSteerSpeed = 0. + elif candidate == CAR.KONA: + ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 1275. + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 13.73 #Spec + tire_stiffness_factor = 0.385 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + elif candidate == CAR.IONIQ: + ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 1275. + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 13.73 #Spec + tire_stiffness_factor = 0.385 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + ret.minSteerSpeed = 32 * CV.MPH_TO_MS + elif candidate == CAR.KONA_EV: + ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 1685. + STD_CARGO_KG + ret.wheelbase = 2.7 + ret.steerRatio = 13.73 #Spec + tire_stiffness_factor = 0.385 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + elif candidate == CAR.IONIQ_EV_LTD: + ret.lateralTuning.pid.kf = 0.00006 + ret.mass = 1490. + STD_CARGO_KG #weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx + ret.wheelbase = 2.7 + ret.steerRatio = 13.73 #Spec + tire_stiffness_factor = 0.385 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + ret.minSteerSpeed = 32 * CV.MPH_TO_MS + elif candidate == CAR.KIA_FORTE: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 3558. * CV.LB_TO_KG + ret.wheelbase = 2.80 + ret.steerRatio = 13.75 + tire_stiffness_factor = 0.5 + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + ret.centerToFront = ret.wheelbase * 0.4 @@ -108,6 +152,17 @@ def update(self, c, can_strings): ret.buttonEvents = [] events = self.create_common_events(ret) + #TODO: addd abs(self.CS.angle_steers) > 90 to 'steerTempUnavailable' event + + if ret.cruiseState.enabled and not self.cruise_enabled_prev: + events.append(create_event('pcmEnable', [ET.ENABLE])) + elif not ret.cruiseState.enabled: + events.append(create_event('pcmDisable', [ET.USER_DISABLE])) + + # disable on pedals rising edge or when brake is pressed and speed isn't zero + if (ret.gasPressed and not self.gas_pressed_prev) or \ + (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgoRaw > 0.1)): + events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) # low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s) if ret.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.: @@ -119,14 +174,16 @@ def update(self, c, can_strings): ret.events = events + self.gas_pressed_prev = ret.gasPressed + self.brake_pressed_prev = ret.brakePressed + self.cruise_enabled_prev = ret.cruiseState.enabled + self.CS.out = ret.as_reader() return self.CS.out def apply(self, c): - - hud_alert = get_hud_alerts(c.hudControl.visualAlert) - - can_sends = self.CC.update(c.enabled, self.CS, c.actuators, - c.cruiseControl.cancel, hud_alert) - + can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, + c.cruiseControl.cancel, c.hudControl.visualAlert, c.hudControl.leftLaneVisible, + c.hudControl.rightLaneVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart) + self.frame += 1 return can_sends diff --git a/selfdrive/car/hyundai/radar_interface.py b/selfdrive/car/hyundai/radar_interface.py index b2f76511360320..dd5fd12e8ba53d 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -1,5 +1,77 @@ #!/usr/bin/env python3 +import os +import time +from cereal import car +from opendbc.can.parser import CANParser from selfdrive.car.interfaces import RadarInterfaceBase +from selfdrive.car.hyundai.values import DBC + +def get_radar_can_parser(CP): + signals = [ + # sig_name, sig_address, default + ("ACC_ObjStatus", "SCC11", 0), + ("ACC_ObjLatPos", "SCC11", 0), + ("ACC_ObjDist", "SCC11", 0), + ("ACC_ObjRelSpd", "SCC11", 0), + ] + checks = [ + # address, frequency + ("SCC11", 50), + ] + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) + class RadarInterface(RadarInterfaceBase): - pass + def __init__(self, CP): + # radar + self.pts = {} + self.delay = 0 # Delay of radar + self.rcp = get_radar_can_parser(CP) + self.updated_messages = set() + self.trigger_msg = 0x420 + self.track_id = 0 + self.radar_off_can = CP.radarOffCan + + def update(self, can_strings): + if self.radar_off_can: + if 'NO_RADAR_SLEEP' not in os.environ: + time.sleep(0.05) # radard runs on RI updates + + return car.RadarData.new_message() + + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) + + if self.trigger_msg not in self.updated_messages: + return None + + rr = self._update(self.updated_messages) + self.updated_messages.clear() + + return rr + + + def _update(self, updated_messages): + ret = car.RadarData.new_message() + cpt = self.rcp.vl + errors = [] + if not self.rcp.can_valid: + errors.append("canError") + ret.errors = errors + + valid = cpt["SCC11"]['ACC_ObjStatus'] + if valid: + for ii in range(2): + if ii not in self.pts: + self.pts[ii] = car.RadarData.RadarPoint.new_message() + self.pts[ii].trackId = self.track_id + self.track_id += 1 + self.pts[ii].dRel = cpt["SCC11"]['ACC_ObjDist'] # from front of car + self.pts[ii].yRel = -cpt["SCC11"]['ACC_ObjLatPos'] # in car frame's y axis, left is negative + self.pts[ii].vRel = cpt["SCC11"]['ACC_ObjRelSpd'] + self.pts[ii].aRel = float('nan') + self.pts[ii].yvRel = float('nan') + self.pts[ii].measured = True + + ret.points = list(self.pts.values()) + return ret diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 7fe689c623a49b..a86469ea84824c 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -2,16 +2,7 @@ from selfdrive.car import dbc_dict Ecu = car.CarParams.Ecu -VisualAlert = car.CarControl.HUDControl.VisualAlert - -def get_hud_alerts(visual_alert): - if visual_alert == VisualAlert.steerRequired: - return 5 - else: - return 0 - # Steer torque limits - class SteerLimitParams: STEER_MAX = 255 # 409 is the max, 255 is stock STEER_DELTA_UP = 3 @@ -22,11 +13,21 @@ class SteerLimitParams: class CAR: ELANTRA = "HYUNDAI ELANTRA LIMITED ULTIMATE 2017" - GENESIS = "HYUNDAI GENESIS 2018" - KIA_OPTIMA = "KIA OPTIMA SX 2019" + HYUNDAI_GENESIS = "HYUNDAI GENESIS 2015-2016" + KIA_OPTIMA = "KIA OPTIMA SX 2019 & 2016" + KIA_OPTIMA_H = "KIA OPTIMA HYBRID 2017 & SPORTS 2019" KIA_SORENTO = "KIA SORENTO GT LINE 2018" KIA_STINGER = "KIA STINGER GT2 2018" SANTA_FE = "HYUNDAI SANTA FE LIMITED 2019" + SANTA_FE_1 = "HYUNDAI SANTA FE has no scc" + KONA = "HYUNDAI KONA 2019" + KONA_EV = "HYUNDAI KONA ELECTRIC 2019" + GENESIS_G90 = "GENESIS G90 2017" + GENESIS_G80 = "GENESIS G80 2017" + IONIQ = "HYUNDAI IONIQ HYBRID PREMIUM 2017" + IONIQ_EV_LTD = "HYUNDAI IONIQ ELECTRIC LIMITED 2019" + KIA_FORTE = "KIA FORTE E 2018" + ELANTRA_GT_I30 = "HYUNDAI I30 N LINE 2019 & GT 2018 DCT" class Buttons: NONE = 0 @@ -38,11 +39,38 @@ class Buttons: CAR.ELANTRA: [{ 66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 897: 8, 832: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1314: 8, 1322: 8, 1345: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 2001: 8, 2003: 8, 2004: 8, 2009: 8, 2012: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }], - CAR.GENESIS: [{ + CAR.ELANTRA_GT_I30: [{ + 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1193: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1952: 8, 1960: 8, 1988: 8, 2000: 8, 2001: 8, 2005: 8, 2008: 8, 2009: 8, 2013: 8, 2017: 8, 2025: 8 + }, + { + 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8 + }, + { + 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1960: 8, 1990: 8, 1998: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2008: 8, 2009: 8, 2012: 8, 2013: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 + }], + CAR.HYUNDAI_GENESIS: [{ 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1024: 2, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1342: 6, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1456: 4 }, { 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1024: 2, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1378: 4, 1379: 8, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1456: 4 + }, + { + 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1268: 8, 1280: 1, 1281: 3, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1437: 8, 1456: 4 + }, + { + 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1378: 4, 1379: 8, 1384: 5, 1407: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4 + }, + { + 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4 + }], + CAR.SANTA_FE: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1379: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8 + }, + { + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 764: 8, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1186: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8 + }, + { + 67: 8, 68: 8, 80: 4, 160: 8, 161: 8, 272: 8, 288: 4, 339: 8, 356: 8, 357: 8, 399: 8, 544: 8, 608: 8, 672: 8, 688: 5, 704: 1, 790: 8, 809: 8, 848: 8, 880: 8, 898: 8, 900: 8, 901: 8, 904: 8, 1056: 8, 1064: 8, 1065: 8, 1072: 8, 1075: 8, 1087: 8, 1088: 8, 1151: 8, 1200: 8, 1201: 8, 1232: 4, 1264: 8, 1265: 8, 1266: 8, 1296: 8, 1306: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1348: 8, 1349: 8, 1369: 8, 1370: 8, 1371: 8, 1407: 8, 1415: 8, 1419: 8, 1440: 8, 1442: 4, 1461: 8, 1470: 8 }], CAR.KIA_OPTIMA: [ { @@ -58,13 +86,39 @@ class Buttons: CAR.KIA_STINGER: [{ 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 576: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1378: 4, 1379: 8, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1456: 4, 1470: 8 }], - CAR.SANTA_FE: [{ - 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1379: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8 + CAR.GENESIS_G80: [{ + 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1024: 2, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1191: 2, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1456: 4, 1470: 8 }, { - 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 764: 8, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1186: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8 - } - ], + 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 546: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1157: 4, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1437: 8, 1456: 4, 1470: 8 + }, + { + 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1157: 4, 1162: 8, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1193: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4, 1470: 8 + }], + CAR.GENESIS_G90: [{ + 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1162: 4, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2003: 8, 2004: 8, 2005: 8, 2008: 8, 2011: 8, 2012: 8, 2013: 8 + }], + CAR.IONIQ: [{ + 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 576: 8, 593: 8, 688: 5, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1173: 8, 1225: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1322: 8, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1407: 8, 1419: 8, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470:8, 1476: 8, 1535: 8 + }], + CAR.IONIQ_EV_LTD: [{ + 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 7, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1168: 7, 1173: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1407: 8, 1419: 8, 1425: 2, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1507: 8, 1535: 8 + }], + CAR.KONA: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 354: 3, 356: 4, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 909: 8, 916: 8, 1040: 8, 1078: 4, 1107: 5, 1136: 8, 1156: 8, 1170: 8, 1173: 8, 1191: 2, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1384: 8, 1394: 8,1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 2004: 8, 2009: 8, 2012: 8 + }], + CAR.KONA_EV: [{ + 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 549: 8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1225: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1307: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1378: 4, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1473: 8, 1507: 8, 1535: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8 + }], + CAR.KIA_FORTE: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1078: 4, 1107: 5, 1136: 8, 1156: 8, 1170: 8, 1173: 8, 1191: 2, 1225: 8, 1265: 4, 1280: 4, 1287: 4, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1384: 8, 1394: 8, 1407: 8, 1427: 6, 1456: 4, 1470: 8 + }], + CAR.KIA_OPTIMA_H: [{ + 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1151: 6, 1168: 7, 1173: 8, 1236: 2, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1371: 8, 1407: 8, 1419: 8, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470: 8, 1476: 8, 1535: 8 + }, + { + 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 576: 8, 593: 8, 688: 5, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 909: 8, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1151: 6, 1168: 7, 1173: 8, 1180: 8, 1186: 2, 1191: 2, 1265: 4, 1268: 8, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1371: 8, 1407: 8, 1419: 8, 1420: 8, 1425: 2, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470: 8, 1476: 8, 1535: 8 + }], } ECU_FINGERPRINT = { @@ -73,22 +127,31 @@ class Buttons: CHECKSUM = { "crc8": [CAR.SANTA_FE], - "6B": [CAR.KIA_SORENTO, CAR.GENESIS], - "7B": [CAR.KIA_STINGER, CAR.ELANTRA, CAR.KIA_OPTIMA], + "6B": [CAR.KIA_SORENTO, CAR.HYUNDAI_GENESIS], } FEATURES = { - "use_cluster_gears": [CAR.ELANTRA], # Use Cluster for Gear Selection, rather than Transmission - "use_tcu_gears": [CAR.KIA_OPTIMA], # Use TCU Message for Gear Selection + "use_cluster_gears": [CAR.ELANTRA, CAR.KONA, CAR.ELANTRA_GT_I30], # Use Cluster for Gear Selection, rather than Transmission + "use_tcu_gears": [CAR.KIA_OPTIMA], # Use TCU Message for Gear Selection + "use_elect_gears": [CAR.KIA_OPTIMA_H, CAR.IONIQ_EV_LTD, CAR.KONA_EV], # Use TCU Message for Gear Selection } DBC = { CAR.ELANTRA: dbc_dict('hyundai_kia_generic', None), - CAR.GENESIS: dbc_dict('hyundai_kia_generic', None), + CAR.HYUNDAI_GENESIS: dbc_dict('hyundai_kia_generic', None), CAR.KIA_OPTIMA: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_OPTIMA_H: dbc_dict('hyundai_kia_generic', None), CAR.KIA_SORENTO: dbc_dict('hyundai_kia_generic', None), CAR.KIA_STINGER: dbc_dict('hyundai_kia_generic', None), CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', None), + CAR.GENESIS_G90: dbc_dict('hyundai_kia_generic', None), + CAR.GENESIS_G80: dbc_dict('hyundai_kia_generic', None), + CAR.IONIQ: dbc_dict('hyundai_kia_generic', None), + CAR.IONIQ_EV_LTD: dbc_dict('hyundai_kia_generic', None), + CAR.KONA: dbc_dict('hyundai_kia_generic', None), + CAR.KONA_EV: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_FORTE: dbc_dict('hyundai_kia_generic', None), + CAR.ELANTRA_GT_I30: dbc_dict('hyundai_kia_generic', None), } -STEER_THRESHOLD = 100 +STEER_THRESHOLD = 150 From 95ba22867fe2e1a37e6c19d671db0a55e3975cf4 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:16:34 -0700 Subject: [PATCH 02/28] Cleanup --- selfdrive/car/hyundai/carcontroller.py | 24 +++++----- selfdrive/car/hyundai/carstate.py | 21 +++++---- selfdrive/car/hyundai/hyundaican.py | 62 ++++++++------------------ selfdrive/car/hyundai/interface.py | 1 - 4 files changed, 44 insertions(+), 64 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 5baa5e7281a0b5..30c816db9dfe32 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -5,15 +5,17 @@ from opendbc.can.packer import CANPacker VisualAlert = car.CarControl.HUDControl.VisualAlert + + def process_hud_alert(enabled, fingerprint, visual_alert, left_line, - right_line, left_lane_depart, right_lane_depart): + right_line, left_lane_depart, right_lane_depart): hud_alert = 0 if visual_alert == VisualAlert.steerRequired: hud_alert = 3 # initialize to no line visible lane_visible = 1 - if left_line and right_line or hud_alert: #HUD alert only display when LKAS status is active + if left_line and right_line or hud_alert: #HUD alert only display when LKAS status is active if enabled or hud_alert: lane_visible = 3 else: @@ -27,12 +29,13 @@ def process_hud_alert(enabled, fingerprint, visual_alert, left_line, left_lane_warning = 0 right_lane_warning = 0 if left_lane_depart: - left_lane_warning = 1 if fingerprint in [CAR.GENESIS , CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 + left_lane_warning = 1 if fingerprint in [CAR.GENESIS, CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 if right_lane_depart: - right_lane_warning = 1 if fingerprint in [CAR.GENESIS , CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 + right_lane_warning = 1 if fingerprint in [CAR.GENESIS, CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 return hud_alert, lane_visible, left_lane_warning, right_lane_warning + class CarController(): def __init__(self, dbc_name, CP, VM): self.apply_steer_last = 0 @@ -44,9 +47,8 @@ def __init__(self, dbc_name, CP, VM): self.last_lead_distance = 0 def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, - left_line, right_line, left_lane_depart, right_lane_depart): - - ### Steering Torque + left_line, right_line, left_lane_depart, right_lane_depart): + # Steering Torque new_steer = actuators.steer * SteerLimitParams.STEER_MAX apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, SteerLimitParams) self.steer_rate_limited = new_steer != apply_steer @@ -65,8 +67,8 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, self.apply_steer_last = apply_steer hud_alert, lane_visible, left_lane_warning, right_lane_warning =\ - process_hud_alert(enabled, self.car_fingerprint, visual_alert, - left_line, right_line,left_lane_depart, right_lane_depart) + process_hud_alert(enabled, self.car_fingerprint, visual_alert, + left_line, right_line,left_lane_depart, right_lane_depart) can_sends = [] @@ -74,7 +76,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, clu11_cnt = frame % 0x10 can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, steer_req, lkas11_cnt, lkas_active, - CS.lkas11, hud_alert, lane_visible, left_lane_depart, right_lane_depart, keep_stock=True)) + CS.lkas11, hud_alert, lane_visible, left_lane_depart, right_lane_depart)) if pcm_cancel_cmd: can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.CANCEL, clu11_cnt)) @@ -95,6 +97,6 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, self.clu11_cnt = 0 # reset lead distnce after the car starts moving elif self.last_lead_distance != 0: - self.last_lead_distance = 0 + self.last_lead_distance = 0 return can_sends diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 5c31b6165adf18..6e5899f86520ab 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -6,13 +6,14 @@ GearShifter = car.CarState.GearShifter -class CarState(CarStateBase): +class CarState(CarStateBase): def update(self, cp, cp_cam): ret = car.CarState.new_message() ret.doorOpen = not any([cp.vl["CGW1"]['CF_Gway_DrvDrSw'],cp.vl["CGW1"]['CF_Gway_AstDrSw'], - cp.vl["CGW2"]['CF_Gway_RLDrSw'], cp.vl["CGW2"]['CF_Gway_RRDrSw']]) + cp.vl["CGW2"]['CF_Gway_RLDrSw'], cp.vl["CGW2"]['CF_Gway_RRDrSw']]) + ret.seatbeltUnlatched = cp.vl["CGW1"]['CF_Gway_DrvSeatBeltSw'] == 0 ret.wheelSpeeds.fl = cp.vl["WHL_SPD11"]['WHL_SPD_FL'] * CV.KPH_TO_MS @@ -34,9 +35,10 @@ def update(self, cp, cp_cam): ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD # cruise state - ret.cruiseState.enabled = cp.vl["SCC12"]['ACCMode'] != 0 ret.cruiseState.available = True + ret.cruiseState.enabled = cp.vl["SCC12"]['ACCMode'] != 0 ret.cruiseState.standstill = cp.vl["SCC11"]['SCCInfoDisplay'] == 4. + if ret.cruiseState.enabled: is_set_speed_in_mph = int(cp.vl["CLU11"]["CF_Clu_SPEED_UNIT"]) speed_conv = CV.MPH_TO_MS if is_set_speed_in_mph else CV.KPH_TO_MS @@ -44,17 +46,23 @@ def update(self, cp, cp_cam): else: ret.cruiseState.speed = 0 - ret.brake = 0 # FIXME + # TODO: Find brake pressure + ret.brake = 0 ret.brakePressed = cp.vl["TCS13"]['DriverBraking'] != 0 + + # TODO: Check this ret.brakeLights = bool(cp.vl["TCS13"]['BrakeLight'] or self.brake_pressed) + + #TODO: find pedal signal for EV/HYBRID Cars if (cp.vl["TCS13"]["DriverOverride"] == 0 and cp.vl["TCS13"]['ACC_REQ'] == 1): pedal_gas = 0 else: pedal_gas = cp.vl["EMS12"]['TPS'] + ret.gasPressed = pedal_gas > 1e-3 ret.gas = cp.vl["EMS12"]['TPS'] - #TODO: find pedal signal for EV/HYBRID Cars + # TODO: refactor gear parsing in function # Gear Selection via Cluster - For those Kia/Hyundai which are not fully discovered, we can use the Cluster Indicator for Gear Selection, as this seems to be standard over all cars, but is not the preferred method. if self.CP.carFingerprint in FEATURES["use_cluster_gears"]: if cp.vl["CLU15"]["CF_Clu_InhibitD"] == 1: @@ -111,14 +119,12 @@ def update(self, cp, cp_cam): self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw'] self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] #0 NOT ACTIVE, 1 ACTIVE self.steer_warning = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail'] - self.brake_error = 0 self.lead_distance = cp.vl["SCC11"]['ACC_ObjDist'] return ret @staticmethod def get_can_parser(CP): - signals = [ # sig_name, sig_address, default ("WHL_SPD_FL", "WHL_SPD11", 0), @@ -250,7 +256,6 @@ def get_cam_can_parser(CP): ("CF_Lkas_LdwsRHWarning", "LKAS11", 0), ("CF_Lkas_HbaLamp", "LKAS11", 0), ("CF_Lkas_FcwBasReq", "LKAS11", 0), - ("CF_Lkas_ToiFlt", "LKAS11", 0), ("CF_Lkas_HbaSysState", "LKAS11", 0), ("CF_Lkas_FcwOpt", "LKAS11", 0), ("CF_Lkas_HbaOpt", "LKAS11", 0), diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 44c53e487d7692..dacbfd495a7327 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -3,40 +3,25 @@ hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) + def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, - lane_visible, left_lane_depart, right_lane_depart, keep_stock=False): - values = { - "CF_Lkas_Bca_R": lkas11["CF_Lkas_Bca_R"] if keep_stock else 3, - "CF_Lkas_LdwsSysState": lane_visible, - "CF_Lkas_SysWarning": hud_alert, - "CF_Lkas_LdwsLHWarning": left_lane_depart, - "CF_Lkas_LdwsRHWarning": right_lane_depart, - "CF_Lkas_HbaLamp": lkas11["CF_Lkas_HbaLamp"] if keep_stock else 0, - "CF_Lkas_FcwBasReq": lkas11["CF_Lkas_FcwBasReq"] if keep_stock else 0, - "CR_Lkas_StrToqReq": apply_steer, - "CF_Lkas_ActToi": steer_req, - "CF_Lkas_ToiFlt": 0, - "CF_Lkas_HbaSysState": lkas11["CF_Lkas_HbaSysState"] if keep_stock else 1, - "CF_Lkas_FcwOpt": lkas11["CF_Lkas_FcwOpt"] if keep_stock else 0, - "CF_Lkas_HbaOpt": lkas11["CF_Lkas_HbaOpt"] if keep_stock else 3, - "CF_Lkas_MsgCount": cnt, - "CF_Lkas_FcwSysState": lkas11["CF_Lkas_FcwSysState"] if keep_stock else 0, - "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": lkas11["CF_Lkas_FcwOpt_USM"] if keep_stock else 2, - "CF_Lkas_LdwsOpt_USM": lkas11["CF_Lkas_LdwsOpt_USM"] if keep_stock else 3, - } + lane_visible, left_lane_depart, right_lane_depart): + values = lkas11 + values["CF_Lkas_LdwsSysState"] = lane_visible + values["CF_Lkas_SysWarning"] = hud_alert + 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"] = 0 + values["CF_Lkas_MsgCount"] = cnt + values["CF_Lkas_Chksum"] = 0 + + # TODO: Why can't we copy from stock? if car_fingerprint == CAR.GENESIS: values["CF_Lkas_Bca_R"] = 2 - values["CF_Lkas_HbaSysState"] = lkas11["CF_Lkas_HbaSysState"] if keep_stock else 0 - values["CF_Lkas_HbaOpt"] = lkas11["CF_Lkas_HbaOpt"] if keep_stock else 1 - values["CF_Lkas_FcwOpt_USM"] = lkas11["CF_Lkas_FcwOpt_USM"] if keep_stock else 2 - values["CF_Lkas_LdwsOpt_USM"] = lkas11["CF_Lkas_LdwsOpt_USM"] if keep_stock else 0 if car_fingerprint == CAR.KIA_OPTIMA: values["CF_Lkas_Bca_R"] = 0 - values["CF_Lkas_HbaOpt"] = lkas11["CF_Lkas_HbaOpt"] if keep_stock else 1 - values["CF_Lkas_FcwOpt_USM"] = lkas11["CF_Lkas_FcwOpt_USM"] if keep_stock else 0 dat = packer.make_can_msg("LKAS11", 0, values)[2] @@ -55,20 +40,9 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, return packer.make_can_msg("LKAS11", 0, values) -def create_clu11(packer, clu11, button, cnt): - values = { - "CF_Clu_CruiseSwState": button, - "CF_Clu_CruiseSwMain": clu11["CF_Clu_CruiseSwMain"], - "CF_Clu_SldMainSW": clu11["CF_Clu_SldMainSW"], - "CF_Clu_ParityBit1": clu11["CF_Clu_ParityBit1"], - "CF_Clu_VanzDecimal": clu11["CF_Clu_VanzDecimal"], - "CF_Clu_Vanz": clu11["CF_Clu_Vanz"], - "CF_Clu_SPEED_UNIT": clu11["CF_Clu_SPEED_UNIT"], - "CF_Clu_DetentOut": clu11["CF_Clu_DetentOut"], - "CF_Clu_RheostatLevel": clu11["CF_Clu_RheostatLevel"], - "CF_Clu_CluInfo": clu11["CF_Clu_CluInfo"], - "CF_Clu_AmpInfo": clu11["CF_Clu_AmpInfo"], - "CF_Clu_AliveCnt1": cnt, - } +def create_clu11(packer, clu11, button, cnt): + values = clu11 + values["CF_Clu_CruiseSwState"] = button + values["CF_Clu_CruiseSwState"] = cnt return packer.make_can_msg("CLU11", 0, values) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 32800e5455c90d..ba8f4863db447d 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -125,7 +125,6 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] - ret.centerToFront = ret.wheelbase * 0.4 # TODO: get actual value, for now starting with reasonable value for From 21ae9fe34e555bf918f884aa9fbe86f4b06f9d09 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:19:35 -0700 Subject: [PATCH 03/28] Update readme --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb244135d16f18..94722bc37421db 100644 --- a/README.md +++ b/README.md @@ -132,15 +132,23 @@ Community Maintained Cars and Features | Chrysler | Pacifica 2020 | Adaptive Cruise | Stock | 0mph | 39mph | | Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | | Chrysler | Pacifica Hybrid 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph | +| Genesis | G80 20182 | All | Stock | 0mph | 0mph | +| Genesis | G90 20182 | All | Stock | 0mph | 0mph | | GMC | Acadia Denali 20183| Adaptive Cruise | openpilot | 0mph | 7mph | | Holden | Astra 20171 | Adaptive Cruise | openpilot | 0mph | 7mph | | Hyundai | Elantra 2017-192 | SCC + LKAS | Stock | 19mph | 34mph | -| Hyundai | Genesis 20182 | All | Stock | 19mph | 34mph | +| Hyundai | Genesis 2015-162 | SCC + LKAS | Stock | 19mph | 37mph | +| Hyundai | Ioniq 20172 | SCC + LKAS | Stock | 0mph | 32mph | +| Hyundai | Ioniq 2019 EV2 | SCC + LKAS | Stock | 0mph | 32mph | +| Hyundai | Kona 2017-192 | SCC + LKAS | Stock | 22mph | 0mph | +| Hyundai | Kona 2019 EV2 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Santa Fe 20192 | All | Stock | 0mph | 0mph | | Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Stock | 0mph | 9mph | | Jeep | Grand Cherokee 2019 | Adaptive Cruise | Stock | 0mph | 39mph | +| Kia | Forte 20182 | SCC + LKAS | Stock | 0mph | 0mph | +| Kia | Optima 20172 | SCC + LKAS/LDWS | Stock | 0mph | 32mph | | Kia | Optima 20192 | SCC + LKAS | Stock | 0mph | 0mph | -| Kia | Sorento 20182 | All | Stock | 0mph | 0mph | +| Kia | Sorento 20182 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Stinger 20182 | SCC + LKAS | Stock | 0mph | 0mph | | Nissan | Leaf 2019 | Propilot | Stock | 0mph | 0mph | | Nissan | X-Trail 2018 | Propilot | Stock | 0mph | 0mph | From 7ad33ab67c5f2768698b8bd3d57130afc18576ba Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:27:57 -0700 Subject: [PATCH 04/28] more fixes and cleanup --- selfdrive/car/hyundai/carcontroller.py | 7 ++++--- selfdrive/car/hyundai/carstate.py | 2 +- selfdrive/car/hyundai/hyundaican.py | 2 +- selfdrive/car/hyundai/interface.py | 14 -------------- selfdrive/car/hyundai/radar_interface.py | 6 +++--- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 30c816db9dfe32..6b4b433c1c5d43 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -29,9 +29,9 @@ def process_hud_alert(enabled, fingerprint, visual_alert, left_line, left_lane_warning = 0 right_lane_warning = 0 if left_lane_depart: - left_lane_warning = 1 if fingerprint in [CAR.GENESIS, CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 + left_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 if right_lane_depart: - right_lane_warning = 1 if fingerprint in [CAR.GENESIS, CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 + right_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 return hud_alert, lane_visible, left_lane_warning, right_lane_warning @@ -55,8 +55,9 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, # disable if steer angle reach 90 deg, otherwise mdps fault in some models lkas_active = enabled and abs(CS.angle_steers) < 90. + # fix for Genesis hard fault at low speed - if CS.v_ego < 16.7 and self.car_fingerprint == CAR.GENESIS: + if CS.v_ego < 16.7 and self.car_fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80]: lkas_active = 0 if not lkas_active: diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 6e5899f86520ab..92291c52344acd 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -51,7 +51,7 @@ def update(self, cp, cp_cam): ret.brakePressed = cp.vl["TCS13"]['DriverBraking'] != 0 # TODO: Check this - ret.brakeLights = bool(cp.vl["TCS13"]['BrakeLight'] or self.brake_pressed) + ret.brakeLights = bool(cp.vl["TCS13"]['BrakeLight'] or ret.brake_pressed) #TODO: find pedal signal for EV/HYBRID Cars if (cp.vl["TCS13"]["DriverOverride"] == 0 and cp.vl["TCS13"]['ACC_REQ'] == 1): diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index dacbfd495a7327..cfbe2db95963cb 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -18,7 +18,7 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, values["CF_Lkas_Chksum"] = 0 # TODO: Why can't we copy from stock? - if car_fingerprint == CAR.GENESIS: + if car_fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80]: values["CF_Lkas_Bca_R"] = 2 if car_fingerprint == CAR.KIA_OPTIMA: values["CF_Lkas_Bca_R"] = 0 diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index ba8f4863db447d..ebe50a01920293 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -153,16 +153,6 @@ def update(self, c, can_strings): events = self.create_common_events(ret) #TODO: addd abs(self.CS.angle_steers) > 90 to 'steerTempUnavailable' event - if ret.cruiseState.enabled and not self.cruise_enabled_prev: - events.append(create_event('pcmEnable', [ET.ENABLE])) - elif not ret.cruiseState.enabled: - events.append(create_event('pcmDisable', [ET.USER_DISABLE])) - - # disable on pedals rising edge or when brake is pressed and speed isn't zero - if (ret.gasPressed and not self.gas_pressed_prev) or \ - (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgoRaw > 0.1)): - events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) - # low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s) if ret.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.: self.low_speed_alert = True @@ -173,10 +163,6 @@ def update(self, c, can_strings): ret.events = events - self.gas_pressed_prev = ret.gasPressed - self.brake_pressed_prev = ret.brakePressed - self.cruise_enabled_prev = ret.cruiseState.enabled - self.CS.out = ret.as_reader() return self.CS.out diff --git a/selfdrive/car/hyundai/radar_interface.py b/selfdrive/car/hyundai/radar_interface.py index dd5fd12e8ba53d..444fab781f0413 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -6,6 +6,7 @@ from selfdrive.car.interfaces import RadarInterfaceBase from selfdrive.car.hyundai.values import DBC + def get_radar_can_parser(CP): signals = [ # sig_name, sig_address, default @@ -38,19 +39,18 @@ def update(self, can_strings): time.sleep(0.05) # radard runs on RI updates return car.RadarData.new_message() - + vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None - rr = self._update(self.updated_messages) + rr = self._update(self.updated_messages) self.updated_messages.clear() return rr - def _update(self, updated_messages): ret = car.RadarData.new_message() cpt = self.rcp.vl From ea9daa40fab9ee83a8b4ce07cc39cfc9aa94cc6e Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:35:55 -0700 Subject: [PATCH 05/28] Old genesis --- selfdrive/car/hyundai/carcontroller.py | 2 +- selfdrive/car/hyundai/hyundaican.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 6b4b433c1c5d43..e41f57e91817ac 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -57,7 +57,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, lkas_active = enabled and abs(CS.angle_steers) < 90. # fix for Genesis hard fault at low speed - if CS.v_ego < 16.7 and self.car_fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80]: + if CS.v_ego < 16.7 and self.car_fingerprint == CAR.HYUNDAI_GENESIS: lkas_active = 0 if not lkas_active: diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index cfbe2db95963cb..ce7cf3b574b3dd 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -18,7 +18,7 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, values["CF_Lkas_Chksum"] = 0 # TODO: Why can't we copy from stock? - if car_fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80]: + if car_fingerprint in == CAR.HYUNDAI_GENESIS: values["CF_Lkas_Bca_R"] = 2 if car_fingerprint == CAR.KIA_OPTIMA: values["CF_Lkas_Bca_R"] = 0 From 7174a20b57bb201cf535c76900eea59eb6fc3792 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:37:13 -0700 Subject: [PATCH 06/28] Typoe --- selfdrive/car/hyundai/hyundaican.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index ce7cf3b574b3dd..259d6e43f98006 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -18,7 +18,7 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, values["CF_Lkas_Chksum"] = 0 # TODO: Why can't we copy from stock? - if car_fingerprint in == CAR.HYUNDAI_GENESIS: + if car_fingerprint == CAR.HYUNDAI_GENESIS: values["CF_Lkas_Bca_R"] = 2 if car_fingerprint == CAR.KIA_OPTIMA: values["CF_Lkas_Bca_R"] = 0 From 9613895aac2ebda4ca16f73deab28ca8d0f9dd3c Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:39:59 -0700 Subject: [PATCH 07/28] Test car models --- selfdrive/car/hyundai/hyundaican.py | 2 +- selfdrive/test/test_car_models.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 259d6e43f98006..870e66f5da39e1 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -17,7 +17,7 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, values["CF_Lkas_MsgCount"] = cnt values["CF_Lkas_Chksum"] = 0 - # TODO: Why can't we copy from stock? + # These cars fault if BCA is forwarded while torque is applied if car_fingerprint == CAR.HYUNDAI_GENESIS: values["CF_Lkas_Bca_R"] = 2 if car_fingerprint == CAR.KIA_OPTIMA: diff --git a/selfdrive/test/test_car_models.py b/selfdrive/test/test_car_models.py index 23408cf057d039..4348b004c49885 100755 --- a/selfdrive/test/test_car_models.py +++ b/selfdrive/test/test_car_models.py @@ -352,8 +352,8 @@ def get_route_log(route_name): CHRYSLER.JEEP_CHEROKEE, CHRYSLER.JEEP_CHEROKEE_2019, CHRYSLER.PACIFICA_2018, - CHRYSLER.PACIFICA_2020, CHRYSLER.PACIFICA_2018_HYBRID, + CHRYSLER.PACIFICA_2020, GM.CADILLAC_ATS, GM.HOLDEN_ASTRA, GM.MALIBU, @@ -361,9 +361,19 @@ def get_route_log(route_name): HONDA.CRV, HONDA.RIDGELINE, HYUNDAI.ELANTRA, - HYUNDAI.GENESIS, + HYUNDAI.ELANTRA_GT_I30, + HYUNDAI.GENESIS_G80, + HYUNDAI.GENESIS_G90, + HYUNDAI.HYUNDAI_GENESIS, + HYUNDAI.IONIQ, + HYUNDAI.IONIQ_EV_LTD, + HYUNDAI.KIA_FORTE, + HYUNDAI.KIA_OPTIMA, + HYUNDAI.KIA_OPTIMA_H, HYUNDAI.KIA_SORENTO, HYUNDAI.KIA_STINGER, + HYUNDAI.KONA, + HYUNDAI.KONA_EV, TOYOTA.CAMRYH, TOYOTA.CHR, TOYOTA.CHRH, From ae117c0df2913ff4f03897148311db06aa4000bf Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:41:19 -0700 Subject: [PATCH 08/28] Update comment --- selfdrive/car/hyundai/hyundaican.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 870e66f5da39e1..28903e41ec1e38 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -17,7 +17,8 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, values["CF_Lkas_MsgCount"] = cnt values["CF_Lkas_Chksum"] = 0 - # These cars fault if BCA is forwarded while torque is applied + # This field is actually LdwsActivemode + # Genesis and Optima fault when forwarding while engaged if car_fingerprint == CAR.HYUNDAI_GENESIS: values["CF_Lkas_Bca_R"] = 2 if car_fingerprint == CAR.KIA_OPTIMA: From 09566d9c4800b98a8b337d4175051ec1376612c2 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:45:11 -0700 Subject: [PATCH 09/28] Fix brake pressed --- selfdrive/car/hyundai/carstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 92291c52344acd..619c827e0667db 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -51,7 +51,7 @@ def update(self, cp, cp_cam): ret.brakePressed = cp.vl["TCS13"]['DriverBraking'] != 0 # TODO: Check this - ret.brakeLights = bool(cp.vl["TCS13"]['BrakeLight'] or ret.brake_pressed) + ret.brakeLights = bool(cp.vl["TCS13"]['BrakeLight'] or ret.brakePressed) #TODO: find pedal signal for EV/HYBRID Cars if (cp.vl["TCS13"]["DriverOverride"] == 0 and cp.vl["TCS13"]['ACC_REQ'] == 1): From b473957b8196af268087c9d42dc66a2e46304441 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:46:26 -0700 Subject: [PATCH 10/28] Update release notes --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 7c1b817ef6a856..853eddfdddad8e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,9 +1,9 @@ Version 0.7.5 (2020-xx-xx) ======================== * Right-Hand Drive support for both driving and driver monitoring! -* New driving model: * New driver monitoring model: overall improvement on comma two * Driver camera preview in settings to improve mounting position +* Added support for many Hyundai, Kia, Genesis models thanks to xx979xx! * 2019 Nissan X-Trail and 2018 Nissan Leaf support thanks to avolmensky! Version 0.7.4 (2020-03-20) From a7e49fb1894a1ecc98125463aa189f19c943b40c Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:55:02 -0700 Subject: [PATCH 11/28] Fix vEgo --- selfdrive/car/hyundai/carcontroller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index e41f57e91817ac..1d1fb71ac6cff6 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -57,7 +57,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, lkas_active = enabled and abs(CS.angle_steers) < 90. # fix for Genesis hard fault at low speed - if CS.v_ego < 16.7 and self.car_fingerprint == CAR.HYUNDAI_GENESIS: + if CS.out.vEgo < 16.7 and self.car_fingerprint == CAR.HYUNDAI_GENESIS: lkas_active = 0 if not lkas_active: @@ -100,4 +100,5 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, elif self.last_lead_distance != 0: self.last_lead_distance = 0 + return can_sends From c10f1e453e8f6b6b7be68dd7109580bcc6569753 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 14:57:16 -0700 Subject: [PATCH 12/28] Add sonata --- selfdrive/car/hyundai/values.py | 37 ++++++++++++++++++------------- selfdrive/test/test_car_models.py | 1 + 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index a86469ea84824c..9d8af0423d5d21 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -11,23 +11,26 @@ class SteerLimitParams: STEER_DRIVER_MULTIPLIER = 2 STEER_DRIVER_FACTOR = 1 + class CAR: ELANTRA = "HYUNDAI ELANTRA LIMITED ULTIMATE 2017" + ELANTRA_GT_I30 = "HYUNDAI I30 N LINE 2019 & GT 2018 DCT" + GENESIS_G80 = "GENESIS G80 2017" + GENESIS_G90 = "GENESIS G90 2017" HYUNDAI_GENESIS = "HYUNDAI GENESIS 2015-2016" + IONIQ = "HYUNDAI IONIQ HYBRID PREMIUM 2017" + IONIQ_EV_LTD = "HYUNDAI IONIQ ELECTRIC LIMITED 2019" + KIA_FORTE = "KIA FORTE E 2018" KIA_OPTIMA = "KIA OPTIMA SX 2019 & 2016" KIA_OPTIMA_H = "KIA OPTIMA HYBRID 2017 & SPORTS 2019" KIA_SORENTO = "KIA SORENTO GT LINE 2018" KIA_STINGER = "KIA STINGER GT2 2018" - SANTA_FE = "HYUNDAI SANTA FE LIMITED 2019" - SANTA_FE_1 = "HYUNDAI SANTA FE has no scc" KONA = "HYUNDAI KONA 2019" KONA_EV = "HYUNDAI KONA ELECTRIC 2019" - GENESIS_G90 = "GENESIS G90 2017" - GENESIS_G80 = "GENESIS G80 2017" - IONIQ = "HYUNDAI IONIQ HYBRID PREMIUM 2017" - IONIQ_EV_LTD = "HYUNDAI IONIQ ELECTRIC LIMITED 2019" - KIA_FORTE = "KIA FORTE E 2018" - ELANTRA_GT_I30 = "HYUNDAI I30 N LINE 2019 & GT 2018 DCT" + SANTA_FE = "HYUNDAI SANTA FE LIMITED 2019" + SANTA_FE_1 = "HYUNDAI SANTA FE has no scc" + SONATA = "HYUNDAI SONATA 2020" + class Buttons: NONE = 0 @@ -72,6 +75,9 @@ class Buttons: { 67: 8, 68: 8, 80: 4, 160: 8, 161: 8, 272: 8, 288: 4, 339: 8, 356: 8, 357: 8, 399: 8, 544: 8, 608: 8, 672: 8, 688: 5, 704: 1, 790: 8, 809: 8, 848: 8, 880: 8, 898: 8, 900: 8, 901: 8, 904: 8, 1056: 8, 1064: 8, 1065: 8, 1072: 8, 1075: 8, 1087: 8, 1088: 8, 1151: 8, 1200: 8, 1201: 8, 1232: 4, 1264: 8, 1265: 8, 1266: 8, 1296: 8, 1306: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1348: 8, 1349: 8, 1369: 8, 1370: 8, 1371: 8, 1407: 8, 1415: 8, 1419: 8, 1440: 8, 1442: 4, 1461: 8, 1470: 8 }], + CAR.SONATA: [ + {67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 545: 8, 546: 8, 547: 8, 548: 8, 549: 8, 550: 8, 576: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 8, 865: 8, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 908: 8, 909: 8, 912: 7, 913: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1089: 5, 1107: 5, 1108: 8, 1114: 8, 1136: 8, 1145: 8, 1151: 8, 1155: 8, 1156: 8, 1157: 4, 1162: 8, 1164: 8, 1168: 8, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1184: 8, 1186: 2, 1191: 2, 1193: 8, 1210: 8, 1225: 8, 1227: 8, 1265: 4, 1268: 8, 1280: 8, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1330: 8, 1339: 8, 1342: 6, 1343: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1394: 8, 1407: 8, 1419: 8, 1427: 6, 1446: 8, 1456: 4, 1460: 8, 1470: 8, 1485: 8, 1504: 3}, + ], CAR.KIA_OPTIMA: [ { 64: 8, 66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 447: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 6, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1186: 2, 1191: 2, 1253: 8, 1254: 8, 1255: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 1952: 8, 1960: 8, 1988: 8, 1996: 8, 2001: 8, 2004: 8, 2008: 8, 2009: 8, 2012: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 @@ -138,20 +144,21 @@ class Buttons: DBC = { CAR.ELANTRA: dbc_dict('hyundai_kia_generic', None), + CAR.ELANTRA_GT_I30: dbc_dict('hyundai_kia_generic', None), + CAR.GENESIS_G80: dbc_dict('hyundai_kia_generic', None), + CAR.GENESIS_G90: dbc_dict('hyundai_kia_generic', None), CAR.HYUNDAI_GENESIS: dbc_dict('hyundai_kia_generic', None), + CAR.IONIQ: dbc_dict('hyundai_kia_generic', None), + CAR.IONIQ_EV_LTD: dbc_dict('hyundai_kia_generic', None), + CAR.KIA_FORTE: dbc_dict('hyundai_kia_generic', None), CAR.KIA_OPTIMA: dbc_dict('hyundai_kia_generic', None), CAR.KIA_OPTIMA_H: dbc_dict('hyundai_kia_generic', None), CAR.KIA_SORENTO: dbc_dict('hyundai_kia_generic', None), CAR.KIA_STINGER: dbc_dict('hyundai_kia_generic', None), - CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', None), - CAR.GENESIS_G90: dbc_dict('hyundai_kia_generic', None), - CAR.GENESIS_G80: dbc_dict('hyundai_kia_generic', None), - CAR.IONIQ: dbc_dict('hyundai_kia_generic', None), - CAR.IONIQ_EV_LTD: dbc_dict('hyundai_kia_generic', None), CAR.KONA: dbc_dict('hyundai_kia_generic', None), CAR.KONA_EV: dbc_dict('hyundai_kia_generic', None), - CAR.KIA_FORTE: dbc_dict('hyundai_kia_generic', None), - CAR.ELANTRA_GT_I30: dbc_dict('hyundai_kia_generic', None), + CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', None), + CAR.SONATA: dbc_dict('hyundai_kia_generic', None), } STEER_THRESHOLD = 150 diff --git a/selfdrive/test/test_car_models.py b/selfdrive/test/test_car_models.py index 4348b004c49885..33ec741b515dad 100755 --- a/selfdrive/test/test_car_models.py +++ b/selfdrive/test/test_car_models.py @@ -374,6 +374,7 @@ def get_route_log(route_name): HYUNDAI.KIA_STINGER, HYUNDAI.KONA, HYUNDAI.KONA_EV, + HYUNDAI.SONATA, TOYOTA.CAMRYH, TOYOTA.CHR, TOYOTA.CHRH, From dc04e5e93eca5fe38f99af498be6f334ee8ec6ef Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 15:01:25 -0700 Subject: [PATCH 13/28] Add sonata values --- selfdrive/car/hyundai/interface.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index ebe50a01920293..c1ff9221aa1bd2 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -35,6 +35,14 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False, ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[9., 22.], [9., 22.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.35], [0.05, 0.09]] ret.minSteerSpeed = 0. + elif candidate == CAR.SONATA: + ret.lateralTuning.pid.kf = 0.00005 + ret.mass = 1513. + STD_CARGO_KG + ret.wheelbase = 2.84 + ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable + ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] + ret.minSteerSpeed = 0. elif candidate == CAR.KIA_SORENTO: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 1985. + STD_CARGO_KG From 4eb2650c952a501ca4838f2a9343f0112b054de6 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 15:05:07 -0700 Subject: [PATCH 14/28] Temporarily remove doors check. It doesn't work --- selfdrive/car/hyundai/carstate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 619c827e0667db..48c24ab31ba615 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -11,8 +11,10 @@ class CarState(CarStateBase): def update(self, cp, cp_cam): ret = car.CarState.new_message() - ret.doorOpen = not any([cp.vl["CGW1"]['CF_Gway_DrvDrSw'],cp.vl["CGW1"]['CF_Gway_AstDrSw'], - cp.vl["CGW2"]['CF_Gway_RLDrSw'], cp.vl["CGW2"]['CF_Gway_RRDrSw']]) + # TODO: This is not working + # ret.doorOpen = not any([cp.vl["CGW1"]['CF_Gway_DrvDrSw'],cp.vl["CGW1"]['CF_Gway_AstDrSw'], + # cp.vl["CGW2"]['CF_Gway_RLDrSw'], cp.vl["CGW2"]['CF_Gway_RRDrSw']]) + ret.doorOpen = False ret.seatbeltUnlatched = cp.vl["CGW1"]['CF_Gway_DrvSeatBeltSw'] == 0 From b39e2d9c7ba031391c3a5c318d3b097359d181b3 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 16:34:01 -0700 Subject: [PATCH 15/28] Sonata uses crc8 --- selfdrive/car/hyundai/values.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 9d8af0423d5d21..1358bed2a870e2 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -132,7 +132,7 @@ class Buttons: } CHECKSUM = { - "crc8": [CAR.SANTA_FE], + "crc8": [CAR.SANTA_FE, CAR.SONATA], "6B": [CAR.KIA_SORENTO, CAR.HYUNDAI_GENESIS], } From a863dafc835109e28336631378a345eafbc762a8 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 16:49:57 -0700 Subject: [PATCH 16/28] Fix tests --- selfdrive/car/hyundai/carcontroller.py | 2 +- selfdrive/car/hyundai/carstate.py | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 1d1fb71ac6cff6..05b5df62368a6a 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -54,7 +54,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, self.steer_rate_limited = new_steer != apply_steer # disable if steer angle reach 90 deg, otherwise mdps fault in some models - lkas_active = enabled and abs(CS.angle_steers) < 90. + lkas_active = enabled and abs(CS.out.steeringAngle) < 90. # fix for Genesis hard fault at low speed if CS.out.vEgo < 16.7 and self.car_fingerprint == CAR.HYUNDAI_GENESIS: diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 48c24ab31ba615..702d429eb53c02 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -62,7 +62,7 @@ def update(self, cp, cp_cam): pedal_gas = cp.vl["EMS12"]['TPS'] ret.gasPressed = pedal_gas > 1e-3 - ret.gas = cp.vl["EMS12"]['TPS'] + ret.gas = pedal_gas # TODO: refactor gear parsing in function # Gear Selection via Cluster - For those Kia/Hyundai which are not fully discovered, we can use the Cluster Indicator for Gear Selection, as this seems to be standard over all cars, but is not the preferred method. @@ -188,6 +188,8 @@ def get_can_parser(CP): ("SCCInfoDisplay", "SCC11", 0), ("ACC_ObjDist", "SCC11", 0), ("ACCMode", "SCC12", 1), + + ("TPS", "EMS12", 0), ] checks = [ @@ -203,30 +205,23 @@ def get_can_parser(CP): ("SAS11", 100), ("SCC11", 50), ("SCC12", 50), + ("EMS12", 100), ] if CP.carFingerprint in FEATURES["use_cluster_gears"]: signals += [ - ("BRAKE_ACT", "EMS12", 0), - ("PV_AV_CAN", "EMS12", 0), - ("TPS", "EMS12", 0), ("CF_Clu_InhibitD", "CLU15", 0), ("CF_Clu_InhibitP", "CLU15", 0), ("CF_Clu_InhibitN", "CLU15", 0), ("CF_Clu_InhibitR", "CLU15", 0), ] checks += [ - ("EMS12", 100), ("CLU15", 5) ] elif CP.carFingerprint in FEATURES["use_tcu_gears"]: signals += [ - ("BRAKE_ACT", "EMS12", 0), - ("PV_AV_CAN", "EMS12", 0), - ("TPS", "EMS12", 0), ("CUR_GR", "TCU12",0) ] checks += [ - ("EMS12", 100), ("TCU12", 100) ] elif CP.carFingerprint in FEATURES["use_elect_gears"]: @@ -234,13 +229,9 @@ def get_can_parser(CP): checks += [("ELECT_GEAR", 20)] else: signals += [ - ("BRAKE_ACT", "EMS12", 0), - ("PV_AV_CAN", "EMS12", 0), - ("TPS", "EMS12", 0), ("CF_Lvr_Gear","LVR12",0) ] checks += [ - ("EMS12", 100), ("LVR12", 100) ] From 872bebddc768aae10d79da6838ae0764c1b4137f Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 16:57:13 -0700 Subject: [PATCH 17/28] Changes for LFA --- selfdrive/car/hyundai/hyundaican.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 28903e41ec1e38..6bf9ffa127a1b9 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -17,6 +17,11 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, values["CF_Lkas_MsgCount"] = cnt values["CF_Lkas_Chksum"] = 0 + # LFA + if car_fingerprint == CAR.SONATA: + values["CF_Lkas_LdwsActivemode"] = 3 + values["CF_Lkas_FcwOpt_USM"] = 2 + # This field is actually LdwsActivemode # Genesis and Optima fault when forwarding while engaged if car_fingerprint == CAR.HYUNDAI_GENESIS: From fa69149681a509ae4602579ee4f0f5c05670ee79 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 16:58:05 -0700 Subject: [PATCH 18/28] Add comment --- selfdrive/car/hyundai/hyundaican.py | 1 + 1 file changed, 1 insertion(+) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 6bf9ffa127a1b9..cdbf2d5ddbab42 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -18,6 +18,7 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, values["CF_Lkas_Chksum"] = 0 # LFA + # TODO: check if 0x4A7 is present instead of harcoding if car_fingerprint == CAR.SONATA: values["CF_Lkas_LdwsActivemode"] = 3 values["CF_Lkas_FcwOpt_USM"] = 2 From eba87315f87c87a985f26b122a76791ff131674f Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 18:36:02 -0700 Subject: [PATCH 19/28] Does this improve the hud? --- selfdrive/car/hyundai/carcontroller.py | 8 +++----- selfdrive/car/hyundai/hyundaican.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 05b5df62368a6a..b6bddb4138942a 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -63,21 +63,19 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, if not lkas_active: apply_steer = 0 - steer_req = 1 if apply_steer else 0 - self.apply_steer_last = apply_steer hud_alert, lane_visible, left_lane_warning, right_lane_warning =\ process_hud_alert(enabled, self.car_fingerprint, visual_alert, - left_line, right_line,left_lane_depart, right_lane_depart) + left_line, right_line, left_lane_depart, right_lane_depart) can_sends = [] lkas11_cnt = frame % 0x10 clu11_cnt = frame % 0x10 - can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, steer_req, lkas11_cnt, lkas_active, - CS.lkas11, hud_alert, lane_visible, left_lane_depart, right_lane_depart)) + can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, lkas_active, lkas11_cnt, + CS.lkas11, hud_alert, lane_visible, left_lane_warning, right_lane_warning)) if pcm_cancel_cmd: can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.CANCEL, clu11_cnt)) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index cdbf2d5ddbab42..547547c7fb3403 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -4,7 +4,7 @@ hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) -def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, +def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, lkas11, hud_alert, lane_visible, left_lane_depart, right_lane_depart): values = lkas11 values["CF_Lkas_LdwsSysState"] = lane_visible From d41400023c35b3b400c334e39e996131818c7b42 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 18:45:08 -0700 Subject: [PATCH 20/28] Proper signal name --- selfdrive/car/hyundai/carcontroller.py | 10 +++------- selfdrive/car/hyundai/hyundaican.py | 10 +++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index b6bddb4138942a..34af243e02fb8b 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -70,15 +70,11 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart) can_sends = [] - - lkas11_cnt = frame % 0x10 - clu11_cnt = frame % 0x10 - - can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, lkas_active, lkas11_cnt, + can_sends.append(create_lkas11(self.packer, frame, self.car_fingerprint, apply_steer, lkas_active, CS.lkas11, hud_alert, lane_visible, left_lane_warning, right_lane_warning)) if pcm_cancel_cmd: - can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.CANCEL, clu11_cnt)) + can_sends.append(create_clu11(self.packer, frame, CS.clu11, Buttons.CANCEL)) elif CS.out.cruiseState.standstill: # run only first time when the car stopped @@ -88,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, clu11_cnt)) + can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.RES_ACCEL)) self.resume_cnt += 1 # interval after 6 msgs if self.resume_cnt > 5: diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 547547c7fb3403..120066a4cf0ae0 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -4,7 +4,7 @@ hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) -def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, lkas11, hud_alert, +def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11, hud_alert, lane_visible, left_lane_depart, right_lane_depart): values = lkas11 values["CF_Lkas_LdwsSysState"] = lane_visible @@ -14,13 +14,13 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, lkas11, values["CR_Lkas_StrToqReq"] = apply_steer values["CF_Lkas_ActToi"] = steer_req values["CF_Lkas_ToiFlt"] = 0 - values["CF_Lkas_MsgCount"] = cnt + values["CF_Lkas_MsgCount"] = frame % 0x10 values["CF_Lkas_Chksum"] = 0 # LFA # TODO: check if 0x4A7 is present instead of harcoding if car_fingerprint == CAR.SONATA: - values["CF_Lkas_LdwsActivemode"] = 3 + values["CF_Lkas_Bca_R"] = 3 values["CF_Lkas_FcwOpt_USM"] = 2 # This field is actually LdwsActivemode @@ -48,8 +48,8 @@ def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, lkas11, return packer.make_can_msg("LKAS11", 0, values) -def create_clu11(packer, clu11, button, cnt): +def create_clu11(packer, frame, clu11, button): values = clu11 values["CF_Clu_CruiseSwState"] = button - values["CF_Clu_CruiseSwState"] = cnt + values["CF_Clu_CruiseSwState"] = frame % 0x10 return packer.make_can_msg("CLU11", 0, values) From 21276fee6351f6cd0bc518ba4e729ba3fea41334 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 20:38:57 -0700 Subject: [PATCH 21/28] Force the right value --- selfdrive/car/hyundai/hyundaican.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 120066a4cf0ae0..b5fb909fc98b17 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -21,7 +21,7 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11 # TODO: check if 0x4A7 is present instead of harcoding if car_fingerprint == CAR.SONATA: values["CF_Lkas_Bca_R"] = 3 - values["CF_Lkas_FcwOpt_USM"] = 2 + values["CF_Lkas_LdwsOpt_USM"] = 2 # This field is actually LdwsActivemode # Genesis and Optima fault when forwarding while engaged From 4a473e8225fb5bdfc367871229b388b136f7deb3 Mon Sep 17 00:00:00 2001 From: Comma Device Date: Wed, 15 Apr 2020 12:03:29 -0700 Subject: [PATCH 22/28] some ui stuff --- selfdrive/car/hyundai/hyundaican.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index b5fb909fc98b17..6e6a72f72d815c 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -20,14 +20,27 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11 # LFA # TODO: check if 0x4A7 is present instead of harcoding if car_fingerprint == CAR.SONATA: + # LdwSysState doesn't seem to do anything on the Sonota + values["CF_Lkas_Bca_R"] = 3 values["CF_Lkas_LdwsOpt_USM"] = 2 + # FcwOpt_USM 5 = Orange blinking car + lanes + # FcwOpt_USM 4 = Orange car + lanes + # FcwOpt_USM 3 = Green blinking car + lanes + # 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 + + # TODO: LFA stuff (steering wheel) is in 0x485 + # Make sure there is no dash error when pressing LFA button on wheel + # This field is actually LdwsActivemode # Genesis and Optima fault when forwarding while engaged - if car_fingerprint == CAR.HYUNDAI_GENESIS: + elif car_fingerprint == CAR.HYUNDAI_GENESIS: values["CF_Lkas_Bca_R"] = 2 - if car_fingerprint == CAR.KIA_OPTIMA: + elif car_fingerprint == CAR.KIA_OPTIMA: values["CF_Lkas_Bca_R"] = 0 dat = packer.make_can_msg("LKAS11", 0, values)[2] From f1973b1cdb0bdf68f0527d3d37aef0b255c607bc Mon Sep 17 00:00:00 2001 From: Comma Device Date: Wed, 15 Apr 2020 12:18:00 -0700 Subject: [PATCH 23/28] more comments --- selfdrive/car/hyundai/carcontroller.py | 4 +--- selfdrive/car/hyundai/hyundaican.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 34af243e02fb8b..4373137c16b111 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -9,9 +9,7 @@ def process_hud_alert(enabled, fingerprint, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart): - hud_alert = 0 - if visual_alert == VisualAlert.steerRequired: - hud_alert = 3 + hud_alert = (visual_alert == VisualAlert.steerRequired) # initialize to no line visible lane_visible = 1 diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 6e6a72f72d815c..dec33eb2f271b8 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -8,7 +8,7 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11 lane_visible, left_lane_depart, right_lane_depart): values = lkas11 values["CF_Lkas_LdwsSysState"] = lane_visible - values["CF_Lkas_SysWarning"] = hud_alert + values["CF_Lkas_SysWarning"] = 3 if hud_alert else 0 values["CF_Lkas_LdwsLHWarning"] = left_lane_depart values["CF_Lkas_LdwsRHWarning"] = right_lane_depart values["CR_Lkas_StrToqReq"] = apply_steer @@ -17,11 +17,12 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11 values["CF_Lkas_MsgCount"] = frame % 0x10 values["CF_Lkas_Chksum"] = 0 - # LFA - # TODO: check if 0x4A7 is present instead of harcoding + if car_fingerprint == CAR.SONATA: # LdwSysState doesn't seem to do anything on the Sonota + # TODO: what does the stock system send? Can we forward it? + # TODO: use CF_Lkas_BCA_R to send lane lines. 1 = left, 2, = right, 3 = both values["CF_Lkas_Bca_R"] = 3 values["CF_Lkas_LdwsOpt_USM"] = 2 @@ -33,12 +34,17 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11 # FcwOpt_USM 0 = No car + lanes values["CF_Lkas_FcwOpt_USM"] = 2 if steer_req 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 hud_alert else 0 + # TODO: LFA stuff (steering wheel) is in 0x485 # Make sure there is no dash error when pressing LFA button on wheel - # This field is actually LdwsActivemode - # Genesis and Optima fault when forwarding while engaged elif car_fingerprint == CAR.HYUNDAI_GENESIS: + # This field is actually LdwsActivemode + # Genesis and Optima fault when forwarding while engaged values["CF_Lkas_Bca_R"] = 2 elif car_fingerprint == CAR.KIA_OPTIMA: values["CF_Lkas_Bca_R"] = 0 From e38cc5436d8415bcf0c3c75c72b7fc2dd7b8b04a Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 15 Apr 2020 12:47:09 -0700 Subject: [PATCH 24/28] Show lane lines on sonata --- selfdrive/car/hyundai/carcontroller.py | 36 ++++++++++++++------------ selfdrive/car/hyundai/hyundaican.py | 19 ++++++-------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 4373137c16b111..8ee14144c64040 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -7,21 +7,21 @@ VisualAlert = car.CarControl.HUDControl.VisualAlert -def process_hud_alert(enabled, fingerprint, visual_alert, left_line, - right_line, left_lane_depart, right_lane_depart): - hud_alert = (visual_alert == VisualAlert.steerRequired) +def process_hud_alert(enabled, fingerprint, visual_alert, left_lane, + right_lane, left_lane_depart, right_lane_depart): + sys_warning = (visual_alert == VisualAlert.steerRequired) # initialize to no line visible - lane_visible = 1 - if left_line and right_line or hud_alert: #HUD alert only display when LKAS status is active - if enabled or hud_alert: - lane_visible = 3 + sys_state = 1 + if left_lane and right_lane or sys_warning: #HUD alert only display when LKAS status is active + if enabled or sys_warning: + sys_state = 3 else: - lane_visible = 4 - elif left_line: - lane_visible = 5 - elif right_line: - lane_visible = 6 + sys_state = 4 + elif left_lane: + sys_state = 5 + elif right_lane: + sys_state = 6 # initialize to no warnings left_lane_warning = 0 @@ -31,7 +31,7 @@ def process_hud_alert(enabled, fingerprint, visual_alert, left_line, if right_lane_depart: right_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 - return hud_alert, lane_visible, left_lane_warning, right_lane_warning + return sys_warning, sys_state, left_lane_warning, right_lane_warning class CarController(): @@ -45,7 +45,7 @@ def __init__(self, dbc_name, CP, VM): self.last_lead_distance = 0 def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, - left_line, right_line, left_lane_depart, right_lane_depart): + left_lane, right_lane, left_lane_depart, right_lane_depart): # Steering Torque new_steer = actuators.steer * SteerLimitParams.STEER_MAX apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, SteerLimitParams) @@ -63,13 +63,15 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, self.apply_steer_last = apply_steer - hud_alert, lane_visible, left_lane_warning, right_lane_warning =\ + sys_warning, sys_state, left_lane_warning, right_lane_warning =\ process_hud_alert(enabled, self.car_fingerprint, visual_alert, - left_line, right_line, left_lane_depart, right_lane_depart) + left_lane, right_lane, left_lane_depart, right_lane_depart) can_sends = [] can_sends.append(create_lkas11(self.packer, frame, self.car_fingerprint, apply_steer, lkas_active, - CS.lkas11, hud_alert, lane_visible, left_lane_warning, right_lane_warning)) + CS.lkas11, sys_warning, sys_state, + left_lane, right_lane, + left_lane_warning, right_lane_warning)) if pcm_cancel_cmd: can_sends.append(create_clu11(self.packer, frame, CS.clu11, Buttons.CANCEL)) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index dec33eb2f271b8..f29a1a5ac093b8 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -4,11 +4,13 @@ hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) -def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11, hud_alert, - lane_visible, left_lane_depart, right_lane_depart): +def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, + lkas11, sys_warning, sys_state, + left_lane, right_lane, + left_lane_depart, right_lane_depart): values = lkas11 - values["CF_Lkas_LdwsSysState"] = lane_visible - values["CF_Lkas_SysWarning"] = 3 if hud_alert else 0 + 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 @@ -17,13 +19,8 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11 values["CF_Lkas_MsgCount"] = frame % 0x10 values["CF_Lkas_Chksum"] = 0 - if car_fingerprint == CAR.SONATA: - # LdwSysState doesn't seem to do anything on the Sonota - # TODO: what does the stock system send? Can we forward it? - - # TODO: use CF_Lkas_BCA_R to send lane lines. 1 = left, 2, = right, 3 = both - values["CF_Lkas_Bca_R"] = 3 + values["CF_Lkas_Bca_R"] = int(left_lane) + int(right_lane) << 1 values["CF_Lkas_LdwsOpt_USM"] = 2 # FcwOpt_USM 5 = Orange blinking car + lanes @@ -37,7 +34,7 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11 # 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 hud_alert else 0 + 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 From 2a1ee6350618eb16037a310d7b61b89b887cb07e Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 15 Apr 2020 15:45:23 -0700 Subject: [PATCH 25/28] cleanup dash --- opendbc | 2 +- panda | 2 +- selfdrive/car/hyundai/carcontroller.py | 11 ++++++++--- selfdrive/car/hyundai/hyundaican.py | 27 +++++++++++++++++++++----- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/opendbc b/opendbc index a57e7ddbd72c92..b69398525a4f3d 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit a57e7ddbd72c92241d5d6442da9d47c55e95a8cf +Subproject commit b69398525a4f3d590305df171572415568e365aa diff --git a/panda b/panda index 781f3dae97a325..56748696054851 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 781f3dae97a3258b7bcc27dec5723e3d1b07c025 +Subproject commit 56748696054851feb7c4c150b52197b8a28db018 diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 8ee14144c64040..79d509a1da8b77 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -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 diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index f29a1a5ac093b8..46838d650a938e 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -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) From a425c0a4c60f6464e5d471c028ed0bdc28855353 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 15 Apr 2020 16:43:06 -0700 Subject: [PATCH 26/28] fix last ui issues --- selfdrive/car/hyundai/hyundaican.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 46838d650a938e..7a72145e03a339 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -20,7 +20,7 @@ def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, values["CF_Lkas_Chksum"] = 0 if car_fingerprint == CAR.SONATA: - values["CF_Lkas_Bca_R"] = int(left_lane) + int(right_lane) << 1 + values["CF_Lkas_Bca_R"] = int(left_lane) + (int(right_lane) << 1) values["CF_Lkas_LdwsOpt_USM"] = 2 # FcwOpt_USM 5 = Orange blinking car + lanes @@ -29,7 +29,7 @@ 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 enabled else 0 + values["CF_Lkas_FcwOpt_USM"] = 2 if enabled else 1 # 4 is keep hands on wheel # 5 is keep hands on wheel (red) @@ -70,7 +70,7 @@ def create_clu11(packer, frame, clu11, button): def create_lfa_mfa(packer, frame, enabled): values = { - "LFA_ACTIVE": enabled, + "ACTIVE": enabled, } # ACTIVE 1 = Green steering wheel icon From 9638f1d5495e92b2d633a193f00a65f8268b170c Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 15 Apr 2020 17:58:59 -0700 Subject: [PATCH 27/28] Fix doors --- panda | 2 +- selfdrive/car/hyundai/carstate.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/panda b/panda index 56748696054851..435cabe7f7a02a 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 56748696054851feb7c4c150b52197b8a28db018 +Subproject commit 435cabe7f7a02a0c732725b97cbb7192a68a406d diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 702d429eb53c02..dcb5844c2ca1de 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -11,10 +11,8 @@ class CarState(CarStateBase): def update(self, cp, cp_cam): ret = car.CarState.new_message() - # TODO: This is not working - # ret.doorOpen = not any([cp.vl["CGW1"]['CF_Gway_DrvDrSw'],cp.vl["CGW1"]['CF_Gway_AstDrSw'], - # cp.vl["CGW2"]['CF_Gway_RLDrSw'], cp.vl["CGW2"]['CF_Gway_RRDrSw']]) - ret.doorOpen = False + ret.doorOpen = any([cp.vl["CGW1"]['CF_Gway_DrvDrSw'],cp.vl["CGW1"]['CF_Gway_AstDrSw'], + cp.vl["CGW2"]['CF_Gway_RLDrSw'], cp.vl["CGW2"]['CF_Gway_RRDrSw']]) ret.seatbeltUnlatched = cp.vl["CGW1"]['CF_Gway_DrvSeatBeltSw'] == 0 From c6368b8412e3d9b4286f047f34403a0b2ace93bb Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 15 Apr 2020 18:18:03 -0700 Subject: [PATCH 28/28] update CI --- selfdrive/test/process_replay/ref_commit | 2 +- selfdrive/test/process_replay/test_processes.py | 2 +- selfdrive/test/test_car_models.py | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index c6b5354ad2d908..fb8118eea16d3a 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -3523742130b9e0554bab4ac5bc5ab535f1342e90 \ No newline at end of file +9638f1d5495e92b2d633a193f00a65f8268b170c \ No newline at end of file diff --git a/selfdrive/test/process_replay/test_processes.py b/selfdrive/test/process_replay/test_processes.py index 6425d38a7f5f2a..68571ba601f053 100755 --- a/selfdrive/test/process_replay/test_processes.py +++ b/selfdrive/test/process_replay/test_processes.py @@ -19,7 +19,7 @@ ("TOYOTA", "77611a1fac303767|2020-02-29--13-29-33--3"), # TOYOTA.COROLLA_TSS2 ("GM", "7cc2a8365b4dd8a9|2018-12-02--12-10-44--2"), # GM.ACADIA ("CHRYSLER", "b6849f5cf2c926b1|2020-02-28--07-29-48--13"), # CHRYSLER.PACIFICA - ("HYUNDAI", "38bfd238edecbcd7|2018-08-29--22-02-15--4"), # HYUNDAI.SANTA_FE + ("HYUNDAI", "5b7c365c50084530|2020-04-15--16-13-24--3"), # HYUNDAI.SONATA #("CHRYSLER", "b6e1317e1bfbefa6|2020-03-04--13-11-40"), # CHRYSLER.JEEP_CHEROKEE ("SUBARU", "7873afaf022d36e2|2019-07-03--18-46-44--0"), # SUBARU.IMPREZA ("VOLKSWAGEN", "76b83eb0245de90e|2020-03-05--19-16-05--3"), # VW.GOLF diff --git a/selfdrive/test/test_car_models.py b/selfdrive/test/test_car_models.py index 33ec741b515dad..3f2b81002c1742 100755 --- a/selfdrive/test/test_car_models.py +++ b/selfdrive/test/test_car_models.py @@ -172,6 +172,10 @@ def get_route_log(route_name): 'carFingerprint': HYUNDAI.KIA_OPTIMA, 'enableCamera': True, }, + "5b7c365c50084530|2020-04-15--16-13-24": { + 'carFingerprint': HYUNDAI.SONATA, + 'enableCamera': True, + }, "f7b6be73e3dfd36c|2019-05-12--18-07-16": { 'carFingerprint': TOYOTA.AVALON, 'enableCamera': False, @@ -336,6 +340,7 @@ def get_route_log(route_name): 'carFingerprint': NISSAN.LEAF, 'enableCamera': True, }, + } passive_routes = [ @@ -374,7 +379,6 @@ def get_route_log(route_name): HYUNDAI.KIA_STINGER, HYUNDAI.KONA, HYUNDAI.KONA_EV, - HYUNDAI.SONATA, TOYOTA.CAMRYH, TOYOTA.CHR, TOYOTA.CHRH,