mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-17 06:13:52 +08:00
bsm
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user