Skip to content

Commit

Permalink
Debug UI: Toggle to display debug UI elements
Browse files Browse the repository at this point in the history
  • Loading branch information
alfhern committed Jan 31, 2024
1 parent 704c16b commit 82eab1f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ std::unordered_map<std::string, uint32_t> 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},
Expand Down
1 change: 1 addition & 0 deletions selfdrive/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def manager_init() -> None:
("HandsOnWheelMonitoring", "0"),
("OpenpilotEnabledToggle", "1"),
("LongitudinalPersonality", str(log.LongitudinalPersonality.standard)),
("ShowDebugUI", "1"),
("TurnVisionControl", "1"),
]
if not PC:
Expand Down
6 changes: 6 additions & 0 deletions selfdrive/ui/qt/offroad/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/ui/qt/onroad.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -114,6 +115,8 @@ class AnnotatedCameraWidget : public CameraWidget {
bool showVTC = false;
QString vtcSpeed;
QColor vtcColor;

bool showDebugUI = false;

protected:
void paintGL() override;
Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 82eab1f

Please sign in to comment.