Retain aircraft through native landing and qualify bounded input diagnostics
This commit is contained in:
@@ -29,7 +29,18 @@ def need(value, reason):
|
||||
|
||||
|
||||
def perform_alignment(guard, require_idle, mouse, observe, geometry, calibration, approach_evidence, report, *, clock, sleep, notify):
|
||||
need('alignment_proof' not in report, 'Alignment attempt already exists')
|
||||
return _perform_alignment(guard, require_idle, mouse, observe, geometry, calibration, approach_evidence, report, clock=clock, sleep=sleep, notify=notify)
|
||||
|
||||
|
||||
def perform_facing(guard, require_idle, mouse, observe, geometry, calibration, approach_evidence, report, *, clock, sleep, notify):
|
||||
"""Separate facing-only outcome; requires exact disabled-door/lock diagnostics."""
|
||||
return _perform_alignment(guard, require_idle, mouse, observe, geometry, calibration, approach_evidence, report, clock=clock, sleep=sleep, notify=notify, facing=True)
|
||||
|
||||
|
||||
def _perform_alignment(guard, require_idle, mouse, observe, geometry, calibration, approach_evidence, report, *, clock, sleep, notify, facing=False):
|
||||
proof_key = 'facing_proof' if facing else 'alignment_proof'
|
||||
event_prefix = 'facing' if facing else 'alignment'
|
||||
need(proof_key not in report, 'Alignment attempt already exists')
|
||||
pinned = copy.deepcopy(geometry)
|
||||
target_for(pinned) # Existing measured authored-enclosure compatibility gate.
|
||||
approach = report.get('approach_proof', {})
|
||||
@@ -57,7 +68,10 @@ def perform_alignment(guard, require_idle, mouse, observe, geometry, calibration
|
||||
state = {'requested': True, 'completed': False, 'nonce': pinned['nonce'], 'geometry': pinned,
|
||||
'started_monotonic': started, 'finished_monotonic': None, 'deadline_monotonic': deadline,
|
||||
'initial_sample': None, 'final_sample': None, 'selection_samples': [], 'motions': [], 'samples': []}
|
||||
report['alignment_proof'] = state
|
||||
report[proof_key] = state
|
||||
if facing:
|
||||
state['facing_samples'] = []
|
||||
del state['selection_samples']
|
||||
previous = None; active_turn = None; requests = 0
|
||||
|
||||
def neutral(s):
|
||||
@@ -87,6 +101,11 @@ def perform_alignment(guard, require_idle, mouse, observe, geometry, calibration
|
||||
need(number(s['pressed']) == 0 and number(s['progress']) == 0 and s['performing'] is False and number(s['duration']) == 4,
|
||||
'Gate interaction began during yaw-only alignment')
|
||||
bearing(s)
|
||||
if facing and s['context_selected']:
|
||||
from prison_action_selection_proof import choices_for
|
||||
actions = choices_for(s, pinned)
|
||||
if 'actions' not in state: state['actions'] = actions
|
||||
need(state['actions'] == actions, 'Original facing action identities/order changed')
|
||||
if active_turn is not None:
|
||||
before_yaw, sign = active_turn
|
||||
change = delta(yaw(s['direction']), before_yaw)
|
||||
@@ -123,6 +142,12 @@ def perform_alignment(guard, require_idle, mouse, observe, geometry, calibration
|
||||
abs(delta(yaw(second['direction']), yaw(first['direction']))) <= .2)
|
||||
|
||||
def selected(s):
|
||||
if facing:
|
||||
if not s['context_selected'] or not s['cached_performable'] or abs(delta(bearing(s), yaw(s['direction']))) > 3:
|
||||
return False
|
||||
from prison_action_selection_proof import choices_for
|
||||
choices_for(s, pinned)
|
||||
return True
|
||||
return s['selected'] and s['context_selected'] and s['cached_performable'] and s['progress_bound'] and abs(delta(bearing(s), yaw(s['direction']))) <= 3
|
||||
|
||||
def selection_pair():
|
||||
@@ -132,14 +157,14 @@ def perform_alignment(guard, require_idle, mouse, observe, geometry, calibration
|
||||
return []
|
||||
|
||||
try:
|
||||
notify({'kind': 'alignment-pending', 'deadline_monotonic': deadline})
|
||||
notify({'kind': event_prefix+'-pending', 'deadline_monotonic': deadline})
|
||||
initial = read()
|
||||
# First receipt cannot extend the frozen original READY-derived lease.
|
||||
# Deduct the explicit 500ms observation/dispatch reserve, not just age.
|
||||
deadline = min(deadline, initial['received_monotonic']+(queued+45000-initial['real_ms'])/1000-.5)
|
||||
state['deadline_monotonic'] = deadline
|
||||
need(clock() < deadline, 'Fresh native sample leaves no alignment time')
|
||||
notify({'kind': 'alignment-pending', 'deadline_monotonic': deadline})
|
||||
notify({'kind': event_prefix+'-pending', 'deadline_monotonic': deadline})
|
||||
current = initial
|
||||
while clock() < deadline:
|
||||
pair = selection_pair()
|
||||
@@ -150,7 +175,7 @@ def perform_alignment(guard, require_idle, mouse, observe, geometry, calibration
|
||||
continue
|
||||
require_idle()
|
||||
need(clock() < deadline, 'Frozen alignment deadline exceeded at completion')
|
||||
state['selection_samples'] = pair; state['completed'] = True
|
||||
state['facing_samples' if facing else 'selection_samples'] = pair; state['completed'] = True
|
||||
return state
|
||||
error = delta(bearing(current), yaw(current['direction']))
|
||||
if abs(error) <= 3:
|
||||
@@ -192,4 +217,4 @@ def perform_alignment(guard, require_idle, mouse, observe, geometry, calibration
|
||||
raise
|
||||
finally:
|
||||
state['finished_monotonic'] = clock()
|
||||
notify({'kind': 'alignment-finished', 'successful': state['completed']})
|
||||
notify({'kind': event_prefix+'-finished', 'successful': state['completed']})
|
||||
|
||||
Reference in New Issue
Block a user