raylib: flip! (#36319)

* flip!

* add ui

* ?

* qt is extra

* low node

* add uiDebug

* fix

* fix dat

* bump double increase for tol

* it's ~11ms but double for tol

* fix report

* Update selfdrive/test/test_onroad.py
pull/36294/head^2
Shane Smiskol 3 days ago committed by GitHub
parent cec7a5dc98
commit b3eba70b7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      selfdrive/SConscript
  2. 6
      selfdrive/test/test_onroad.py
  3. 12
      selfdrive/ui/onroad/augmented_road_view.py
  4. 2
      selfdrive/ui/tests/test_raylib_ui.py
  5. 2
      selfdrive/ui/tests/test_ui/raylib_screenshots.py
  6. 2
      system/manager/build.py
  7. 4
      system/manager/process_config.py

@ -3,4 +3,5 @@ SConscript(['controls/lib/lateral_mpc_lib/SConscript'])
SConscript(['controls/lib/longitudinal_mpc_lib/SConscript']) SConscript(['controls/lib/longitudinal_mpc_lib/SConscript'])
SConscript(['locationd/SConscript']) SConscript(['locationd/SConscript'])
SConscript(['modeld/SConscript']) SConscript(['modeld/SConscript'])
SConscript(['ui/SConscript']) if GetOption('extras'):
SConscript(['ui/SConscript'])

@ -32,7 +32,7 @@ CPU usage budget
TEST_DURATION = 25 TEST_DURATION = 25
LOG_OFFSET = 8 LOG_OFFSET = 8
MAX_TOTAL_CPU = 300. # total for all 8 cores MAX_TOTAL_CPU = 315. # total for all 8 cores
PROCS = { PROCS = {
# Baseline CPU usage by process # Baseline CPU usage by process
"selfdrive.controls.controlsd": 16.0, "selfdrive.controls.controlsd": 16.0,
@ -42,7 +42,7 @@ PROCS = {
"./encoderd": 13.0, "./encoderd": 13.0,
"./camerad": 10.0, "./camerad": 10.0,
"selfdrive.controls.plannerd": 8.0, "selfdrive.controls.plannerd": 8.0,
"./ui": 18.0, "selfdrive.ui.ui": 24.0,
"system.sensord.sensord": 13.0, "system.sensord.sensord": 13.0,
"selfdrive.controls.radard": 2.0, "selfdrive.controls.radard": 2.0,
"selfdrive.modeld.modeld": 22.0, "selfdrive.modeld.modeld": 22.0,
@ -215,7 +215,7 @@ class TestOnroad:
print(result) print(result)
assert max(ts) < 250. assert max(ts) < 250.
assert np.mean(ts) < 10. assert np.mean(ts) < 20. # TODO: ~6-11ms, increase consistency
#self.assertLess(np.std(ts), 5.) #self.assertLess(np.std(ts), 5.)
# some slow frames are expected since camerad/modeld can preempt ui # some slow frames are expected since camerad/modeld can preempt ui

@ -1,6 +1,7 @@
import time
import numpy as np import numpy as np
import pyray as rl import pyray as rl
from cereal import log from cereal import log, messaging
from msgq.visionipc import VisionStreamType from msgq.visionipc import VisionStreamType
from openpilot.selfdrive.ui.ui_state import ui_state, UIStatus, UI_BORDER_SIZE from openpilot.selfdrive.ui.ui_state import ui_state, UIStatus, UI_BORDER_SIZE
from openpilot.selfdrive.ui.onroad.alert_renderer import AlertRenderer from openpilot.selfdrive.ui.onroad.alert_renderer import AlertRenderer
@ -48,8 +49,12 @@ class AugmentedRoadView(CameraView):
self.alert_renderer = AlertRenderer() self.alert_renderer = AlertRenderer()
self.driver_state_renderer = DriverStateRenderer() self.driver_state_renderer = DriverStateRenderer()
# debug
self._pm = messaging.PubMaster(['uiDebug'])
def _render(self, rect): def _render(self, rect):
# Only render when system is started to avoid invalid data access # Only render when system is started to avoid invalid data access
start_draw = time.monotonic()
if not ui_state.started: if not ui_state.started:
return return
@ -93,6 +98,11 @@ class AugmentedRoadView(CameraView):
# End clipping region # End clipping region
rl.end_scissor_mode() rl.end_scissor_mode()
# publish uiDebug
msg = messaging.new_message('uiDebug')
msg.uiDebug.drawTimeMillis = (time.monotonic() - start_draw) * 1000
self._pm.send('uiDebug', msg)
def _handle_mouse_press(self, _): def _handle_mouse_press(self, _):
if not self._hud_renderer.user_interacting() and self._click_callback is not None: if not self._hud_renderer.user_interacting() and self._click_callback is not None:
self._click_callback() self._click_callback()

@ -2,7 +2,7 @@ import time
from openpilot.selfdrive.test.helpers import with_processes from openpilot.selfdrive.test.helpers import with_processes
@with_processes(["raylib_ui"]) @with_processes(["ui"])
def test_raylib_ui(): def test_raylib_ui():
"""Test initialization of the UI widgets is successful.""" """Test initialization of the UI widgets is successful."""
time.sleep(1) time.sleep(1)

@ -160,7 +160,7 @@ class TestUI:
time.sleep(0.01) time.sleep(0.01)
pyautogui.mouseUp(self.ui.left + x, self.ui.top + y, *args, **kwargs) pyautogui.mouseUp(self.ui.left + x, self.ui.top + y, *args, **kwargs)
@with_processes(["raylib_ui"]) @with_processes(["ui"])
def test_ui(self, name, setup_case): def test_ui(self, name, setup_case):
self.setup() self.setup()
time.sleep(UI_DELAY) # wait for UI to start time.sleep(UI_DELAY) # wait for UI to start

@ -14,7 +14,7 @@ from openpilot.system.version import get_build_metadata
MAX_CACHE_SIZE = 4e9 if "CI" in os.environ else 2e9 MAX_CACHE_SIZE = 4e9 if "CI" in os.environ else 2e9
CACHE_DIR = Path("/data/scons_cache" if AGNOS else "/tmp/scons_cache") CACHE_DIR = Path("/data/scons_cache" if AGNOS else "/tmp/scons_cache")
TOTAL_SCONS_NODES = 3275 TOTAL_SCONS_NODES = 2280
MAX_BUILD_PROGRESS = 100 MAX_BUILD_PROGRESS = 100
def build(spinner: Spinner, dirty: bool = False, minimal: bool = False) -> None: def build(spinner: Spinner, dirty: bool = False, minimal: bool = False) -> None:

@ -80,8 +80,8 @@ procs = [
PythonProcess("dmonitoringmodeld", "selfdrive.modeld.dmonitoringmodeld", driverview, enabled=(WEBCAM or not PC)), PythonProcess("dmonitoringmodeld", "selfdrive.modeld.dmonitoringmodeld", driverview, enabled=(WEBCAM or not PC)),
PythonProcess("sensord", "system.sensord.sensord", only_onroad, enabled=not PC), PythonProcess("sensord", "system.sensord.sensord", only_onroad, enabled=not PC),
NativeProcess("ui", "selfdrive/ui", ["./ui"], always_run, watchdog_max_dt=(5 if not PC else None)), # NativeProcess("ui", "selfdrive/ui", ["./ui"], always_run, enabled=False, watchdog_max_dt=(5 if not PC else None)),
PythonProcess("raylib_ui", "selfdrive.ui.ui", always_run, enabled=False, watchdog_max_dt=(5 if not PC else None)), PythonProcess("ui", "selfdrive.ui.ui", always_run, watchdog_max_dt=(5 if not PC else None)),
PythonProcess("soundd", "selfdrive.ui.soundd", only_onroad), PythonProcess("soundd", "selfdrive.ui.soundd", only_onroad),
PythonProcess("locationd", "selfdrive.locationd.locationd", only_onroad), PythonProcess("locationd", "selfdrive.locationd.locationd", only_onroad),
NativeProcess("_pandad", "selfdrive/pandad", ["./pandad"], always_run, enabled=False), NativeProcess("_pandad", "selfdrive/pandad", ["./pandad"], always_run, enabled=False),

Loading…
Cancel
Save