"""Retry residual collision failures from the preceding valid pose.""" import json import numpy as np from l20_bottle_sequence import BASE,OUT from l20_contact import ContactRefiner src=np.load(BASE/'motion.npz');m=dict(np.load(OUT/'registered_motion.npz')) s=ContactRefiner(json.loads((OUT/'object_spec.json').read_text()),OUT) names=list(m['joint_names']);reports=[] for t in np.where(m['penetration_m']>.0015)[0]: active=np.array([src['qpos'][t,names.index(n)] for n in s.cal.active]) x,_,r=s.solve(active,src['wrist_pos'][t],src['wrist_quat_wxyz'][t],m['bottle_pos'][t],m['bottle_quat_wxyz'][t],initial=m['optimization_variables'][t-1]) if r['max_penetration_after_mm'].0015)[0].tolist()})