From 308672a963f72a72f24519c3e8c32388934a1026 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Wed, 15 May 2024 20:23:48 -0700 Subject: [PATCH] Visuals - Model UI - Path Edges Adjust the width of the path edges shown on your UI to represent different driving modes and statuses. Default is 20% of the total path. Blue = Navigation Light Blue = 'Always On Lateral' Green = Default Orange = 'Experimental Mode' Red = 'Traffic Mode' Yellow = 'Conditional Experimental Mode' Overriden --- selfdrive/ui/qt/onroad.cc | 44 +++++++++++++++++++++++++++++++++++++++ selfdrive/ui/ui.cc | 6 +++++- selfdrive/ui/ui.h | 2 ++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 8cc695d..4eb5e27 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -1036,6 +1036,50 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { paintLane(scene.track_adjacent_vertices[5], laneWidthRight, blindSpotRight); } + // Paint path edges + QLinearGradient pe(0, height(), 0, 0); + auto setGradientColors = [&](const QColor &baseColor) { + pe.setColorAt(0.0, baseColor); + QColor color = baseColor; + color.setAlphaF(0.5); + pe.setColorAt(0.5, color); + color.setAlphaF(0.1); + pe.setColorAt(1.0, color); + }; + + if (alwaysOnLateralActive) { + setGradientColors(bg_colors[STATUS_ALWAYS_ON_LATERAL_ACTIVE]); + } else if (conditionalStatus == 1 || conditionalStatus == 3 || conditionalStatus == 5) { + setGradientColors(bg_colors[STATUS_CONDITIONAL_OVERRIDDEN]); + } else if (experimentalMode) { + setGradientColors(bg_colors[STATUS_EXPERIMENTAL_MODE_ACTIVE]); + } else if (trafficModeActive) { + setGradientColors(bg_colors[STATUS_TRAFFIC_MODE_ACTIVE]); + } else if (scene.navigate_on_openpilot) { + setGradientColors(bg_colors[STATUS_NAVIGATION_ACTIVE]); + } else if (currentHolidayTheme != 0) { + const std::map &colorMap = std::get<2>(holidayThemeConfiguration[currentHolidayTheme]); + for (const std::pair &entry : colorMap) { + pe.setColorAt(entry.first, entry.second.color().darker(120)); + } + } else if (customColors != 0) { + const std::map &colorMap = std::get<2>(themeConfiguration[customColors]); + for (const std::pair &entry : colorMap) { + pe.setColorAt(entry.first, entry.second.color().darker(120)); + } + } else { + pe.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 1.0)); + pe.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.00, 0.68, 0.5)); + pe.setColorAt(1.0, QColor::fromHslF(112 / 360., 1.00, 0.68, 0.1)); + } + + QPainterPath path; + path.addPolygon(scene.track_vertices); + path.addPolygon(scene.track_edge_vertices); + + painter.setBrush(pe); + painter.drawPath(path); + painter.restore(); } diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 08f8d34..65dab42 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -128,7 +128,10 @@ void update_model(UIState *s, } } max_idx = get_path_length_idx(plan_position, max_distance); - update_line_data(s, plan_position, 0.9, 1.22, &scene.track_vertices, max_idx, false); + update_line_data(s, plan_position, scene.model_ui ? path * (1 - scene.path_edge_width / 100) : 0.9, 1.22, &scene.track_vertices, max_idx, false); + + // Update path edges + update_line_data(s, plan_position, scene.model_ui ? path : 0, 1.22, &scene.track_edge_vertices, max_idx, false); // Update adjacent paths for (int i = 4; i <= 5; i++) { @@ -384,6 +387,7 @@ void ui_update_frogpilot_params(UIState *s) { scene.dynamic_path_width = scene.model_ui && params.getBool("DynamicPathWidth"); scene.hide_lead_marker = scene.model_ui && params.getBool("HideLeadMarker"); scene.lane_line_width = params.getInt("LaneLinesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f; + scene.path_edge_width = params.getInt("PathEdgeWidth"); bool quality_of_life_controls = params.getBool("QOLControls"); scene.reverse_cruise = quality_of_life_controls && params.getBool("ReverseCruise"); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index e1ed9c1..f92ca13 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -265,6 +265,7 @@ typedef struct UIScene { float lane_width_right; float lat_accel; float lead_detection_threshold; + float path_edge_width; float speed_jerk; float speed_jerk_difference; float speed_limit; @@ -291,6 +292,7 @@ typedef struct UIScene { int wheel_icon; QPolygonF track_adjacent_vertices[6]; + QPolygonF track_edge_vertices; } UIScene;