Keep Subaru AOL armed across an early paddle denial

This commit is contained in:
firestar5683
2026-11-25 21:40:33 -06:00
parent 1317718b6d
commit 7ff81a0ffb
5 changed files with 59 additions and 9 deletions
+12 -1
View File
@@ -697,7 +697,10 @@ class Car:
getattr(self.aol_transport_feedback, 'subaru_main_retained_native_ns', 0) == int(native.observedMonoTime))
volkswagen_reverse_pending = bool(volkswagen_aol and not transport_reset and native is not None and
getattr(self.aol_transport_feedback, 'volkswagen_reverse_retained_native_ns', 0) == int(native.observedMonoTime))
rejected = native_reset or (not angle_arm_pending and not subaru_braked_main_pending and
paddle_denial = getattr(getattr(self, 'aol_transport_feedback', None), 'subaru_paddle_denial', None)
subaru_paddle_pending = bool(paddle_denial and not transport_reset and native is not None and
paddle_denial[0] == int(native.observedMonoTime))
rejected = native_reset or (not angle_arm_pending and not subaru_braked_main_pending and not subaru_paddle_pending and
not volkswagen_initial_wait and not volkswagen_reverse_pending and not honda_eps_pending and
native_latch_rejected(self.CP, native, state=CS if angle_panda_ready else None))
rejection_ns = now_ns if native_reset else int(native.observedMonoTime) if rejected else 0
@@ -1081,6 +1084,9 @@ class Car:
if self.aol_card_intent is not None:
allowed_latch, pause_lateral, pause_longitudinal = self.aol_card_intent.output(CS)
lateral_armed = self.aol_card_intent.allowed_latch
paddle_denial = getattr(getattr(self, 'aol_transport_feedback', None), 'subaru_paddle_denial', None)
if paddle_denial and not paddle_denial[3]:
allowed_latch = False
intent_deadline_ns = int(cs_send.logMonoTime) + 200_000_000
publication = (getattr(self.aol_card_intent, 'intent_publication', None) if self.CP.brand == 'volkswagen' else None)
if publication is not None:
@@ -1905,6 +1911,11 @@ class Car:
subaru_aol.sync_legacy_card_lateral(self, CS, CC)
if getattr(self, "redneck_cruise", None):
self.redneck_cruise.update(self, CS, CC, now_nanos)
paddle_denial = getattr(getattr(self, 'aol_transport_feedback', None), 'subaru_paddle_denial', None)
if CC.latActive and not CC.enabled and paddle_denial and not paddle_denial[3]:
suppressed = CC.as_builder()
suppressed.latActive = False
CC = suppressed.as_reader()
self.last_actuators_output, can_sends = self.CI.apply(CC, now_nanos)
self.publish_sendcan(can_sends, valid=CS.canValid)
if learning_snapshot is not None and self.learning_send_committed_mono_ns:
+14 -2
View File
@@ -1256,6 +1256,12 @@ class TransportPauseFeedback:
cp_identity(cp) == self.cp)
continuity = bool(not self.session or axis.sessionId == self.session and
(axis.sequence > self.sequence or axis.sequence == self.sequence and signature == self.signature))
pending_paddle = self.subaru_paddle_denial
if pending_paddle is not None and not pending_paddle[3] and (
not current or not continuity or now_ns - pending_paddle[0] > AXIS_MAX_AGE_NS):
self.subaru_paddle_denial = None
self.failed = True
return True
if not current and continuity and cp.brand == 'subaru':
from openpilot.starpilot.car.subaru.aol import retain_stopped_intent
if retain_stopped_intent(self, sm, cp, cs, axis, now_ns, latched=latched, producer=intent_producer_session, signature=signature):
@@ -1424,8 +1430,14 @@ class TransportPauseFeedback:
return False
if cp.brand == 'subaru' and current and continuity:
from openpilot.starpilot.car.subaru.paused_intent import retain_paddle_denial, retain_paused_restriction
if (retain_paddle_denial(self, sm, cp, cs, axis, stamp, now_ns, latched=latched, producer=intent_producer_session) or
retain_paused_restriction(self, sm, cp, cs, axis, stamp, now_ns, latched=latched, producer=intent_producer_session)):
pending_paddle = self.subaru_paddle_denial
if retain_paddle_denial(self, sm, cp, cs, axis, stamp, now_ns, latched=latched, producer=intent_producer_session):
self.sequence, self.signature = int(axis.sequence), signature
return False
if pending_paddle is not None and not pending_paddle[3]:
self.failed = True
return True
if retain_paused_restriction(self, sm, cp, cs, axis, stamp, now_ns, latched=latched, producer=intent_producer_session):
self.sequence, self.signature = int(axis.sequence), signature
return False
fit_eps_retained = False
@@ -147,7 +147,7 @@ def retain_paddle_denial(feedback, sm, cp, state, axis, stamp, now_ns, *, latche
paddle = known_paddle_pause(cp, state)
drive = state.gearShifter == structs.CarState.GearShifter.drive
epoch = int(axis.intentIntegrityEpoch)
if (not (paddle or pending is not None and drive) or not latched or feedback.failed or feedback.paused or
if (not (paddle or drive) or not latched or feedback.failed or feedback.paused or
feedback.pending_event or feedback.retention_started_ns or feedback.source_retention_started_ns or
not feedback.ever_lateral_active or previous is None or not feedback.session or not producer or
previous[0] != feedback.session or previous[7] != feedback.session or previous[5] != 'none' or
@@ -175,13 +175,16 @@ def retain_paddle_denial(feedback, sm, cp, state, axis, stamp, now_ns, *, latche
return False
denied_ns = int(native.observedMonoTime)
if pending is None:
if (not paddle or not previous[9] or not previous[11] or not previous[13] or
if (not previous[9] or not previous[11] or not previous[13] or
not 0 < previous[8] <= previous[2] <= now_ns <= previous[4] or
not 0 < feedback.healthy_native_ns < denied_ns <= now_ns):
return False
elif pending != (denied_ns, producer, epoch):
elif pending[:3] != (denied_ns, producer, epoch):
return False
feedback.subaru_paddle_denial = denied_ns, producer, epoch
confirmed = paddle or bool(pending and pending[3])
if (not confirmed or pending is not None and not pending[3]) and now_ns - denied_ns > AXIS_MAX_AGE_NS:
return False
feedback.subaru_paddle_denial = denied_ns, producer, epoch, confirmed
return True
@@ -26,6 +26,7 @@ from openpilot.starpilot.car.subaru.tests.native_fixture import subaru_native_pa
def test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(candidate, subaru_native_pair, tmp_path, aol=True, manual=False, stop_resume=False,
hard_stop_native_first=False, main_only=False, preferences=None, firmware=None,
manual_ratio=None, camera_hud=False, manual_phase=0,
paddle_gear_delay=0,
deadline_gap=False, fixed_angle_handoff=False, host_first_stop=False,
source_outage=False, vm_angle_handoff=0, crawl=False, eps_brake_join=False,
high_angle_guard=False, main_on_brake=False, guard_brake_release=False,
@@ -208,11 +209,17 @@ def test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(candidate,
if source_outage:
pending_host_can.append((now, incoming))
safety.set_timer((now // 1000) & 0xFFFFFFFF)
panda_gear_ahead = bool(paddle_gear_delay and elapsed == 150 + manual_phase - paddle_gear_delay)
for addr, data, bus in incoming:
if panda_gear_ahead and addr == 0x48 and bus == 0:
raw = bytearray(data)
raw[3] = manual_ratio
raw[0] = (0x48 + sum(raw[1:])) & 255
data = bytes(raw)
safety.safety_rx_hook(libsafety_py.make_CANPacket(addr, bus, data))
safety.safety_tick()
hard_stop_receipt = (hard_stop_native_first or host_first_stop) and elapsed == 125
paddle_native_receipt = bool(manual_phase and elapsed == 150 + manual_phase)
paddle_native_receipt = bool(manual_phase and elapsed == 150 + manual_phase - paddle_gear_delay)
if hard_stop_receipt or paddle_native_receipt:
# Native zero wheels and its USB poll precede the host's stopped CarState.
receipt, hard_order = pandad.step(driven, published, now)
@@ -437,6 +444,16 @@ def test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(candidate,
'events': [str(e.name) for e in driven['onroadEvents'].onroadEvents],
}
rows.append(row)
if paddle_gear_delay:
denial_tick = 150 + manual_phase - paddle_gear_delay
if denial_tick <= elapsed < 150 + manual_phase:
assert not row['intent'] and not row['lat'], row
assert all(not steering['request'] for steering in row['steering']), row
if panda_gear_ahead:
assert row['cardLatch'] and row['armed'], row
if paddle_gear_delay > 4 and elapsed == denial_tick + 4:
assert not row['cardLatch'] and not row['armed'], row
return
if main_during_eps and 35 <= tick < 50:
assert cs.steerFaultTemporary and not row['lat'] and not row['long'] and row['permission'] == 0, row
assert all(not frame['request'] and frame['output'] == 0 and frame['nativeAccepted'] for frame in row['steering']), row
@@ -828,3 +845,10 @@ def test_actual_crosstrek_native_first_paddle_pause(subaru_native_pair, tmp_path
test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(
CAR.SUBARU_IMPREZA_2020, subaru_native_pair, tmp_path, main_only=True, manual_ratio=145, manual_phase=phase,
preferences={'SubaruSNG': True})
@pytest.mark.parametrize("phase, delay", ((4, 1), (7, 1), (7, 5)))
def test_actual_crosstrek_panda_denial_before_card_gear(subaru_native_pair, tmp_path, phase, delay):
test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(
CAR.SUBARU_IMPREZA_2020, subaru_native_pair, tmp_path, main_only=True, manual_ratio=145, manual_phase=phase,
paddle_gear_delay=delay, preferences={'SubaruSNG': True})
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "bf46a568f9a676654a627a96d7e38067ba6bf1aea9bf7bd829c12c29e884fa6a", "schema_version": 1}
{"protected_inventory_sha256": "4aa69c8ccd4db6c592aa7626e1c75533788b1c35fbbb2724d76cef24538d8303", "schema_version": 1}