mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 06:03:41 +08:00
Show End to End Slowdown Reasons on Both Displays
This commit is contained in:
@@ -72,6 +72,8 @@ def driving_mode_description(state: OnroadState) -> str:
|
||||
mode = state.conditional_effective
|
||||
experimental = (mode.effective_experimental if mode is not None else
|
||||
state.experimental_enabled and state.conditional_configured in (None, ModeChoice.STOCK))
|
||||
if experimental and state.e2e_slowdown is not None:
|
||||
return f"E2E · {state.e2e_slowdown}"
|
||||
return "ACC - End to End" if experimental else "ACC - Chill"
|
||||
if state.lateral_active:
|
||||
return "Always On Lateral"
|
||||
|
||||
@@ -113,6 +113,8 @@ def gauge_data(state: OnroadState, *, lead_stopped: bool = False) -> AetherGauge
|
||||
state.appearance.camera_view in (CameraViewChoice.DRIVER, CameraViewChoice.NONE) or state.reverse_driver_camera):
|
||||
return None
|
||||
current = reason(state) if status(state) is not None else None
|
||||
if state.e2e_slowdown == 'Stopping':
|
||||
return AetherGaugeData('STOPPING', color=COLOR_FORCE_STOP, indicator_type=IndicatorType.STOP_LIGHT)
|
||||
if current == 'cem_stop' or stop_observed(state):
|
||||
# The current receipt has no committed distance. Preserve the light/road
|
||||
# graphic without claiming a numeric distance from an unrelated model path.
|
||||
@@ -135,7 +137,7 @@ def gauge_data(state: OnroadState, *, lead_stopped: bool = False) -> AetherGauge
|
||||
color=glow_color(intensity(curvature)) if curvature is not None else COLOR_CEM_SPEED,
|
||||
indicator_type=IndicatorType.ROAD_CURVE, indicator_value=curvature or 0.0,
|
||||
reduction_text=f'-{reduction}' if reduction > 0 else '', is_numeric=shown is not None)
|
||||
if current in ('cem_lead', 'ccm_lead'):
|
||||
if state.e2e_slowdown == 'Lead vehicle' or current in ('cem_lead', 'ccm_lead'):
|
||||
lead = state.conditional_lead
|
||||
# Only current radar metrics may classify the lead as stopped/slower.
|
||||
stopped = lead is not None and lead.speed_mps < (1.2 if lead_stopped else 0.8)
|
||||
@@ -143,6 +145,8 @@ def gauge_data(state: OnroadState, *, lead_stopped: bool = False) -> AetherGauge
|
||||
color=COLOR_LEAD_STOPPED if stopped else COLOR_LEAD_SLOWER,
|
||||
indicator_type=IndicatorType.LEAD,
|
||||
indicator_extra='stopped' if stopped else 'slower' if lead is not None else '')
|
||||
if state.e2e_slowdown is not None:
|
||||
return AetherGaugeData(state.e2e_slowdown.upper(), color=COLOR_REDUCTION)
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ class MiciSidebarWidgets:
|
||||
def _conditional(self, center: rl.Rectangle, state: OnroadState) -> None:
|
||||
conditional = conditional_status(state)
|
||||
preview = state.visual_preview
|
||||
if stop_active(state) or stop_observed(state):
|
||||
if state.e2e_slowdown == 'Stopping' or stop_active(state) or stop_observed(state):
|
||||
self._stop_icon(center)
|
||||
elif (preview is not None and preview.curve_curvature is not None and state.alert.size != AlertSize.FULL) or curve_controlling(state):
|
||||
self._curve_icon(center)
|
||||
@@ -254,6 +254,8 @@ class MiciSidebarWidgets:
|
||||
icon = {'cem_stop': 'stop', 'cem_lead': 'lead', 'ccm_lead': 'lead',
|
||||
'cem_curve': 'curve', 'cem_signal': 'turn',
|
||||
'cem_speed': 'speed', 'cem_open_road': 'speed', 'cem_speed_limit': 'speed', 'ccm_speed': 'speed'}.get(reason)
|
||||
if family == 'E2E':
|
||||
icon = {'Lead vehicle': 'lead', 'Curve': 'curve', 'Slowing': 'speed'}.get(state.e2e_slowdown)
|
||||
if icon == 'stop':
|
||||
self._stop_icon(center)
|
||||
elif icon == 'lead':
|
||||
|
||||
@@ -453,9 +453,9 @@ class StarShellSession(TeslaSpeedActions):
|
||||
EXPERIMENTAL: FavoriteAction(EXPERIMENTAL, "End to End", kind="toggle",
|
||||
state_label=("Overridden Chill" if (state.conditional_effective is not None and
|
||||
state.conditional_effective.reason == 'manual_chill') else
|
||||
"Forced Experimental" if (state.conditional_effective is not None and
|
||||
"Forced End to End" if (state.conditional_effective is not None and
|
||||
state.conditional_effective.reason == 'manual_experimental') else
|
||||
"Automatic Experimental" if (state.conditional_effective is not None and
|
||||
"Automatic End to End" if (state.conditional_effective is not None and
|
||||
state.conditional_effective.effective_experimental) else
|
||||
"On" if state.experimental_enabled else "Off"), available=exp_available,
|
||||
reason=("Active longitudinal control and current conditional status required" if conditional else
|
||||
|
||||
@@ -346,6 +346,9 @@ class TestOnroadAxes(unittest.TestCase):
|
||||
self.ui.sm.put('longitudinalPlan', NS(aTarget=-0.5, hasLead=True, shouldStop=False, longitudinalPlanSource='lead0'))
|
||||
slowing = self.state(True, True)
|
||||
self.assertEqual(slowing.e2e_slowdown, 'Lead vehicle')
|
||||
self.assertEqual(driving_mode_description(slowing), 'E2E · Lead vehicle')
|
||||
from openpilot.starpilot.ui.onroad_cem_gauge import IndicatorType, gauge_data
|
||||
self.assertEqual(gauge_data(slowing).indicator_type, IndicatorType.LEAD)
|
||||
self.assertEqual(rgba(axis_status_color(slowing)), (218, 111, 37, 255))
|
||||
self.assertEqual(rgba(axis_status_color(replace(combined, longitudinal_active=False))), (10, 186, 181, 255))
|
||||
self.assertEqual(rgba(axis_status_color(replace(combined, lateral_active=False))), (255, 105, 180, 255))
|
||||
|
||||
Reference in New Issue
Block a user