User set steer ratio
This commit is contained in:
@@ -412,6 +412,8 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||||||
{"StandardFollow", PERSISTENT},
|
{"StandardFollow", PERSISTENT},
|
||||||
{"StandardJerk", PERSISTENT},
|
{"StandardJerk", PERSISTENT},
|
||||||
{"StandbyMode", PERSISTENT},
|
{"StandbyMode", PERSISTENT},
|
||||||
|
{"SteerRatio", PERSISTENT},
|
||||||
|
{"SteerRatioStock", PERSISTENT},
|
||||||
{"StockTune", PERSISTENT},
|
{"StockTune", PERSISTENT},
|
||||||
{"StoppingDistance", PERSISTENT},
|
{"StoppingDistance", PERSISTENT},
|
||||||
{"TetheringEnabled", PERSISTENT},
|
{"TetheringEnabled", PERSISTENT},
|
||||||
|
|||||||
@@ -863,7 +863,7 @@ class Controls:
|
|||||||
# Update VehicleModel
|
# Update VehicleModel
|
||||||
lp = self.sm['liveParameters']
|
lp = self.sm['liveParameters']
|
||||||
x = max(lp.stiffnessFactor, 0.1)
|
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)
|
self.VM.update_params(x, sr)
|
||||||
|
|
||||||
# Update Torque Params
|
# Update Torque Params
|
||||||
@@ -1241,6 +1241,9 @@ class Controls:
|
|||||||
|
|
||||||
lateral_tune = self.params.get_bool("LateralTune")
|
lateral_tune = self.params.get_bool("LateralTune")
|
||||||
self.force_auto_tune = lateral_tune and self.params.get_float("ForceAutoTune")
|
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.lock_doors = self.params.get_bool("LockDoors")
|
self.frogpilot_variables.lock_doors = self.params.get_bool("LockDoors")
|
||||||
self.frogpilot_variables.long_pitch = self.params.get_bool("LongPitch")
|
self.frogpilot_variables.long_pitch = self.params.get_bool("LongPitch")
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
|
|||||||
{"LateralTune", "Lateral Tuning", "Modify openpilot's steering behavior.", "../frogpilot/assets/toggle_icons/icon_lateral_tune.png"},
|
{"LateralTune", "Lateral Tuning", "Modify openpilot's steering behavior.", "../frogpilot/assets/toggle_icons/icon_lateral_tune.png"},
|
||||||
{"ForceAutoTune", "Force Auto Tune", "Forces comma's auto lateral tuning for unsupported vehicles.", ""},
|
{"ForceAutoTune", "Force Auto Tune", "Forces comma's auto lateral tuning for unsupported vehicles.", ""},
|
||||||
{"NNFF", "NNFF - Neural Network Feedforward", "Use Twilsonco's Neural Network Feedforward for enhanced precision in lateral control.", ""},
|
{"NNFF", "NNFF - Neural Network Feedforward", "Use Twilsonco's Neural Network Feedforward for enhanced precision in lateral control.", ""},
|
||||||
|
{"SteerRatio", steerRatioStock != 0 ? QString("Steer Ratio (Default: %1)").arg(steerRatioStock, 0, 'f', 2) : "Steer Ratio", "Set a custom steer ratio for your vehicle controls.", ""},
|
||||||
{"UseLateralJerk", "Use Lateral Jerk", "Include steer torque necessary to achieve desired steer rate (lateral jerk).", ""},
|
{"UseLateralJerk", "Use Lateral Jerk", "Include steer torque necessary to achieve desired steer rate (lateral jerk).", ""},
|
||||||
|
|
||||||
{"LongitudinalTune", "Longitudinal Tuning", "Modify openpilot's acceleration and braking behavior.", "../frogpilot/assets/toggle_icons/icon_longitudinal_tune.png"},
|
{"LongitudinalTune", "Longitudinal Tuning", "Modify openpilot's acceleration and braking behavior.", "../frogpilot/assets/toggle_icons/icon_longitudinal_tune.png"},
|
||||||
@@ -230,6 +231,8 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
toggle = lateralTuneToggle;
|
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, "", 1, 0.01);
|
||||||
|
|
||||||
} else if (param == "LongitudinalTune") {
|
} else if (param == "LongitudinalTune") {
|
||||||
FrogPilotParamManageControl *longitudinalTuneToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
FrogPilotParamManageControl *longitudinalTuneToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||||
@@ -527,6 +530,30 @@ void FrogPilotControlsPanel::updateToggles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FrogPilotControlsPanel::updateCarToggles() {
|
void FrogPilotControlsPanel::updateCarToggles() {
|
||||||
|
steerRatioStock = params.getFloat("SteerRatioStock");
|
||||||
|
|
||||||
|
if (steerRatioStock == 0.0) {
|
||||||
|
QTimer *timer = new QTimer(this);
|
||||||
|
timer->setInterval(1000);
|
||||||
|
connect(timer, &QTimer::timeout, this, [this, timer]() {
|
||||||
|
steerRatioStock = params.getFloat("SteerRatioStock");
|
||||||
|
if (steerRatioStock != 0.0) {
|
||||||
|
timer->stop();
|
||||||
|
timer->deleteLater();
|
||||||
|
|
||||||
|
FrogPilotParamValueControl *steerRatioToggle = static_cast<FrogPilotParamValueControl*>(toggles["SteerRatio"]);
|
||||||
|
steerRatioToggle->setTitle(QString("Steer Ratio (Default: %1)").arg(steerRatioStock, 0, 'f', 2));
|
||||||
|
steerRatioToggle->updateControl(steerRatioStock * 0.75, steerRatioStock * 1.25, "", 0.01);
|
||||||
|
steerRatioToggle->refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
timer->start();
|
||||||
|
} else {
|
||||||
|
FrogPilotParamValueControl *steerRatioToggle = static_cast<FrogPilotParamValueControl*>(toggles["SteerRatio"]);
|
||||||
|
steerRatioToggle->setTitle(QString("Steer Ratio (Default: %1)").arg(steerRatioStock, 0, 'f', 2));
|
||||||
|
steerRatioToggle->updateControl(steerRatioStock * 0.75, steerRatioStock * 1.25, "", 0.01);
|
||||||
|
steerRatioToggle->refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrogPilotControlsPanel::updateMetric() {
|
void FrogPilotControlsPanel::updateMetric() {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ private:
|
|||||||
std::set<QString> experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaScreen"};
|
std::set<QString> experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaScreen"};
|
||||||
std::set<QString> fireTheBabysitterKeys = {"NoLogging", "MuteOverheated", "NoUploads", "OfflineMode"};
|
std::set<QString> fireTheBabysitterKeys = {"NoLogging", "MuteOverheated", "NoUploads", "OfflineMode"};
|
||||||
std::set<QString> laneChangeKeys = {"LaneChangeTime", "LaneDetection", "LaneDetectionWidth", "OneLaneChange"};
|
std::set<QString> laneChangeKeys = {"LaneChangeTime", "LaneDetection", "LaneDetectionWidth", "OneLaneChange"};
|
||||||
std::set<QString> lateralTuneKeys = {"ForceAutoTune", "NNFF", "UseLateralJerk"};
|
std::set<QString> lateralTuneKeys = {"ForceAutoTune", "NNFF", "SteerRatio", "UseLateralJerk"};
|
||||||
std::set<QString> longitudinalTuneKeys = {"AccelerationProfile", "DecelerationProfile", "AggressiveAcceleration", "LeadDetectionThreshold", "SmoothBraking", "StoppingDistance", "TrafficMode"};
|
std::set<QString> longitudinalTuneKeys = {"AccelerationProfile", "DecelerationProfile", "AggressiveAcceleration", "LeadDetectionThreshold", "SmoothBraking", "StoppingDistance", "TrafficMode"};
|
||||||
std::set<QString> mtscKeys = {"DisableMTSCSmoothing", "MTSCAggressiveness", "MTSCCurvatureCheck", "MTSCLimit"};
|
std::set<QString> mtscKeys = {"DisableMTSCSmoothing", "MTSCAggressiveness", "MTSCCurvatureCheck", "MTSCLimit"};
|
||||||
std::set<QString> qolKeys = {"DisableOnroadUploads", "HigherBitrate", "NavChill", "PauseLateralOnSignal", "ReverseCruise", "SetSpeedOffset"};
|
std::set<QString> qolKeys = {"DisableOnroadUploads", "HigherBitrate", "NavChill", "PauseLateralOnSignal", "ReverseCruise", "SetSpeedOffset"};
|
||||||
@@ -61,4 +61,6 @@ private:
|
|||||||
|
|
||||||
bool isMetric = params.getBool("IsMetric");
|
bool isMetric = params.getBool("IsMetric");
|
||||||
bool started = false;
|
bool started = false;
|
||||||
|
|
||||||
|
float steerRatioStock = params.getFloat("SteerRatioStock");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ def main():
|
|||||||
CP = msg
|
CP = msg
|
||||||
cloudlog.info("paramsd got CarParams")
|
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
|
min_sr, max_sr = 0.5 * CP.steerRatio, 2.0 * CP.steerRatio
|
||||||
|
|
||||||
params = params_reader.get("LiveParameters")
|
params = params_reader.get("LiveParameters")
|
||||||
|
|||||||
Reference in New Issue
Block a user