"""Apply the selected bounded-drive contact model after geometric preparation.""" from pathlib import Path import json,xml.etree.ElementTree as E O=Path(__file__).resolve().parents[1]/'output/collision_fix_20260915';p=O/'datasets/processed/current/l20/bimanual/boxes/scene_act.xml';tree=E.parse(p);r=tree.getroot();r.find('option').set('iterations','80');r.find('option').set('ls_iterations','50') for g in r.findall('.//geom'): if g.get('contype') in ['1','2']:g.set('solimp','.999 .9999 .0001 .5 2');g.set('solref','.005 1') for a in r.findall('actuator/position'): n=a.get('name') if '_object_' in n:continue if '_hand_pos_' in n:kp,kv,limit=500,30,20 elif '_hand_rot_' in n:kp,kv,limit=15,2,2 else:kp,kv,limit=4,.15,.1 a.attrib.update(kp=str(kp),kv=str(kv),forcerange=f'{-limit} {limit}') tree.write(p);(O/'physics_parameters.json').write_text(json.dumps({'solver_iterations':80,'ls_iterations':50,'wrist_position_kp':500,'wrist_position_kv':30,'wrist_force_cap_N':20,'wrist_rotation_kp':15,'wrist_rotation_kv':2,'wrist_torque_cap_Nm':2,'finger_kp':4,'finger_kv':.15,'finger_torque_cap_Nm':.1,'contact_solimp':[.999,.9999,.0001,.5,2],'contact_solref':[.005,1],'note':'Simulation drive assumptions, not measured hardware ratings. Chosen after full-clip CPU control-replay comparison.'},indent=2))