split out experimental long toggle (#25698)

* split out experimental long toggle

* clean up

* update translations
This commit is contained in:
Adeeb Shihadeh
2022-09-07 20:38:04 -07:00
committed by GitHub
parent da6c7311a3
commit 3ef37fe2e8
8 changed files with 110 additions and 64 deletions
@@ -66,7 +66,8 @@ class LongitudinalPlanner:
self.solverExecutionTime = 0.0
def read_param(self):
self.mpc.mode = 'blended' if self.params.get_bool('EndToEndLong') else 'acc'
e2e = self.params.get_bool('EndToEndLong') and self.CP.openpilotLongitudinalControl
self.mpc.mode = 'blended' if e2e else 'acc'
def parse_model(self, model_msg):
if (len(model_msg.position.x) == 33 and
+27 -35
View File
@@ -65,6 +65,12 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
"",
"../assets/offroad/icon_road.png",
},
{
"ExperimentalLongitudinalEnabled",
tr("Experimental openpilot longitudinal control"),
tr("<b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b>"),
"../assets/offroad/icon_speed_limit.png",
},
#ifdef ENABLE_MAPS
{
"NavSettingTime24h",
@@ -92,23 +98,7 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
toggles[param.toStdString()] = toggle;
}
QObject::connect(toggles["EndToEndLong"], &ParamControl::toggleFlipped, [=](bool state) {
auto cp_bytes = params.get("CarParamsPersistent");
if (!cp_bytes.empty()) {
AlignedBuffer aligned_buf;
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size()));
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
if (CP.getExperimentalLongitudinalAvailable()) {
params.putBool("ExperimentalLongitudinalEnabled", state);
} else {
params.remove("ExperimentalLongitudinalEnabled");
}
} else {
params.remove("ExperimentalLongitudinalEnabled");
}
});
connect(uiState(), &UIState::offroadTransition, [=]() {
connect(toggles["ExperimentalLongitudinalEnabled"], &ToggleControl::toggleFlipped, [=]() {
updateToggles();
});
}
@@ -118,8 +108,8 @@ void TogglesPanel::showEvent(QShowEvent *event) {
}
void TogglesPanel::updateToggles() {
// update e2e toggle
auto toggle = toggles["EndToEndLong"];
auto e2e_toggle = toggles["EndToEndLong"];
auto op_long_toggle = toggles["ExperimentalLongitudinalEnabled"];
const QString e2e_description = tr("Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental.");
auto cp_bytes = params.get("CarParamsPersistent");
@@ -128,29 +118,31 @@ void TogglesPanel::updateToggles() {
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size()));
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
const bool exp_long = CP.getExperimentalLongitudinalAvailable();
const bool op_long = CP.getOpenpilotLongitudinalControl() && !CP.getExperimentalLongitudinalAvailable();
if (op_long) {
// normal description and toggle
if (!CP.getExperimentalLongitudinalAvailable()) {
params.remove("ExperimentalLongitudinalEnabled");
toggle->setDescription(e2e_description);
} else if (exp_long) {
toggle->setDescription("<b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b><br><br>" + e2e_description);
if (params.getBool("EndToEndLong") && !params.getBool("ExperimentalLongitudinalEnabled")) {
params.remove("EndToEndLong");
}
}
op_long_toggle->setVisible(CP.getExperimentalLongitudinalAvailable());
const bool op_long = CP.getOpenpilotLongitudinalControl() && !CP.getExperimentalLongitudinalAvailable();
const bool exp_long_enabled = CP.getExperimentalLongitudinalAvailable() && params.getBool("ExperimentalLongitudinalEnabled");
if (op_long || exp_long_enabled) {
// normal description and toggle
e2e_toggle->setEnabled(true);
e2e_toggle->setDescription(e2e_description);
} else {
// no long for now
e2e_toggle->setEnabled(false);
params.remove("EndToEndLong");
params.remove("ExperimentalLongitudinalEnabled");
toggle->setDescription("<b>openpilot longitudinal control is not currently available for this car.</b><br><br>" + e2e_description);
const QString no_long = "openpilot longitudinal control is not currently available for this car.";
const QString exp_long = "Enable experimental longitudinal control to enable this.";
e2e_toggle->setDescription("<b>" + (CP.getExperimentalLongitudinalAvailable() ? exp_long : no_long) + "</b><br><br>" + e2e_description);
}
toggle->refresh();
toggle->setEnabled(op_long || (exp_long && !uiState()->scene.started));
e2e_toggle->refresh();
} else {
toggle->setDescription(e2e_description);
e2e_toggle->setDescription(e2e_description);
op_long_toggle->setVisible(false);
}
}
+6 -3
View File
@@ -164,9 +164,12 @@ private:
QPainter p(this);
p.setPen(Qt::gray);
for (int i = 0; i < inner_layout.count() - 1; ++i) {
QRect r = inner_layout.itemAt(i)->geometry();
int bottom = r.bottom() + inner_layout.spacing() / 2;
p.drawLine(r.left() + 40, bottom, r.right() - 40, bottom);
QWidget *widget = inner_layout.itemAt(i)->widget();
if (widget->isVisible()) {
QRect r = inner_layout.itemAt(i)->geometry();
int bottom = r.bottom() + inner_layout.spacing() / 2;
p.drawLine(r.left() + 40, bottom, r.right() - 40, bottom);
}
}
}
QVBoxLayout outer_layout;
+15 -5
View File
@@ -108,7 +108,7 @@
<context>
<name>DevicePanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="+159"/>
<location filename="../qt/offroad/settings.cc" line="+151"/>
<source>Dongle ID</source>
<translation> (Dongle ID)</translation>
</message>
@@ -1153,7 +1153,7 @@ location set</source>
<context>
<name>TogglesPanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="-332"/>
<location filename="../qt/offroad/settings.cc" line="-324"/>
<source>Enable openpilot</source>
<translation>openpilot </translation>
</message>
@@ -1198,12 +1198,22 @@ location set</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+59"/>
<location line="+6"/>
<source>Experimental openpilot longitudinal control</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>&lt;b&gt;WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.&lt;/b&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+42"/>
<source>Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-65"/>
<location line="-55"/>
<source>Disengage On Accelerator Pedal</source>
<translation> openpilot </translation>
</message>
@@ -1213,7 +1223,7 @@ location set</source>
<translation> openpilot </translation>
</message>
<message>
<location line="+12"/>
<location line="+18"/>
<source>Show ETA in 24h Format</source>
<translation>24</translation>
</message>
+15 -5
View File
@@ -108,7 +108,7 @@
<context>
<name>DevicePanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="+159"/>
<location filename="../qt/offroad/settings.cc" line="+151"/>
<source>Dongle ID</source>
<translation>Dongle ID</translation>
</message>
@@ -1153,7 +1153,7 @@ location set</source>
<context>
<name>TogglesPanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="-332"/>
<location filename="../qt/offroad/settings.cc" line="-324"/>
<source>Enable openpilot</source>
<translation>openpilot </translation>
</message>
@@ -1198,12 +1198,22 @@ location set</source>
<translation>🌮 e2e long ( ) 🌮 </translation>
</message>
<message>
<location line="+59"/>
<location line="+6"/>
<source>Experimental openpilot longitudinal control</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>&lt;b&gt;WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.&lt;/b&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+42"/>
<source>Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-65"/>
<location line="-55"/>
<source>Disengage On Accelerator Pedal</source>
<translation> </translation>
</message>
@@ -1213,7 +1223,7 @@ location set</source>
<translation> openpilot이 .</translation>
</message>
<message>
<location line="+12"/>
<location line="+18"/>
<source>Show ETA in 24h Format</source>
<translation>24 </translation>
</message>
+15 -5
View File
@@ -108,7 +108,7 @@
<context>
<name>DevicePanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="+159"/>
<location filename="../qt/offroad/settings.cc" line="+151"/>
<source>Dongle ID</source>
<translation>Dongle ID</translation>
</message>
@@ -1157,7 +1157,7 @@ trabalho definido</translation>
<context>
<name>TogglesPanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="-332"/>
<location filename="../qt/offroad/settings.cc" line="-324"/>
<source>Enable openpilot</source>
<translation>Ativar openpilot</translation>
</message>
@@ -1202,12 +1202,22 @@ trabalho definido</translation>
<translation>🌮 End-to-end longitudinal (experimental) 🌮</translation>
</message>
<message>
<location line="+59"/>
<location line="+6"/>
<source>Experimental openpilot longitudinal control</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>&lt;b&gt;WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.&lt;/b&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+42"/>
<source>Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-65"/>
<location line="-55"/>
<source>Disengage On Accelerator Pedal</source>
<translation>Desacionar Com Pedal Do Acelerador</translation>
</message>
@@ -1217,7 +1227,7 @@ trabalho definido</translation>
<translation>Quando ativado, pressionar o pedal do acelerador desacionará o openpilot.</translation>
</message>
<message>
<location line="+12"/>
<location line="+18"/>
<source>Show ETA in 24h Format</source>
<translation>Mostrar ETA em formato 24h</translation>
</message>
+15 -5
View File
@@ -108,7 +108,7 @@
<context>
<name>DevicePanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="+159"/>
<location filename="../qt/offroad/settings.cc" line="+151"/>
<source>Dongle ID</source>
<translation>IDDongle ID</translation>
</message>
@@ -1151,7 +1151,7 @@ location set</source>
<context>
<name>TogglesPanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="-332"/>
<location filename="../qt/offroad/settings.cc" line="-324"/>
<source>Enable openpilot</source>
<translation>openpilot</translation>
</message>
@@ -1196,12 +1196,22 @@ location set</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+59"/>
<location line="+6"/>
<source>Experimental openpilot longitudinal control</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>&lt;b&gt;WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.&lt;/b&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+42"/>
<source>Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-65"/>
<location line="-55"/>
<source>Disengage On Accelerator Pedal</source>
<translation></translation>
</message>
@@ -1211,7 +1221,7 @@ location set</source>
<translation>openpilot</translation>
</message>
<message>
<location line="+12"/>
<location line="+18"/>
<source>Show ETA in 24h Format</source>
<translation>24</translation>
</message>
+15 -5
View File
@@ -108,7 +108,7 @@
<context>
<name>DevicePanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="+159"/>
<location filename="../qt/offroad/settings.cc" line="+151"/>
<source>Dongle ID</source>
<translation>Dongle ID</translation>
</message>
@@ -1153,7 +1153,7 @@ location set</source>
<context>
<name>TogglesPanel</name>
<message>
<location filename="../qt/offroad/settings.cc" line="-332"/>
<location filename="../qt/offroad/settings.cc" line="-324"/>
<source>Enable openpilot</source>
<translation> openpilot</translation>
</message>
@@ -1198,12 +1198,22 @@ location set</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+59"/>
<location line="+6"/>
<source>Experimental openpilot longitudinal control</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>&lt;b&gt;WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.&lt;/b&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+42"/>
<source>Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would. Super experimental.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-65"/>
<location line="-55"/>
<source>Disengage On Accelerator Pedal</source>
<translation></translation>
</message>
@@ -1213,7 +1223,7 @@ location set</source>
<translation> openpilot </translation>
</message>
<message>
<location line="+12"/>
<location line="+18"/>
<source>Show ETA in 24h Format</source>
<translation> 24 </translation>
</message>