Temporary HKG longitudinal fixes

This commit is contained in:
FrogAi 2024-07-31 13:17:01 -07:00
parent 8699f29666
commit 27cbcc4d1c
6 changed files with 23 additions and 2 deletions

View File

@ -389,6 +389,7 @@ std::unordered_map<std::string, uint32_t> 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},

View File

@ -22,6 +22,8 @@ BUTTONS_DICT = {Buttons.RES_ACCEL: ButtonType.accelCruise, Buttons.SET_DECEL: Bu
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 @@ class CarInterface(CarInterfaceBase):
# *** 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

View File

@ -209,7 +209,8 @@ class Controls:
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

View File

@ -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());

View File

@ -32,6 +32,7 @@ private:
QMap<QString, QString> carModels;
std::set<QString> gmKeys = {"LongPitch", "NewLongAPIGM", "VoltSNG"};
std::set<QString> hyundaiKeys = {"NewLongAPI"};
std::set<QString> subaruKeys = {"CrosstrekTorque"};
std::set<QString> toyotaKeys = {"ClusterOffset", "SNGHack", "ToyotaDoors", "ToyotaTune"};

1
system/manager/manager.py Normal file → Executable file
View File

@ -213,6 +213,7 @@ def manager_init() -> None:
("MTSCCurvatureCheck", "0"),
("MTSCEnabled", "1"),
("NavigationModels", ""),
("NewLongAPI", "0"),
("NewLongAPIGM", "1"),
("NNFF", "1"),
("NNFFLite", "1"),