Compare commits

...

1 Commits

Author SHA1 Message Date
firestar5683 85df762e34 Fix Laboratory startup and steering availability display 2026-11-11 17:20:00 -06:00
5 changed files with 43 additions and 8 deletions
+2 -1
View File
@@ -554,7 +554,8 @@ def main(demo=False):
meta_extra = meta_main
sm.update(0)
turn_supported = bool(model.npy.get('desire') is not None and model.npy['desire'].shape[-1] == 8)
turn_models = (model.lateral, model.longitudinal) if isinstance(model, LaboratoryPair) else (model,)
turn_supported = all(state.npy.get('desire') is not None and state.npy['desire'].shape[-1] == 8 for state in turn_models)
desire = navigation_turn.select(sm, time.monotonic_ns(), DH.desire,
supported=turn_supported, model_stop=bool(prev_action.shouldStop))
is_rhd = sm["driverMonitoringState"].isRHD
@@ -36,6 +36,29 @@ class TestLaboratoryFrame(unittest.TestCase):
return pair.run_frame(*frame_inputs(pair.lateral), log.ModelDataV2.Action(), .2, .2, 20.,
long_smooth_seconds=0., **kwargs)
def test_actual_modeld_turn_capability_supports_pairs_before_first_frame(self):
import ast
from types import SimpleNamespace
source = Path(__file__).resolve().parents[3] / "selfdrive/modeld/modeld.py"
main = next(node for node in ast.parse(source.read_text()).body if isinstance(node, ast.FunctionDef) and node.name == "main")
assignments = [node for node in ast.walk(main) if isinstance(node, ast.Assign) and
any(isinstance(target, ast.Name) and target.id in ("turn_models", "turn_supported") for target in node.targets)]
caller = compile(ast.fix_missing_locations(ast.Module(body=assignments, type_ignores=[])), str(source), "exec")
def supported(model):
scope = {"model": model, "LaboratoryPair": LaboratoryPair}
exec(caller, scope)
return scope["turn_supported"]
pair = make_pair()
self.assertTrue(supported(pair))
self.assertTrue(supported(pair.lateral))
self.run_frame(pair)
for role in (pair.lateral, pair.longitudinal):
original = role.npy["desire"]
role.npy["desire"] = np.zeros((1, 5), dtype=np.float32)
self.assertFalse(supported(pair))
role.npy["desire"] = original
self.assertFalse(supported(SimpleNamespace(npy={})))
def test_sequential_frame_one_warp_independent_actions_and_current_frame_pose(self):
pair = make_pair()
callback = Mock()
+1 -1
View File
@@ -85,7 +85,7 @@ def clock_text(now: datetime | None = None, use_24_hour: bool = False) -> str:
def axis_status_color(state: OnroadState) -> rl.Color:
"""Retain StarPilot's existing off, AOL, long-only, and combined edge colors."""
lateral = state.lateral_active if state.aol_latched is None else state.aol_latched
lateral = state.lateral_active and state.aol_latched is not False
if state.driver_override_active or state.longitudinal_overridden:
return rl.Color(145, 155, 149, 255)
if lateral and state.switchback_mode:
@@ -55,7 +55,7 @@ class TestOnroadAxes(unittest.TestCase):
intent = IntentState('card-ui', 1, NOW, NOW, NOW + 200_000_000, False, True, False, True, armed)
self.ui.sm.put('aolIntentWire', encode_intent(replace(intent, **changes)))
def test_latch_keeps_border_blue_through_standstill_min_speed_and_reverse(self):
def test_armed_latch_keeps_intent_but_not_active_color_when_steering_pauses(self):
self.ui.aol_runtime = True
self.publish_latch()
for brand in ('hyundai', 'gm', 'toyota', 'ford', 'honda'):
@@ -67,11 +67,21 @@ class TestOnroadAxes(unittest.TestCase):
paused = self.state(False, False)
self.assertTrue(getattr(paused, "aol_latched", False))
self.assertFalse(paused.lateral_active or paused.longitudinal_active or paused.engaged)
self.assertEqual(rgba(axis_status_color(paused)), (10, 186, 181, 255))
self.assertEqual(rgba(axis_status_color(paused)), (18, 40, 57, 255))
self.publish_latch(False)
self.assertFalse(self.state(False, False).aol_latched)
self.assertEqual(rgba(axis_status_color(self.state(False, False))), (18, 40, 57, 255))
def test_missing_model_cannot_show_armed_aol_as_active_steering(self):
self.ui.aol_runtime = True
self.publish_latch()
self.ui.sm.valid["modelV2"] = False
current = self.state(False, False)
self.assertTrue(current.aol_latched)
self.assertFalse(current.lateral_active)
self.assertEqual(rgba(axis_status_color(current)), (18, 40, 57, 255))
self.assertEqual(rgba(axis_status_color(self.state(True, False))), (10, 186, 181, 255))
def test_cleared_latch_does_not_borrow_previous_active_steering_color(self):
self.ui.aol_runtime = True
self.publish_latch()
@@ -280,9 +290,9 @@ class TestOnroadAxes(unittest.TestCase):
(OnroadAlert(size=AlertSize.FULL), blue), (OnroadAlert(size=AlertSize.SMALL, critical=True), blue))]
cases = [(*case, None) for case in cases]
cases += [(False, False, False, alert, color, True) for alert, color in (
(OnroadAlert(), (10, 186, 181, 255)),
(OnroadAlert(size=AlertSize.SMALL, text1='Steering Paused'), (10, 186, 181, 255)),
(OnroadAlert(size=AlertSize.MID), (10, 186, 181, 255)),
(OnroadAlert(), (18, 40, 57, 255)),
(OnroadAlert(size=AlertSize.SMALL, text1='Steering Paused'), (18, 40, 57, 255)),
(OnroadAlert(size=AlertSize.MID), (18, 40, 57, 255)),
(OnroadAlert(size=AlertSize.FULL), blue), (OnroadAlert(size=AlertSize.SMALL, critical=True), blue))]
cases = [(*case, False) for case in cases]
cases += [(True, True, override, alert, color, None, True) for override, alert, color in (
@@ -313,6 +323,7 @@ class TestOnroadAxes(unittest.TestCase):
view.background_layer = None
view.projection_viewport = None
view._corner_cache = Mock()
view._fade = Mock()
view.current_speed = Mock()
view.steering_wheel = Mock()
view.compact_hud = Mock()
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "5e06dbdb156ebe4d76043011c609ca086c212663a43593ec4e5696616d487817", "schema_version": 1}
{"protected_inventory_sha256": "95956b8fbe518cf5d2f9fce5f44218c400ad2fafda771fab3412ffd45be77668", "schema_version": 1}