mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-07 05:42:06 +08:00
split out experimental long toggle (#25698)
* split out experimental long toggle * clean up * update translations
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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><b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b></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>
|
||||
|
||||
@@ -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><b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b></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>
|
||||
|
||||
@@ -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><b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b></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>
|
||||
|
||||
@@ -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>设备ID(Dongle 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><b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b></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>
|
||||
|
||||
@@ -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><b>WARNING: openpilot longitudinal control is experimental for this car and will disable AEB.</b></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>
|
||||
|
||||
Reference in New Issue
Block a user