User set steer ratio

Add toggle to use a custom set steer ratio as opposed to using comma's auto tune value.
This commit is contained in:
FrogAi
2024-03-21 19:18:09 -07:00
parent 937b745156
commit d6995513a4
5 changed files with 34 additions and 2 deletions
+3
View File
@@ -377,6 +377,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"RefuseVolume", PERSISTENT},
{"RelaxedFollow", PERSISTENT},
{"RelaxedJerk", PERSISTENT},
{"ResetSteerRatio", PERSISTENT},
{"ReverseCruise", PERSISTENT},
{"ReverseCruiseUI", PERSISTENT},
{"RoadEdgesWidth", PERSISTENT},
@@ -426,6 +427,8 @@ std::unordered_map<std::string, uint32_t> keys = {
{"StandardFollow", PERSISTENT},
{"StandardJerk", PERSISTENT},
{"StandbyMode", PERSISTENT},
{"SteerRatio", PERSISTENT},
{"SteerRatioStock", PERSISTENT},
{"StockTune", PERSISTENT},
{"StoppingDistance", PERSISTENT},
{"TacoTune", PERSISTENT},
+4 -1
View File
@@ -600,7 +600,7 @@ class Controls:
# Update VehicleModel
lp = self.sm['liveParameters']
x = max(lp.stiffnessFactor, 0.1)
sr = max(lp.steerRatio, 0.1)
sr = max(self.steer_ratio, 0.1) if self.use_custom_steer_ratio else max(lp.steerRatio, 0.1)
self.VM.update_params(x, sr)
# Update Torque Params
@@ -1173,6 +1173,9 @@ class Controls:
lateral_tune = self.params.get_bool("LateralTune")
self.force_auto_tune = lateral_tune and self.params.get_float("ForceAutoTune")
stock_steer_ratio = self.params.get_float("SteerRatioStock")
self.steer_ratio = self.params.get_float("SteerRatio") if lateral_tune else stock_steer_ratio
self.use_custom_steer_ratio = self.steer_ratio != stock_steer_ratio
self.frogpilot_variables.long_pitch = self.params.get_bool("LongPitch")
@@ -80,6 +80,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
{"ForceAutoTune", tr("Force Auto Tune"), tr("Forces comma's auto lateral tuning for unsupported vehicles."), ""},
{"NNFF", tr("NNFF"), tr("Use Twilsonco's Neural Network Feedforward for enhanced precision in lateral control."), ""},
{"NNFFLite", tr("NNFF-Lite"), tr("Use Twilsonco's Neural Network Feedforward for enhanced precision in lateral control for cars without available NNFF logs."), ""},
{"SteerRatio", steerRatioStock != 0 ? QString(tr("Steer Ratio (Default: %1)")).arg(QString::number(steerRatioStock, 'f', 2)) : tr("Steer Ratio"), tr("Use a custom steer ratio as opposed to comma's auto tune value."), ""},
{"TacoTune", tr("Taco Tune"), tr("Use comma's 'Taco Tune' designed for handling left and right turns."), ""},
{"TurnDesires", tr("Use Turn Desires"), tr("Use turn desires for greater precision in turns below the minimum lane change speed."), ""},
@@ -317,6 +318,10 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
}
});
toggle = lateralTuneToggle;
} else if (param == "SteerRatio") {
std::vector<QString> steerRatioToggles{"ResetSteerRatio"};
std::vector<QString> steerRatioToggleNames{"Reset"};
toggle = new FrogPilotParamValueToggleControl(param, title, desc, icon, steerRatioStock * 0.75, steerRatioStock * 1.25, std::map<int, QString>(), this, false, "", 1, 0.01, steerRatioToggles, steerRatioToggleNames);
} else if (param == "LongitudinalTune") {
FrogPilotParamManageControl *longitudinalTuneToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
@@ -820,6 +825,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
}
modelManagerToggle = static_cast<FrogPilotParamManageControl*>(toggles["ModelSelector"]);
steerRatioToggle = static_cast<FrogPilotParamValueToggleControl*>(toggles["SteerRatio"]);
QObject::connect(parent, &SettingsWindow::closeParentToggle, this, &FrogPilotControlsPanel::hideToggles);
QObject::connect(parent, &SettingsWindow::closeSubParentToggle, this, &FrogPilotControlsPanel::hideSubToggles);
@@ -839,6 +845,12 @@ void FrogPilotControlsPanel::updateState(const UIState &s) {
started = s.scene.started;
if (params.getBool("ResetSteerRatio")) {
params.putFloat("SteerRatio", steerRatioStock);
params.putBool("ResetSteerRatio", false);
steerRatioToggle->refresh();
}
downloadModelBtn->setEnabled(s.scene.online);
modelManagerToggle->setEnabled(!s.scene.started);
}
@@ -868,6 +880,11 @@ void FrogPilotControlsPanel::updateCarToggles() {
hasOpenpilotLongitudinal = CP.getOpenpilotLongitudinalControl() && !params.getBool("DisableOpenpilotLongitudinal");
hasPCMCruise = CP.getPcmCruise();
isToyota = carName == "toyota";
steerRatioStock = CP.getSteerRatio();
steerRatioToggle->setTitle(QString(tr("Steer Ratio (Default: %1)")).arg(QString::number(steerRatioStock, 'f', 2)));
steerRatioToggle->updateControl(steerRatioStock * 0.75, steerRatioStock * 1.25, "", 0.01);
steerRatioToggle->refresh();
} else {
hasAutoTune = false;
hasCommaNNFFSupport = false;
@@ -39,12 +39,14 @@ private:
FrogPilotParamManageControl *modelManagerToggle;
FrogPilotParamValueToggleControl *steerRatioToggle;
std::set<QString> aolKeys = {"AlwaysOnLateralMain", "HideAOLStatusBar", "PauseAOLOnBrake"};
std::set<QString> conditionalExperimentalKeys = {"CECurves", "CECurvesLead", "CENavigation", "CESignal", "CESlowerLead", "CEStopLights", "HideCEMStatusBar"};
std::set<QString> deviceManagementKeys = {"DeviceShutdown", "HigherBitrate", "IncreaseThermalLimits", "LowVoltageShutdown", "NoLogging", "NoUploads", "OfflineMode"};
std::set<QString> experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaTap"};
std::set<QString> laneChangeKeys = {"LaneChangeTime", "LaneDetectionWidth", "OneLaneChange"};
std::set<QString> lateralTuneKeys = {"ForceAutoTune", "NNFF", "NNFFLite", "TacoTune", "TurnDesires"};
std::set<QString> lateralTuneKeys = {"ForceAutoTune", "NNFF", "NNFFLite", "SteerRatio", "TacoTune", "TurnDesires"};
std::set<QString> longitudinalTuneKeys = {"AccelerationProfile", "AggressiveAcceleration", "DecelerationProfile", "LeadDetectionThreshold", "SmoothBraking", "StoppingDistance", "TrafficMode"};
std::set<QString> mtscKeys = {"DisableMTSCSmoothing", "MTSCAggressiveness", "MTSCCurvatureCheck"};
std::set<QString> qolKeys = {"CustomCruise", "CustomCruiseLong", "DisableOnroadUploads", "OnroadDistanceButton", "PauseLateralSpeed", "ReverseCruise", "SetSpeedOffset"};
@@ -69,4 +71,6 @@ private:
bool isRelease;
bool isToyota;
bool started;
float steerRatioStock;
};
+5
View File
@@ -133,6 +133,11 @@ def main():
CP = msg
cloudlog.info("paramsd got CarParams")
steer_ratio_stock = params_reader.get_float("SteerRatioStock")
if steer_ratio_stock != CP.steerRatio:
params_reader.put_float("SteerRatio", CP.steerRatio)
params_reader.put_float("SteerRatioStock", CP.steerRatio)
min_sr, max_sr = 0.5 * CP.steerRatio, 2.0 * CP.steerRatio
params = params_reader.get("LiveParameters")