diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/neural_network_lateral_control.cc b/selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/neural_network_lateral_control.cc
index 6e3e244532..d3bc0fffa7 100644
--- a/selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/neural_network_lateral_control.cc
+++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/neural_network_lateral_control.cc
@@ -18,13 +18,9 @@ void NeuralNetworkLateralControl::showEvent(QShowEvent *event) {
}
void NeuralNetworkLateralControl::updateToggle() {
- QString nnff_available_desc = tr("NNLC is currently not available on this platform.");
- QString nnff_fuzzy_desc =
- tr("Match: \"Exact\" is ideal, but \"Fuzzy\" is fine too. Reach out to the sunnypilot team in the following channel at the sunnypilot Discord server if there are any issues:")
- + " #tuning-nnlc";
- QString nnff_status_init = "" + tr("Start the car to check car compatibility") + "";
- QString nnff_not_loaded = "" + tr("NNLC Not Loaded") + "";
- QString nnff_loaded = "" + tr("NNLC Loaded") + "";
+ QString statusInitText = "" + STATUS_CHECK_COMPATIBILITY + "";
+ QString notLoadedText = "" + STATUS_NOT_LOADED + "";
+ QString loadedText = "" + STATUS_LOADED + "";
auto cp_bytes = params.get("CarParamsPersistent");
auto cp_sp_bytes = params.get("CarParamsSPPersistent");
@@ -36,34 +32,32 @@ void NeuralNetworkLateralControl::updateToggle() {
cereal::CarParams::Reader CP = cmsg.getRoot();
cereal::CarParamsSP::Reader CP_SP = cmsg_sp.getRoot();
- /*** NNLC ***/
- {
- if (CP.getSteerControlType() == cereal::CarParams::SteerControlType::ANGLE) {
- params.remove("NeuralNetworkLateralControl");
-
- setDescription(nnffDescriptionBuilder(nnff_available_desc));
- setEnabled(false);
- } else {
- QString nn_model_name = QString::fromStdString(CP_SP.getNeuralNetworkLateralControl().getModel().getName());
- QString nn_fuzzy = CP_SP.getNeuralNetworkLateralControl().getFuzzyFingerprint() ? tr("Fuzzy") : tr("Exact");
+ if (CP.getSteerControlType() == cereal::CarParams::SteerControlType::ANGLE) {
+ params.remove("NeuralNetworkLateralControl");
+ setDescription(nnffDescriptionBuilder(STATUS_NOT_AVAILABLE));
+ setEnabled(false);
+ } else {
+ QString nn_model_name = QString::fromStdString(CP_SP.getNeuralNetworkLateralControl().getModel().getName());
+ QString nn_fuzzy = CP_SP.getNeuralNetworkLateralControl().getFuzzyFingerprint() ?
+ STATUS_MATCH_FUZZY : STATUS_MATCH_EXACT;
+ if (nn_model_name.isEmpty()) {
+ setDescription(nnffDescriptionBuilder(statusInitText));
+ } else if (nn_model_name == "MOCK") {
setDescription(nnffDescriptionBuilder(
- (nn_model_name == "")
- ? nnff_status_init
- : (nn_model_name == "MOCK")
- ? (nnff_not_loaded + "
" + tr(
- "Reach out to the sunnypilot team in the following channel at the sunnypilot Discord server and donate logs to get NNLC loaded for your car: ")
- + "#tuning-nnlc")
- : (nnff_loaded + " | " + tr("Match") + " = " + nn_fuzzy + " | " + nn_model_name + "
" +
- nnff_fuzzy_desc)
+ notLoadedText + "
" + buildSupportText(SUPPORT_DONATE_LOGS)
));
+ } else {
+ QString statusText = loadedText + " | " + STATUS_MATCH + " = " + nn_fuzzy + " | " + nn_model_name;
+ QString explanationText = EXPLANATION_MATCH + " " + buildSupportText(SUPPORT_ISSUES);
+ setDescription(nnffDescriptionBuilder(statusText + "
" + explanationText));
}
}
} else {
- setDescription(nnffDescriptionBuilder(nnff_status_init));
+ setDescription(nnffDescriptionBuilder(statusInitText));
}
- if (getDescription() != nnff_description) {
+ if (getDescription() != getBaseDescription()) {
showDescription();
}
}
diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/neural_network_lateral_control.h b/selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/neural_network_lateral_control.h
index a03df839a4..18a3fac187 100644
--- a/selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/neural_network_lateral_control.h
+++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/neural_network_lateral_control.h
@@ -28,19 +28,37 @@ private:
void refresh();
- QString nnffDescriptionBuilder(const QString &custom_description) {
- QString description = "" +
- custom_description +
- "
" +
- nnff_description;
- return description;
+ // Status messages
+ const QString STATUS_NOT_AVAILABLE = tr("NNLC is currently not available on this platform.");
+ const QString STATUS_CHECK_COMPATIBILITY = tr("Start the car to check car compatibility");
+ const QString STATUS_NOT_LOADED = tr("NNLC Not Loaded");
+ const QString STATUS_LOADED = tr("NNLC Loaded");
+ const QString STATUS_MATCH = tr("Match");
+ const QString STATUS_MATCH_EXACT = tr("Exact");
+ const QString STATUS_MATCH_FUZZY = tr("Fuzzy");
+
+ // Explanations
+ const QString EXPLANATION_MATCH = tr("Match: \"Exact\" is ideal, but \"Fuzzy\" is fine too.");
+ const QString EXPLANATION_FEATURE = tr("Formerly known as \"NNFF\", this replaces the lateral \"torque\" controller, "
+ "with one using a neural network trained on each car's (actually, each separate EPS firmware) driving data for increased controls accuracy.");
+
+ // Support information
+ const QString SUPPORT_CHANNEL = "#tuning-nnlc";
+ const QString SUPPORT_REACH_OUT = tr("Reach out to the sunnypilot team in the following channel at the sunnypilot Discord server");
+ const QString SUPPORT_FEEDBACK = tr("with feedback, or to provide log data for your car if your car is currently unsupported:");
+ const QString SUPPORT_ISSUES = tr("if there are any issues:");
+ const QString SUPPORT_DONATE_LOGS = tr("and donate logs to get NNLC loaded for your car:");
+
+ // Description builders
+ QString buildSupportText(const QString& context) const {
+ return SUPPORT_REACH_OUT + " " + context + " " + SUPPORT_CHANNEL;
}
- const QString nnff_description = QString("%1
"
- "%2")
- .arg(tr("Formerly known as \"NNFF\", this replaces the lateral \"torque\" controller, "
- "with one using a neural network trained on each car's (actually, each separate EPS firmware) driving data for increased controls accuracy."))
- .arg(tr("Reach out to the sunnypilot team in the following channel at the sunnypilot Discord server with feedback, "
- "or to provide log data for your car if your car is currently unsupported: ") +
- "#tuning-nnlc");
+ QString nnffDescriptionBuilder(const QString &custom_description) const {
+ return "" + custom_description + "
" + getBaseDescription();
+ }
+
+ QString getBaseDescription() const {
+ return EXPLANATION_FEATURE + "
" + buildSupportText(SUPPORT_FEEDBACK);
+ }
};