From a7c451a8374cff002e67fe5cb83d7bf9c9e50d8c Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 28 Nov 2026 16:43:36 -0600 Subject: [PATCH] mici: retouch lead car and distance indicator (#39456) --- .../longitudinal/compact_distance_1.png | Bin 0 -> 312 bytes .../longitudinal/compact_distance_2.png | Bin 0 -> 338 bytes .../longitudinal/compact_distance_3.png | Bin 0 -> 371 bytes openpilot/starpilot/ui/onroad_personality.py | 17 +++++++++++++++ .../starpilot/ui/tests/test_long_indicator.py | 20 ++++++++++++------ prebuilt.json | 2 +- 6 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_1.png create mode 100644 openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_2.png create mode 100644 openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_3.png diff --git a/openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_1.png b/openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_1.png new file mode 100644 index 0000000000000000000000000000000000000000..ef3bd64fb57c3b9dd367a828b631e8fa12c1d8c3 GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^wm{6s!3HGf^oYCyQk(@Ik;M!Q+`=Ht$S`Y;1W=H% zILO_JVcj{Imp~3nx}&cn1H;CC?mvmFKt5lIYeY$Kep*R+Vo@rCTV{H0;=GO1l7TXt zJzX3_Dj1(m3luzLAmCyi7$73R&cf>Aq}sqVA%OG25+SXHLQTz99J`$lFL?Ow?3<^T z_M4Yq_B`O1o%`Tp!n-pJ(m7|&_$aoN|Cgw8emV6xr`bxMmyZHl4~5?l73-Y&OZDAz zj^BS|c9%5OvgLgV^i7$ZP`&lPrq-;IHu-Z}lk`3uc6GfJ7Z#ne*PY3`S$~t--h<-o zp6fq2KV6+O@e6O=vcDmnChLFvJC%MTHPLO?zLK8|SC?phu4*W51v;O>)78&qol`;+ E0LbKavj6}9 literal 0 HcmV?d00001 diff --git a/openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_2.png b/openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_2.png new file mode 100644 index 0000000000000000000000000000000000000000..f05824a1494072ff8b4fce8f11621ecb10916616 GIT binary patch literal 338 zcmeAS@N?(olHy`uVBq!ia0vp^UO+6s!3HEZ9)0-$NO2Z;L>4nJa0`PlBg3pY55jgRK=u9He-c@Ne7+Lbh?3y^w370~qErUA%=FyEc^juC17*&7 zx;TbZFuuM1khjS|fb~JSPlNCYwkw=#q<3@)pWx_wz_zJ#7h~Q5wy&~9p2-LJ9@L)P z%K9%>&R6@yk||2djkO=u_pX_Dwe!U3xGvorOO%&O&ykF{I4d+&Uaw$hTj{2D%|M^v z2PN&l&5Q!2VLRE#rs?=@9Y-c%tcIh^cxdb zZ4DG$r;@Sw&vxzX){R~Ts^Pv@IKqwI2J-Ki6!+|LV_baJ4pslSWT&Hv2c8F9J^Zx9 e`<20bu6u_>^)4{WC;b3=jKR~@&t;ucLK6Tx2!V6} literal 0 HcmV?d00001 diff --git a/openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_3.png b/openpilot/selfdrive/assets/icons_mici/longitudinal/compact_distance_3.png new file mode 100644 index 0000000000000000000000000000000000000000..4042700bfe948b2bcdb149d0e51e837faa3bd473 GIT binary patch literal 371 zcmeAS@N?(olHy`uVBq!ia0vp^kw7fO!3HD^rW6552F?PH$YKTtZeb8+WSBKa0w~B> z9OUlAunE>v?EGuK zS+Vi<{4J=MGo7bB>;XdI#UGGxaN4DP^rn}xcdQhxT-TMHq#D?WTMr(5u-!5XVe4U%5IN#x( z)a-~8q9>yBCoAk-Jn6ac6z8Sl!go*dYD|x7XF9n}t$Zz?R1xnf)wI>Nm8?&N^i_9F z77x(-*tA^He?g3!>>G~n4C}An+v05Ukwg7(&s%+q2Ahl>%HJBk9%V28Vti-gj{XRs P&lx;j{an^LB{Ts5H#3Zh literal 0 HcmV?d00001 diff --git a/openpilot/starpilot/ui/onroad_personality.py b/openpilot/starpilot/ui/onroad_personality.py index 21141050d6..18e06efe15 100644 --- a/openpilot/starpilot/ui/onroad_personality.py +++ b/openpilot/starpilot/ui/onroad_personality.py @@ -16,6 +16,7 @@ class PersonalityWidget: self.fonts = fonts self._lead_car = None self._distance = [] + self._compact_art: list[tuple[rl.Texture, int, int]] = [] self._alpha_filter = FirstOrderFilter(0.0, 0.05, 1 / gui_app.target_fps) self._lead_car_filters = tuple(FirstOrderFilter(0.0, 0.1, 1 / gui_app.target_fps) for _ in range(2)) self._distance_filters = [(FirstOrderFilter(0.0, 0.1, 1 / gui_app.target_fps), @@ -54,10 +55,26 @@ class PersonalityWidget: self._draw_centered((texture, 56, 48), rect, 126, 0.9 if state.stock_cruise_active else 0.32) return driver_feedback = profile == Profile.LARGE or state.appearance.wheel_pedal_feedback + if not driver_feedback and not (state.traffic_selected or state.traffic_mode): + self._draw_compact_distance(rect, state, routine) + return self.draw(rect, personality=state.personality, has_lead=state.lead_detected and (state.cruise_active or driver_feedback), longitudinal_active=state.cruise_active, traffic_mode=state.traffic_selected or state.traffic_mode, gas_override=state.gas_pressed_override and driver_feedback, visible=routine) + def _draw_compact_distance(self, rect: rl.Rectangle, state: OnroadState, visible: bool) -> None: + if not self._compact_art: + self._compact_art = [(gui_app.texture(f'icons_mici/longitudinal/{name}.png'), width, height) + for name, width, height in (('car', 40, 31), ('compact_distance_1', 33, 8), + ('compact_distance_2', 40, 9), ('compact_distance_3', 48, 10))] + alpha = self._alpha_filter.update(visible) + active = state.cruise_active + lit_alpha = .9 if active else .63 + for i, (art, y, intensity) in enumerate(zip(self._compact_art, (96, 123, 138, 155), + (self._lead_car_filters[0], *(f for f, _ in self._distance_filters)), strict=True)): + selected = state.lead_detected and active if i == 0 else i <= 1 + state.personality + self._draw_centered(art, rect, y, (.35 + (lit_alpha - .35) * intensity.update(selected)) * alpha) + def draw(self, rect: rl.Rectangle, *, personality: int, has_lead: bool, longitudinal_active: bool, traffic_mode: bool = False, gas_override: bool = False, visible: bool = True, fit: bool = True) -> None: self._prepare() diff --git a/openpilot/starpilot/ui/tests/test_long_indicator.py b/openpilot/starpilot/ui/tests/test_long_indicator.py index 7a90ffd20b..2297d923ec 100644 --- a/openpilot/starpilot/ui/tests/test_long_indicator.py +++ b/openpilot/starpilot/ui/tests/test_long_indicator.py @@ -17,7 +17,8 @@ from openpilot.starpilot.ui.traffic_status import TrafficDisplay def road(**changes): return replace(OnroadState(True, False, 15, 80, SpeedLimitObservation(), - longitudinal_active=True, lead_detected=True), **changes) + longitudinal_active=True, lead_detected=True, + appearance=OnroadAppearance(wheel_pedal_feedback=True)), **changes) @pytest.fixture @@ -45,8 +46,7 @@ def test_same_selected_bars_and_lead_on_both_profiles(display, profile, personal assert all(draws[2 + 2*i].args[3] == pytest.approx(.9 if i <= personality else .35, abs=.001) for i in range(3)) for has_lead, active, white, green in ((False, True, .35, 0), (True, False, 1, 0), (True, True, 0, 1)): draws = settle(display, road(lead_detected=has_lead, longitudinal_active=active)) - expected_white = .35 if profile == Profile.COMPACT and not active else white - assert draws[0].args[3] == pytest.approx(expected_white, abs=.001) + assert draws[0].args[3] == pytest.approx(white, abs=.001) assert draws[1].args[3] == pytest.approx(green, abs=.001) @@ -87,10 +87,11 @@ def test_selection_highlight_waits_for_alert_and_then_expires(display, monkeypat def test_gas_override_blinks_only_selected_bars_and_clears_on_disengagement(display, monkeypatch): monkeypatch.setattr(rl, 'get_time', lambda: 1.1) - state = road(personality=1, gas_pressed_override=True) - draws = settle(display, state) + state = road(personality=1, gas_pressed_override=True, appearance=OnroadAppearance()) + settle(display, state) + draws = display._draw_centered.call_args_list[-4:] + assert draws[1].args[3] == pytest.approx(.9, abs=.001) assert draws[2].args[3] == pytest.approx(.9, abs=.001) - assert draws[4].args[3] == pytest.approx(.9, abs=.001) state = replace(state, appearance=OnroadAppearance(wheel_pedal_feedback=True)) draws = settle(display, state) assert draws[2].args[3] == pytest.approx(.35, abs=.001) @@ -229,3 +230,10 @@ def test_compact_configured_stock_cruise_keeps_the_dim_dial_before_engagement(di display._draw_centered.assert_called_once() args = display._draw_centered.call_args.args assert args[0][0].path.endswith('/speed_dial.png') and args[3] == .32 + +def test_default_compact_distance_draws_the_four_stock_images(display): + settle(display, road(personality=1, appearance=OnroadAppearance())) + calls = display._draw_centered.call_args_list[-4:] + assert [call.args[0][0].path.split('/')[-1] for call in calls] == [ + 'car.png', 'compact_distance_1.png', 'compact_distance_2.png', 'compact_distance_3.png'] + assert [call.args[3] for call in calls] == pytest.approx([.9, .9, .9, .35], abs=.001) diff --git a/prebuilt.json b/prebuilt.json index bd68ddd23a..479b355ad7 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "eb7213db70dcdcd2251b994d591c92df37423d8c09d8f8fd94e04d3c3bc1f80d", "schema_version": 1} +{"protected_inventory_sha256": "0fb8dc9cea76aaca11e94d1aa327ddcba10edf0de16826b11e8ddc5c31c1f1ce", "schema_version": 1}