From 27cbcc4d1c64339e386a1ecfcaaa1130dd614620 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:17:01 -0700 Subject: [PATCH] Temporary HKG longitudinal fixes --- common/params.cc | 1 + selfdrive/car/hyundai/interface.py | 12 ++++++++++++ selfdrive/controls/controlsd.py | 3 ++- .../frogpilot/ui/qt/offroad/vehicle_settings.cc | 7 ++++++- selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h | 1 + system/manager/manager.py | 1 + 6 files changed, 23 insertions(+), 2 deletions(-) mode change 100644 => 100755 system/manager/manager.py diff --git a/common/params.cc b/common/params.cc index 93c7c35f78745c..b0f62bf7422e64 100644 --- a/common/params.cc +++ b/common/params.cc @@ -389,6 +389,7 @@ std::unordered_map keys = { {"MTSCEnabled", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"NavigationModels", PERSISTENT}, {"NextMapSpeedLimit", PERSISTENT}, + {"NewLongAPI", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, {"NewLongAPIGM", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES}, {"NNFF", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"NNFFLite", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index a271dd077ece84..08848fe1d54fdf 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -22,6 +22,8 @@ class CarInterface(CarInterfaceBase): @staticmethod def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs, params): + use_new_api = params.get_bool("NewLongAPI") + ret.carName = "hyundai" ret.radarUnavailable = RADAR_START_ADDR not in fingerprint[1] or DBC[ret.carFingerprint]["radar"] is None @@ -82,8 +84,18 @@ def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, exp # *** longitudinal control *** if candidate in CANFD_CAR: + if not use_new_api: + ret.longitudinalTuning.deadzoneBP = [0.] + ret.longitudinalTuning.deadzoneV = [0.] + ret.longitudinalTuning.kpV = [0.1] + ret.longitudinalTuning.kiV = [0.0] ret.experimentalLongitudinalAvailable = candidate not in (CANFD_UNSUPPORTED_LONGITUDINAL_CAR | CANFD_RADAR_SCC_CAR) else: + if not use_new_api: + ret.longitudinalTuning.deadzoneBP = [0.] + ret.longitudinalTuning.deadzoneV = [0.] + ret.longitudinalTuning.kpV = [0.5] + ret.longitudinalTuning.kiV = [0.0] ret.experimentalLongitudinalAvailable = candidate not in (UNSUPPORTED_LONGITUDINAL_CAR | CAMERA_SCC_CAR) ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable ret.pcmCruise = not ret.openpilotLongitudinalControl diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 6160111c05938a..70df9f6c57443c 100644 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -209,7 +209,8 @@ def __init__(self, CI=None): self.speed_limit_changed = False self.stopped_for_light = False self.update_toggles = False - self.use_old_long = self.CP.carName == "gm" and not self.params.get_bool("NewLongAPIGM") + self.use_old_long = self.CP.carName == "hyundai" and not self.params.get_bool("NewLongAPI") + self.use_old_long |= self.CP.carName == "gm" and not self.params.get_bool("NewLongAPIGM") self.display_timer = 0 self.drive_distance = 0 diff --git a/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc b/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc index e2b61fa5a0c43f..6a5c84ba4fc875 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc +++ b/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc @@ -142,6 +142,8 @@ FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPil {"VoltSNG", tr("2017 Volt SNG"), tr("Enable the 'Stop and Go' hack for 2017 Chevy Volts."), ""}, {"NewLongAPIGM", tr("Use comma's New Longitudinal API"), tr("Use comma's new longitudinal controls that have shown great improvement with acceleration and braking, but has a few issues on some GM vehicles."), ""}, + {"NewLongAPI", tr("Use comma's New Longitudinal API"), tr("Use comma's new longitudinal controls that have shown great improvement with acceleration and braking, but has a few issues on Hyundai/Kia/Genesis."), ""}, + {"CrosstrekTorque", tr("Subaru Crosstrek Torque Increase"), tr("Increases the maximum allowed torque for the Subaru Crosstrek."), ""}, {"ToyotaDoors", tr("Automatically Lock/Unlock Doors"), tr("Automatically lock the doors when in drive and unlock when in park."), ""}, @@ -273,6 +275,7 @@ void FrogPilotVehiclesPanel::hideToggles() { selectModelButton->setVisible(!carMake.isEmpty()); bool gm = carMake == "Buick" || carMake == "Cadillac" || carMake == "Chevrolet" || carMake == "GM" || carMake == "GMC"; + bool hyundai = carMake == "Genesis" || carMake == "Hyundai" || carMake == "Kia"; bool subaru = carMake == "Subaru"; bool toyota = carMake == "Lexus" || carMake == "Toyota"; @@ -301,7 +304,9 @@ void FrogPilotVehiclesPanel::hideToggles() { continue; } - if (gm) { + if (hyundai) { + toggle->setVisible(hyundaiKeys.find(key.c_str()) != hyundaiKeys.end()); + } else if (gm) { toggle->setVisible(gmKeys.find(key.c_str()) != gmKeys.end()); } else if (subaru) { toggle->setVisible(subaruKeys.find(key.c_str()) != subaruKeys.end()); diff --git a/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h b/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h index 454b685cd3377d..abaa3c6e52d134 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h +++ b/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h @@ -32,6 +32,7 @@ class FrogPilotVehiclesPanel : public FrogPilotListWidget { QMap carModels; std::set gmKeys = {"LongPitch", "NewLongAPIGM", "VoltSNG"}; + std::set hyundaiKeys = {"NewLongAPI"}; std::set subaruKeys = {"CrosstrekTorque"}; std::set toyotaKeys = {"ClusterOffset", "SNGHack", "ToyotaDoors", "ToyotaTune"}; diff --git a/system/manager/manager.py b/system/manager/manager.py old mode 100644 new mode 100755 index d5f80de45c0a5b..34f9c513b517ae --- a/system/manager/manager.py +++ b/system/manager/manager.py @@ -213,6 +213,7 @@ def manager_init() -> None: ("MTSCCurvatureCheck", "0"), ("MTSCEnabled", "1"), ("NavigationModels", ""), + ("NewLongAPI", "0"), ("NewLongAPIGM", "1"), ("NNFF", "1"), ("NNFFLite", "1"),