User Set Steer Ratio
This commit is contained in:
@@ -340,6 +340,8 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"SpeedLimitController", PERSISTENT},
|
||||
{"StandardFollow", PERSISTENT},
|
||||
{"StandardJerk", PERSISTENT},
|
||||
{"SteerRatio", PERSISTENT},
|
||||
{"SteerRatioStock", PERSISTENT},
|
||||
{"StoppingDistance", PERSISTENT},
|
||||
{"TetheringEnabled", PERSISTENT},
|
||||
{"TSS2Tune", PERSISTENT},
|
||||
|
||||
@@ -616,7 +616,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)
|
||||
self.VM.update_params(x, sr)
|
||||
|
||||
# Update Torque Params
|
||||
@@ -994,6 +994,9 @@ class Controls:
|
||||
|
||||
self.green_light_alert = self.params.get_bool("GreenLightAlert")
|
||||
|
||||
lateral_tune = self.params.get_bool("LateralTune")
|
||||
self.steer_ratio = self.params.get_int("SteerRatio") / 100 if lateral_tune else self.params.get_int("SteerRatioStock") / 100
|
||||
|
||||
longitudinal_tune = self.params.get_bool("LongitudinalTune")
|
||||
self.sport_plus = self.params.get_int("AccelerationProfile") == 3 and longitudinal_tune
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
|
||||
{"LateralTune", "Lateral Tuning", "Modify openpilot's steering behavior.", "../frogpilot/assets/toggle_icons/icon_lateral_tune.png"},
|
||||
{"AverageCurvature", "Average Desired Curvature", "Use Pfeiferj's distance-based curvature adjustment for improved curve handling.", ""},
|
||||
{"NNFF", "NNFF - Neural Network Feedforward", "Use Twilsonco's Neural Network Feedforward for enhanced precision in lateral control.", ""},
|
||||
{"SteerRatio", steerRatioStock != 0 ? QString("Steer Ratio (Default: " + QString::number(steerRatioStock / 100.0) + ")") : "Steer Ratio", "Set a custom steer ratio for your vehicle controls.", ""},
|
||||
|
||||
{"LongitudinalTune", "Longitudinal Tuning", "Modify openpilot's acceleration and braking behavior.", "../frogpilot/assets/toggle_icons/icon_longitudinal_tune.png"},
|
||||
{"AccelerationProfile", "Acceleration Profile", "Change the acceleration rate to be either sporty or eco-friendly.", ""},
|
||||
@@ -176,6 +177,8 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
|
||||
}
|
||||
});
|
||||
toggle = lateralTuneToggle;
|
||||
} else if (param == "SteerRatio") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, steerRatioStock * 0.75, steerRatioStock * 1.25, std::map<int, QString>(), this, false, "", 100);
|
||||
|
||||
} else if (param == "LongitudinalTune") {
|
||||
FrogPilotParamManageControl *longitudinalTuneToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
@@ -359,11 +362,17 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
|
||||
conditionalExperimentalKeys = {"CECurves", "CECurvesLead", "CESlowerLead", "CENavigation", "CEStopLights", "CESignal"};
|
||||
fireTheBabysitterKeys = {"NoLogging", "MuteDM", "MuteDoor", "MuteOverheated", "MuteSeatbelt"};
|
||||
laneChangeKeys = {"LaneChangeTime", "LaneDetection", "OneLaneChange", "PauseLateralOnSignal"};
|
||||
lateralTuneKeys = {"AverageCurvature", "NNFF"};
|
||||
lateralTuneKeys = {"AverageCurvature", "NNFF", "SteerRatio"};
|
||||
longitudinalTuneKeys = {"AccelerationProfile", "AggressiveAcceleration", "SmoothBraking", "StoppingDistance"};
|
||||
speedLimitControllerKeys = {"Offset1", "Offset2", "Offset3", "Offset4", "SLCFallback", "SLCOverride", "SLCPriority"};
|
||||
visionTurnControlKeys = {};
|
||||
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, [this](bool offroad) {
|
||||
if (!offroad) {
|
||||
updateCarToggles();
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(device(), &Device::interactiveTimeout, this, &FrogPilotControlsPanel::hideSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::closeParentToggle, this, &FrogPilotControlsPanel::hideSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::updateMetric, this, &FrogPilotControlsPanel::updateMetric);
|
||||
@@ -372,6 +381,14 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
|
||||
updateMetric();
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::updateCarToggles() {
|
||||
FrogPilotParamValueControl *steerRatioToggle = static_cast<FrogPilotParamValueControl*>(toggles["SteerRatio"]);
|
||||
steerRatioStock = params.getInt("SteerRatioStock");
|
||||
steerRatioToggle->setTitle(steerRatioStock != 0 ? QString("Steer Ratio (Default: " + QString::number(steerRatioStock / 100.0) + ")") : QString("Steer Ratio"));
|
||||
steerRatioToggle->updateControl(steerRatioStock * 0.75, steerRatioStock * 1.25, "", 100);
|
||||
steerRatioToggle->refresh();
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::updateToggles() {
|
||||
std::thread([this]() {
|
||||
paramsMemory.putBool("FrogPilotTogglesUpdated", true);
|
||||
|
||||
@@ -19,6 +19,7 @@ private:
|
||||
void hideEvent(QHideEvent *event);
|
||||
void hideSubToggles();
|
||||
void parentToggleClicked();
|
||||
void updateCarToggles();
|
||||
void updateMetric();
|
||||
void updateToggles();
|
||||
|
||||
@@ -46,4 +47,5 @@ private:
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
|
||||
bool isMetric = params.getBool("IsMetric");
|
||||
int steerRatioStock = params.getInt("SteerRatioStock");
|
||||
};
|
||||
|
||||
@@ -313,10 +313,11 @@ public:
|
||||
valueLabel->setStyleSheet("QLabel { color: #E0E879; }");
|
||||
}
|
||||
|
||||
void updateControl(int newMinValue, int newMaxValue, const QString &newLabel) {
|
||||
void updateControl(int newMinValue, int newMaxValue, const QString &newLabel, int newDivision = 1) {
|
||||
minValue = newMinValue;
|
||||
maxValue = newMaxValue;
|
||||
labelText = newLabel;
|
||||
division = newDivision;
|
||||
}
|
||||
|
||||
void showEvent(QShowEvent *event) override {
|
||||
@@ -492,10 +493,11 @@ public:
|
||||
valueLabel->setStyleSheet("QLabel { color: #E0E879; }");
|
||||
}
|
||||
|
||||
void updateControl(int newMinValue, int newMaxValue, const QString &newLabel) {
|
||||
void updateControl(int newMinValue, int newMaxValue, const QString &newLabel, int newDivision) {
|
||||
minValue = newMinValue;
|
||||
maxValue = newMaxValue;
|
||||
labelText = newLabel;
|
||||
division = newDivision;
|
||||
}
|
||||
|
||||
void showEvent(QShowEvent *event) override {
|
||||
|
||||
@@ -134,6 +134,11 @@ def main():
|
||||
CP = msg
|
||||
cloudlog.info("paramsd got CarParams")
|
||||
|
||||
steer_ratio_stock = params_reader.get_int("SteerRatioStock")
|
||||
if steer_ratio_stock != CP.steerRatio * 100:
|
||||
params_reader.put_int("SteerRatio", CP.steerRatio * 100)
|
||||
params_reader.put_int("SteerRatioStock", CP.steerRatio * 100)
|
||||
|
||||
min_sr, max_sr = 0.5 * CP.steerRatio, 2.0 * CP.steerRatio
|
||||
|
||||
params = params_reader.get("LiveParameters")
|
||||
|
||||
Reference in New Issue
Block a user