Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions openpilot/selfdrive/assets/icons_mici/personality_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions openpilot/selfdrive/assets/icons_mici/personality_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions openpilot/selfdrive/assets/icons_mici/personality_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions openpilot/selfdrive/assets/icons_mici/speed_limiter_lead.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions openpilot/selfdrive/ui/mici/onroad/augmented_road_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from openpilot.selfdrive.ui.mici.onroad.driver_state import DriverStateRenderer
from openpilot.selfdrive.ui.mici.onroad.hud_renderer import HudRenderer
from openpilot.selfdrive.ui.mici.onroad.model_renderer import ModelRenderer
from openpilot.selfdrive.ui.mici.onroad.confidence_ball import ConfidenceBall
from openpilot.selfdrive.ui.mici.onroad.status_icons import StatusIconColumn
from openpilot.selfdrive.ui.mici.onroad.cameraview import CameraView
from openpilot.system.ui.lib.application import FontWeight, gui_app, MousePos, MouseEvent
from openpilot.system.ui.widgets.label import UnifiedLabel
Expand Down Expand Up @@ -151,7 +151,7 @@ def __init__(self, bookmark_callback=None, stream_type: VisionStreamType = Visio
self._hud_renderer = HudRenderer()
self._alert_renderer = AlertRenderer()
self._driver_state_renderer = DriverStateRenderer()
self._confidence_ball = ConfidenceBall()
self._status_icons = StatusIconColumn()
self._offroad_label = UnifiedLabel("start the car to\nuse openpilot", 54, FontWeight.DISPLAY,
text_color=rl.Color(255, 255, 255, int(255 * 0.9)),
alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
Expand Down Expand Up @@ -240,7 +240,7 @@ def _render(self, _):

# Custom UI extension point - add custom overlays here
# Use self._content_rect for positioning within camera bounds
self._confidence_ball.render(self.rect)
self._status_icons.render(self.rect)

self._bookmark_icon.render(self.rect)

Expand Down
78 changes: 0 additions & 78 deletions openpilot/selfdrive/ui/mici/onroad/confidence_ball.py

This file was deleted.

84 changes: 84 additions & 0 deletions openpilot/selfdrive/ui/mici/onroad/status_icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import pyray as rl

from openpilot.cereal import log
from openpilot.selfdrive.ui.mici.onroad import SIDE_PANEL_WIDTH
from openpilot.selfdrive.ui.ui_state import ui_state
from openpilot.system.ui.lib.application import gui_app
from openpilot.system.ui.widgets import Widget


INACTIVE_COLOR = rl.Color(86, 86, 86, 255)
INACTIVE_TEXTURE_TINT = rl.Color(140, 140, 140, 255)
PlanSource = log.LongitudinalPlan.LongitudinalPlanSource
PERSONALITY_BARS = {
log.LongitudinalPersonality.relaxed: 1,
log.LongitudinalPersonality.standard: 2,
log.LongitudinalPersonality.aggressive: 3,
}


class StatusIconColumn(Widget):
"""Four-slot status rail for experimental mode, speed limiter, eGPU use, and personality."""

def __init__(self):
super().__init__()

self._experimental_texture = gui_app.texture("icons_mici/experimental_mode.png", 48, 48)
self._cruise_texture = gui_app.texture("icons_mici/speed_limiter_cruise.png", 48, 48)
self._lead_texture = gui_app.texture("icons_mici/speed_limiter_lead.png", 48, 48)
self._egpu_texture = gui_app.texture("icons_mici/egpu.png", 50, 37)
self._egpu_gray_texture = gui_app.texture("icons_mici/egpu_gray.png", 50, 37)
self._personality_textures = tuple(
gui_app.texture(f"icons_mici/personality_{bar_count}.png", 56, 20)
for bar_count in range(1, 4)
)

self._experimental_mode = False
self._speed_limiter_texture = self._cruise_texture
self._speed_limiter_active = False
self._using_egpu = False
self._personality_bar_count = 0

def _update_state(self):
sm = ui_state.sm
selfdrive_state_valid = sm.alive["selfdriveState"] and sm.valid["selfdriveState"]
self._experimental_mode = selfdrive_state_valid and sm["selfdriveState"].experimentalMode
personality_available = selfdrive_state_valid and ui_state.has_longitudinal_control
self._personality_bar_count = PERSONALITY_BARS.get(sm["selfdriveState"].personality, 0) if personality_available else 0
source = sm["longitudinalPlan"].longitudinalPlanSource
if source in (PlanSource.lead0, PlanSource.lead1, PlanSource.lead2):
self._speed_limiter_texture = self._lead_texture
elif source == PlanSource.e2e:
self._speed_limiter_texture = self._experimental_texture
else:
self._speed_limiter_texture = self._cruise_texture
self._speed_limiter_active = (sm.alive["carControl"] and sm.valid["carControl"] and
sm["carControl"].longActive and
sm.alive["longitudinalPlan"] and sm.valid["longitudinalPlan"])
self._using_egpu = ui_state.usbgpu and ui_state.usbgpu_compiled

@staticmethod
def _draw_texture_centered(texture: rl.Texture, center: rl.Vector2, tint: rl.Color = rl.WHITE):
pos = rl.Vector2(center.x - texture.width / 2, center.y - texture.height / 2)
rl.draw_texture_ex(texture, pos, 0.0, 1.0, tint)

def _render(self, _):
panel = rl.Rectangle(
self.rect.x + self.rect.width - SIDE_PANEL_WIDTH,
self.rect.y,
SIDE_PANEL_WIDTH,
self.rect.height,
)
center_x = panel.x + panel.width / 2
centers = [rl.Vector2(center_x, panel.y + panel.height * (slot + 0.5) / 4) for slot in range(4)]

experimental_tint = rl.WHITE if self._experimental_mode else INACTIVE_COLOR
self._draw_texture_centered(self._experimental_texture, centers[0], experimental_tint)
limiter_tint = rl.WHITE if self._speed_limiter_active else INACTIVE_COLOR
self._draw_texture_centered(self._speed_limiter_texture, centers[1], limiter_tint)
egpu_texture = self._egpu_texture if self._using_egpu else self._egpu_gray_texture
egpu_tint = rl.WHITE if self._using_egpu else INACTIVE_TEXTURE_TINT
self._draw_texture_centered(egpu_texture, centers[2], egpu_tint)
personality_index = self._personality_bar_count - 1 if self._personality_bar_count else 2
personality_tint = rl.WHITE if self._personality_bar_count else INACTIVE_COLOR
self._draw_texture_centered(self._personality_textures[personality_index], centers[3], personality_tint)
Loading