From ac8511b211b3115633b00efe06beb160d6a4cf2d Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Mon, 8 Jun 2026 20:10:33 -0500 Subject: [PATCH] bsm --- selfdrive/selfdrived/selfdrived.py | 12 +++++++++--- .../selfdrived/tests/test_blindspot_alerts.py | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/selfdrive/selfdrived/selfdrived.py b/selfdrive/selfdrived/selfdrived.py index 0d1da39df..f9799d336 100644 --- a/selfdrive/selfdrived/selfdrived.py +++ b/selfdrive/selfdrived/selfdrived.py @@ -57,15 +57,21 @@ def should_loud_blindspot_alert_without_lateral(CS, sm, starpilot_toggles) -> bo getattr(starpilot_toggles, "loud_blindspot_alert_when_disengaged", False)): return False - if sm['modelV2'].meta.laneChangeState == LaneChangeState.preLaneChange: - return False - left_signal_blocked = bool(CS.leftBlinker and CS.leftBlindspot) right_signal_blocked = bool(CS.rightBlinker and CS.rightBlindspot) one_blinker = bool(CS.leftBlinker) != bool(CS.rightBlinker) if not (one_blinker and (left_signal_blocked or right_signal_blocked)): return False + if sm['modelV2'].meta.laneChangeState == LaneChangeState.preLaneChange: + direction = sm['modelV2'].meta.laneChangeDirection + normal_lane_change_alert = ( + (left_signal_blocked and direction == LaneChangeDirection.left) or + (right_signal_blocked and direction == LaneChangeDirection.right) + ) + if normal_lane_change_alert: + return False + return ( not sm['carControl'].latActive or not sm['starpilotPlan'].lateralCheck or diff --git a/selfdrive/selfdrived/tests/test_blindspot_alerts.py b/selfdrive/selfdrived/tests/test_blindspot_alerts.py index c9456754e..e2876fcde 100644 --- a/selfdrive/selfdrived/tests/test_blindspot_alerts.py +++ b/selfdrive/selfdrived/tests/test_blindspot_alerts.py @@ -5,6 +5,7 @@ from openpilot.selfdrive.selfdrived.selfdrived import should_loud_blindspot_aler LaneChangeState = log.LaneChangeState +LaneChangeDirection = log.LaneChangeDirection def _car_state(left_blinker=False, right_blinker=False, left_blindspot=False, right_blindspot=False): @@ -16,9 +17,10 @@ def _car_state(left_blinker=False, right_blinker=False, left_blindspot=False, ri ) -def _sm(lane_change_state=LaneChangeState.off, lat_active=False, lateral_check=False, pause_lateral=False): +def _sm(lane_change_state=LaneChangeState.off, lane_change_direction=LaneChangeDirection.none, + lat_active=False, lateral_check=False, pause_lateral=False): return { - "modelV2": SimpleNamespace(meta=SimpleNamespace(laneChangeState=lane_change_state)), + "modelV2": SimpleNamespace(meta=SimpleNamespace(laneChangeState=lane_change_state, laneChangeDirection=lane_change_direction)), "carControl": SimpleNamespace(latActive=lat_active), "starpilotPlan": SimpleNamespace(lateralCheck=lateral_check), "starpilotCarState": SimpleNamespace(pauseLateral=pause_lateral), @@ -55,4 +57,12 @@ def test_loud_blindspot_alert_without_lateral_requires_matching_side_and_toggle( def test_loud_blindspot_alert_without_lateral_skips_normal_lane_change_alert_path(): CS = _car_state(left_blinker=True, left_blindspot=True) - assert not should_loud_blindspot_alert_without_lateral(CS, _sm(lane_change_state=LaneChangeState.preLaneChange), _toggles()) + assert not should_loud_blindspot_alert_without_lateral(CS, _sm(lane_change_state=LaneChangeState.preLaneChange, + lane_change_direction=LaneChangeDirection.left), _toggles()) + + +def test_loud_blindspot_alert_without_lateral_handles_paused_pre_lane_change_without_direction(): + CS = _car_state(left_blinker=True, left_blindspot=True) + sm = _sm(lane_change_state=LaneChangeState.preLaneChange, lat_active=True, lateral_check=True, pause_lateral=True) + + assert should_loud_blindspot_alert_without_lateral(CS, sm, _toggles())