MCPcopy
hub / github.com/commaai/openpilot / ui_thread

Function ui_thread

tools/replay/ui.py:32–252  ·  view source on GitHub ↗
(addr)

Source from the content-addressed store, hash-verified

30
31
32def ui_thread(addr):
33 # Get monitor info before creating window
34 rl.set_config_flags(rl.ConfigFlags.FLAG_MSAA_4X_HINT)
35 rl.init_window(1, 1, "")
36 max_height = rl.get_monitor_height(0)
37 rl.close_window()
38
39 hor_mode = os.getenv("HORIZONTAL") is not None
40 hor_mode = True if max_height < 960 + 300 else hor_mode
41
42 if hor_mode:
43 size = (640 + 384 + 640, 960)
44 write_x = 5
45 write_y = 680
46 else:
47 size = (640 + 384, 960 + 300)
48 write_x = 645
49 write_y = 970
50
51 rl.set_trace_log_level(rl.TraceLogLevel.LOG_ERROR)
52 rl.set_config_flags(rl.ConfigFlags.FLAG_MSAA_4X_HINT)
53 rl.init_window(size[0], size[1], "openpilot debug UI")
54 rl.set_target_fps(60)
55
56 # Load font
57 font_path = os.path.join(BASEDIR, "selfdrive/assets/fonts/JetBrainsMono-Medium.ttf")
58 font = rl.load_font_ex(font_path, 32, None, 0)
59
60 camera_view = CameraView("camerad", VisionStreamType.VISION_STREAM_ROAD)
61
62 # Overlay texture for model/lane line drawing
63 overlay_img = np.zeros((480, 640, 4), dtype='uint8')
64 overlay_image = rl.gen_image_color(640, 480, rl.BLANK)
65 overlay_texture = rl.load_texture_from_image(overlay_image)
66 rl.unload_image(overlay_image)
67
68 # lid_overlay array is (lidar_x, lidar_y) = (384, 960)
69 top_down_image = rl.gen_image_color(UP.lidar_x, UP.lidar_y, rl.BLACK)
70 top_down_texture = rl.load_texture_from_image(top_down_image)
71 rl.unload_image(top_down_image)
72
73 sm = messaging.SubMaster(
74 [
75 'carState',
76 'longitudinalPlan',
77 'carControl',
78 'radarState',
79 'liveCalibration',
80 'controlsState',
81 'selfdriveState',
82 'liveTracks',
83 'modelV2',
84 'liveParameters',
85 'roadCameraState',
86 ],
87 addr=addr,
88 )
89

Callers 1

ui.pyFile · 0.85

Calls 14

updateMethod · 0.95
closeMethod · 0.95
CameraViewClass · 0.90
get_blank_lid_overlayFunction · 0.90
init_plotsFunction · 0.90
plot_modelFunction · 0.90
plot_leadFunction · 0.90
CalibrationClass · 0.90
draw_plotsFunction · 0.85
init_windowMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected