IQ.Pilot Prebuilt Release @ 27f668a
This commit is contained in:
3
iqpilot/ui/mici/onroad/__init__.py
Normal file
3
iqpilot/ui/mici/onroad/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
30
iqpilot/ui/mici/onroad/confidence_ball.py
Normal file
30
iqpilot/ui/mici/onroad/confidence_ball.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
import pyray as rl
|
||||
from iqpilot.selfdrive.ui.ui_state import ui_state, UIStatus
|
||||
|
||||
|
||||
ACTIVE_CONFIDENCE_TOP = rl.Color(0x22, 0xB8, 0xB9, 0xFF)
|
||||
ACTIVE_CONFIDENCE_BOTTOM = rl.Color(0x0C, 0x94, 0x96, 0xFF)
|
||||
MEDIUM_CONFIDENCE_TOP = rl.Color(255, 200, 0, 255)
|
||||
MEDIUM_CONFIDENCE_BOTTOM = rl.Color(255, 115, 0, 255)
|
||||
LOW_CONFIDENCE_TOP = rl.Color(255, 0, 21, 255)
|
||||
LOW_CONFIDENCE_BOTTOM = rl.Color(255, 0, 89, 255)
|
||||
|
||||
|
||||
class IQConfidenceBall:
|
||||
@staticmethod
|
||||
def get_animate_status_probs():
|
||||
if ui_state.status == UIStatus.LAT_ONLY:
|
||||
return ui_state.sm['modelV2'].meta.disengagePredictions.steerOverrideProbs
|
||||
|
||||
return ui_state.sm['modelV2'].meta.disengagePredictions.brakeDisengageProbs
|
||||
|
||||
@staticmethod
|
||||
def get_lat_long_dot_colors(confidence: float) -> tuple[rl.Color, rl.Color]:
|
||||
if confidence > 0.5:
|
||||
return ACTIVE_CONFIDENCE_TOP, ACTIVE_CONFIDENCE_BOTTOM
|
||||
if confidence > 0.2:
|
||||
return MEDIUM_CONFIDENCE_TOP, MEDIUM_CONFIDENCE_BOTTOM
|
||||
return LOW_CONFIDENCE_TOP, LOW_CONFIDENCE_BOTTOM
|
||||
43
iqpilot/ui/mici/onroad/emac_source.py
Normal file
43
iqpilot/ui/mici/onroad/emac_source.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
import pyray as rl
|
||||
|
||||
from iqpilot.common.params import Params
|
||||
from iqpilot.ui.onroad.big_model_status import SourceState, draw_source_label, resolve_source
|
||||
from iqpilot.selfdrive.ui.ui_state import ui_state
|
||||
from iqpilot.system.ui.lib.application import FontWeight, gui_app
|
||||
from iqpilot.system.ui.lib.text_measure import measure_text_cached
|
||||
|
||||
_POLL_S = 1.0
|
||||
_FONT_SIZE = 44
|
||||
_WHEEL_H = 50
|
||||
_MARGIN_R = 12
|
||||
_MARGIN_B = 14
|
||||
|
||||
|
||||
class EmacSourceIndicator:
|
||||
def __init__(self):
|
||||
self._params = Params()
|
||||
self._font = gui_app.font(FontWeight.SEMI_BOLD)
|
||||
self._last_poll = 0.0
|
||||
self._label = ""
|
||||
self._state = SourceState.HIDDEN
|
||||
|
||||
def update(self) -> None:
|
||||
now = time.monotonic()
|
||||
if now - self._last_poll < _POLL_S:
|
||||
return
|
||||
self._last_poll = now
|
||||
self._label, self._state = resolve_source(self._params, ui_state.engaged)
|
||||
|
||||
def render(self, rect: rl.Rectangle) -> None:
|
||||
if self._state == SourceState.HIDDEN:
|
||||
return
|
||||
size = measure_text_cached(self._font, self._label, _FONT_SIZE)
|
||||
x = rect.x + rect.width - _MARGIN_R - size.x
|
||||
y = rect.y + rect.height - _MARGIN_B - (_WHEEL_H + size.y) / 2
|
||||
draw_source_label(self._font, self._label, self._state, rl.Vector2(x, y), _FONT_SIZE)
|
||||
31
iqpilot/ui/mici/onroad/hud_renderer.py
Normal file
31
iqpilot/ui/mici/onroad/hud_renderer.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
import pyray as rl
|
||||
|
||||
from iqpilot.selfdrive.ui.mici.onroad.hud_renderer import HudRenderer
|
||||
from iqpilot.ui.onroad.hud_overlays import IQBlindSpotOverlay
|
||||
from iqpilot.ui.mici.onroad.emac_source import EmacSourceIndicator
|
||||
from iqpilot.ui.mici.onroad.speed_limit_sign import MiciSpeedLimitSign
|
||||
|
||||
class IQMiciHudRenderer(HudRenderer):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._overlays = [IQBlindSpotOverlay(), EmacSourceIndicator()]
|
||||
self._speed_limit_sign = MiciSpeedLimitSign()
|
||||
|
||||
def _update_state(self) -> None:
|
||||
super()._update_state()
|
||||
for overlay in self._overlays:
|
||||
overlay.update()
|
||||
self._speed_limit_sign.update()
|
||||
|
||||
def _render(self, rect: rl.Rectangle) -> None:
|
||||
super()._render(rect)
|
||||
for overlay in self._overlays:
|
||||
overlay.render(rect)
|
||||
self._speed_limit_sign.set_obscured(self.drawing_top_icons() or not self._can_draw_top_icons)
|
||||
self._speed_limit_sign.render(rect)
|
||||
|
||||
def _has_blind_spot_detected(self) -> bool:
|
||||
return any(getattr(overlay, "detected", False) for overlay in self._overlays)
|
||||
10
iqpilot/ui/mici/onroad/road_label.py
Normal file
10
iqpilot/ui/mici/onroad/road_label.py
Normal file
@@ -0,0 +1,10 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
from iqpilot.ui.onroad.hud_overlays import RoadNameBanner
|
||||
|
||||
class RoadNameRendererMici(RoadNameBanner):
|
||||
TYPE_SIZE = 18
|
||||
MARGIN = 120
|
||||
GAP = 2
|
||||
TORQUE_SCALE = 1.0
|
||||
75
iqpilot/ui/mici/onroad/speed_limit_sign.py
Normal file
75
iqpilot/ui/mici/onroad/speed_limit_sign.py
Normal file
@@ -0,0 +1,75 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
import math
|
||||
|
||||
from iqpilot.common.filter_simple import FirstOrderFilter
|
||||
from iqpilot.selfdrive.ui.ui_state import ui_state
|
||||
from iqpilot.system.ui.iqwidgets.lib import canvas
|
||||
from iqpilot.system.ui.lib.application import gui_app
|
||||
from iqpilot.ui.onroad.hud_overlays import IQSpeedLimitOverlay, _SL_ASSIST, _SL_DARK, _dim
|
||||
|
||||
_SIGN_X = 16
|
||||
_SIGN_Y = 108
|
||||
_SIGN_W = 60
|
||||
_SIGN_H = 64
|
||||
_BADGE_SIDE = 24
|
||||
|
||||
|
||||
class MiciSpeedLimitSign(IQSpeedLimitOverlay):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._visible = FirstOrderFilter(0.0, 0.1, 1 / gui_app.target_fps)
|
||||
self._obscured = False
|
||||
|
||||
def set_obscured(self, obscured: bool) -> None:
|
||||
self._obscured = obscured
|
||||
|
||||
def _badge(self) -> str:
|
||||
offset = round(self.speed_limit_offset)
|
||||
return f"{offset:+d}" if offset != 0 else ""
|
||||
|
||||
def _render(self, rect):
|
||||
shown = ui_state.speed_limit_mode != 0 and ui_state.is_onroad() and not self._obscured
|
||||
alpha = self._visible.update(1.0 if shown else 0.0)
|
||||
if alpha < 1e-2:
|
||||
return
|
||||
if self.assist_state == _SL_ASSIST.preActive:
|
||||
self.assist_frame += 1
|
||||
pulse = 0.65 + 0.35 * math.sin(self.assist_frame * math.pi / gui_app.target_fps)
|
||||
alpha *= self._pulse_ema.update(pulse)
|
||||
else:
|
||||
self.assist_frame = 0
|
||||
self._pulse_ema.update(1.0)
|
||||
box = canvas.Box(rect.x + _SIGN_X, rect.y + _SIGN_Y, _SIGN_W, _SIGN_H)
|
||||
value, _, tint, has_limit = self._spec()
|
||||
badge = self._badge() if has_limit else ""
|
||||
(self._vienna if ui_state.is_metric else self._mutcd)(box, value, badge, tint, has_limit, alpha)
|
||||
|
||||
def _vienna(self, rect, value, badge, tint, has_limit, alpha=1.0):
|
||||
hub = canvas.Pt(rect.x + rect.width / 2, rect.y + rect.height / 2)
|
||||
radius = rect.width / 2
|
||||
canvas.disc_at(hub, radius, _dim(canvas.WHITE, alpha))
|
||||
canvas.annulus(hub, radius * 0.78, radius, 0, 360, 36, _dim(canvas.RED, alpha))
|
||||
canvas.glyphs_centered(self._bold, value, 22 if len(value) >= 3 else 28, hub, _dim(tint, alpha))
|
||||
if badge:
|
||||
br = _BADGE_SIDE / 2
|
||||
bc = canvas.Pt(rect.x + rect.width - br * 0.35, rect.y + br * 0.35)
|
||||
canvas.disc_at(bc, br, _dim(canvas.BLACK, alpha))
|
||||
canvas.annulus(bc, br - 2, br, 0, 360, 24, _dim(_SL_DARK, alpha))
|
||||
canvas.glyphs_centered(self._bold, badge, 11 if len(badge) >= 3 else 13, bc, _dim(canvas.WHITE, alpha))
|
||||
|
||||
def _mutcd(self, rect, value, badge, tint, has_limit, alpha=1.0):
|
||||
canvas.panel(rect, 0.25, 8, _dim(canvas.WHITE, alpha))
|
||||
inner = canvas.Box(rect.x + 4, rect.y + 4, rect.width - 8, rect.height - 8)
|
||||
canvas.panel_outline(inner, 0.25, 8, 2, _dim(canvas.BLACK, alpha))
|
||||
mid = rect.x + rect.width / 2
|
||||
canvas.glyphs_centered(self._demi, "SPEED", 12, canvas.Pt(mid, rect.y + 14), _dim(canvas.BLACK, alpha))
|
||||
canvas.glyphs_centered(self._demi, "LIMIT", 12, canvas.Pt(mid, rect.y + 25), _dim(canvas.BLACK, alpha))
|
||||
canvas.glyphs_centered(self._bold, value, 30 if len(value) <= 2 else 24, canvas.Pt(mid, rect.y + 45), _dim(tint, alpha))
|
||||
if badge:
|
||||
chip = canvas.Box(rect.x + rect.width - _BADGE_SIDE * 0.55, rect.y - _BADGE_SIDE * 0.55, _BADGE_SIDE, _BADGE_SIDE)
|
||||
canvas.panel(chip, 0.35, 8, _dim(canvas.BLACK, alpha))
|
||||
canvas.panel_outline(chip, 0.35, 8, 2, _dim(_SL_DARK, alpha))
|
||||
canvas.glyphs_centered(self._bold, badge, 11 if len(badge) >= 3 else 13,
|
||||
canvas.Pt(chip.x + _BADGE_SIDE / 2, chip.y + _BADGE_SIDE / 2), _dim(canvas.WHITE, alpha))
|
||||
Reference in New Issue
Block a user