From 071e3bfc96ec99e8c1fa778ca85169c9b8f283ba Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Tue, 26 Mar 2024 23:02:03 -0700 Subject: [PATCH] Force auto tune --- common/params.cc | 1 + selfdrive/controls/controlsd.py | 3 ++- selfdrive/frogpilot/ui/qt/offroad/control_settings.cc | 9 ++++++++- selfdrive/frogpilot/ui/qt/offroad/control_settings.h | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/params.cc b/common/params.cc index 5aaf9af57..9e5eaf84e 100644 --- a/common/params.cc +++ b/common/params.cc @@ -264,6 +264,7 @@ std::unordered_map keys = { {"ExperimentalModeViaDistance", PERSISTENT}, {"ExperimentalModeViaLKAS", PERSISTENT}, {"ExperimentalModeViaTap", PERSISTENT}, + {"ForceAutoTune", PERSISTENT}, {"FrogPilotTogglesUpdated", PERSISTENT}, {"FrogsGoMoo", PERSISTENT}, {"GoatScream", PERSISTENT}, diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 3fdb4abd6..9aeebd3c6 100644 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -565,7 +565,7 @@ class Controls: # Update Torque Params if self.CP.lateralTuning.which() == 'torque': torque_params = self.sm['liveTorqueParameters'] - if self.sm.all_checks(['liveTorqueParameters']) and torque_params.useParams: + if self.sm.all_checks(['liveTorqueParameters']) and (torque_params.useParams or self.force_auto_tune): self.LaC.update_live_torque_params(torque_params.latAccelFactorFiltered, torque_params.latAccelOffsetFiltered, torque_params.frictionCoefficientFiltered) @@ -940,6 +940,7 @@ class Controls: self.experimental_mode_via_lkas = experimental_mode_activation and self.params.get_bool("ExperimentalModeViaLKAS") lateral_tune = self.params.get_bool("LateralTune") + self.force_auto_tune = lateral_tune and self.params.get_float("ForceAutoTune") longitudinal_tune = self.CP.openpilotLongitudinalControl and self.params.get_bool("LongitudinalTune") self.frogpilot_variables.sport_plus = longitudinal_tune and self.params.get_int("AccelerationProfile") == 3 diff --git a/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc b/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc index 5915cd61f..5a465b481 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc +++ b/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc @@ -34,6 +34,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil {"ExperimentalModeViaDistance", tr("Long Pressing the Distance Button"), tr("Enable/disable 'Experimental Mode' by holding down the 'distance' button on your steering wheel for 0.5 seconds."), ""}, {"LateralTune", tr("Lateral Tuning"), tr("Modify openpilot's steering behavior."), "../frogpilot/assets/toggle_icons/icon_lateral_tune.png"}, + {"ForceAutoTune", tr("Force Auto Tune"), tr("Forces comma's auto lateral tuning for unsupported vehicles."), ""}, {"LongitudinalTune", tr("Longitudinal Tuning"), tr("Modify openpilot's acceleration and braking behavior."), "../frogpilot/assets/toggle_icons/icon_longitudinal_tune.png"}, {"AccelerationProfile", tr("Acceleration Profile"), tr("Change the acceleration rate to be either sporty or eco-friendly."), ""}, @@ -182,7 +183,13 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil QObject::connect(lateralTuneToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() { openParentToggle(); for (auto &[key, toggle] : toggles) { - toggle->setVisible(lateralTuneKeys.find(key.c_str()) != lateralTuneKeys.end()); + std::set modifiedLateralTuneKeys = lateralTuneKeys; + + if (hasAutoTune || params.getBool("NNFF")) { + modifiedLateralTuneKeys.erase("ForceAutoTune"); + } + + toggle->setVisible(modifiedLateralTuneKeys.find(key.c_str()) != modifiedLateralTuneKeys.end()); } }); toggle = lateralTuneToggle; diff --git a/selfdrive/frogpilot/ui/qt/offroad/control_settings.h b/selfdrive/frogpilot/ui/qt/offroad/control_settings.h index 47926e9ea..559f35ccc 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/control_settings.h +++ b/selfdrive/frogpilot/ui/qt/offroad/control_settings.h @@ -36,7 +36,7 @@ private: std::set deviceManagementKeys = {"DeviceShutdown", "IncreaseThermalLimits", "LowVoltageShutdown", "NoLogging", "NoUploads", "OfflineMode"}; std::set experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaTap"}; std::set laneChangeKeys = {}; - std::set lateralTuneKeys = {}; + std::set lateralTuneKeys = {"ForceAutoTune"}; std::set longitudinalTuneKeys = {"AccelerationProfile", "AggressiveAcceleration", "DecelerationProfile"}; std::set mtscKeys = {}; std::set qolKeys = {"DisableOnroadUploads"};