From 82eab1f333ee9e33973c8aa2de470999f8d68943 Mon Sep 17 00:00:00 2001 From: Alfonso hernandez Date: Wed, 31 Jan 2024 09:42:42 +0100 Subject: [PATCH] Debug UI: Toggle to display debug UI elements --- common/params.cc | 1 + selfdrive/manager/manager.py | 1 + selfdrive/ui/qt/offroad/settings.cc | 6 ++++++ selfdrive/ui/qt/onroad.cc | 3 ++- selfdrive/ui/qt/onroad.h | 3 +++ selfdrive/ui/ui.cc | 1 + selfdrive/ui/ui.h | 3 +++ 7 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/params.cc b/common/params.cc index 9c6600cc159c6c..7ed9331305c2f5 100644 --- a/common/params.cc +++ b/common/params.cc @@ -189,6 +189,7 @@ std::unordered_map keys = { {"RecordFrontLock", PERSISTENT}, // for the internal fleet {"ReplayControlsState", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION}, {"ShouldDoUpdate", CLEAR_ON_MANAGER_START}, + {"ShowDebugUI", PERSISTENT}, {"SnoozeUpdate", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION}, {"SshEnabled", PERSISTENT}, {"SubscriberInfo", PERSISTENT}, diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index be8025bb227b37..09e33b20b40e52 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -47,6 +47,7 @@ def manager_init() -> None: ("HandsOnWheelMonitoring", "0"), ("OpenpilotEnabledToggle", "1"), ("LongitudinalPersonality", str(log.LongitudinalPersonality.standard)), + ("ShowDebugUI", "1"), ("TurnVisionControl", "1"), ] if not PC: diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 9184a3e57e80d0..f71e8bf8f92b33 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -83,6 +83,12 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { "Use vision path predictions to estimate the appropriate speed to drive through turns ahead.", "../assets/offroad/icon_road.png", }, + { + "ShowDebugUI", + "Show debug UI elements", + "Show UI elements that aid debugging.", + "../assets/offroad/icon_calibration.png", + }, #ifdef ENABLE_MAPS { "NavSettingTime24h", diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 074297c4720b23..e961e7edcff759 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -333,6 +333,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) { vtcSpeed = QString::number(std::nearbyint(vtc_speed)); vtcColor = tcs_colors[int(vtcState)]; vtcColor.setAlpha(lpSoruce == cereal::LongitudinalPlan::LongitudinalPlanSource::TURN ? 255 : 100); + showDebugUI = s.scene.show_debug_ui; // DM icon transition dm_fade_state = std::clamp(dm_fade_state+0.2*(0.5-dmActive), 0.0, 1.0); @@ -439,7 +440,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) { p.setFont(InterFont(66)); drawText(p, rect().center().x(), 290, speedUnit, 200); - if (showVTC) { + if (showDebugUI && showVTC) { drawVisionTurnControllerUI(p, set_speed_rect.left(), set_speed_rect.bottom() + sign_margin, set_speed_rect.width(), vtcColor, vtcSpeed, 100); } diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index 931e50c69c44e5..594880066469a0 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -72,6 +72,7 @@ class AnnotatedCameraWidget : public CameraWidget { Q_PROPERTY(bool showVTC MEMBER showVTC); Q_PROPERTY(QString vtcSpeed MEMBER vtcSpeed); Q_PROPERTY(QColor vtcColor MEMBER vtcColor); + Q_PROPERTY(bool showDebugUI MEMBER showDebugUI); public: explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0); @@ -114,6 +115,8 @@ class AnnotatedCameraWidget : public CameraWidget { bool showVTC = false; QString vtcSpeed; QColor vtcColor; + + bool showDebugUI = false; protected: void paintGL() override; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 20dfb12ef900e2..1af819900c5e9d 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -231,6 +231,7 @@ void UIState::updateStatus() { if (scene.started) { status = STATUS_DISENGAGED; scene.started_frame = sm->frame; + scene.show_debug_ui = Params().getBool("ShowDebugUI"); } started_prev = scene.started; emit offroadTransition(!scene.started); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 04c0abf706f570..e3eaf0008f17cb 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -133,6 +133,9 @@ typedef struct UIScene { mat3 view_from_wide_calib = DEFAULT_CALIBRATION; cereal::PandaState::PandaType pandaType; + // Debug UI + bool show_debug_ui; + // modelV2 float lane_line_probs[4]; float road_edge_stds[2];