44 lines
2.5 KiB
Python
44 lines
2.5 KiB
Python
"""Offline hand/table sweep at staged rotation endpoints; no hardware."""
|
|
import json
|
|
import numpy as np
|
|
from scipy.spatial import ConvexHull
|
|
from offline_table_guard import ROOT
|
|
from search_cup_poses_offline import PoseGuard
|
|
from check_index_board_hover import hand_geometry
|
|
from left_index_pointing_pose import pointing_target
|
|
from g20_left_lookup import LeftLookup
|
|
|
|
|
|
def main():
|
|
cap=ROOT/'data/start_evidence_20260927T053837893105Z'
|
|
plan=json.loads((cap/'lift_rotate_point_validation.json').read_text())
|
|
plane=json.loads((cap/'index_hover_validation.json').read_text())
|
|
raw=json.loads((ROOT/'data/left_hand_open_q10r1mak/result.json').read_text())['final_feedback']
|
|
target=pointing_target(raw,LeftLookup())
|
|
candidates=[r for r in plan['candidates'] if 'rotate_joints' in r]
|
|
guard=PoseGuard(plane['table_normal'],plane['table_point_m'])
|
|
mount=json.loads((ROOT/'config/left_hand_mount.json').read_text())
|
|
guard.mount=np.array(mount['rotation_Arm_Tip_to_hand'])
|
|
rows=[dict(lift_m=c['lift_m'],yaw=c['palm_down_yaw_deg'],minimum_hand_plane_gap_m=float('inf'),minimum_full_body_gap_m=float('inf')) for c in candidates]
|
|
if candidates:
|
|
for fraction in np.linspace(0,1,65):
|
|
value=np.rint((1-fraction)*np.array(raw)+fraction*np.array(target)).astype(int).tolist()
|
|
_,cloud,_=hand_geometry(value);guard.cloud=cloud[ConvexHull(cloud).vertices]
|
|
for candidate,row in zip(candidates,rows):
|
|
q=np.array(candidate['rotate_joints'][-1]);T=guard.fk(q)
|
|
world=(guard.cloud@guard.mount.T+guard.hand_center)@T[:3,:3].T+T[:3,3]
|
|
gap=float(((world-guard.p)@guard.n).min())
|
|
row['minimum_hand_plane_gap_m']=min(gap,row['minimum_hand_plane_gap_m'])
|
|
row['minimum_full_body_gap_m']=min(guard.clearance(q)[0],row['minimum_full_body_gap_m'])
|
|
report=dict(executable=False,motion_sent=False,samples_per_candidate=65,candidates=rows,
|
|
scope='sampled hand closure at each successful rotation endpoint vs infinite table plane',
|
|
limitations=['No continuous/asynchronous hand following bound; not a hardware certificate.',
|
|
'Inter-finger shape distances are rigid-pose invariant; other contacts not checked.'])
|
|
output=cap/'rotated_closure_validation.json';output.write_text(json.dumps(report,indent=2))
|
|
print('Closure endpoints checked:',len(rows))
|
|
print('Hand-only >=20mm:',sum(r['minimum_hand_plane_gap_m']>=.02 for r in rows))
|
|
print(output)
|
|
|
|
|
|
if __name__=='__main__':main()
|