From aecaa132e377884c6cf75162023884464405fd3e Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:23:19 -0700 Subject: [PATCH] Subaru Crosstrek Torque increase Add toggle to increase the torque for the Subaru Crosstrek. --- common/params.cc | 1 + panda/board/safety/safety_subaru.h | 2 +- selfdrive/car/subaru/interface.py | 6 ++++-- selfdrive/car/subaru/values.py | 2 ++ selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc | 6 ++++-- selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/params.cc b/common/params.cc index 127eddc73..dbf2c1d7f 100644 --- a/common/params.cc +++ b/common/params.cc @@ -248,6 +248,7 @@ std::unordered_map keys = { {"CEStopLightsLead", PERSISTENT}, {"Compass", PERSISTENT}, {"ConditionalExperimental", PERSISTENT}, + {"CrosstrekTorque", PERSISTENT}, {"CurrentHolidayTheme", PERSISTENT}, {"CustomAlerts", PERSISTENT}, {"CustomColors", PERSISTENT}, diff --git a/panda/board/safety/safety_subaru.h b/panda/board/safety/safety_subaru.h index 924b76761..7c887a011 100644 --- a/panda/board/safety/safety_subaru.h +++ b/panda/board/safety/safety_subaru.h @@ -17,7 +17,7 @@ } -const SteeringLimits SUBARU_STEERING_LIMITS = SUBARU_STEERING_LIMITS_GENERATOR(2047, 50, 70); +const SteeringLimits SUBARU_STEERING_LIMITS = SUBARU_STEERING_LIMITS_GENERATOR(3071, 50, 70); const SteeringLimits SUBARU_GEN2_STEERING_LIMITS = SUBARU_STEERING_LIMITS_GENERATOR(1000, 40, 40); diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index cd8be60f0..66c63a5e0 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -11,6 +11,8 @@ class CarInterface(CarInterfaceBase): @staticmethod def _get_params(ret, params, candidate: CAR, fingerprint, car_fw, disable_openpilot_long, experimental_long, docs): + crosstrek_torque_increase = params.get_bool("CrosstrekTorque") + ret.carName = "subaru" ret.radarUnavailable = True # for HYBRID CARS to be upstreamed, we need: @@ -51,9 +53,9 @@ class CarInterface(CarInterfaceBase): elif candidate == CAR.IMPREZA: ret.steerActuatorDelay = 0.4 # end-to-end angle controller ret.lateralTuning.init('pid') - ret.lateralTuning.pid.kf = 0.00005 + ret.lateralTuning.pid.kf = 0.00003333 if crosstrek_torque_increase else 0.00005 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 20.], [0., 20.]] - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.3], [0.02, 0.03]] + ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.133, 0.2], [0.0133, 0.02]] if crosstrek_torque_increase else [[0.2, 0.3], [0.02, 0.03]] elif candidate == CAR.IMPREZA_2020: ret.lateralTuning.init('pid') diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index 600cfc2e2..3fe484336 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -26,6 +26,8 @@ class CarControllerParams: self.STEER_DELTA_DOWN = 40 elif CP.carFingerprint == CAR.IMPREZA_2020: self.STEER_MAX = 1439 + elif CP.carFingerprint == CAR.IMPREZA and Params().get_bool("CrosstrekTorque"): + self.STEER_MAX = 3071 else: self.STEER_MAX = 2047 diff --git a/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc b/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc index 9333662f7..f630b9583 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc +++ b/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc @@ -115,6 +115,8 @@ FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPil {"LongPitch", tr("Long Pitch Compensation"), tr("Smoothen out the gas and pedal controls."), ""}, {"GasRegenCmd", tr("Truck Tune"), tr("Increase the acceleration and smoothen out the brake control when coming to a stop. For use on Silverado/Sierra only."), ""}, + {"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."), ""}, {"LongitudinalTune", tr("Longitudinal Tune"), tr("Use a custom Toyota longitudinal tune.\n\nCydia = More focused on TSS-P vehicles but works for all Toyotas\n\nDragonPilot = Focused on TSS2 vehicles\n\nFrogPilot = Takes the best of both worlds with some personal tweaks focused around FrogsGoMoo's 2019 Lexus ES 350"), ""}, }; @@ -161,7 +163,7 @@ FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPil }); } - std::set rebootKeys = {"GasRegenCmd"}; + std::set rebootKeys = {"CrosstrekTorque", "GasRegenCmd"}; for (const QString &key : rebootKeys) { QObject::connect(toggles[key.toStdString().c_str()], &ToggleControl::toggleFlipped, [this]() { if (started) { @@ -256,7 +258,7 @@ void FrogPilotVehiclesPanel::hideToggles() { std::set evCarKeys = {}; std::set gmTruckKeys = {"GasRegenCmd"}; - std::set imprezaKeys = {}; + std::set imprezaKeys = {"CrosstrekTorque"}; std::set longitudinalKeys = {"GasRegenCmd", "LongitudinalTune", "LongPitch"}; std::set sngKeys = {}; diff --git a/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h b/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h index 79e49d5e9..a7eaeb9e7 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h +++ b/selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h @@ -30,7 +30,7 @@ private: QStringList models; std::set gmKeys = {"GasRegenCmd", "LongPitch"}; - std::set subaruKeys = {}; + std::set subaruKeys = {"CrosstrekTorque"}; std::set toyotaKeys = {"LongitudinalTune", "ToyotaDoors"}; std::map toggles;