Skip to content

Commit

Permalink
Temporary HKG longitudinal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FrogAi committed Aug 6, 2024
1 parent 8699f29 commit 27cbcc4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
12 changes: 12 additions & 0 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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."), ""},
Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class FrogPilotVehiclesPanel : public FrogPilotListWidget {
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"};

Expand Down
1 change: 1 addition & 0 deletions system/manager/manager.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def manager_init() -> None:
("MTSCCurvatureCheck", "0"),
("MTSCEnabled", "1"),
("NavigationModels", ""),
("NewLongAPI", "0"),
("NewLongAPIGM", "1"),
("NNFF", "1"),
("NNFFLite", "1"),
Expand Down

0 comments on commit 27cbcc4

Please sign in to comment.