diff --git a/policies.csv b/policies.csv new file mode 100644 index 0000000000000000000000000000000000000000..88203ee9cb3d14c4a42d021ac6f4be308cddf957 --- /dev/null +++ b/policies.csv @@ -0,0 +1,421 @@ +task,task_set,session,agent,model,harness,harness_version,effort,service_tier,success_rate,scored_version,policy_lines,budget_used,cost_usd,tokens_input_uncached,tokens_cached,tokens_output,status,files +dishwasher_close,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,5,161,97540,20.5678,1133120,32137793,253846,scored,policies/dishwasher_close/opus-s1/policy.py +dishwasher_close,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,2,153,101000,25.0822,1365184,43104886,277080,scored,policies/dishwasher_close/opus-s2/policy.py +dishwasher_close,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,10,291,93322,15.1431,566146,32371214,207061,scored,policies/dishwasher_close/opus-s3/policy.py +dishwasher_load_cups,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,83,78,745,100443,35.1785,1026158,96381670,384765,scored,policies/dishwasher_load_cups/opus-s1/policy.py +dishwasher_load_cups,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,1,47,440,93009,20.9347,709428,51484778,245087,scored,policies/dishwasher_load_cups/opus-s2/policy.py +dishwasher_load_cups,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,1,92,897,93571,27.4713,1019723,64438875,321410,scored,policies/dishwasher_load_cups/opus-s3/policy.py;policies/dishwasher_load_cups/opus-s3/g1kin.py;policies/dishwasher_load_cups/opus-s3/vision.py +drawer_top_close,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,5,76,76438,1.1959,56304,1645669,20834,scored,policies/drawer_top_close/opus-s1/policy.py +drawer_top_close,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,2,102,62872,3.0479,118863,5070562,54170,scored,policies/drawer_top_close/opus-s2/policy.py +drawer_top_close,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,2,83,39811,0.7328,41639,683259,13158,scored,policies/drawer_top_close/opus-s3/policy.py +drawer_top_open,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,99,40,280,96255,11.3522,313708,27804385,164149,scored,policies/drawer_top_open/opus-s1/policy.py +drawer_top_open,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,98,23,410,72905,7.3521,251482,15127712,115777,scored,policies/drawer_top_open/opus-s2/policy.py;policies/drawer_top_open/opus-s2/g1kin.py;policies/drawer_top_open/opus-s2/handles.py +drawer_top_open,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,67,491,96799,14.276,563764,33987631,148490,scored,policies/drawer_top_open/opus-s3/policy.py;policies/drawer_top_open/opus-s3/headcam.py;policies/drawer_top_open/opus-s3/kin.py +move_plate,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,21,40,648,99896,24.5393,797274,58034979,327799,scored,policies/move_plate/opus-s1/policy.py +move_plate,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,15,20,532,94087,14.3046,369119,35091038,216740,scored,policies/move_plate/opus-s2/policy.py +move_plate,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,23,53,692,95511,44.5888,650252,58262275,273955,scored,policies/move_plate/opus-s3/policy.py;policies/move_plate/opus-s3/ctrl.py;policies/move_plate/opus-s3/fk.py;policies/move_plate/opus-s3/vision.py +move_two_plates,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,8,104,807,98595,21.2487,515493,55727710,299046,scored,policies/move_two_plates/opus-s1/policy.py +move_two_plates,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,15,55,475,99431,25.7318,1021489,52229355,355796,scored,policies/move_two_plates/opus-s2/policy.py +move_two_plates,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,22,71,509,96262,22.1373,471033,63574291,282810,scored,policies/move_two_plates/opus-s3/policy.py +pick_box,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,44,21,435,98066,11.0736,314827,26845900,159349,scored,policies/pick_box/opus-s1/policy.py +pick_box,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,99,19,352,95241,8.6046,294983,18720577,125075,scored,policies/pick_box/opus-s2/policy.py +pick_box,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,71,55,458,87969,12.1171,328279,30767594,162469,scored,policies/pick_box/opus-s3/policy.py +reach_target_dual,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,71,25,600,92723,9.509,284849,19598954,165575,scored,policies/reach_target_dual/opus-s1/policy.py +reach_target_dual,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,99,30,619,78293,8.2644,257355,17205019,138278,scored,policies/reach_target_dual/opus-s2/policy.py;policies/reach_target_dual/opus-s2/g1reach_geom.py;policies/reach_target_dual/opus-s2/g1reach_vision.py +reach_target_dual,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,65,22,586,97748,12.7152,326052,33161318,173800,scored,policies/reach_target_dual/opus-s3/policy.py +reach_target_multi_modal,core,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,25,514,72915,6.2168,217025,11210367,111963,scored,policies/reach_target_multi_modal/opus-s1/policy.py +reach_target_multi_modal,core,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,12,431,63229,11.4473,203072,13483866,96862,scored,policies/reach_target_multi_modal/opus-s2/policy.py +reach_target_multi_modal,core,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,13,416,76234,5.4287,188612,9819067,97836,scored,policies/reach_target_multi_modal/opus-s3/policy.py +dishwasher_load_cutlery,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,12,23,414,98591,21.7517,632187,55739064,277429,scored,policies/dishwasher_load_cutlery/opus-s1/policy.py +dishwasher_load_cutlery,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,12,76,653,97562,26.3891,773789,72029314,289764,scored,policies/dishwasher_load_cutlery/opus-s2/policy.py;policies/dishwasher_load_cutlery/opus-s2/g1kin.py +dishwasher_load_cutlery,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,5,44,719,98242,30.8292,1401407,61153240,369463,scored,policies/dishwasher_load_cutlery/opus-s3/policy.py;policies/dishwasher_load_cutlery/opus-s3/kin.py;policies/dishwasher_load_cutlery/opus-s3/vision.py +dishwasher_load_plates,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,38,5,504,98993,28.738,802629,78612684,329847,scored,policies/dishwasher_load_plates/opus-s1/policy.py;policies/dishwasher_load_plates/opus-s1/g1lib.py +dishwasher_load_plates,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,108,844,69573,23.0032,717072,53233481,331096,crashed,policies/dishwasher_load_plates/opus-s2/policy.py;policies/dishwasher_load_plates/opus-s2/camgeo.py;policies/dishwasher_load_plates/opus-s2/g1fk.py +dishwasher_load_plates,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,1,128,778,98474,31.7166,912451,85541156,365562,scored,policies/dishwasher_load_plates/opus-s3/policy.py;policies/dishwasher_load_plates/opus-s3/camera.py;policies/dishwasher_load_plates/opus-s3/g1kin.py;policies/dishwasher_load_plates/opus-s3/vision.py +flip_cup,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,91,22,457,96178,14.7238,395543,32962244,248415,scored,policies/flip_cup/opus-s1/policy.py;policies/flip_cup/opus-s1/g1kin.py +flip_cup,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,97,24,379,99151,8.8696,288161,17966606,148595,scored,policies/flip_cup/opus-s2/policy.py +flip_cup,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,94,15,348,93526,15.6327,420664,38350075,224531,scored,policies/flip_cup/opus-s3/policy.py +flip_cutlery,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,18,892,93601,47.1235,750166,55369141,326445,crashed,policies/flip_cutlery/opus-s1/policy.py;policies/flip_cutlery/opus-s1/g1lib.py +flip_cutlery,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,70,22,514,98544,29.422,774697,78684158,374504,scored,policies/flip_cutlery/opus-s2/policy.py +flip_cutlery,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,19,65,965,99477,25.5416,824521,67359092,273780,scored,policies/flip_cutlery/opus-s3/policy.py;policies/flip_cutlery/opus-s3/g1kin.py;policies/flip_cutlery/opus-s3/vision.py +put_cups,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,14,24,685,100773,23.5961,471030,72129014,270212,scored,policies/put_cups/opus-s1/policy.py +put_cups,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,75,1034,90637,34.0351,1270191,85736420,336430,scored,policies/put_cups/opus-s2/policy.py;policies/put_cups/opus-s2/cupvision.py;policies/put_cups/opus-s2/g1kin.py +put_cups,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,114,1054,94174,28.2013,907163,74850528,298800,scored,policies/put_cups/opus-s3/policy.py;policies/put_cups/opus-s3/g1kin.py;policies/put_cups/opus-s3/vision.py +reach_target_single,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,21,313,75936,5.5224,188338,9945105,101370,scored,policies/reach_target_single/opus-s1/policy.py +reach_target_single,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,99,6,282,63432,2.6867,110452,3708444,53089,scored,policies/reach_target_single/opus-s2/policy.py +reach_target_single,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,5,304,61465,3.3768,143837,4269392,68634,scored,policies/reach_target_single/opus-s3/policy.py +sandwich_remove,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,41,1452,83741,51.8504,986747,52274058,380705,scored,policies/sandwich_remove/opus-s1/policy.py +sandwich_remove,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,3,577,94323,35.3219,1219015,86497651,413639,scored,policies/sandwich_remove/opus-s2/policy.py;policies/sandwich_remove/opus-s2/g1kin.py +sandwich_remove,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,1,83,906,86442,19.3325,633358,48405165,229324,scored,policies/sandwich_remove/opus-s3/policy.py;policies/sandwich_remove/opus-s3/camera.py;policies/sandwich_remove/opus-s3/g1kin.py;policies/sandwich_remove/opus-s3/vision.py +saucepan_to_hob,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,2,1181,96315,44.7686,501879,60833144,313099,scored,policies/saucepan_to_hob/opus-s1/policy.py;policies/saucepan_to_hob/opus-s1/g1fk.py;policies/saucepan_to_hob/opus-s1/g1ik.py;policies/saucepan_to_hob/opus-s1/headcam.py;policies/saucepan_to_hob/opus-s1/planner.py;policies/saucepan_to_hob/opus-s1/skills.py;policies/saucepan_to_hob/opus-s1/skills2.py +saucepan_to_hob,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,25,117,841,96902,33.8742,601773,110019845,352958,scored,policies/saucepan_to_hob/opus-s2/policy.py;policies/saucepan_to_hob/opus-s2/cam.py;policies/saucepan_to_hob/opus-s2/kin.py +saucepan_to_hob,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,27,670,100619,26.2397,670116,73566161,308422,scored,policies/saucepan_to_hob/opus-s3/policy.py;policies/saucepan_to_hob/opus-s3/camera.py;policies/saucepan_to_hob/opus-s3/g1fk.py;policies/saucepan_to_hob/opus-s3/vision.py +stack_blocks,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,60,691,100186,13.3625,311348,35380984,189859,scored,policies/stack_blocks/opus-s1/policy.py;policies/stack_blocks/opus-s1/g1kin.py;policies/stack_blocks/opus-s1/headcam.py;policies/stack_blocks/opus-s1/percept.py +stack_blocks,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,0,51,686,99747,20.4689,463202,58920920,249056,scored,policies/stack_blocks/opus-s2/policy.py +stack_blocks,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,1,55,903,98547,18.4384,438427,50722627,239411,scored,policies/stack_blocks/opus-s3/policy.py;policies/stack_blocks/opus-s3/cam.py;policies/stack_blocks/opus-s3/fk.py +wall_cupboard_close,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,8,227,54297,3.8848,145748,7020095,65771,scored,policies/wall_cupboard_close/opus-s1/policy.py +wall_cupboard_close,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,8,215,71831,5.7503,192422,10439327,106194,scored,policies/wall_cupboard_close/opus-s2/policy.py +wall_cupboard_close,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,14,308,83224,12.167,360281,29352788,170771,scored,policies/wall_cupboard_close/opus-s3/policy.py +wall_cupboard_open,extended,opus-s1,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,44,516,58867,16.2642,411076,47936895,169501,scored,policies/wall_cupboard_open/opus-s1/policy.py +wall_cupboard_open,extended,opus-s2,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,67,584,66416,14.4947,382475,36751337,204308,scored,policies/wall_cupboard_open/opus-s2/policy.py;policies/wall_cupboard_open/opus-s2/ctrl.py;policies/wall_cupboard_open/opus-s2/fk.py;policies/wall_cupboard_open/opus-s2/vision.py +wall_cupboard_open,extended,opus-s3,opus55,Claude Opus 5.5,Claude Code,2.1.280 (Claude Code),high,default,100,42,503,86142,21.2168,488020,60100953,264711,scored,policies/wall_cupboard_open/opus-s3/policy.py +dishwasher_close,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,2,58,93180,8.29,122103,6026112,20770,scored,policies/dishwasher_close/astra-s1/policy.py +dishwasher_close,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,3,44,77778,20.03,165712,16604288,35430,scored,policies/dishwasher_close/astra-s2/policy.py +dishwasher_close,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,2,67,94948,6.91,155149,4026240,26569,scored,policies/dishwasher_close/astra-s3/policy.py +dishwasher_load_cups,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,18,16,541,100489,31.51,386004,24206464,68817,scored,policies/dishwasher_load_cups/astra-s1/policy.py +dishwasher_load_cups,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,16,26,163,101000,23.24,238919,17284736,71387,scored,policies/dishwasher_load_cups/astra-s2/policy.py +dishwasher_load_cups,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,30,11,140,100490,18.38,212694,13128832,62401,scored,policies/dishwasher_load_cups/astra-s3/policy.py +drawer_top_close,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,96,3,19,44059,1.6,62045,792320,3678,scored,policies/drawer_top_close/astra-s1/policy.py +drawer_top_close,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,4,35,38773,1.34,33861,768384,4667,scored,policies/drawer_top_close/astra-s2/policy.py +drawer_top_close,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,2,33,39653,1.93,42585,1217536,5757,scored,policies/drawer_top_close/astra-s3/policy.py +drawer_top_open,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,13,77,99558,7.51,101607,5139712,27052,scored,policies/drawer_top_open/astra-s1/policy.py +drawer_top_open,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,97,4,32,100624,5.24,82794,3558144,17174,scored,policies/drawer_top_open/astra-s2/policy.py +drawer_top_open,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,3,34,81799,6.94,136351,4522368,21177,scored,policies/drawer_top_open/astra-s3/policy.py +move_plate,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,36,8,213,99651,35.27,593640,24072192,105312,scored,policies/move_plate/astra-s1/policy.py +move_plate,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,2,7,81,100806,10.91,175551,7486976,33294,scored,policies/move_plate/astra-s2/policy.py +move_plate,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,4,17,135,100950,10.14,165785,6296192,43749,scored,policies/move_plate/astra-s3/policy.py +move_two_plates,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,0,10,126,101000,10.96,176690,7036288,43192,scored,policies/move_two_plates/astra-s1/policy.py +move_two_plates,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,38,11,81,101000,9.77,207720,6020096,33412,scored,policies/move_two_plates/astra-s2/policy.py +move_two_plates,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,9,18,128,99449,16.26,189610,11486720,57476,scored,policies/move_two_plates/astra-s3/policy.py +pick_box,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,64,10,86,99951,11.94,215735,8406528,27464,scored,policies/pick_box/astra-s1/policy.py +pick_box,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,85,9,115,100912,13.39,302846,8494592,37243,scored,policies/pick_box/astra-s2/policy.py +pick_box,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,12,5,98,100989,12.31,152527,8983808,36106,scored,policies/pick_box/astra-s3/policy.py +reach_target_dual,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,16,168,100688,5.61,88871,3438592,25740,scored,policies/reach_target_dual/astra-s1/policy.py +reach_target_dual,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,93,13,96,100787,6.95,197016,3795840,23626,scored,policies/reach_target_dual/astra-s2/policy.py +reach_target_dual,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,75,16,118,100505,5.38,131429,2925056,22763,scored,policies/reach_target_dual/astra-s3/policy.py +reach_target_multi_modal,core,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,75,11,86,100708,5.1,69649,3254528,22965,scored,policies/reach_target_multi_modal/astra-s1/policy.py +reach_target_multi_modal,core,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,97,7,71,91340,3.27,66544,1918336,13633,scored,policies/reach_target_multi_modal/astra-s2/policy.py +reach_target_multi_modal,core,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,95,14,120,100790,5.55,145474,2887296,24153,scored,policies/reach_target_multi_modal/astra-s3/policy.py +dishwasher_load_cutlery,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,5,8,187,100425,32.04,537960,23006208,72998,scored,policies/dishwasher_load_cutlery/astra-s1/policy.py +dishwasher_load_cutlery,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,0,19,134,100596,31.93,430713,23540992,81705,scored,policies/dishwasher_load_cutlery/astra-s2/policy.py +dishwasher_load_cutlery,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,0,26,92,100292,38.35,568538,28855808,76077,scored,policies/dishwasher_load_cutlery/astra-s3/policy.py +dishwasher_load_plates,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,2,9,76,99944,15.76,231241,10711808,54755,scored,policies/dishwasher_load_plates/astra-s1/policy.py +dishwasher_load_plates,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,3,25,141,100093,13.43,312520,7859072,49009,scored,policies/dishwasher_load_plates/astra-s2/policy.py +dishwasher_load_plates,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,6,18,72,99930,18.92,234380,13420928,63154,scored,policies/dishwasher_load_plates/astra-s3/policy.py +flip_cup,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,29,14,143,100011,6.02,103289,3514624,29431,scored,policies/flip_cup/astra-s1/policy.py +flip_cup,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,59,17,226,101000,12.81,284696,7709696,45109,scored,policies/flip_cup/astra-s2/policy.py +flip_cup,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,27,8,176,100973,10.42,149383,6733696,43808,scored,policies/flip_cup/astra-s3/policy.py +flip_cutlery,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,3,2,120,100990,18.06,180636,13646336,52123,scored,policies/flip_cutlery/astra-s1/policy.py +flip_cutlery,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,0,7,140,100766,20.99,259702,15024128,67307,scored,policies/flip_cutlery/astra-s2/policy.py +flip_cutlery,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,0,4,84,100995,18.69,291977,12728704,60881,scored,policies/flip_cutlery/astra-s3/policy.py +put_cups,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,0,9,139,100990,31.84,455674,23117824,83221,scored,policies/put_cups/astra-s1/policy.py +put_cups,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,15,7,252,100411,35.41,567932,25012736,94378,scored,policies/put_cups/astra-s2/policy.py +put_cups,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,9,12,185,100779,33.52,419729,25229312,81862,scored,policies/put_cups/astra-s3/policy.py +reach_target_single,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,98,9,93,84355,2.3,50662,1257472,10762,scored,policies/reach_target_single/astra-s1/policy.py +reach_target_single,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,97,2,49,51150,1.95,54615,906880,9890,scored,policies/reach_target_single/astra-s2/policy.py +reach_target_single,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,7,133,87460,3.57,92040,1680640,19328,scored,policies/reach_target_single/astra-s3/policy.py +sandwich_remove,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,15,23,75,100996,18.82,259718,13591808,52539,scored,policies/sandwich_remove/astra-s1/policy.py +sandwich_remove,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,0,19,109,100987,20.43,292448,15093504,48256,scored,policies/sandwich_remove/astra-s2/policy.py +sandwich_remove,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,0,2,107,100707,23.16,324564,16173568,74811,scored,policies/sandwich_remove/astra-s3/policy.py +saucepan_to_hob,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,14,13,102,100596,40.51,490089,32914048,53973,scored,policies/saucepan_to_hob/astra-s1/policy.py +saucepan_to_hob,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,18,10,83,99657,19.9,214314,15634048,42357,scored,policies/saucepan_to_hob/astra-s2/policy.py +saucepan_to_hob,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,47,12,108,99303,31.22,276486,25323136,62661,scored,policies/saucepan_to_hob/astra-s3/policy.py +stack_blocks,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,1,21,190,100921,15.03,214461,9778048,62184,scored,policies/stack_blocks/astra-s1/policy.py +stack_blocks,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,2,11,182,100980,9.12,136704,5114624,52802,scored,policies/stack_blocks/astra-s2/policy.py +stack_blocks,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,0,12,182,100487,15.61,180803,11342592,49270,scored,policies/stack_blocks/astra-s3/policy.py +wall_cupboard_close,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,100,2,37,58670,2.24,56232,1209216,9328,scored,policies/wall_cupboard_close/astra-s1/policy.py +wall_cupboard_close,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,1,32,77232,2.89,61133,1617536,13291,scored,policies/wall_cupboard_close/astra-s2/policy.py +wall_cupboard_close,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,default,100,1,34,94540,1.87,43019,1073280,7423,scored,policies/wall_cupboard_close/astra-s3/policy.py +wall_cupboard_open,extended,astra-s1,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,0,2,74,99746,11.56,245305,6689792,48351,scored,policies/wall_cupboard_open/astra-s1/policy.py +wall_cupboard_open,extended,astra-s2,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,100,2,58,95955,5.53,89536,3909248,14555,scored,policies/wall_cupboard_open/astra-s2/policy.py +wall_cupboard_open,extended,astra-s3,astra,GPT-6 Astra,Codex CLI,codex-cli 0.153.4,high,fast,100,1,97,82617,10.75,148044,6993664,45502,scored,policies/wall_cupboard_open/astra-s3/policy.py +dishwasher_close,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,4,99,100190,4.94,222736,19202176,65210,scored,policies/dishwasher_close/gpt6sol-s1/policy.py +dishwasher_close,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,4,139,97513,8.34,443554,32466304,96339,scored,policies/dishwasher_close/gpt6sol-s2/policy.py +dishwasher_close,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,10,100,100465,7.47,1036477,21887616,101699,scored,policies/dishwasher_close/gpt6sol-s3/policy.py +dishwasher_load_cups,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,2,4,83,100298,8.52,450665,34261120,76388,scored,policies/dishwasher_load_cups/gpt6sol-s1/policy.py +dishwasher_load_cups,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,1,108,99186,11.9,467302,49467776,107496,scored,policies/dishwasher_load_cups/gpt6sol-s2/policy.py +dishwasher_load_cups,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,3,18,178,100738,9.84,488716,39528448,95426,scored,policies/dishwasher_load_cups/gpt6sol-s3/policy.py +drawer_top_close,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,98,4,19,98624,0.96,70330,3215232,18033,scored,policies/drawer_top_close/gpt6sol-s1/policy.py +drawer_top_close,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,100,1,22,62982,0.87,84544,2557952,18790,scored,policies/drawer_top_close/gpt6sol-s2/policy.py +drawer_top_close,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,100,2,33,99493,1.89,157670,6451456,28761,scored,policies/drawer_top_close/gpt6sol-s3/policy.py +drawer_top_open,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,55,6,99,100515,4.48,212238,17338368,59253,scored,policies/drawer_top_open/gpt6sol-s1/policy.py +drawer_top_open,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,66,4,46,100451,5.62,355132,21216256,66358,scored,policies/drawer_top_open/gpt6sol-s2/policy.py +drawer_top_open,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,36,7,55,100467,3.87,192760,15085184,46667,scored,policies/drawer_top_open/gpt6sol-s3/policy.py +move_plate,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,1,2,78,100940,4.93,428716,17004800,67518,scored,policies/move_plate/gpt6sol-s1/policy.py +move_plate,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,7,1,46,98450,4.49,153898,18555520,46954,scored,policies/move_plate/gpt6sol-s2/policy.py +move_plate,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,5,4,95,100985,3.16,276824,10279936,54879,scored,policies/move_plate/gpt6sol-s3/policy.py +move_two_plates,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,5,125,99976,6.98,250929,28520960,77161,scored,policies/move_two_plates/gpt6sol-s1/policy.py +move_two_plates,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,2,111,100919,7.47,272352,31418624,63844,scored,policies/move_two_plates/gpt6sol-s2/policy.py +move_two_plates,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,2,41,100719,4.23,300144,15474944,53221,scored,policies/move_two_plates/gpt6sol-s3/policy.py +pick_box,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,2,147,98440,8.73,929378,29795200,91495,scored,policies/pick_box/gpt6sol-s1/policy.py +pick_box,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,3,81,100242,6.29,432872,23279360,76901,scored,policies/pick_box/gpt6sol-s2/policy.py +pick_box,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,0,2,152,100815,2.67,125885,9573888,50417,scored,policies/pick_box/gpt6sol-s3/policy.py +reach_target_dual,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,33,5,125,100190,4.32,190172,16452480,64887,scored,policies/reach_target_dual/gpt6sol-s1/policy.py +reach_target_dual,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,58,8,119,101000,3.41,182509,12503936,54014,scored,policies/reach_target_dual/gpt6sol-s2/policy.py +reach_target_dual,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,20,9,97,100329,3.66,212669,12790144,67186,scored,policies/reach_target_dual/gpt6sol-s3/policy.py +reach_target_multi_modal,core,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,73,6,73,100221,1.16,84385,3576320,27682,scored,policies/reach_target_multi_modal/gpt6sol-s1/policy.py +reach_target_multi_modal,core,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,86,7,88,100444,1.32,83615,4431872,26896,scored,policies/reach_target_multi_modal/gpt6sol-s2/policy.py +reach_target_multi_modal,core,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,default,99,11,98,100197,1.22,88363,3609344,31930,scored,policies/reach_target_multi_modal/gpt6sol-s3/policy.py +dishwasher_load_cutlery,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,1,4,142,100387,4.0,377518,13077632,63228,scored,policies/dishwasher_load_cutlery/gpt6sol-s1/policy.py +dishwasher_load_cutlery,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,2,107,100882,4.05,248219,15073152,53917,scored,policies/dishwasher_load_cutlery/gpt6sol-s2/policy.py +dishwasher_load_cutlery,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,2,97,100909,4.39,384367,14751488,66674,scored,policies/dishwasher_load_cutlery/gpt6sol-s3/policy.py +dishwasher_load_plates,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,3,115,100717,4.82,227375,18108288,74773,scored,policies/dishwasher_load_plates/gpt6sol-s1/policy.py +dishwasher_load_plates,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,4,63,100485,3.42,151079,12883840,54030,scored,policies/dishwasher_load_plates/gpt6sol-s2/policy.py +dishwasher_load_plates,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,6,116,100705,3.69,208885,12863104,69497,scored,policies/dishwasher_load_plates/gpt6sol-s3/policy.py +flip_cup,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,5,131,100344,7.09,219927,29419136,76484,scored,policies/flip_cup/gpt6sol-s1/policy.py +flip_cup,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,1,3,109,100805,6.8,436842,26130688,70005,scored,policies/flip_cup/gpt6sol-s2/policy.py +flip_cup,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,1,3,34,100798,2.0,178660,6027392,44013,scored,policies/flip_cup/gpt6sol-s3/policy.py +flip_cutlery,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,2,119,100806,4.76,411860,15615616,81550,scored,policies/flip_cutlery/gpt6sol-s1/policy.py +flip_cutlery,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,2,2,109,100527,4.49,185591,17486592,61752,scored,policies/flip_cutlery/gpt6sol-s2/policy.py +flip_cutlery,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,1,3,108,99050,2.53,161526,8312192,54394,scored,policies/flip_cutlery/gpt6sol-s3/policy.py +put_cups,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,6,97,100128,7.07,458834,26926464,76592,scored,policies/put_cups/gpt6sol-s1/policy.py +put_cups,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,1,159,100557,6.21,256511,23709184,95621,scored,policies/put_cups/gpt6sol-s2/policy.py +put_cups,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,3,154,100985,7.04,454176,25980544,93369,scored,policies/put_cups/gpt6sol-s3/policy.py +reach_target_single,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,80,4,70,100272,1.74,121422,5645056,36639,scored,policies/reach_target_single/gpt6sol-s1/policy.py +reach_target_single,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,53,3,98,100493,1.5,101846,4487552,39586,scored,policies/reach_target_single/gpt6sol-s2/policy.py +reach_target_single,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,50,3,83,100972,0.76,64388,1802624,27186,scored,policies/reach_target_single/gpt6sol-s3/policy.py +sandwich_remove,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,1,81,100644,3.41,199414,12395008,52881,scored,policies/sandwich_remove/gpt6sol-s1/policy.py +sandwich_remove,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,3,89,100662,10.56,514886,41831680,116536,scored,policies/sandwich_remove/gpt6sol-s2/policy.py +sandwich_remove,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,3,81,100511,6.89,524306,24896640,86701,scored,policies/sandwich_remove/gpt6sol-s3/policy.py +saucepan_to_hob,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,4,133,100955,7.94,251222,33142528,81107,scored,policies/saucepan_to_hob/gpt6sol-s1/policy.py +saucepan_to_hob,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,1,125,100868,2.81,187305,9603968,51104,scored,policies/saucepan_to_hob/gpt6sol-s2/policy.py +saucepan_to_hob,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,1,87,100990,3.37,161874,12737664,49443,scored,policies/saucepan_to_hob/gpt6sol-s3/policy.py +stack_blocks,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,8,198,100696,8.83,402316,35649408,89532,scored,policies/stack_blocks/gpt6sol-s1/policy.py +stack_blocks,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,4,156,99720,4.33,168357,17058048,57992,scored,policies/stack_blocks/gpt6sol-s2/policy.py +stack_blocks,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,2,138,100906,2.02,122265,6534784,47156,scored,policies/stack_blocks/gpt6sol-s3/policy.py +wall_cupboard_close,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,100,1,43,100581,1.53,130902,4572160,35170,scored,policies/wall_cupboard_close/gpt6sol-s1/policy.py +wall_cupboard_close,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,100,1,32,54886,0.93,125723,2324480,21411,scored,policies/wall_cupboard_close/gpt6sol-s2/policy.py +wall_cupboard_close,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,2,95,100325,1.93,131797,6223360,41939,scored,policies/wall_cupboard_close/gpt6sol-s3/policy.py +wall_cupboard_open,extended,gpt6sol-s1,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,2,72,100870,7.85,799166,27047424,84150,scored,policies/wall_cupboard_open/gpt6sol-s1/policy.py +wall_cupboard_open,extended,gpt6sol-s2,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,3,36,101000,3.41,192374,11239040,77915,scored,policies/wall_cupboard_open/gpt6sol-s2/policy.py +wall_cupboard_open,extended,gpt6sol-s3,gpt6sol,GPT-6 Sol,Codex CLI,codex-cli 0.157.1,high,fast,0,5,17,100975,2.77,150400,9276544,61839,scored,policies/wall_cupboard_open/gpt6sol-s3/policy.py +dishwasher_close,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,36,157,100835,3.21,403847,14552576,94590,scored,policies/dishwasher_close/gpt61sol-s1/policy.py +dishwasher_close,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,5,78,100981,2.09,254597,8151936,76960,scored,policies/dishwasher_close/gpt61sol-s2/policy.py +dishwasher_close,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,5,105,100633,2.06,202973,10248832,63385,scored,policies/dishwasher_close/gpt61sol-s3/policy.py +dishwasher_load_cups,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,36,8,77,100347,2.14,288298,9871488,57553,scored,policies/dishwasher_load_cups/gpt61sol-s1/policy.py +dishwasher_load_cups,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,2,19,120,100802,1.64,133539,7979264,57502,scored,policies/dishwasher_load_cups/gpt61sol-s2/policy.py +dishwasher_load_cups,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,15,17,125,100795,2.65,227970,14738560,71873,scored,policies/dishwasher_load_cups/gpt61sol-s3/policy.py +drawer_top_close,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,2,19,48565,0.25,53328,903552,5105,scored,policies/drawer_top_close/gpt61sol-s1/policy.py +drawer_top_close,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,2,22,96213,0.3,57390,1171072,6555,scored,policies/drawer_top_close/gpt61sol-s2/policy.py +drawer_top_close,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,1,41,60843,0.34,57363,1253760,10196,scored,policies/drawer_top_close/gpt61sol-s3/policy.py +drawer_top_open,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,40,13,98,100982,0.82,125696,3659520,20308,scored,policies/drawer_top_open/gpt61sol-s1/policy.py +drawer_top_open,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,3,66,88613,0.74,98223,3186688,22662,scored,policies/drawer_top_open/gpt61sol-s2/policy.py +drawer_top_open,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,34,15,34,101000,1.25,181377,5928320,29194,scored,policies/drawer_top_open/gpt61sol-s3/policy.py +move_plate,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,7,4,99,100932,0.96,103511,4179712,33695,scored,policies/move_plate/gpt61sol-s1/policy.py +move_plate,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,2,151,100960,0.95,103347,3928192,34967,scored,policies/move_plate/gpt61sol-s2/policy.py +move_plate,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,17,7,38,101000,0.73,87638,2978176,25286,scored,policies/move_plate/gpt61sol-s3/policy.py +move_two_plates,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,17,153,100954,2.28,227069,10540800,76836,scored,policies/move_two_plates/gpt61sol-s1/policy.py +move_two_plates,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,8,22,144,101000,1.57,152675,7315456,53682,scored,policies/move_two_plates/gpt61sol-s2/policy.py +move_two_plates,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,34,67,100991,2.15,196180,11639296,58872,scored,policies/move_two_plates/gpt61sol-s3/policy.py +pick_box,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,2,94,100945,0.88,98715,4099840,27470,scored,policies/pick_box/gpt61sol-s1/policy.py +pick_box,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,52,14,92,101000,1.23,162806,5624576,34502,scored,policies/pick_box/gpt61sol-s2/policy.py +pick_box,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,2,172,100492,2.33,187656,13785088,57426,scored,policies/pick_box/gpt61sol-s3/policy.py +reach_target_dual,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,82,12,170,101000,1.09,130332,3925504,44108,scored,policies/reach_target_dual/gpt61sol-s1/policy.py +reach_target_dual,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,61,13,140,100760,0.76,103112,2719104,28392,scored,policies/reach_target_dual/gpt61sol-s2/policy.py +reach_target_dual,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,66,9,113,99489,0.58,81897,2347776,18214,scored,policies/reach_target_dual/gpt61sol-s3/policy.py +reach_target_multi_modal,core,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,81,11,153,100861,0.93,116455,3386240,35549,scored,policies/reach_target_multi_modal/gpt61sol-s1/policy.py +reach_target_multi_modal,core,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,97,9,152,100752,1.07,179517,3396608,37570,scored,policies/reach_target_multi_modal/gpt61sol-s2/policy.py +reach_target_multi_modal,core,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,14,152,100045,0.66,86235,3200128,17112,scored,policies/reach_target_multi_modal/gpt61sol-s3/policy.py +dishwasher_load_cutlery,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,21,106,100947,2.45,208559,12400768,79521,scored,policies/dishwasher_load_cutlery/gpt61sol-s1/policy.py +dishwasher_load_cutlery,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,12,91,101000,4.03,441517,21943680,94872,scored,policies/dishwasher_load_cutlery/gpt61sol-s2/policy.py +dishwasher_load_cutlery,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,11,58,100971,2.22,280522,8884224,77315,scored,policies/dishwasher_load_cutlery/gpt61sol-s3/policy.py +dishwasher_load_plates,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,7,98,100875,2.12,186222,10526336,69453,scored,policies/dishwasher_load_plates/gpt61sol-s1/policy.py +dishwasher_load_plates,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,8,132,100854,2.08,179783,11737472,54435,scored,policies/dishwasher_load_plates/gpt61sol-s2/policy.py +dishwasher_load_plates,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,2,5,94,100797,2.41,180521,13691776,68193,scored,policies/dishwasher_load_plates/gpt61sol-s3/policy.py +flip_cup,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,23,12,137,100051,1.15,172849,4176384,38683,scored,policies/flip_cup/gpt61sol-s1/policy.py +flip_cup,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,51,16,100,101000,1.69,258739,6592768,51194,scored,policies/flip_cup/gpt61sol-s2/policy.py +flip_cup,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,4,70,100916,1.44,150848,6722688,46738,scored,policies/flip_cup/gpt61sol-s3/policy.py +flip_cutlery,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,1,11,115,100998,2.16,187832,12233728,56551,scored,policies/flip_cutlery/gpt61sol-s1/policy.py +flip_cutlery,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,12,9,95,101000,2.92,239592,17344640,70835,scored,policies/flip_cutlery/gpt61sol-s2/policy.py +flip_cutlery,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,1,7,305,100626,2.24,217621,11378816,67081,scored,policies/flip_cutlery/gpt61sol-s3/policy.py +put_cups,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,7,155,100990,4.49,611624,22465664,102164,scored,policies/put_cups/gpt61sol-s1/policy.py +put_cups,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,15,182,100980,3.17,341232,13551744,112939,scored,policies/put_cups/gpt61sol-s2/policy.py +put_cups,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,18,169,101000,3.36,570837,11331072,108346,scored,policies/put_cups/gpt61sol-s3/policy.py +reach_target_single,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,84,9,135,100774,1.23,133084,5763328,38581,scored,policies/reach_target_single/gpt61sol-s1/policy.py +reach_target_single,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,97,6,68,100707,0.72,95406,3347072,19761,scored,policies/reach_target_single/gpt61sol-s2/policy.py +reach_target_single,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,97,9,115,100449,0.7,75292,2892672,25897,scored,policies/reach_target_single/gpt61sol-s3/policy.py +sandwich_remove,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,4,78,100969,1.44,170874,5327616,56837,scored,policies/sandwich_remove/gpt61sol-s1/policy.py +sandwich_remove,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,8,232,100977,5.8,576813,32899968,136127,scored,policies/sandwich_remove/gpt61sol-s2/policy.py +sandwich_remove,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,1,6,81,100933,3.41,503712,16425600,76320,scored,policies/sandwich_remove/gpt61sol-s3/policy.py +saucepan_to_hob,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,75,12,117,100167,2.41,191107,15502976,47427,scored,policies/saucepan_to_hob/gpt61sol-s1/policy.py +saucepan_to_hob,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,19,107,100974,7.23,680154,42682624,160635,scored,policies/saucepan_to_hob/gpt61sol-s2/policy.py +saucepan_to_hob,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,13,85,100804,5.08,544349,28178688,117573,scored,policies/saucepan_to_hob/gpt61sol-s3/policy.py +stack_blocks,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,19,207,100845,1.25,129108,5636096,42450,scored,policies/stack_blocks/gpt61sol-s1/policy.py +stack_blocks,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,1,8,123,100909,1.29,175139,5038464,43971,scored,policies/stack_blocks/gpt61sol-s2/policy.py +stack_blocks,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,0,18,162,100988,3.53,395041,19723136,77116,scored,policies/stack_blocks/gpt61sol-s3/policy.py +wall_cupboard_close,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,2,34,53040,0.38,102671,1021056,6882,scored,policies/wall_cupboard_close/gpt61sol-s1/policy.py +wall_cupboard_close,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,1,36,74285,0.37,62738,1461760,10092,scored,policies/wall_cupboard_close/gpt61sol-s2/policy.py +wall_cupboard_close,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,1,44,77046,0.61,94356,2283776,19105,scored,policies/wall_cupboard_close/gpt61sol-s3/policy.py +wall_cupboard_open,extended,gpt61sol-s1,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,9,92,100268,1.4,150676,6042496,49511,scored,policies/wall_cupboard_open/gpt61sol-s1/policy.py +wall_cupboard_open,extended,gpt61sol-s2,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,16,59,100544,1.52,159271,7363456,46579,scored,policies/wall_cupboard_open/gpt61sol-s2/policy.py +wall_cupboard_open,extended,gpt61sol-s3,gpt61sol,GPT-6.1 Sol,Codex CLI,codex-cli 0.160.0,high,default,100,23,67,100806,2.97,542669,10807040,80620,scored,policies/wall_cupboard_open/gpt61sol-s3/policy.py +dishwasher_close,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,3,172,99479,25.84,2638836,92998447,196433,scored,policies/dishwasher_close/kimi31pro-s1/policy.py +dishwasher_close,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,44,107,100834,12.87,1465462,41783683,158143,scored,policies/dishwasher_close/kimi31pro-s2/policy.py +dishwasher_close,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,21,103,97720,10.08,1367379,32126991,92343,scored,policies/dishwasher_close/kimi31pro-s3/policy.py +dishwasher_load_cups,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,4,51,258,99173,7.81,1048849,22731868,116620,scored,policies/dishwasher_load_cups/kimi31pro-s1/policy.py +dishwasher_load_cups,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,2,120,100826,10.32,1374067,31828546,121017,scored,policies/dishwasher_load_cups/kimi31pro-s2/policy.py +dishwasher_load_cups,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,6,191,100984,33.9,2141360,135555878,250753,scored,policies/dishwasher_load_cups/kimi31pro-s3/policy.py +drawer_top_close,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,100,10,37,47126,1.78,171714,5251772,38632,scored,policies/drawer_top_close/kimi31pro-s1/policy.py +drawer_top_close,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,22,1,93,100990,4.2,477519,11684633,90526,scored,policies/drawer_top_close/kimi31pro-s2/policy.py +drawer_top_close,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,47,2,12,27480,2.54,344588,7268434,39595,scored,policies/drawer_top_close/kimi31pro-s3/policy.py +drawer_top_open,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,1,143,100160,21.51,1624586,82815037,170160,scored,policies/drawer_top_open/kimi31pro-s1/policy.py +drawer_top_open,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,84,16,178,100740,7.75,1072686,23228374,95990,scored,policies/drawer_top_open/kimi31pro-s2/policy.py +drawer_top_open,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,16,2,67,100090,13.82,1189909,48440339,175430,scored,policies/drawer_top_open/kimi31pro-s3/policy.py +move_plate,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,2,169,100456,12.53,1376250,41738450,142781,scored,policies/move_plate/kimi31pro-s1/policy.py +move_plate,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,6,145,101000,10.54,2195146,25647472,102360,scored,policies/move_plate/kimi31pro-s2/policy.py +move_plate,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,4,137,100505,6.37,692320,19870710,100816,scored,policies/move_plate/kimi31pro-s3/policy.py +move_two_plates,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,2,123,100982,19.54,1571399,74601158,147398,scored,policies/move_two_plates/kimi31pro-s1/policy.py +move_two_plates,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,3,113,99933,11.74,993052,42926281,116768,scored,policies/move_two_plates/kimi31pro-s2/policy.py +move_two_plates,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,14,165,75520,20.12,7076912,29820431,0,scored,policies/move_two_plates/kimi31pro-s3/policy.py +pick_box,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,2,175,101000,11.12,1343697,35017296,143024,scored,policies/pick_box/kimi31pro-s1/policy.py +pick_box,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,2,302,99306,17.65,1551173,65500939,144739,scored,policies/pick_box/kimi31pro-s2/policy.py +pick_box,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,2,196,100770,10.07,1063395,33441344,125604,scored,policies/pick_box/kimi31pro-s3/policy.py +reach_target_dual,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,1,176,100996,18.23,578494,75117705,205298,scored,policies/reach_target_dual/kimi31pro-s1/policy.py +reach_target_dual,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,7,2,109,100743,8.68,272686,34333818,126815,scored,policies/reach_target_dual/kimi31pro-s2/policy.py +reach_target_dual,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,48,18,157,96196,10.13,1624501,29532872,97779,scored,policies/reach_target_dual/kimi31pro-s3/policy.py +reach_target_multi_modal,core,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,100,2,133,61407,3.24,237188,10691400,63080,scored,policies/reach_target_multi_modal/kimi31pro-s1/policy.py +reach_target_multi_modal,core,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,59,21,134,100592,7.67,698839,24789431,131623,scored,policies/reach_target_multi_modal/kimi31pro-s2/policy.py +reach_target_multi_modal,core,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,87,18,151,90814,7.98,1040095,24828078,93330,scored,policies/reach_target_multi_modal/kimi31pro-s3/policy.py +dishwasher_load_cutlery,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,,,821,0.1918,42861,219392,6218,"void: the submission is the untouched template, byte for byte", +dishwasher_load_cutlery,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,1,3,147,100785,12.91,1447603,43324273,134620,scored,policies/dishwasher_load_cutlery/kimi31pro-s2/policy.py +dishwasher_load_cutlery,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,2,4,97,100494,8.18,1449313,21729425,93508,scored,policies/dishwasher_load_cutlery/kimi31pro-s3/policy.py +dishwasher_load_plates,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,58,147,99711,15.27,1417903,54830037,146869,scored,policies/dishwasher_load_plates/kimi31pro-s1/policy.py +dishwasher_load_plates,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,5,159,100974,13.19,1323105,46738979,119289,scored,policies/dishwasher_load_plates/kimi31pro-s2/policy.py +dishwasher_load_plates,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,24,182,100972,14.39,1497896,51333817,112691,scored,policies/dishwasher_load_plates/kimi31pro-s3/policy.py +flip_cup,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,16,24,251,100424,23.04,2264885,82605124,199038,scored,policies/flip_cup/kimi31pro-s1/policy.py +flip_cup,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,4,119,100526,8.48,1449193,22994743,98569,scored,policies/flip_cup/kimi31pro-s2/policy.py +flip_cup,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,6,171,100360,16.16,1593746,55952345,178175,scored,policies/flip_cup/kimi31pro-s3/policy.py +flip_cutlery,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,3,77,101000,18.33,1616796,67391437,161848,scored,policies/flip_cutlery/kimi31pro-s1/policy.py +flip_cutlery,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,2,157,100032,16.57,2342684,52061947,147298,scored,policies/flip_cutlery/kimi31pro-s2/policy.py +flip_cutlery,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,4,213,100904,14.76,1638935,52125966,105456,scored,policies/flip_cutlery/kimi31pro-s3/policy.py +put_cups,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,4,160,101000,21.58,2156299,76760386,191187,scored,policies/put_cups/kimi31pro-s1/policy.py +put_cups,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,15,221,100964,33.21,2265763,133290768,201760,scored,policies/put_cups/kimi31pro-s2/policy.py +put_cups,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,,,82240,19.5631,2451637,73299331,0,"void: the submission is the untouched template, byte for byte", +reach_target_single,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,55,19,98,100554,5.68,468778,18708216,100362,scored,policies/reach_target_single/kimi31pro-s1/policy.py +reach_target_single,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,82,14,97,101000,4.02,722904,10301131,51849,scored,policies/reach_target_single/kimi31pro-s2/policy.py +reach_target_single,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,77,41,256,100787,6.74,519030,23842406,93519,scored,policies/reach_target_single/kimi31pro-s3/policy.py +sandwich_remove,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,,,100441,37.3048,3360394,144788284,162634,void: no scorable program, +sandwich_remove,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,3,82,100779,20.24,2248109,71117595,152507,scored,policies/sandwich_remove/kimi31pro-s2/policy.py +sandwich_remove,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,,,23434,10.1799,964302,36613602,92855,"void: the submission is the untouched template, byte for byte", +saucepan_to_hob,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,,,89074,19.8253,1996139,79165191,0,"void: the submission is the untouched template, byte for byte", +saucepan_to_hob,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,,,52447,31.0943,2849385,126977835,0,"void: the submission is the untouched template, byte for byte", +saucepan_to_hob,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,4,174,101000,19.42,1539782,73384258,165937,scored,policies/saucepan_to_hob/kimi31pro-s3/policy.py +stack_blocks,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,20,379,100980,15.31,1857221,52029868,118615,scored,policies/stack_blocks/kimi31pro-s1/policy.py +stack_blocks,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,10,243,100913,11.39,994472,41168132,116345,scored,policies/stack_blocks/kimi31pro-s2/policy.py +stack_blocks,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,20,247,100754,9.52,1438339,26497118,134111,scored,policies/stack_blocks/kimi31pro-s3/policy.py +wall_cupboard_close,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,100,3,87,101000,10.77,1449393,32198873,143605,scored,policies/wall_cupboard_close/kimi31pro-s1/policy.py +wall_cupboard_close,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,100,3,107,99527,14.37,1372206,51855060,125606,scored,policies/wall_cupboard_close/kimi31pro-s2/policy.py +wall_cupboard_close,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,5,60,100150,13.85,474662,59318197,103372,scored,policies/wall_cupboard_close/kimi31pro-s3/policy.py +wall_cupboard_open,extended,kimi31pro-s1,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,5,211,100988,24.33,1806666,94241616,186347,scored,policies/wall_cupboard_open/kimi31pro-s1/policy.py +wall_cupboard_open,extended,kimi31pro-s2,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,100,2,130,100665,21.41,1649981,83226309,146548,scored,policies/wall_cupboard_open/kimi31pro-s2/policy.py +wall_cupboard_open,extended,kimi31pro-s3,kimi31pro,Kimi K3.1 Pro,Claude Code,2.1.280 (Claude Code),max,default,0,10,113,100691,19.98,1683608,74864319,163777,scored,policies/wall_cupboard_open/kimi31pro-s3/policy.py +dishwasher_close,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,201,101000,0.39,204589,69002240,255874,scored,policies/dishwasher_close/deepseek1017-s1/policy.py +dishwasher_close,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,11,230,94732,0.37,184656,57161216,281094,scored,policies/dishwasher_close/deepseek1017-s2/policy.py +dishwasher_close,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,4,246,100713,0.35,146458,59107200,258764,scored,policies/dishwasher_close/deepseek1017-s3/policy.py +dishwasher_load_cups,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,111,100884,0.54,226126,98663040,346425,scored,policies/dishwasher_load_cups/deepseek1017-s1/policy.py +dishwasher_load_cups,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,13,168,100957,0.42,198063,70754688,295829,scored,policies/dishwasher_load_cups/deepseek1017-s2/policy.py +dishwasher_load_cups,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,157,99643,0.42,171957,66204928,321972,scored,policies/dishwasher_load_cups/deepseek1017-s3/policy.py +drawer_top_close,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,99,6,112,100839,0.1,84497,8438400,105770,scored,policies/drawer_top_close/deepseek1017-s1/policy.py +drawer_top_close,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,91,4,141,94881,0.29,126286,35281920,277891,scored,policies/drawer_top_close/deepseek1017-s2/policy.py +drawer_top_close,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,99,1,45,75732,0.17,115825,20380800,157577,scored,policies/drawer_top_close/deepseek1017-s3/policy.py +drawer_top_open,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,174,100980,0.28,145982,36591872,252743,scored,policies/drawer_top_open/deepseek1017-s1/policy.py +drawer_top_open,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,4,187,101000,0.32,178503,44942848,256281,scored,policies/drawer_top_open/deepseek1017-s2/policy.py +drawer_top_open,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,3,197,100642,0.34,164202,52971518,265152,scored,policies/drawer_top_open/deepseek1017-s3/policy.py +move_plate,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,211,101000,0.4,207672,62723840,303746,scored,policies/move_plate/deepseek1017-s1/policy.py +move_plate,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,182,100180,0.49,567149,76743552,298932,scored,policies/move_plate/deepseek1017-s2/policy.py +move_plate,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,3,133,96151,0.4,186296,67842048,274474,scored,policies/move_plate/deepseek1017-s3/policy.py +move_two_plates,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,3,270,76987,0.45,327873,85036416,241065,scored,policies/move_two_plates/deepseek1017-s1/policy.py +move_two_plates,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,,,40703,0.2219,152753,26107648,201073,"void: the submission is the untouched template, byte for byte", +move_two_plates,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,3,145,68182,0.38,198103,61976960,266211,scored,policies/move_two_plates/deepseek1017-s3/policy.py +pick_box,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,219,99654,0.38,188495,54425472,313074,scored,policies/pick_box/deepseek1017-s1/policy.py +pick_box,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,12,393,98395,0.28,182161,32797056,261412,scored,policies/pick_box/deepseek1017-s2/policy.py +pick_box,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,,,7501,0.0389,44047,3133952,38175,"void: the submission is the untouched template, byte for byte", +reach_target_dual,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,190,98640,0.36,134260,44014208,342111,scored,policies/reach_target_dual/deepseek1017-s1/policy.py +reach_target_dual,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,20,14,268,99709,0.24,110742,23923200,258267,scored,policies/reach_target_dual/deepseek1017-s2/policy.py +reach_target_dual,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,35,8,124,100008,0.33,178787,43235456,296723,scored,policies/reach_target_dual/deepseek1017-s3/policy.py +reach_target_multi_modal,core,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,63,721,0,0.3,118122,40599808,274976,scored,policies/reach_target_multi_modal/deepseek1017-s1/policy.py +reach_target_multi_modal,core,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,10,26,862,0,0.19,82518,17546880,215648,scored,policies/reach_target_multi_modal/deepseek1017-s2/policy.py +reach_target_multi_modal,core,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,1,35,814,0,0.19,118697,19942784,194487,scored,policies/reach_target_multi_modal/deepseek1017-s3/policy.py +dishwasher_load_cutlery,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,50,573,0,0.25,147283,31369472,217120,scored,policies/dishwasher_load_cutlery/deepseek1017-s1/policy.py +dishwasher_load_cutlery,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,27,822,0,0.23,104908,23742208,240090,scored,policies/dishwasher_load_cutlery/deepseek1017-s2/policy.py +dishwasher_load_cutlery,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,32,355,0,0.28,131116,42646912,224315,scored,policies/dishwasher_load_cutlery/deepseek1017-s3/policy.py +dishwasher_load_plates,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,20,405,0,0.16,111802,17052288,145445,scored,policies/dishwasher_load_plates/deepseek1017-s1/policy.py +dishwasher_load_plates,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,28,664,0,0.17,106315,14820992,180846,scored,policies/dishwasher_load_plates/deepseek1017-s2/policy.py +dishwasher_load_plates,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,15,308,0,0.2,101588,24100608,182959,scored,policies/dishwasher_load_plates/deepseek1017-s3/policy.py +flip_cup,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,1,220,89712,0.36,198883,57252992,269053,scored,policies/flip_cup/deepseek1017-s1/policy.py +flip_cup,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,289,101000,0.37,153283,46425344,338559,scored,policies/flip_cup/deepseek1017-s2/policy.py +flip_cup,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,4,364,98663,0.43,208183,79748608,261940,scored,policies/flip_cup/deepseek1017-s3/policy.py +flip_cutlery,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,4,123,100834,0.37,176180,67763840,237990,scored,policies/flip_cutlery/deepseek1017-s1/policy.py +flip_cutlery,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,12,376,84990,0.33,179809,50946560,258173,scored,policies/flip_cutlery/deepseek1017-s2/policy.py +flip_cutlery,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,9,275,69176,0.34,153510,48504960,280593,scored,policies/flip_cutlery/deepseek1017-s3/policy.py +put_cups,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,4,211,97878,0.41,192879,69361920,293616,scored,policies/put_cups/deepseek1017-s1/policy.py +put_cups,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,13,175,97890,0.53,185285,92579328,374570,scored,policies/put_cups/deepseek1017-s2/policy.py +put_cups,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,4,160,99516,0.33,159376,52464512,254944,scored,policies/put_cups/deepseek1017-s3/policy.py +reach_target_single,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,61,6,279,101000,0.22,157419,25130624,195171,scored,policies/reach_target_single/deepseek1017-s1/policy.py +reach_target_single,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,24,17,203,99324,0.42,220768,58817792,346202,scored,policies/reach_target_single/deepseek1017-s2/policy.py +reach_target_single,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,96,7,193,100791,0.17,125264,14373248,184587,scored,policies/reach_target_single/deepseek1017-s3/policy.py +sandwich_remove,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,3,191,100534,0.33,150285,46318848,280017,scored,policies/sandwich_remove/deepseek1017-s1/policy.py +sandwich_remove,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,2,162,95147,0.55,232599,100829824,362609,scored,policies/sandwich_remove/deepseek1017-s2/policy.py +sandwich_remove,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,10,287,91722,0.36,213255,56174976,258989,scored,policies/sandwich_remove/deepseek1017-s3/policy.py +saucepan_to_hob,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,357,100792,0.4,176679,70610176,274608,scored,policies/saucepan_to_hob/deepseek1017-s1/policy.py +saucepan_to_hob,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,4,292,99505,0.41,193278,68477440,289438,scored,policies/saucepan_to_hob/deepseek1017-s2/policy.py +saucepan_to_hob,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,7,299,99986,0.4,225951,62242304,293726,scored,policies/saucepan_to_hob/deepseek1017-s3/policy.py +stack_blocks,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,7,311,101000,0.25,130863,30753152,235879,scored,policies/stack_blocks/deepseek1017-s1/policy.py +stack_blocks,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,303,100764,0.28,155075,36112512,252010,scored,policies/stack_blocks/deepseek1017-s2/policy.py +stack_blocks,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,11,236,97363,0.33,143559,48217728,268558,scored,policies/stack_blocks/deepseek1017-s3/policy.py +wall_cupboard_close,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,3,149,100068,0.36,172993,47115776,322495,scored,policies/wall_cupboard_close/deepseek1017-s1/policy.py +wall_cupboard_close,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,100,1,122,93791,0.34,152725,51454464,263385,scored,policies/wall_cupboard_close/deepseek1017-s2/policy.py +wall_cupboard_close,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,3,182,95457,0.43,189866,60228352,370109,scored,policies/wall_cupboard_close/deepseek1017-s3/policy.py +wall_cupboard_open,extended,deepseek1017-s1,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,5,225,100539,0.47,206259,76819968,342657,scored,policies/wall_cupboard_open/deepseek1017-s1/policy.py +wall_cupboard_open,extended,deepseek1017-s2,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,4,119,86678,0.57,287459,105897728,354574,scored,policies/wall_cupboard_open/deepseek1017-s2/policy.py +wall_cupboard_open,extended,deepseek1017-s3,deepseek1017,DeepSeek V4.1 Flash (1017),DeepSeek CLI (dsh),0.2.1-rc.2,max,default,0,6,119,101000,0.46,191728,72174976,358948,scored,policies/wall_cupboard_open/deepseek1017-s3/policy.py +dishwasher_close,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,3,54,98701,0.68,223622,6669056,25348,scored,policies/dishwasher_close/gpt61terra-s1/policy.py +dishwasher_close,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,74,96350,1.07,185708,14334720,32671,scored,policies/dishwasher_close/gpt61terra-s2/policy.py +dishwasher_close,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,4,47,100780,0.96,104394,13574144,34402,scored,policies/dishwasher_close/gpt61terra-s3/policy.py +dishwasher_load_cups,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,1,68,30927,0.49,106260,6052992,16980,scored,policies/dishwasher_load_cups/gpt61terra-s1/policy.py +dishwasher_load_cups,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,3,44,34530,0.47,115270,5379712,17328,scored,policies/dishwasher_load_cups/gpt61terra-s2/policy.py +dishwasher_load_cups,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,36,7,43,87426,1.12,211917,15364864,28831,scored,policies/dishwasher_load_cups/gpt61terra-s3/policy.py +drawer_top_close,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,70,4,17,101000,0.24,66134,2510464,10387,scored,policies/drawer_top_close/gpt61terra-s1/policy.py +drawer_top_close,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,88,6,16,97369,0.27,67925,3137920,8580,scored,policies/drawer_top_close/gpt61terra-s2/policy.py +drawer_top_close,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,81,5,15,97928,0.25,49107,3182464,9257,scored,policies/drawer_top_close/gpt61terra-s3/policy.py +drawer_top_open,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,100,4,37,100418,0.47,128277,4772864,19997,scored,policies/drawer_top_open/gpt61terra-s1/policy.py +drawer_top_open,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,37,100934,0.5,87065,6531072,17661,scored,policies/drawer_top_open/gpt61terra-s2/policy.py +drawer_top_open,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,27,5,46,101000,0.83,177732,10476928,25999,scored,policies/drawer_top_open/gpt61terra-s3/policy.py +move_plate,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,3,2,38,100751,0.46,98398,5232768,19043,scored,policies/move_plate/gpt61terra-s1/policy.py +move_plate,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,56,98241,0.8,116997,10929280,27762,scored,policies/move_plate/gpt61terra-s2/policy.py +move_plate,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,1,6,31,99847,0.66,91464,8794880,25468,scored,policies/move_plate/gpt61terra-s3/policy.py +move_two_plates,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,1,59,100920,0.58,112054,7130624,22364,scored,policies/move_two_plates/gpt61terra-s1/policy.py +move_two_plates,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,3,70,98195,0.98,168479,13447040,27076,scored,policies/move_two_plates/gpt61terra-s2/policy.py +move_two_plates,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,5,11,52,99784,1.03,145823,14936320,27246,scored,policies/move_two_plates/gpt61terra-s3/policy.py +pick_box,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,3,4,37,101000,0.79,153827,10743040,20264,scored,policies/pick_box/gpt61terra-s1/policy.py +pick_box,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,8,6,35,100837,0.67,119766,8539776,24597,scored,policies/pick_box/gpt61terra-s2/policy.py +pick_box,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,6,110,94000,1.19,176197,17336320,30040,scored,policies/pick_box/gpt61terra-s3/policy.py +reach_target_dual,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,67,7,54,96185,0.44,137351,4476672,15883,scored,policies/reach_target_dual/gpt61terra-s1/policy.py +reach_target_dual,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,34,6,57,98847,0.72,131414,8145920,35830,scored,policies/reach_target_dual/gpt61terra-s2/policy.py +reach_target_dual,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,34,8,63,100905,0.66,171551,7149184,26445,scored,policies/reach_target_dual/gpt61terra-s3/policy.py +reach_target_multi_modal,core,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,86,7,66,100097,0.42,101419,4562560,17918,scored,policies/reach_target_multi_modal/gpt61terra-s1/policy.py +reach_target_multi_modal,core,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,84,6,28,100916,0.48,69440,6277248,19104,scored,policies/reach_target_multi_modal/gpt61terra-s2/policy.py +reach_target_multi_modal,core,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,46,10,45,100242,0.56,116136,6442624,23939,scored,policies/reach_target_multi_modal/gpt61terra-s3/policy.py +dishwasher_load_cutlery,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,1,3,71,82391,0.98,156026,13393280,31086,scored,policies/dishwasher_load_cutlery/gpt61terra-s1/policy.py +dishwasher_load_cutlery,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,48,21947,0.29,70957,2932864,13523,scored,policies/dishwasher_load_cutlery/gpt61terra-s2/policy.py +dishwasher_load_cutlery,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,67,99850,1.36,379275,15532288,40728,scored,policies/dishwasher_load_cutlery/gpt61terra-s3/policy.py +dishwasher_load_plates,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,14,44,90029,0.75,90559,10237824,28764,scored,policies/dishwasher_load_plates/gpt61terra-s1/policy.py +dishwasher_load_plates,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,7,71,83599,0.84,125740,11471616,28697,scored,policies/dishwasher_load_plates/gpt61terra-s2/policy.py +dishwasher_load_plates,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,7,56,99279,0.93,166678,12973696,23863,scored,policies/dishwasher_load_plates/gpt61terra-s3/policy.py +flip_cup,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,4,61,100613,0.71,102528,8874112,32701,scored,policies/flip_cup/gpt61terra-s1/policy.py +flip_cup,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,65,100522,0.67,95250,9125504,23874,scored,policies/flip_cup/gpt61terra-s2/policy.py +flip_cup,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,11,5,62,99768,0.74,208184,8265472,22878,scored,policies/flip_cup/gpt61terra-s3/policy.py +flip_cutlery,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,3,3,80,95340,0.78,113036,10792448,24865,scored,policies/flip_cutlery/gpt61terra-s1/policy.py +flip_cutlery,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,90,99755,0.64,96904,8498432,23176,scored,policies/flip_cutlery/gpt61terra-s2/policy.py +flip_cutlery,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,1,37,99228,0.63,158757,6823680,25373,scored,policies/flip_cutlery/gpt61terra-s3/policy.py +put_cups,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,4,49,96760,0.54,86884,6914176,21985,scored,policies/put_cups/gpt61terra-s1/policy.py +put_cups,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,15,62,98660,0.64,96275,7722752,30687,scored,policies/put_cups/gpt61terra-s2/policy.py +put_cups,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,40,12940,0.25,61814,2774528,10661,scored,policies/put_cups/gpt61terra-s3/policy.py +reach_target_single,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,30,6,29,100406,0.33,61329,3848960,14967,scored,policies/reach_target_single/gpt61terra-s1/policy.py +reach_target_single,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,66,6,34,101000,0.3,93833,2734592,14649,scored,policies/reach_target_single/gpt61terra-s2/policy.py +reach_target_single,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,78,4,91,100112,0.4,94014,4663552,15357,scored,policies/reach_target_single/gpt61terra-s3/policy.py +sandwich_remove,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,43,94222,0.76,117504,10146432,27209,scored,policies/sandwich_remove/gpt61terra-s1/policy.py +sandwich_remove,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,33,57777,0.54,123946,6094080,22380,scored,policies/sandwich_remove/gpt61terra-s2/policy.py +sandwich_remove,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,44,56010,0.48,68793,6278784,19039,scored,policies/sandwich_remove/gpt61terra-s3/policy.py +saucepan_to_hob,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,1,41,100545,0.81,124926,11319296,24054,scored,policies/saucepan_to_hob/gpt61terra-s1/policy.py +saucepan_to_hob,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,52,100934,0.77,107157,10763648,25228,scored,policies/saucepan_to_hob/gpt61terra-s2/policy.py +saucepan_to_hob,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,1,40,38951,0.32,62405,3927552,11898,scored,policies/saucepan_to_hob/gpt61terra-s3/policy.py +stack_blocks,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,3,76,99440,0.86,115164,11490944,33586,scored,policies/stack_blocks/gpt61terra-s1/policy.py +stack_blocks,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,5,108,88720,1.16,144596,17021056,32016,scored,policies/stack_blocks/gpt61terra-s2/policy.py +stack_blocks,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,6,136,98620,1.01,170707,13534592,31994,scored,policies/stack_blocks/gpt61terra-s3/policy.py +wall_cupboard_close,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,48,101000,0.41,79880,4750464,17830,scored,policies/wall_cupboard_close/gpt61terra-s1/policy.py +wall_cupboard_close,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,100,1,17,53820,0.22,78406,1948416,8433,scored,policies/wall_cupboard_close/gpt61terra-s2/policy.py +wall_cupboard_close,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,1,41,99593,0.36,69664,4271232,16132,scored,policies/wall_cupboard_close/gpt61terra-s3/policy.py +wall_cupboard_open,extended,gpt61terra-s1,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,2,50,99699,0.56,171769,5635200,21473,scored,policies/wall_cupboard_open/gpt61terra-s1/policy.py +wall_cupboard_open,extended,gpt61terra-s2,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,4,59,99078,0.58,85954,7069568,28030,scored,policies/wall_cupboard_open/gpt61terra-s2/policy.py +wall_cupboard_open,extended,gpt61terra-s3,gpt61terra,GPT-6.1 Terra,Codex CLI,codex-cli 0.164.0,high,default,0,6,28,98905,0.86,103286,12311168,28846,scored,policies/wall_cupboard_open/gpt61terra-s3/policy.py diff --git a/policies/stack_blocks/deepseek1017-s2/episodes.csv b/policies/stack_blocks/deepseek1017-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..a3ea9a0ba9447dbf7430412d78976a9251da4070 --- /dev/null +++ b/policies/stack_blocks/deepseek1017-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/deepseek1017-s2/policy.py b/policies/stack_blocks/deepseek1017-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..2872450f7cb6ab60a2da89256ac392ef11fa0089 --- /dev/null +++ b/policies/stack_blocks/deepseek1017-s2/policy.py @@ -0,0 +1,303 @@ +"""Control policy for the G1 ``stack_blocks`` task. + +The robot starts at the source table with red blocks right next to its open +grippers. The destination is another table carrying a green pad which may +appear anywhere in the room, so the policy grabs the blocks first, scans for +the green pad with the head camera and then carries the blocks to it. + +Only the robot's own cameras and proprioception are used. All logic is +deterministic (no wall clock, no unseeded randomness). +""" + +import cv2 +import numpy as np + + +def _wrap(a): + return (a + np.pi) % (2 * np.pi) - np.pi + + +class Policy: + # ---------------------------------------------------------------- helpers + @staticmethod + def _green_blob(im): + """Largest green blob in an 84x84 RGB image -> (area, cx, cy).""" + r = im[:, :, 0].astype(np.int16) + g = im[:, :, 1].astype(np.int16) + b = im[:, :, 2].astype(np.int16) + m = ((g > r + 18) & (g > b + 18) & (g > 52)).astype(np.uint8) * 255 + if m.sum() == 0: + return 0, 42.0, 42.0 + try: + n, lab, stats, cents = cv2.connectedComponentsWithStats(m, 8) + except Exception: + return 0, 42.0, 42.0 + best, bx, by = 0, 42.0, 42.0 + for i in range(1, n): + a = int(stats[i, 4]) + if a > best: + best = a + bx, by = float(cents[i, 0]), float(cents[i, 1]) + return best, bx, by + + def _carry(self, raw, lift=0.32, elbow=0.14): + raw[5] = lift + raw[6] = 0.0 + raw[7] = elbow + raw[8] = 0.0 + raw[9] = 0.0 + raw[10] = 0.0 + raw[11] = 0.0 + raw[12] = lift + raw[13] = 0.0 + raw[14] = elbow + raw[15] = 0.0 + raw[16] = 0.0 + raw[17] = 0.0 + raw[18] = 0.0 + raw[19] = 1.0 + raw[20] = 1.0 + return raw + + def _normal(self, raw): + raw[2] = 0.74 + raw[4] = 0.0 + return raw + + # ------------------------------------------------------------------ reset + def reset(self, obs, tools): + ld = np.asarray(obs["low_dim_obs"]) + self.sx = float(ld[21]) + self.sy = float(ld[22]) + self.syaw = float(ld[24]) + self.t = 0 + self.state = "grab" + self.scan_k = 0 + self.scan_t = 0 + self.scan_phase = 0 + self.leg = 0 + self.legs = [ + (self.sx - 1.0, self.sy - 2.6), + (self.sx + 6.2, self.sy - 2.6), + (self.sx + 6.2, self.sy - 5.0), + (self.sx + 1.0, self.sy - 5.0), + (self.sx + 1.0, self.sy - 6.8), + (self.sx + 6.5, self.sy - 6.8), + (self.sx + 6.5, self.sy + 2.6), + (self.sx + 1.0, self.sy + 2.6), + (self.sx + 1.0, self.sy + 5.0), + (self.sx - 2.0, self.sy + 5.0), + (self.sx - 2.0, self.sy + 2.0), + (self.sx - 4.0, self.sy + 2.0), + (self.sx - 4.0, self.sy - 2.0), + (self.sx - 6.0, self.sy - 2.0), + ] + self.green_seen = 0 + self.last_blob = (0, 42.0, 42.0) + self.place_t = 0 + self.approach_t = 0 + self.last_pos = (self.sx, self.sy) + self.approach_stall = 0 + self.wrist_seen = 0 + + # -------------------------------------------------------------------- act + def act(self, obs, tools): + ld = np.asarray(obs["low_dim_obs"]) + x = float(ld[21]) + y = float(ld[22]) + z = float(ld[23]) + yaw = float(ld[24]) + raw = np.asarray(tools.hold_action(), dtype=np.float32) + t = self.t + self.t += 1 + + if z < 0.45: # fallen: freeze + return raw + + # ------------------------------------------------ 1. grasp the blocks + if self.state == "grab": + raw = self._carry(raw, lift=0.30, elbow=0.12) + if t >= 50: + self.state = "retreat" + return raw + + # ------------------------------------------------ 2. back away + if self.state == "retreat": + raw = self._carry(raw, lift=0.30, elbow=0.12) + raw[0] = -0.45 + if t >= 165: + self.state = "scan0" + self.scan_k = 0 + self.scan_phase = 0 + self.scan_t = 0 + return raw + + # ------------------------------------------------ 3. initial tall scan + if self.state == "scan0": + target = self.syaw + self.scan_k * np.pi / 4.0 + err = _wrap(target - yaw) + if self.scan_phase == 0: + # rotate at normal height + raw = self._carry(raw) + self._normal(raw) + if abs(err) > 0.06 and self.scan_t < 70: + raw[3] = float(np.clip(2.4 * err, -0.65, 0.65)) + self.scan_t += 1 + return raw + self.scan_phase = 1 + self.scan_t = 0 + if self.scan_phase == 1: + # settle tall, lean back and look around + raw = self._carry(raw) + raw[2] = 0.92 + raw[4] = -0.2 + if self.scan_t < 30: + self.scan_t += 1 + return raw + try: + im = tools.image("head") + area, cx, cy = self._green_blob(im) + except Exception: + area, cx, cy = 0, 42.0, 42.0 + if area >= 5: + self.state = "approach" + self.last_blob = (area, cx, cy) + self.approach_t = 0 + return raw + self.scan_phase = 2 + self.scan_t = 0 + if self.scan_phase == 2: + # back to normal before next rotation + raw = self._carry(raw) + self._normal(raw) + self.scan_t += 1 + if self.scan_t >= 12: + self.scan_k += 1 + self.scan_phase = 0 + self.scan_t = 0 + if self.scan_k >= 8: + self.state = "search" + self.leg = 0 + return raw + + # ------------------------------------------------ 4. search the room + if self.state == "search": + try: + im = tools.image("head") + area, cx, cy = self._green_blob(im) + except Exception: + area, cx, cy = 0, 42.0, 42.0 + if area < 9 and self.t % 4 == 0: + # the wrist cameras can spot a near pad the head camera misses + try: + wl = tools.image("left_wrist") + ar1, _, _ = self._green_blob(wl) + wr = tools.image("right_wrist") + ar2, _, _ = self._green_blob(wr) + except Exception: + ar1 = ar2 = 0 + if max(ar1, ar2) >= 9: + self.wrist_seen += 1 + else: + self.wrist_seen = 0 + if self.wrist_seen >= 2: + self.state = "approach" + self.last_blob = (max(ar1, ar2), 42.0, 60.0) + self.approach_t = 0 + return raw + if area >= 8: + self.green_seen += 1 + else: + self.green_seen = 0 + if self.green_seen >= 2: + self.state = "approach" + self.last_blob = (area, cx, cy) + self.approach_t = 0 + return raw + + if self.leg >= len(self.legs): + self.state = "idle" + return raw + tx, ty = self.legs[self.leg] + dx, dy = tx - x, ty - y + dist = float(np.hypot(dx, dy)) + if dist < 0.45: + self.leg += 1 + return raw + target = float(np.arctan2(dy, dx)) + err = _wrap(target - yaw) + raw = self._carry(raw) + raw[0] = 0.55 if abs(err) < 0.7 else 0.05 + raw[3] = float(np.clip(2.2 * err, -0.55, 0.55)) + return raw + + # ------------------------------------------------ 5. approach the pad + if self.state == "approach": + self.approach_t += 1 + try: + im = tools.image("head") + area, cx, cy = self._green_blob(im) + except Exception: + area, cx, cy = 0, 42.0, 42.0 + if area >= 5: + self.last_blob = (area, cx, cy) + else: + area, cx, cy = self.last_blob + bearing = -(cx - 42.0) / 42.0 * 0.55 + raw = self._carry(raw) + raw[3] = float(np.clip(1.8 * bearing, -0.45, 0.45)) + if area < 40: + raw[0] = 0.32 + elif area < 120: + raw[0] = 0.18 + else: + raw[0] = 0.0 + # stalled against the table -> place now + moved = ((x - self.last_pos[0]) ** 2 + (y - self.last_pos[1]) ** 2) ** 0.5 + if self.approach_t % 20 == 0: + if moved < 0.05: + self.approach_stall += 1 + else: + self.approach_stall = 0 + self.last_pos = (x, y) + if self.approach_t > 25 and (area >= 110 or (area >= 60 and cy > 46)): + self.state = "place" + self.place_t = 0 + if self.approach_t > 300 or self.approach_stall >= 2: + self.state = "place" + self.place_t = 0 + return raw + + # ------------------------------------------------ 6. place the blocks + if self.state == "place": + self.place_t += 1 + raw[0] = 0.0 + raw[2] = 0.66 + raw[4] = 0.55 + raw[5] = 0.95 + raw[6] = 0.0 + raw[7] = -0.10 + raw[8] = 0.0 + raw[9] = 0.0 + raw[10] = 0.0 + raw[11] = 0.0 + raw[12] = 0.95 + raw[13] = 0.0 + raw[14] = -0.10 + raw[15] = 0.0 + raw[16] = 0.0 + raw[17] = 0.0 + raw[18] = 0.0 + if self.place_t < 40: + raw[19] = 1.0 + raw[20] = 1.0 + else: + raw[19] = 0.0 + raw[20] = 0.0 + if self.place_t > 80: + self.state = "idle" + return raw + + # ------------------------------------------------------------- idle + raw = self._carry(raw, lift=0.0, elbow=0.0) + return raw diff --git a/policies/stack_blocks/deepseek1017-s3/episodes.csv b/policies/stack_blocks/deepseek1017-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..d28e80207ef36a32ed52e3c6486b0df710f6ccc7 --- /dev/null +++ b/policies/stack_blocks/deepseek1017-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,579,terminated,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,634,terminated,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/deepseek1017-s3/policy.py b/policies/stack_blocks/deepseek1017-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..250cf9da2191b3bac96e431e27a7532332a8ad01 --- /dev/null +++ b/policies/stack_blocks/deepseek1017-s3/policy.py @@ -0,0 +1,236 @@ +"""Hand-written control policy for the G1 "stack blocks" task. + +Pipeline (all control is deterministic, fixed thresholds tuned on the dev seeds): + +1. grasp -- the ready pose puts both grippers just behind two of the three + blocks. Lean the torso slightly, strafe right, creep forward while the + block in the right wrist camera is tracked, then squat, close both + grippers and lift the arms. +2. carry -- walk around the block table (north side) to the east side of the + green pad table using pelvis odometry. +3. place -- face the pad, push up to the table edge, lean forward so the + hands reach over the pad, and release the blocks. + +Only the robot's own cameras and proprioception are used. +""" + +import cv2 +import numpy as np + + +# ---------------------------------------------------------------------------- +# small image helpers +# ---------------------------------------------------------------------------- +def _red_blob(img): + """Largest red blob of an RGB image -> (cx, cy, area) or None.""" + r = img[..., 0].astype(np.int16) + g = img[..., 1].astype(np.int16) + b = img[..., 2].astype(np.int16) + m = ((r > 80) & (r > g + 40) & (r > b + 40)).astype(np.uint8) + n, _lab, stats, cent = cv2.connectedComponentsWithStats(m, 8) + best = None + for i in range(1, n): + a = int(stats[i, cv2.CC_STAT_AREA]) + if a >= 10 and (best is None or a > best[2]): + best = (float(cent[i][0]), float(cent[i][1]), a) + return best + + +def _green_blob(img): + """Largest green (target pad) blob of an RGB image -> (cx, cy, area).""" + r = img[..., 0].astype(np.int16) + g = img[..., 1].astype(np.int16) + b = img[..., 2].astype(np.int16) + m = ((g > r + 25) & (g > b + 25) & (g > 100)).astype(np.uint8) + if int(m.sum()) == 0: + return None + ys, xs = np.where(m) + return (float(xs.mean()), float(ys.mean()), int(m.sum())) + + +def _wrap(a): + return (a + np.pi) % (2.0 * np.pi) - np.pi + + +# waypoints: around the north side of the block table, then south along its +# east side to the green pad table. +WAYPOINTS = ((0.30, 1.15), (1.90, 1.05), (2.15, 0.0)) + +# phase lengths (control steps) +P_PITCH = 30 +P_STRAFE = 20 +P_FWD = 175 +P_SQUAT = 35 +P_CLOSE = 30 +P_LIFT = 30 + + +class Policy: + """Deterministic scripted pick / carry / place policy.""" + + def reset(self, obs, tools): + self.t = 0 + self.hold = np.asarray(tools.hold_action(), dtype=np.float64) + self.phase = 0 + self.phase_t = 0 + self.done = False + self.wp = 0 + self.nav_t = 0 + self.nav_last = None + self.nav_stuck = 0 + self.pitch = 0.0 + + # ------------------------------------------------------------------ + def _pose(self, obs): + ld = obs["low_dim_obs"] + return (float(ld[21]), float(ld[22]), float(ld[23]), float(ld[24])) + + def act(self, obs, tools): + self.t += 1 + self.phase_t += 1 + raw = self.hold.copy() + + # ---------------------------------------------------------- grasp + if self.phase <= 3: + raw[19] = 0.6 + raw[20] = 0.6 + elif self.phase <= 9: + raw[19] = 1.0 + raw[20] = 1.0 + + if self.phase == 0: + raw[4] = 0.10 + if self.phase_t >= P_PITCH: + self._next() + elif self.phase == 1: + raw[4] = 0.10 + raw[1] = -0.15 + if self.phase_t >= P_STRAFE: + self._next() + elif self.phase == 2: + raw[4] = 0.10 + cur = _red_blob(tools.image("right_wrist")) + if cur is None: + raw[0] = 0.0 + else: + cx, cy, _area = cur + raw[0] = 0.0 if cy > 50.0 else 0.10 + vy = float(np.clip(-0.006 * (cx - 43.0), -0.15, 0.15)) + raw[1] = 0.0 if abs(vy) < 0.06 else vy + if cy > 50.0 and abs(cx - 43.0) < 8.0: + self._next() + if self.phase == 2 and self.phase_t >= P_FWD: + self._next() + elif self.phase == 3: + raw[2] = 0.66 + raw[4] = 0.10 + if self.phase_t >= P_SQUAT: + self._next() + elif self.phase == 4: + raw[2] = 0.66 + raw[4] = 0.10 + if self.phase_t >= P_CLOSE: + self._next() + elif self.phase == 5: + raw[2] = 0.66 + raw[4] = 0.10 + raw[5] = -0.30 + raw[12] = -0.30 + if self.phase_t >= P_LIFT: + self._next() + # ---------------------------------------------------------- carry + elif self.phase == 6: + raw[5] = -0.30 + raw[12] = -0.30 + raw[4] = 0.10 + # stand up very gently from the grasp squat so the held blocks do + # not slip out of the grippers + raw[2] = 0.66 + 0.08 * min(1.0, self.phase_t / 250.0) + if self.phase_t < 250: + # stand up in place first; do not disturb the grip while the + # body rises + return raw + if self.wp >= len(WAYPOINTS): + self._next() + else: + p = self._pose(obs) + tx, ty = WAYPOINTS[self.wp] + dx, dy = tx - p[0], ty - p[1] + d = float(np.hypot(dx, dy)) + if self.nav_last is not None and abs(p[3]) < 50.0: + step_moved = float(np.hypot(p[0] - self.nav_last[0], + p[1] - self.nav_last[1])) + if step_moved < 0.004 and self.nav_t > 90: + self.nav_stuck += 1 + else: + self.nav_stuck = 0 + self.nav_last = p + self.nav_t += 1 + if d < 0.16 or self.nav_stuck > 45 or self.nav_t > 420: + self.wp += 1 + self.nav_t = 0 + self.nav_last = None + self.nav_stuck = 0 + else: + des = float(np.arctan2(dy, dx)) + err = _wrap(des - p[3]) + raw[3] = float(np.clip(2.2 * err, -0.8, 0.8)) + raw[0] = float( + 0.38 * max(0.0, min(1.0, (0.9 - abs(err)) / 0.6)) + * max(0.3, min(1.0, d / 0.4)) + ) + # ---------------------------------------------------------- place + elif self.phase == 7: + raw[5] = -0.30 + raw[12] = -0.30 + raw[4] = 0.05 + p = self._pose(obs) + err = _wrap(np.pi - p[3]) + if abs(err) < 0.04 or self.phase_t > 260: + self._next() + else: + raw[3] = float(np.clip(2.5 * err, -0.9, 0.9)) + elif self.phase == 8: + raw[5] = -0.30 + raw[12] = -0.30 + raw[4] = 0.10 + raw[0] = 0.15 + raw[3] = float(np.clip(2.5 * _wrap(np.pi - self._pose(obs)[3]), -0.5, 0.5)) + + if self.phase_t >= 70: + self._next() + elif self.phase == 9: + # reach down-forward over the table towards the pad + raw[2] = 0.72 + raw[4] = 0.35 + raw[5] = 0.35 + raw[12] = 0.35 + if self.phase_t >= 30: + self._next() + elif self.phase == 10: + raw[2] = 0.72 + raw[4] = 0.40 + raw[5] = 0.45 + raw[12] = 0.45 + raw[19] = 0.0 + raw[20] = 0.0 + if self.phase_t >= 40: + self._next() + elif self.phase == 11: + # settle and lift the empty grippers clear of the pad + raw[2] = 0.74 + raw[4] = 0.20 + raw[5] = 0.10 + raw[12] = 0.10 + raw[19] = 0.0 + raw[20] = 0.0 + if self.phase_t >= 30: + self._next() + else: + raw = self.hold.copy() + raw[4] = 0.1 + return raw + + def _next(self): + self.phase += 1 + self.phase_t = 0 diff --git a/policies/stack_blocks/gpt61sol-s1/episodes.csv b/policies/stack_blocks/gpt61sol-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..d6d5a61765dc915507e4ad60262eecea45d15f15 --- /dev/null +++ b/policies/stack_blocks/gpt61sol-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,4495,terminated,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,1653,terminated,0 +620006,0,8750,timeout,0 +620007,0,4578,terminated,0 +620008,0,8750,timeout,0 +620009,0,2568,terminated,0 +620010,0,8750,timeout,0 +620011,0,1947,terminated,0 +620012,0,8750,timeout,0 +620013,0,3392,terminated,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,3748,terminated,0 +620017,0,8750,timeout,0 +620018,0,4188,terminated,0 +620019,0,8750,timeout,0 +620020,0,3487,terminated,0 +620021,0,4965,terminated,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,4753,terminated,0 +620026,0,8750,timeout,0 +620027,0,4069,terminated,0 +620028,0,8750,timeout,0 +620029,0,3205,terminated,0 +620030,0,1688,terminated,0 +620031,0,8750,timeout,0 +620032,0,4723,terminated,0 +620033,0,2517,terminated,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,3240,terminated,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,3896,terminated,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,4267,terminated,0 +620045,0,8750,timeout,0 +620046,0,3741,terminated,0 +620047,0,8750,timeout,0 +620048,0,3577,terminated,0 +620049,0,8750,timeout,0 +620050,0,2446,terminated,0 +620051,0,3211,terminated,0 +620052,0,7386,terminated,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,2186,terminated,0 +620056,0,4775,terminated,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8522,terminated,0 +620061,0,8750,timeout,0 +620062,0,2152,terminated,0 +620063,0,8750,timeout,0 +620064,0,1923,terminated,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,4238,terminated,0 +620068,0,8750,timeout,0 +620069,0,4927,terminated,0 +620070,0,8750,timeout,0 +620071,0,7167,terminated,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,2057,terminated,0 +620078,0,8750,timeout,0 +620079,0,3928,terminated,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,4196,terminated,0 +620083,0,3371,terminated,0 +620084,0,7686,terminated,0 +620085,0,8750,timeout,0 +620086,0,4814,terminated,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,3337,terminated,0 +620092,0,8750,timeout,0 +620093,0,4041,terminated,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,3847,terminated,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/gpt61sol-s1/policy.py b/policies/stack_blocks/gpt61sol-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..2199f740f833e2bd8357d57b271c7ae775d2fa42 --- /dev/null +++ b/policies/stack_blocks/gpt61sol-s1/policy.py @@ -0,0 +1,207 @@ +"""Deterministic visual control for transferring and stacking three blocks. + +Colour segmentation supplies image errors; body pose closes the navigation +loop. All constants and state transitions are hand-written. No demonstration, +seed identity, fitted model, or stored placement data is read at runtime. +""" + +import numpy as np +import cv2 + + +def blobs(im, color='red'): + r,g,b=im[:,:,0].astype(float),im[:,:,1].astype(float),im[:,:,2].astype(float) + if color=='red': m=(r>100)&(r>1.6*g)&(r>1.6*b) + else: m=(g>95)&(g>1.35*r)&(g>1.2*b) + n,l,s,c=cv2.connectedComponentsWithStats(m.astype(np.uint8)) + return [(cc,np.sqrt(ss[4]),ss) for ss,cc in zip(s[1:],c[1:]) if ss[4]>12] + +class Policy: + def reset(self,obs,tools): + self.a=np.asarray(tools.hold_action(),dtype=float) + self.a[19:]=0 + self.phase='open';self.start=0;self.servo=0 + self.route=[(0,-1,0),(2.4,-1,0),(2.4,0,0),(2.4,0,np.pi)] + self.ri=0;self.stable=0;self.pickx=0;self.pickpitch=0;self.rightpitch=0;self.placebase=None;self.level=1;self.returning=False;self.stackoffset=None;self.held_uv=None;self.last=self.a.copy();self.limits=(np.array(tools.info['raw_low']),np.array(tools.info['raw_high'])) + def transition(self,name,t): + self.phase=name;self.start=t;self.stable=0 + def drive(self,p,x,y,yaw): + err=np.array([x,y])-p[:2];co=np.cos(p[3]);si=np.sin(p[3]);v=np.array([co*err[0]+si*err[1],-si*err[0]+co*err[1]])*1.2 + norm=np.linalg.norm(v) + if norm>.4:v*=.4/norm + if np.linalg.norm(err)<.025:v[:]=0 + elif norm<.07:v*=.07/max(norm,1e-8) + ye=(yaw-p[3]+np.pi)%(2*np.pi)-np.pi + self.a[:2]=v;self.a[3]=np.clip(ye*1.8,-.5,.5) if abs(ye)>.02 else 0 + return np.linalg.norm(err)<.035 and abs(ye)<.04 + def act(self,obs,tools): + t=obs['t'];p=obs['low_dim_obs'][21:25];dt=t-self.start + if self.phase in ['approach','align_left','place_left','release_left','clear_left','align_right','place_right','release_right','clear_right','arrived']: + ye=(np.pi-p[3]+np.pi)%(2*np.pi)-np.pi + self.a[3]=np.clip(ye*1.5,-.25,.25) + if self.phase=='open': + if dt>=60:self.transition('grasp',t) + elif self.phase=='grasp': + if dt%10==0: + vals=[] + for j,cam in enumerate(['left_wrist','right_wrist']): + bs=blobs(tools.image(cam));rr=min(bs,key=lambda z:abs(z[0][0]-42)) if bs else None + vals.append(rr) + if rr: + c,sz,_=rr + self.a[7+7*j]+=np.clip((42-c[0])*.0015,-.02,.02) + self.a[5+7*j]+=np.clip((c[1]-20)*.001,-.02,.02) + self.a[0]=.08 if any(rr and rr[1]<39 for rr in vals) else 0 + good=all(rr and abs(rr[0][0]-42)<2 and abs(rr[0][1]-20)<2 and rr[1]>39 for rr in vals) + self.stable=self.stable+10 if good else 0 + if self.stable>=80 or dt>800: + self.a[:2]=0;self.a[19]=1;self.pickx=p[0];self.pickpitch=self.a[5];self.transition('left_close',t) + elif self.phase=='left_close': + if dt>70: + self.a[5]=-.12;self.transition('right_grasp',t) + elif self.phase=='right_grasp': + if dt%10==0: + bs=blobs(tools.image('right_wrist'));rr=min(bs,key=lambda z:abs(z[0][0]-42)) if bs else None + if rr: + c,sz,_=rr + self.a[14]+=np.clip((42-c[0])*.0015,-.015,.015) + self.a[12]+=np.clip((c[1]-20)*.001,-.015,.015) + self.a[0]=.06 if sz<53 and p[0]50 + self.stable=self.stable+10 if good else 0 + if self.stable>=70 or dt>400: + self.a[:2]=0;self.a[20]=1;self.rightpitch=self.a[12];self.transition('close',t) + elif self.phase=='close': + if dt>70: + self.a[5]=self.a[12]=-.12 + self.transition('lift',t) + elif self.phase=='lift': + if dt>100:self.transition('route',t) + elif self.phase=='route': + x,y,yaw=self.route[self.ri] + if self.drive(p,x,y,yaw): + self.stable+=1 + if self.stable>10: + self.ri+=1;self.stable=0 + if self.ri==len(self.route): + self.a[:2]=0;self.a[3]=0 + if self.returning: + self.a[12]=.20;self.a[13]=0;self.a[14]=0;self.a[20]=0;self.transition('third_approach',t) + else:self.transition('approach',t) + elif self.phase=='approach': + if dt%10==0: + bs=blobs(tools.image('head'),'green') + if bs: + c,sz,_=max(bs,key=lambda b:b[1]) + self.a[0]=.1 if c[1]<42 else 0 + self.a[1]=np.clip((42-c[0])*.005,-.12,.12) if abs(c[0]-42)>3 else 0 + if c[1]>=42: + self.a[:2]=0;self.transition('align_left' if self.level==1 else 'align_right',t) + elif self.phase=='align_left': + if dt%10==0: + im=tools.image('head');gs=blobs(im,'green');rs=blobs(im) + if gs and rs: + gc,_,_=max(gs,key=lambda b:b[1]);rc,_,_=max([b for b in rs if b[0][0]<60 and b[1]>5] or rs,key=lambda b:b[1]) + self.a[7]+=np.clip((rc[0]-gc[0])*.003,-.02,.02) + self.stable=self.stable+10 if abs(rc[0]-gc[0])<1.5 else 0 + if self.stable>60 or dt>500:self.transition('place_left',t) + elif self.phase=='place_left': + self.a[5]=min(self.pickpitch,self.a[5]+.0015) + if dt%10==0 and dt>260: + im=tools.image('head');gs=blobs(im,'green');rs=blobs(im) + if gs and rs: + gc,_,st=max(gs,key=lambda b:b[1]);gc=np.array([st[0]+(st[2]-1)/2,st[1]+(st[3]-1)/2]) + rc,_,_=max([b for b in rs if b[0][0]<60 and b[1]>5] or rs,key=lambda b:b[1]) + self.a[7]+=np.clip((rc[0]-gc[0])*.003,-.02,.02) + dy=rc[1]-(gc[1]-4) + self.a[0]=(.065 if dy>1.5 else -.065 if dy< -1.5 else 0) + good=abs(rc[0]-gc[0])<1.5 and abs(dy)<1.5 + self.stable=self.stable+10 if good else 0 + if self.stable>60 or dt>350: + self.a[0]=0;self.a[19]=0;self.transition('release_left',t) + elif self.phase=='release_left': + if dt>100: + self.placebase=p[:2].copy();self.a[0]=-.08;self.transition('clear_left',t) + elif self.phase=='clear_left': + if dt>70: + self.a[0]=0;self.a[5]=-.12;self.a[7]=.5;self.a[8]=0;self.held_uv=None;self.transition('align_right',t) + elif self.phase=='align_right': + # Translate the body until the carried cube is above the base cube. + # Keeping the carrying arm in its pickup orientation avoids twisting + # the cube while bringing the two hands into the same workspace. + self.a[0]=0 + if dt%10==0: + rs=[b for b in blobs(tools.image('head')) if b[1]>5] + if len(rs)>=2: + held=min(rs,key=lambda b:b[0][1]) + ground=max(rs,key=lambda b:b[0][1]) + dx=held[0][0]-ground[0][0] + self.a[1]=.07 if dx>1.5 else -.07 if dx< -1.5 else 0 + self.stable=self.stable+10 if abs(dx)<1.5 else 0 + else:self.a[1]=0 + if self.stable>50 or dt>400: + self.a[:2]=0;self.upperbase=p[:2].copy() + self.transition('place_right',t) + elif self.phase=='place_right': + targetpitch=self.rightpitch-.13*self.level + self.a[12]=min(targetpitch,self.a[12]+.0015) + if dt<200:self.drive(p,self.upperbase[0]-.03,self.upperbase[1],np.pi) + elif dt%10==0: + rs=[b for b in blobs(tools.image('head')) if b[1]>5] + if len(rs)>=2: + held=min(rs,key=lambda b:b[0][1]);ground=max(rs,key=lambda b:b[0][1]) + dx=held[0][0]-ground[0][0] + dy=held[0][1]-ground[0][1]+7+3.5*(self.level-1) + self.a[1]=.065 if dx>1.5 else -.065 if dx< -1.5 else 0 + self.a[0]=.065 if dy>1.5 else -.065 if dy< -1.5 else 0 + self.stable=self.stable+10 if abs(dx)<1.5 and abs(dy)<1.5 else 0 + else: + self.a[:2]=0;self.stable+=10 + if self.stable>50 or dt>450: + self.a[:2]=0;self.a[20]=0;self.transition('release_right',t) + elif self.phase=='release_right': + if dt>100: + self.a[0]=-.08;self.transition('clear_right',t) + elif self.phase=='clear_right': + if dt>70: + self.a[0]=0;self.a[12]=-.35 + if self.level==2:self.transition('finished',t) + else: + self.route=[(2.4,0,np.pi),(2.4,-1,np.pi),(0,-1,0),(.08,0,0)] + self.ri=0;self.returning=True;self.transition('route',t) + + elif self.phase=='third_approach': + ye=(-p[3]+np.pi)%(2*np.pi)-np.pi;self.a[3]=np.clip(ye*1.5,-.25,.25) + if dt%10==0 and dt>80: + rs=blobs(tools.image('head')) + if rs: + c,sz,_=max(rs,key=lambda b:b[1]) + self.a[0]=.08 if c[1]<41 else 0 + self.a[1]=.07 if c[0]<63 else -.07 if c[0]>67 else 0 + if c[1]>=41 and abs(c[0]-65)<3: + self.a[:2]=0;self.transition('third_grasp',t) + elif self.phase=='third_grasp': + ye=(-p[3]+np.pi)%(2*np.pi)-np.pi + self.a[3]=np.clip(ye*1.5,-.25,.25) + if dt%10==0 and dt>70: + bs=blobs(tools.image('right_wrist'));rr=max(bs,key=lambda z:z[1]) if bs else None + if rr: + c,sz,_=rr + self.a[14]+=np.clip((42-c[0])*.0015,-.02,.02) + self.a[12]+=np.clip((c[1]-20)*.001,-.02,.02) + self.a[0]=.06 if sz<52 and abs(c[0]-42)<5 else 0 + self.stable=self.stable+10 if sz>50 and abs(c[0]-42)<2 and abs(c[1]-20)<2 else 0 + if self.stable>60 or dt>350: + self.a[0]=0;self.a[20]=1;self.rightpitch=self.a[12];self.transition('third_close',t) + elif self.phase=='third_close': + if dt>80: + self.a[12]=-.12;self.level=2;self.returning=False + self.route=[(0,-1,0),(2.4,-1,0),(2.4,0,0),(2.4,0,np.pi)] + self.ri=0;self.transition('route',t) + if self.phase=='finished': + self.a[:2]=0;self.a[3]=0 + out=self.a.copy() + if self.phase in ['align_right','place_right','release_right','clear_right']:out[5:12]=self.last[5:12]+np.clip(out[5:12]-self.last[5:12],-.008,.008) + out=np.clip(out,self.limits[0],self.limits[1]) + self.last=out.copy() + return out diff --git a/policies/stack_blocks/gpt61sol-s2/episodes.csv b/policies/stack_blocks/gpt61sol-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..56a3127689e55257217cba6fafae5a8e03c32d8f --- /dev/null +++ b/policies/stack_blocks/gpt61sol-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,1484,terminated,0 +620004,0,7970,terminated,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,1573,terminated,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,4783,terminated,0 +620012,0,8750,timeout,0 +620013,0,4584,terminated,0 +620014,0,8750,timeout,0 +620015,0,2028,terminated,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,7461,terminated,0 +620020,0,7859,terminated,0 +620021,0,8750,timeout,0 +620022,1,7957,success,0 +620023,0,1596,terminated,0 +620024,0,8750,timeout,0 +620025,0,5058,terminated,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,1539,terminated,0 +620032,0,8622,terminated,0 +620033,0,8750,timeout,0 +620034,0,1074,terminated,0 +620035,0,8508,terminated,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,4806,terminated,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8532,terminated,0 +620051,0,8735,terminated,0 +620052,0,4382,terminated,0 +620053,0,1629,terminated,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,955,terminated,0 +620063,0,4639,terminated,0 +620064,0,8750,timeout,0 +620065,0,8581,terminated,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,5145,terminated,0 +620069,0,1606,terminated,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8647,terminated,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8248,terminated,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,1476,terminated,0 +620093,0,8750,timeout,0 +620094,0,5356,terminated,0 +620095,0,8750,timeout,0 +620096,0,1196,terminated,0 +620097,0,1570,terminated,0 +620098,0,1546,terminated,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/gpt61sol-s2/policy.py b/policies/stack_blocks/gpt61sol-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..ded6780ae2d949fec9eb1f0c6683b2059637166a --- /dev/null +++ b/policies/stack_blocks/gpt61sol-s2/policy.py @@ -0,0 +1,123 @@ +"""Deterministic visual grasping, closed-loop walking, and block stacking.""" +import numpy as np +import cv2 + +class Policy: + def reset(self, obs, tools): + self.a=np.asarray(tools.hold_action(),dtype=float) + self.target=self.a.copy();self.target[19:21]=0 + self.target[5:12]=[-.6,.405,0,.4,0,0,0] + self.target[12:19]=[-.6,-.42,0,.4,0,0,0] + self.state='prepare';self.age=0;self.block=0;self.retry=0 + self.route=[];self.good=0 + + def phase(self,s): + self.state=s;self.age=0 + + @staticmethod + def blob(im,green=False): + r,g,b=im[:,:,0].astype(float),im[:,:,1].astype(float),im[:,:,2].astype(float) + mask=((g>100)&(g>r*1.25)&(g>b*1.15)) if green else ((r>110)&(r>g*1.8)&(r>b*1.8)) + n,lab,stats,cent=cv2.connectedComponentsWithStats(mask.astype('uint8'),8) + candidates=[i for i in range(1,n) if stats[i,4]>20] + if not candidates:return None + i=max(candidates,key=lambda i:stats[i,4]) + return cent[i][0],cent[i][1],stats[i,4],stats[i,2],stats[i,3] + + def nav(self,obs): + q=obs['low_dim_obs'];x,y,z,yaw=q[21:25] + gx,gy,ga=self.route[0];d=np.array([gx-x,gy-y]);er=(ga-yaw+np.pi)%(2*np.pi)-np.pi + cs,sn=np.cos(yaw),np.sin(yaw) + v=np.array([cs*d[0]+sn*d[1],-sn*d[0]+cs*d[1]]) + dist=np.linalg.norm(v) + if dist<.025:v[:]=0 + else:v*=min(.55,max(.08,dist*1.8))/dist + if abs(er)>.25:v*=.25 + self.target[:2]=v;self.target[3]=np.clip(2*er,-.8,.8) + if (dist<.035 and abs(er)<.045) or self.age>550: + self.route.pop(0);self.age=0 + if not self.route: + self.target[:2]=0;self.target[3]=0;self.phase(self.after_nav) + + def act(self,obs,tools): + self.age+=1 + t=self.target + if self.state=='nav':self.nav(obs) + elif self.state=='prepare': + if self.age>110:self.good=0;self.phase('source_align') + elif self.state=='source_align': + if self.age%5==0: + im=tools.image('head');r,g,b=im[:,:,0].astype(float),im[:,:,1].astype(float),im[:,:,2].astype(float) + mask=((r>110)&(r>g*1.8)&(r>b*1.8)).astype('uint8') + n,lab,st,cen=cv2.connectedComponentsWithStats(mask,8) + candidates=[i for i in range(1,n) if st[i,4]>8 and 12=25 or self.age>150: + t[:2]=0;t[3]=0;self.phase('source_settle') + elif self.state=='source_settle': + if self.age>45:self.phase('lower') + elif self.state=='lower': + t[2]=.6 + if self.age>130:self.phase('align') + elif self.state=='align': + if self.age%20==0: + p=self.blob(tools.image('right_wrist')) + if p: + cx,cy,area,w,h=p + t[13]+=np.clip((36-cx)*.0025,-.035,.035) + t[2]=np.clip(t[2]+np.clip((area-2300)*.000004,-.007,.007),.56,.68) + t[12]+=np.clip((cy-41)*.0025,-.035,.035) + t[13]=np.clip(t[13],-.75,.65);t[12]=np.clip(t[12],-.95,-.3) + if self.age>220:self.phase('close') + elif self.state=='close': + t[20]=1 + if self.age>65:self.phase('lift') + elif self.state=='lift': + t[2]=.74 + t[5]=t[12]=-.8;t[8]=t[15]=.8;t[13]=-.42 + # Use the same carrying pose for each block. + if self.age>130: + p=self.blob(tools.image('right_wrist')) + if (not p or p[2]<450) and self.retry<1: + self.retry+=1;t[20]=0;t[12]=-.6;t[13]=-.42;t[15]=.4;self.phase('lower') + else: + self.route=[(-.18,float(obs['low_dim_obs'][22]),0),(-.18,.9,0),(2.2,.9,0),(2.2,-.24,0),(2.2,-.24,np.pi),(2.07,-.24,np.pi)] + self.after_nav='settle';self.phase('nav') + elif self.state=='settle': + if self.age>60:self.phase('place') + elif self.state=='place': + t[2]=.62+.065*self.block + if self.age>140:self.phase('release') + elif self.state=='release': + t[20]=0 + if self.age>80:self.phase('withdraw') + elif self.state=='withdraw': + t[2]=.74 + if self.age>120: + self.block+=1 + if self.block>=3:self.phase('finish') + else: + sy=[0.,.33,.43][self.block] + self.route=[(2.22,-.24,np.pi),(2.22,.9,np.pi),(-.18,.9,np.pi),(-.18,.9,0),(-.18,sy,0),(.11,sy,0)] + self.after_nav='new_grasp';self.phase('nav') + elif self.state=='new_grasp': + t[5:12]=[-.6,.405,0,.4,0,0,0] + t[12:19]=[-.6,-.42,0,.4,0,0,0];self.retry=0 + if self.age>100:self.good=0;self.phase('source_align') + elif self.state=='finish': + t[:2]=0;t[3]=0 + # Arm and body targets are moved gradually to avoid ejecting a block. + rate=np.array([1,1,.0015,1,.003]+[.006]*14+[.06,.06]) + self.a+=np.clip(t-self.a,-rate,rate) + return self.a.copy() diff --git a/policies/stack_blocks/gpt61sol-s3/episodes.csv b/policies/stack_blocks/gpt61sol-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..20c7187d02b34c26d6e4f9ded9934ce4a58533df --- /dev/null +++ b/policies/stack_blocks/gpt61sol-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,4514,terminated,0 +620004,0,2033,terminated,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,4668,terminated,0 +620009,0,4166,terminated,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,4748,terminated,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,7468,terminated,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,4945,terminated,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,1262,terminated,0 +620026,0,4771,terminated,0 +620027,0,8750,timeout,0 +620028,0,4870,terminated,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,837,terminated,0 +620032,0,1443,terminated,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,4103,terminated,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,4373,terminated,0 +620048,0,8750,timeout,0 +620049,0,4122,terminated,0 +620050,0,8750,timeout,0 +620051,0,4822,terminated,0 +620052,0,4251,terminated,0 +620053,0,8104,terminated,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,4827,terminated,0 +620059,0,7853,terminated,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8092,terminated,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,4766,terminated,0 +620067,0,4525,terminated,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,4744,terminated,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,7492,terminated,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,4097,terminated,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,7725,terminated,0 +620089,0,8015,terminated,0 +620090,0,4988,terminated,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/gpt61sol-s3/policy.py b/policies/stack_blocks/gpt61sol-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..bf9b6d47159cbf057c32ff1ca386cef5358fa4a3 --- /dev/null +++ b/policies/stack_blocks/gpt61sol-s3/policy.py @@ -0,0 +1,162 @@ +"""Deterministic camera feedback controller for transferring and stacking blocks.""" +import numpy as np +import cv2 + + +def blobs(im, color='red'): + r,g,b = [im[:,:,k].astype(np.int16) for k in range(3)] + if color == 'red': + mask = (r>95)&(r>1.6*g)&(r>1.6*b) + else: + mask = (g>100)&(g>1.25*r)&(g>1.25*b) + n,labels,stats,centers = cv2.connectedComponentsWithStats(mask.astype(np.uint8)) + return sorted([(int(stats[k,4]),centers[k],stats[k,:4]) + for k in range(1,n) if stats[k,4]>8],key=lambda x:-x[0]) + + +class Policy: + def reset(self, obs, tools): + self.a=np.asarray(tools.hold_action(),dtype=float) + self.a[19:21]=0 + self.state='grasp' + self.st=0 + self.trip=0 + self.route=0 + self.last_seen=None + self.dest_y=-.12 + self.track=None + self.aligned=0 + + def change(self, state): + self.state=state + self.st=0 + + def navigate(self, obs, target): + x,y,z,yaw=obs['low_dim_obs'][21:25] + tx,ty,tw=target + dx,dy=tx-x,ty-y + vel=np.clip(np.array([dx,dy])*1.6,-.45,.45) + dist=np.hypot(dx,dy) + if dist<.035: + vel[:]=0 + elif np.linalg.norm(vel)<.075: + vel*=.075/np.linalg.norm(vel) + self.a[0]=np.cos(yaw)*vel[0]+np.sin(yaw)*vel[1] + self.a[1]=-np.sin(yaw)*vel[0]+np.cos(yaw)*vel[1] + err=(tw-yaw+np.pi)%(2*np.pi)-np.pi + self.a[3]=np.clip(err*1.6,-.65,.65) + return dist<.045 and abs(err)<.05 + + def approach(self, values, rate=.004): + for k,v in values.items(): + self.a[k]+=np.clip(v-self.a[k],-rate,rate) + + def act(self, obs, tools): + a=self.a + t=self.st + if self.state=='grasp': + a[0:2]=0;a[3]=0;a[4]=0;a[20]=0 + if t%3==0: + cams=[(1,'right_wrist')] + if self.trip==0: + cams.insert(0,(0,'left_wrist')) + for j,cam in cams: + objects=blobs(tools.image(cam)) + if objects: + if j==1: + ref=np.array([42.,28.]) if self.track is None else self.track + candidates=[v for v in objects if v[0]>35] + if not candidates:continue + selected=min(candidates,key=lambda v:np.sum((v[1]-ref)**2)) + if self.track is not None and np.linalg.norm(selected[1]-ref)>20:continue + area,(x,y),box=selected + self.track=np.array([x,y]) + else: + area,(x,y),box=objects[0] + k=5+7*j + a[k]=np.clip(a[k]+.0018*(y-34),-1.1,.3) + a[k+1]=np.clip(a[k+1]+.0018*(42-x),-1.1,1.1) + a[k+4]=-a[k+1] + a[k+5]=-a[k] + if j==1:self.last_seen=area + if self.trip>0: + a[5]=a[12];a[6]=-a[13];a[9]=-a[6];a[10]=-a[5] + if t>80:a[2]=max(.51,a[2]-.002) + if t>=550: + a[20]=1 + self.change('close') + elif self.state=='close': + if t>=65:self.change('lift') + elif self.state=='lift': + a[2]=min(.78,a[2]+.002) + if t>=180: + self.route=0 + self.change('outbound') + elif self.state=='outbound': + routes=[(-.10,1.05,0),(2.50,1.05,0), + (2.50,self.dest_y,-np.pi),(2.10,self.dest_y,-np.pi)] + if self.navigate(obs,routes[self.route]) or (self.route==3 and t>1300): + self.route+=1 + if self.route==len(routes): + a[0:2]=0;a[3]=0 + self.change('reach') + elif self.state=='reach': + a[0:2]=0;a[3]=0 + self.approach({2:.78,4:.2,12:-1.3,13:0,14:0,15:.8, + 16:0,17:.3,18:0},.006) + if t>240:self.change('lower') + elif self.state=='lower': + # Maintain the horizontal reach while setting the block down. + a[2]=max(.74+.02*self.trip,a[2]-.0007) + if t>100: + a[20]=0 + self.change('release') + elif self.state=='release': + if t>70:self.change('withdraw') + elif self.state=='withdraw': + self.approach({2:.78,4:0,12:-.8,13:-.4,15:0,16:.4,17:.8},.004) + if t>200: + self.trip+=1 + if self.trip>=3:self.change('settle') + else: + self.route=0 + self.change('return') + elif self.state=='return': + sy=.27 + routes=[(2.50,1.05,-np.pi),(.10,1.05,0),(.10,sy,0)] + if self.navigate(obs,routes[self.route]): + self.route+=1 + if self.route==len(routes): + a[0:2]=0;a[3]=0 + self.change('prepare') + elif self.state=='prepare': + a[20]=0 + self.approach({2:.74,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0},.004) + if t>250: + self.last_seen=None + self.track=None + self.aligned=0 + self.change('align_source') + elif self.state=='align_source': + yaw=obs['low_dim_obs'][24] + a[3]=np.clip(1.6*((-yaw+np.pi)%(2*np.pi)-np.pi),-.3,.3) + if t%5==0: + objects=[v for v in blobs(tools.image('head')) if v[0]>14 and v[1][1]<60] + if objects: + obj=max(objects,key=lambda v:v[1][0]) + x,y=obj[1] + ex,ey=67-x,25-y + vx=0 if abs(ey)<4 else np.sign(ey)*max(.07,min(.14,.007*abs(ey))) + vy=0 if abs(ex)<4 else np.sign(ex)*max(.07,min(.18,.007*abs(ex))) + a[0]=vx;a[1]=vy + self.aligned=self.aligned+5 if abs(ex)<4 and abs(ey)<4 else 0 + else: + a[0]=0;a[1]=-.1 + if self.aligned>=15 or t>140: + a[0:2]=0;a[3]=0 + self.track=None + self.change('grasp') + elif self.state=='settle': + a[0:2]=0;a[3]=0 + self.st+=1 + return a.copy() diff --git a/policies/stack_blocks/gpt61terra-s1/episodes.csv b/policies/stack_blocks/gpt61terra-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..459a7c9d2ed1a285e6015ba27579c168231ca9eb --- /dev/null +++ b/policies/stack_blocks/gpt61terra-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,661,terminated,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,736,terminated,0 +620016,0,8750,timeout,0 +620017,0,1036,terminated,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,474,terminated,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,1107,terminated,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/gpt61terra-s1/policy.py b/policies/stack_blocks/gpt61terra-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..979eca05cfce189143ac680be4bd85dc059b982a --- /dev/null +++ b/policies/stack_blocks/gpt61terra-s1/policy.py @@ -0,0 +1,76 @@ +"""Deterministic visual manipulation and waypoint control for stack_blocks.""" +import math +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.a=np.asarray(tools.hold_action(),dtype=np.float32) + self.a[19:21]=0 + self.phase='pickup1'; self.start=0; self.route=0 + + def change(self, phase, t): + self.phase=phase; self.start=t + + def walk(self, obs, goal): + q=obs['low_dim_obs']; x,y,yaw=q[21],q[22],q[24] + dx=goal[0]-x;dy=goal[1]-y + ang=(goal[2]-yaw+math.pi)%(2*math.pi)-math.pi + vx=np.clip(.8*dx,-.16,.16); vy=np.clip(.8*dy,-.16,.16) + if math.hypot(dx,dy)<.06: vx=vy=0 + self.a[0]=vx*math.cos(yaw)+vy*math.sin(yaw) + self.a[1]=-vx*math.sin(yaw)+vy*math.cos(yaw) + self.a[3]=np.clip(.8*ang,-.3,.3) if abs(ang)>.06 else 0 + return math.hypot(dx,dy)<.08 and abs(ang)<.09 + + def act(self, obs, tools): + t=obs['t']; age=t-self.start; q=obs['low_dim_obs'] + a=self.a + if self.phase=='pickup1': + a[6]=.35;a[13]=-.35 + if age<90: a[0]=.12 if q[21]<.24 else 0 + elif age<180: a[0]=0;a[2]=.65 + elif age<270: a[19:21]=1 + elif age<370:a[2]=.74 + else:self.route=0;self.change('out1',t) + elif self.phase in ('out1','out2'): + goals=[(-.07,0,0),(-.07,-.78,0),(1.35,-.78,0),(1.35,-.78,1.6)] + if self.walk(obs,goals[self.route]): + self.route+=1 + if self.route==len(goals):a[0:2]=0;a[3]=0;self.change('place1' if self.phase=='out1' else 'place3',t) + elif self.phase=='place1': + a[0:2]=0;a[3]=0 + z=min(1.,age/300.) + a[6]=.35*(1-z);a[13]=-.35*(1-z) + a[5]=a[12]=-.6*z;a[8]=a[15]=z + if age>375: + w=min(1.,(age-375)/150.);a[5]=a[12]=-.6-.65*w;a[8]=a[15]=1.-.9*w + if age>550:a[2]=.65 + if age>650:a[19]=0 + if age>825: + w=min(1.,(age-825)/150.);a[5]=-.8-.4*w;a[8]=.7+.5*w + if age>1050: + w=min(1.,(age-1050)/180.);a[13]=.27*w + if age>1250:a[20]=0 + if age>1400: + a[2]=.74;a[5:19]=0;a[19:21]=0 + if age>1500:self.route=0;self.change('back',t) + elif self.phase=='back': + goals=[(1.35,-.85,0),(-.07,-.8,0),(-.07,0,0),(.24,0,0)] + if self.walk(obs,goals[self.route]): + self.route+=1 + if self.route==len(goals):a[0:2]=0;a[3]=0;self.change('pickup3',t) + elif self.phase=='pickup3': + a[6]=.5;a[13]=0 + if age<70:a[0]=.12 if q[21]<.24 else 0 + elif age<160:a[0]=0;a[2]=.65 + elif age<250:a[20]=1 + elif age<350:a[2]=.74 + else:self.route=0;self.change('out2',t) + elif self.phase=='place3': + a[0:2]=0;a[3]=0 + z=min(1.,age/300.) + a[13]=.27*z;a[12]=-1.25*z;a[15]=.1*z + if age>350:a[2]=.68 + if age>450:a[20]=0 + if age>600:a[12]=-1.2;a[15]=1.2 + return a.copy() diff --git a/policies/stack_blocks/gpt61terra-s2/episodes.csv b/policies/stack_blocks/gpt61terra-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..29afd2d2acd4855e7a7feab8abd47059199abdd2 --- /dev/null +++ b/policies/stack_blocks/gpt61terra-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,1555,terminated,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,2178,terminated,0 +620025,0,8750,timeout,0 +620026,0,5117,terminated,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,1692,terminated,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,5704,terminated,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,2199,terminated,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,3032,terminated,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,2335,terminated,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/gpt61terra-s2/policy.py b/policies/stack_blocks/gpt61terra-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..54891af402b38d0e293c49f77fe4a57793a14db6 --- /dev/null +++ b/policies/stack_blocks/gpt61terra-s2/policy.py @@ -0,0 +1,108 @@ +"""Deterministic vision-assisted block transfer controller.""" +import math +import numpy as np +import cv2 + +class Policy: + def reset(self, obs, tools): + self.a=np.asarray(tools.hold_action(),dtype=np.float32) + self.phase='pickup'; self.enter=0 + self.left_roll=.25; self.right_roll=-.15 + im=tools.image('head') + mask=((im[:,:,0]>130)&(im[:,:,0]>im[:,:,1]*1.7)&(im[:,:,0]>im[:,:,2]*1.7)).astype(np.uint8) + n, lab, stats, cent=cv2.connectedComponentsWithStats(mask) + blobs=sorted([cent[i,0] for i in range(1,n) if stats[i,4]>=7]) + if len(blobs)>=3: + self.left_roll=float(np.clip(.25-(blobs[0]-15)*.012,.05,.45)) + self.right_roll=float(np.clip(-.15-(blobs[-1]-66)*.012,-.4,.05)) + self.a[19:21]=0 + self.a[6]=self.left_roll;self.a[13]=self.right_roll + def switch(self,p,t): + self.phase=p; self.enter=t + def act(self,obs,tools): + t=obs['t']; x,y,z,yaw=map(float,obs['low_dim_obs'][21:25]); dt=t-self.enter + a=self.a.copy();a[0]=a[1]=a[3]=0 + phase=self.phase + if phase=='pickup': + a[0]=.1 if 30<=dt<85 else 0 + if dt>=100:a[2]=.65 + if dt==140:a[5]=a[12]=-.1 + if 170<=dt<320 and dt%10==0: + for camera, pi, ri, wanted in [('left_wrist',5,6,35),('right_wrist',12,13,45)]: + im=tools.image(camera) + red=(im[:,:,0]>120)&(im[:,:,0]>1.6*im[:,:,1])&(im[:,:,0]>1.6*im[:,:,2]) + yy,xx=np.nonzero(red) + if len(xx)>20: + dx=wanted-float(np.mean(xx)); dy=float(np.mean(yy))-35 + if abs(dx)>8:a[ri]=np.clip(a[ri]+np.clip(dx*.0015,-.025,.025),-.5,.55) + if abs(dy)>10:a[pi]=np.clip(a[pi]+np.clip(dy*.0015,-.025,.025),-.3,.25) + if dt>=340:a[19:21]=1 + if dt>=470:a[2]=.74 + if dt>=620:self.switch('out_side',t) + elif phase=='out_side': + a[1]=-.25; a[3]=np.clip(-yaw,-.3,.3) + if y<-.95 or dt>450:self.switch('out_forward',t) + elif phase=='out_forward': + a[0]=.25; a[3]=np.clip(-yaw,-.3,.3) + if x>1.25 or dt>450:self.switch('turn_pad',t) + elif phase=='turn_pad': + a[3]=np.clip(1.57-yaw,-.3,.3) + if yaw>1.50 or dt>450:self.switch('approach_pad',t) + elif phase=='approach_pad': + a[0]=.12;a[3]=np.clip(1.57-yaw,-.3,.3) + if y>-.68 or dt>300:self.switch('first_place',t) + elif phase=='first_place': + a[4]=.8;a[12]=-.30;a[13]=-.15 + if dt>200:a[2]=.70 + if dt>400:a[20]=0 + if dt>550:self.switch('shift',t) + elif phase=='shift': + a[4]=0;a[2]=.74;a[12]=-.6 + if dt>100: + a[1]=-.12;a[3]=np.clip(1.57-yaw,-.3,.3) + if (dt>100 and x>1.57) or dt>300:self.switch('second_place',t) + elif phase=='second_place': + a[4]=.45;a[5]=-.3;a[6]=-.35 + if dt>180:a[2]=.73 + if dt>350:a[19]=0 + if dt>500:self.switch('back_from_pad',t) + elif phase=='back_from_pad': + a[2]=.74;a[4]=0;a[5]=a[12]=-.1;a[6]=.25;a[13]=-.15 + if dt>100:a[0]=-.20 + a[3]=np.clip(1.57-yaw,-.3,.3) + if y<-.98 or dt>400:self.switch('turn_home',t) + elif phase=='turn_home': + a[3]=np.clip(-yaw,-.3,.3) + if yaw<.07 or dt>400:self.switch('home_forward',t) + elif phase=='home_forward': + a[0]=-.25;a[3]=np.clip(-yaw,-.3,.3) + if x<.22 or dt>500:self.switch('home_side',t) + elif phase=='home_side': + a[1]=.22;a[3]=np.clip(-yaw,-.3,.3) + if y>.12 or dt>500:self.switch('third_pick',t) + elif phase=='third_pick': + a[2]=.74;a[4]=0;a[12]=0;a[13]=-.15;a[20]=0 + if dt>100:a[0]=.1 + if dt>150:a[0]=0 + if dt>200:a[2]=.65 + if dt>240:a[12]=-.1 + if dt>350:a[20]=1 + if dt>450:a[2]=.74 + if dt>600:self.switch('return_side',t) + elif phase=='return_side': + a[1]=-.25;a[3]=np.clip(-yaw,-.3,.3) + if y<-.95 or dt>500:self.switch('return_forward',t) + elif phase=='return_forward': + a[0]=.25;a[3]=np.clip(-yaw,-.3,.3) + if x>1.25 or dt>500:self.switch('return_turn',t) + elif phase=='return_turn': + a[3]=np.clip(1.57-yaw,-.3,.3) + if yaw>1.5 or dt>450:self.switch('return_approach',t) + elif phase=='return_approach': + a[0]=.12;a[3]=np.clip(1.57-yaw,-.3,.3) + if y>-.68 or dt>300:self.switch('third_place',t) + elif phase=='third_place': + a[4]=.5;a[12]=-.3;a[13]=-.15 + if dt>300:a[20]=0 + self.a=a.copy() + return a diff --git a/policies/stack_blocks/gpt61terra-s3/episodes.csv b/policies/stack_blocks/gpt61terra-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..68e8224f48b9a67149ee3ef9c0540aa98a006d1e --- /dev/null +++ b/policies/stack_blocks/gpt61terra-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,1267,terminated,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,1061,terminated,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,878,terminated,0 +620010,0,1432,terminated,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,1385,terminated,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,7611,terminated,0 +620017,0,8750,timeout,0 +620018,0,1225,terminated,0 +620019,0,7669,terminated,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,6345,terminated,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,6411,terminated,0 +620031,0,8750,timeout,0 +620032,0,7812,terminated,0 +620033,0,8750,timeout,0 +620034,0,6981,terminated,0 +620035,0,8750,timeout,0 +620036,0,7432,terminated,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,7478,terminated,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,7358,terminated,0 +620050,0,7209,terminated,0 +620051,0,1990,terminated,0 +620052,0,8750,timeout,0 +620053,0,6931,terminated,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,7153,terminated,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,1799,terminated,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,2171,terminated,0 +620066,0,8750,timeout,0 +620067,0,840,terminated,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,7390,terminated,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,552,terminated,0 +620074,0,1843,terminated,0 +620075,0,8750,timeout,0 +620076,0,2201,terminated,0 +620077,0,8750,timeout,0 +620078,0,581,terminated,0 +620079,0,1255,terminated,0 +620080,0,511,terminated,0 +620081,0,778,terminated,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,1187,terminated,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,568,terminated,0 +620090,0,8750,timeout,0 +620091,0,761,terminated,0 +620092,0,8750,timeout,0 +620093,0,6715,terminated,0 +620094,0,6277,terminated,0 +620095,0,1248,terminated,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/gpt61terra-s3/policy.py b/policies/stack_blocks/gpt61terra-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..3562c954d39b6a0ff605a32509e314467eced0c5 --- /dev/null +++ b/policies/stack_blocks/gpt61terra-s3/policy.py @@ -0,0 +1,136 @@ +import math +import numpy as np +import cv2 + +class Policy: + def reset(self, obs, tools): + self.a = np.asarray(tools.hold_action(), dtype=np.float32) + self.a[19:21] = 0 + self.a[6] = .22 + self.a[13] = -.22 + self.third_x = .2 + self.third_y = .17 + self.approach_steps = 35 + im = tools.image('head') + red = ((im[:,:,0] > 130) & (im[:,:,0] > im[:,:,1]*1.7) & (im[:,:,0] > im[:,:,2]*1.7)).astype(np.uint8) + n, labels, stats, centers = cv2.connectedComponentsWithStats(red) + blobs = sorted([(centers[i][0], centers[i][1], stats[i,4]) for i in range(1,n) if stats[i,4] >= 25], key=lambda p:p[0]) + if len(blobs) >= 3: + left, mid, right = blobs[0], blobs[len(blobs)//2], blobs[-1] + self.a[6] = np.clip(.22 + (13.3-left[0])*.020, -.15, .50) + self.a[13] = np.clip(-.22 + (66.5-right[0])*.020, -.50, .15) + self.approach_steps = int(round(np.clip(35 - ((left[1]+right[1])*.5-25.0)*2.5, 17, 50))) + self.third_x = float(np.clip(.2 - (mid[1]-26.7)*.010, .12, .26)) + self.third_y = float(np.clip(.17 - (mid[0]-36.2)*.010, -.05, .38)) + self.stage = 0 + self.n = 0 + self.waypoints = [] + self.point = 0 + self.wait = 0 + self.point_steps = 0 + + def next(self): + self.stage += 1 + self.n = 0 + + def path(self, points): + self.waypoints = points + self.point = 0 + self.wait = 0 + self.point_steps = 0 + + def navigate(self, obs): + if self.point >= len(self.waypoints): + self.a[0:2]=0; self.a[3]=0 + return True + x,y,yaw = self.waypoints[self.point] + X,Y,_,th = obs['low_dim_obs'][21:25] + dx,dy=x-X,y-Y + ang=(yaw-th+math.pi)%(2*math.pi)-math.pi + dist=math.hypot(dx,dy) + self.point_steps += 1 + if (dist < .055 and abs(ang)<.075) or (self.point_steps > 350 and dist < .09 and abs(ang) < .13): + self.a[0:2]=0;self.a[3]=0 + self.wait+=1 + if self.wait>=30: + self.point+=1; self.wait=0; self.point_steps=0 + return False + self.wait=0 + v=np.clip(np.array([dx,dy])*1.0,-.27,.27) + self.a[0]=math.cos(th)*v[0]+math.sin(th)*v[1] + self.a[1]=-math.sin(th)*v[0]+math.cos(th)*v[1] + if dist<.05:self.a[0:2]=0 + self.a[3]=np.clip(ang*1.3,-.5,.5) + return False + + def act(self, obs, tools): + s=self.stage; self.n+=1 + if s==0: + self.a[0]=.2 + if self.n>=self.approach_steps:self.a[0]=0;self.next() + elif s==1: + self.a[2]=.63 + if self.n>=150:self.next() + elif s==2: + self.a[19:21]=1 + if self.n>=100:self.next() + elif s==3: + self.a[2]=.74 + if self.n>=150: + self.path([(.2,0,1.57),(.2,.9,1.57),(.2,.9,0),(2.7,.9,0),(2.7,.9,-1.57),(2.7,0,-1.57),(2.7,0,3.14),(1.9,.18,3.14)]);self.next() + elif s==4: + if self.navigate(obs):self.next() + elif s==5: + self.a[2]=.63 + if self.n>=150:self.next() + elif s==6: + self.a[19]=0 + if self.n>=120:self.next() + elif s==7: + self.a[2]=.74;self.a[5]=-.5 + if self.n>=150:self.path([(1.9,-.32,3.14)]);self.next() + elif s==8: + if self.navigate(obs):self.next() + elif s==9: + self.a[2]=.69 + if self.n>=150:self.next() + elif s==10: + self.a[20]=0 + if self.n>=120:self.next() + elif s==11: + self.a[2]=.74;self.a[12]=-.5 + if self.n>=150: + self.path([(2.7,-.32,3.14),(2.7,.9,1.57),(.2,.9,3.14),(.2,.9,0),(self.third_x,self.third_y,0)]);self.next() + elif s==12: + if self.navigate(obs):self.next() + elif s==13: + self.a[12]=0 + if self.n < 40: + self.a[13]=-.22 + elif self.n % 10 == 0: + im = tools.image('right_wrist') + mask = ((im[:,:,0] > 130) & (im[:,:,0] > im[:,:,1]*1.7) & (im[:,:,0] > im[:,:,2]*1.7)).astype(np.uint8) + count, labels, stats, centers = cv2.connectedComponentsWithStats(mask) + candidates = [i for i in range(1,count) if stats[i,4] >= 20] + if candidates: + i = max(candidates, key=lambda j:stats[j,4]) + self.a[13] = np.clip(self.a[13] + np.clip((35-centers[i,0])*.002, -.035, .035), -.5, .15) + if self.n>=120:self.next() + elif s==14: + self.a[2]=.63 + if self.n>=150:self.next() + elif s==15: + self.a[20]=1 + if self.n>=120:self.next() + elif s==16: + self.a[2]=.74 + if self.n>=150: + self.path([(.2,.9,1.57),(.2,.9,0),(2.7,.9,0),(2.7,0,-1.57),(2.7,0,3.14),(1.9,-.32,3.14)]);self.next() + elif s==17: + if self.navigate(obs):self.next() + elif s==18: + self.a[20]=0 + if self.n>=120:self.next() + elif s==19: + self.a[12]=-.5 + return self.a.copy() diff --git a/policies/stack_blocks/gpt6sol-s1/episodes.csv b/policies/stack_blocks/gpt6sol-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..27a1f7b0bcc9b13296c9320727b7e99049a047f3 --- /dev/null +++ b/policies/stack_blocks/gpt6sol-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,573,terminated,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,5192,terminated,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,654,terminated,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,648,terminated,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,2900,terminated,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,703,terminated,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,1401,terminated,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,2883,terminated,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/gpt6sol-s1/policy.py b/policies/stack_blocks/gpt6sol-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..bc365f1298e8c816f63f271a5a37c23e15b69b8d --- /dev/null +++ b/policies/stack_blocks/gpt6sol-s1/policy.py @@ -0,0 +1,198 @@ +"""Deterministic whole-body script for the block stacking task.""" + +import math +import numpy as np +import cv2 + + +def angle_error(target, actual): + return math.atan2(math.sin(target - actual), math.cos(target - actual)) + + +class Policy: + def reset(self, obs, tools): + self.a = np.asarray(tools.hold_action(), dtype=np.float32).copy() + self.a[19:21] = 0.0 + self.phase = 0 + self.clock = 0 + self.entered = False + self.stages = [] + + def hold(n, edits=None): + self.stages.append(('hold', n, edits or {})) + + def turn(yaw): + self.stages.append(('turn', yaw, {})) + hold(20, {3: 0}) + + def walk(axis, target, yaw, speed=.28): + self.stages.append(('walk', (axis, target, yaw, speed), {})) + hold(25, {0: 0, 1: 0, 3: 0}) + + def strafe(target, yaw): + self.stages.append(('strafe', (target, yaw), {})) + hold(20, {0: 0, 1: 0, 3: 0}) + + def back(target): + self.stages.append(('back', target, {})) + hold(20, {0: 0, 1: 0, 3: 0}) + + def adjust(x, y): + for _ in range(3): + self.stages.append(('adjust', (x, y), {})) + hold(20, {0: 0, 1: 0, 3: 0}) + + def align(camera, joint, target, pixels_per_radian): + self.stages.append(('align', (camera, joint, target, pixels_per_radian), {})) + + # Grasp the two outside blocks, one hand at a time. + self.stages.append(('approach', .225, {})) + hold(30) + hold(60, {5: -.3, 6: .3, 10: .9}) + align('left_wrist', 6, 50, 245) + hold(60, {19: 1}) + hold(60, {5: -.5, 10: 1.2}) + hold(60, {12: -.3, 13: -.3, 17: .9}) + align('right_wrist', 13, 40, 90) + hold(60, {20: 1}) + hold(60, {12: -.5, 17: 1.2}) + + # Pass north of both tables, then approach the east side of the pad. + strafe(1.2, 0) + walk('x', 2.3, 0) + strafe(0, 0) + turn(math.pi) + walk('x', 1.85, math.pi) + adjust(1.94, .24) + + # Place the first block. + hold(60, {6: -.35}) + hold(80, {19: 0}) + hold(60, {5: -.3, 6: .3, 10: .9}) + hold(80) + + # Move the base so the right hand is over the placed block. + adjust(1.95, -.20) + hold(90, {20: 0}) + hold(60, {12: -.8}) + hold(90) + + # Return for the remaining center block. + back(2.3) + strafe(1.2, math.pi) + walk('x', .05, math.pi) + strafe(-.14, math.pi) + adjust(.08, -.14) + turn(0) + adjust(.08, -.14) + self.stages.append(('approach', .225, {})) + hold(30) + hold(60, {5: -.3, 6: .3, 10: .9}) + align('left_wrist', 6, 23, 245) + hold(60, {19: 1}) + hold(60, {5: -.5, 10: 1.2}) + + # Carry the center block to the stack. + strafe(1.2, 0) + walk('x', 2.3, 0) + strafe(0, 0) + turn(math.pi) + walk('x', 1.85, math.pi) + adjust(1.94, .24) + hold(60, {5: -.7, 6: -.35}) + hold(80, {19: 0}) + hold(60, {5: -.3, 6: .3, 10: .9}) + hold(150) + + def act(self, obs, tools): + pose = obs['low_dim_obs'] + while self.phase < len(self.stages): + kind, param, edits = self.stages[self.phase] + if not self.entered: + for i, value in edits.items(): + self.a[i] = value + if kind == 'align': + camera, joint, target, scale = param + image = tools.image(camera) + red = ((image[:, :, 0] > 100) & + (image[:, :, 0] > 1.7 * image[:, :, 1]) & + (image[:, :, 0] > 1.7 * image[:, :, 2])).astype(np.uint8) + n, _, stats, centers = cv2.connectedComponentsWithStats(red, 8) + if n > 1: + i = 1 + int(np.argmax(stats[1:, 4])) + if stats[i, 4] > 350: + delta = np.clip((target - centers[i, 0]) / scale, -.15, .15) + self.a[joint] += delta + self.entered = True + self.clock = 0 + + finished = False + if kind == 'hold': + if 0 not in edits: + self.a[0] = 0 + if 1 not in edits: + self.a[1] = 0 + if 3 not in edits: + self.a[3] = 0 + finished = self.clock >= param + elif kind == 'align': + self.a[0:2] = 0 + self.a[3] = 0 + finished = self.clock >= 35 + elif kind == 'approach': + self.a[0] = .20 + self.a[1] = 0 + self.a[3] = 0 + finished = float(pose[21]) > param or self.clock > 250 + elif kind == 'turn': + err = angle_error(param, float(pose[24])) + self.a[0:2] = 0 + turn_limit = .35 if self.a[19] > .5 or self.a[20] > .5 else .8 + self.a[3] = np.clip(err, -turn_limit, turn_limit) + finished = abs(err) < .025 or self.clock > 600 + elif kind == 'strafe': + target, yaw = param + coord = float(pose[22]) + if self.clock == 0: + self.direction = 1 if target > coord else -1 + self.a[0] = 0 + self.a[1] = self.direction * .5 * math.cos(float(pose[24])) + self.a[3] = np.clip(.8 * angle_error(yaw, float(pose[24])), -.25, .25) + finished = self.direction * (target - coord) < .02 or self.clock > 500 + elif kind == 'back': + self.a[0] = -.35 + self.a[1] = 0 + self.a[3] = np.clip(.8 * angle_error(math.pi, float(pose[24])), -.25, .25) + finished = float(pose[21]) > param - .02 or self.clock > 200 + elif kind == 'walk': + axis, target, yaw, speed = param + coord = float(pose[21 if axis == 'x' else 22]) + if self.clock == 0: + self.direction = 1 if target > coord else -1 + self.a[0] = speed + self.a[1] = 0 + self.a[3] = np.clip(.8 * angle_error(yaw, float(pose[24])), -.2, .2) + finished = self.direction * (target - coord) < .015 or self.clock > 1000 + else: + x, y = param + ex, ey = x - float(pose[21]), y - float(pose[22]) + yaw = float(pose[24]) + vx = math.cos(yaw) * ex + math.sin(yaw) * ey + vy = -math.sin(yaw) * ex + math.cos(yaw) * ey + self.a[0] = np.clip(1.2 * vx, -.2, .2) + self.a[1] = np.clip(1.2 * vy, -.2, .2) + for i, error in ((0, vx), (1, vy)): + if .025 < abs(error) and abs(self.a[i]) < .07: + self.a[i] = math.copysign(.07, self.a[i]) + self.a[3] = 0 + finished = (abs(ex) < .025 and abs(ey) < .025) or self.clock > 250 + + if finished: + self.phase += 1 + self.entered = False + continue + self.clock += 1 + return self.a.copy() + self.a[0:2] = 0 + self.a[3] = 0 + return self.a.copy() diff --git a/policies/stack_blocks/gpt6sol-s2/episodes.csv b/policies/stack_blocks/gpt6sol-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..0df0d0c9502a1165e06b717ecfae6f7cc8821bb2 --- /dev/null +++ b/policies/stack_blocks/gpt6sol-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,5155,terminated,0 +620009,0,8750,timeout,0 +620010,0,2207,terminated,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,377,terminated,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,5119,terminated,0 +620022,0,8750,timeout,0 +620023,0,4777,terminated,0 +620024,0,826,terminated,0 +620025,0,4523,terminated,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,1935,terminated,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,377,terminated,0 +620047,0,8750,timeout,0 +620048,0,4123,terminated,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,4789,terminated,0 +620055,0,8750,timeout,0 +620056,0,392,terminated,0 +620057,0,8750,timeout,0 +620058,0,4276,terminated,0 +620059,0,8750,timeout,0 +620060,0,1912,terminated,0 +620061,0,8750,timeout,0 +620062,0,819,terminated,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,395,terminated,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,1905,terminated,0 +620073,0,396,terminated,0 +620074,0,371,terminated,0 +620075,0,372,terminated,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,400,terminated,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,383,terminated,0 +620090,0,8750,timeout,0 +620091,0,4522,terminated,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,2138,terminated,0 diff --git a/policies/stack_blocks/gpt6sol-s2/policy.py b/policies/stack_blocks/gpt6sol-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..6e667b60468840afd40b4b335b50361428eaef4a --- /dev/null +++ b/policies/stack_blocks/gpt6sol-s2/policy.py @@ -0,0 +1,156 @@ +"""Deterministic camera and proprioceptive controller for the block task.""" + +import math +import numpy as np + + +def _wrap(v): + return (v + math.pi) % (2 * math.pi) - math.pi + + +class Policy: + def reset(self, obs, tools): + self.a = np.asarray(tools.hold_action(), dtype=np.float32) + self.a[2] = 0.74 + self.a[4] = 0 + self.a[5:19] = 0 + self.a[5] = self.a[12] = 0.2 + self.a[6] = 0.3 + self.a[13] = -0.3 + self.a[19:21] = 0 + self.phase = 0 + self.age = 0 + self.near = 0 + self.third_y = None + self.grab_tries = 0 + + def _nav(self, obs, x, y, heading, speed=0.28): + q = obs["low_dim_obs"] + dx = x - float(q[21]) + dy = y - float(q[22]) + yaw = float(q[24]) + err = _wrap(heading - yaw) + near = math.hypot(dx, dy) < 0.07 and abs(err) < 0.05 + if near: + self.a[0] = self.a[1] = self.a[3] = 0 + self.near += 1 + else: + self.near = 0 + v = np.clip(np.array([dx, dy]) * 1.5, -speed, speed) + c = math.cos(yaw) + s = math.sin(yaw) + self.a[0] = c * v[0] + s * v[1] + self.a[1] = -s * v[0] + c * v[1] + self.a[3] = np.clip(1.5 * err, -0.4, 0.4) + if math.hypot(dx, dy) < 0.07: + self.a[0:2] = 0 + return self.near >= 30 or self.age > 850 + + def act(self, obs, tools): + self.a[0] = self.a[1] = self.a[3] = 0 + p = self.phase + done = False + if p == 0: + done = self.age >= 70 + elif p == 1: + self.a[0] = 0.12 + done = self.age >= 100 + elif p == 2: + self.a[19:21] = 1 + done = self.age >= 70 + elif p == 3: + self.a[0] = -0.2 + done = self.age >= 140 + elif p == 4: + done = self._nav(obs, 0, -1.5, 0) + elif p == 5: + self.a[5] = self.a[12] = -0.2 + done = self._nav(obs, 2.25, -1.5, 0) + elif p == 6: + done = self._nav(obs, 2.04, -0.07, math.pi) + elif p == 7: + self.a[12] = 0 + self.a[13] = 0.3 + done = self.age >= 100 + elif p == 8: + self.a[20] = 0 + done = self.age >= 120 + elif p == 9: + self.a[12] = -0.2 + self.a[13] = -0.3 + done = self._nav(obs, 2.04, 0.25, math.pi, 0.2) + elif p == 10: + self.a[5] = -0.1 + self.a[6] = -0.1 + done = self.age >= 100 + elif p == 11: + self.a[19] = 0 + done = self.age >= 120 + elif p == 12: + self.a[5:19] = 0 + done = self._nav(obs, 2.25, -1.5, math.pi) + elif p == 13: + done = self._nav(obs, 0, -1.5, math.pi) + elif p == 14: + q = obs["low_dim_obs"] + if self.third_y is None and math.hypot(float(q[21]) - 0.1, float(q[22]) + 0.08) < 0.1 and abs(_wrap(float(q[24]))) < 0.1: + im = tools.image("head") + rr = im[:, :, 0].astype(np.int16) + gg = im[:, :, 1].astype(np.int16) + bb = im[:, :, 2].astype(np.int16) + mask = (rr > 140) & (rr > gg * 1.7) & (rr > bb * 1.5) + mask[45:, :] = False + xs = np.where(mask)[1] + if len(xs) >= 5: + self.third_y = float(np.clip(float(q[22]) + (12.0 - float(np.median(xs))) / 140.0, -0.3, 0.15)) + else: + self.third_y = -0.08 + self.near = 0 + done = self._nav(obs, 0.1, self.third_y if self.third_y is not None else -0.08, 0) + elif p == 15: + self.a[5] = 0.2 + self.a[6] = 0.1 - 0.1 * self.grab_tries + self.a[19] = 0 + done = self.age >= 70 + elif p == 16: + self.a[0] = 0.12 + done = self.age >= 60 - 10 * self.grab_tries + elif p == 17: + self.a[19] = 1 + done = self.age >= 70 + elif p == 18: + self.a[0] = -0.2 + done = self.age >= 140 + elif p == 19: + if self.age == 0 and self.grab_tries < 2: + im = tools.image("left_wrist") + rr = im[:, :, 0].astype(np.int16) + gg = im[:, :, 1].astype(np.int16) + bb = im[:, :, 2].astype(np.int16) + held_pixels = int(((rr > 140) & (rr > gg * 1.7) & (rr > bb * 1.5)).sum()) + if held_pixels < 450: + self.grab_tries += 1 + self.third_y = None + self.phase = 14 + self.a[19] = 0 + return self.a.copy() + done = self._nav(obs, 0, -1.5, 0) + elif p == 20: + self.a[5] = -0.2 + done = self._nav(obs, 2.25, -1.5, 0) + elif p == 21: + done = self._nav(obs, 2.04, 0.25, math.pi) + elif p == 22: + self.a[5] = -0.1 + self.a[6] = -0.1 + done = self.age >= 100 + elif p == 23: + self.a[19] = 0 + done = self.age >= 120 + if done: + self.phase += 1 + self.age = 0 + self.near = 0 + else: + self.age += 1 + return self.a.copy() diff --git a/policies/stack_blocks/gpt6sol-s3/episodes.csv b/policies/stack_blocks/gpt6sol-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..07713af5e158534461310f3553da26a556f79344 --- /dev/null +++ b/policies/stack_blocks/gpt6sol-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,4410,terminated,0 +620001,0,966,terminated,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,4401,terminated,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8564,terminated,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,7410,terminated,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,3862,terminated,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,4049,terminated,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/gpt6sol-s3/policy.py b/policies/stack_blocks/gpt6sol-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..00c5e5da08f663473d66ca77de5cb6f24923567d --- /dev/null +++ b/policies/stack_blocks/gpt6sol-s3/policy.py @@ -0,0 +1,138 @@ +"""Hand-written, deterministic block transport controller.""" +import math +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.base = np.asarray(tools.hold_action(), dtype=np.float32) + self.phase = "approach" + self.age = 0 + self.trip = 0 + + def change(self, name): + self.phase = name + self.age = 0 + + @staticmethod + def wrap(x): + return (x + math.pi) % (2 * math.pi) - math.pi + + def go(self, a, q, x, y, yaw=0., speed=.27): + dx, dy = x - float(q[21]), y - float(q[22]) + c, s = math.cos(float(q[24])), math.sin(float(q[24])) + a[0] = np.clip(1.5 * (c * dx + s * dy), -speed, speed) + a[1] = np.clip(1.5 * (-s * dx + c * dy), -speed, speed) + if abs(a[0]) < .06: a[0] = 0 + if abs(a[1]) < .06: a[1] = 0 + err = self.wrap(yaw - float(q[24])) + a[3] = np.clip(1.2 * err, -.5, .5) + return math.hypot(dx, dy) < .055 and abs(err) < .07 + + @staticmethod + def arms(a, p=-.5, torso=0., grip=1.): + a[4] = torso + a[5:12] = (p, .1, -.1, 0, 0, .3, -.6) + a[12:19] = (p, -.1, .1, 0, 0, .3, .6) + a[19:21] = grip + + def act(self, obs, tools): + q = obs['low_dim_obs'] + a = self.base.copy() + self.age += 1 + p = self.phase + if p == 'approach': + self.arms(a, grip=0) + offset = (0., .10, -.10)[min(self.trip, 2)] + a[0] = .12 if q[21] < .22 else 0 + a[1] = np.clip(1.5 * (offset - q[22]), -.12, .12) + if abs(a[1]) < .06: a[1] = 0 + a[3] = np.clip(-1.2 * q[24], -.3, .3) + if q[21] >= .22 or self.age > 240: + self.change('reach') + elif p == 'reach': + self.arms(a, .1, .15, 0) + if self.age >= 80: self.change('close') + elif p == 'close': + self.arms(a, .1, .15, 1) + if self.age >= 60: self.change('lift1') + elif p == 'lift1': + z = min(1., self.age / 100.) + self.arms(a, .1 - .2*z, .15*(1-z), 1) + if self.age >= 100: self.change('lift2') + elif p == 'lift2': + z = min(1., self.age / 150.) + self.arms(a, -.1 - .4*z, 0, 1) + if self.age >= 150: self.change('back') + elif p == 'back': + self.arms(a) + if self.go(a, q, .02, 0, speed=.16) or self.age > 180: + self.change('north') + elif p == 'north': + self.arms(a) + if self.go(a, q, .02, 1.16) or self.age > 450: + self.change('east') + elif p == 'east': + self.arms(a) + if self.go(a, q, 1.45, 1.16) or self.age > 550: + self.change('turn_pad') + elif p == 'turn_pad': + self.arms(a) + if self.go(a, q, 1.45, 1.16, -math.pi/2, .18) or self.age > 260: + self.change('pad') + elif p == 'pad': + self.arms(a) + if self.go(a, q, 1.30, .77, -math.pi/2, .16) or self.age > 300: + self.change('lower_left') + elif p == 'lower_left': + z = min(1., self.age / 100.) + self.arms(a, -.5 + .6*z, .15*z) + a[12] = -.5 + if self.age >= 100: self.change('release_left') + elif p == 'release_left': + self.arms(a, .1, .15) + a[12] = -.5 + a[19] = 0 + if self.age >= 75: self.change('raise_left') + elif p == 'raise_left': + self.arms(a, .1 - .6*min(1., self.age/100.)) + a[19] = 0 + if self.age >= 100: self.change('pad_right') + elif p == 'pad_right': + self.arms(a) + a[19] = 0 + if self.go(a, q, 1.53, .77, -math.pi/2, .13) or self.age > 200: + self.change('lower_right') + elif p == 'lower_right': + z = min(1., self.age/100.) + self.arms(a) + a[19] = 0 + a[4] = .15*z + a[12] = -.5 + .6*z + if self.age >= 100: self.change('release_right') + elif p == 'release_right': + self.arms(a) + a[19:21] = 0 + a[4] = .15 + a[12] = .1 + if self.age >= 75: self.change('leave_pad') + elif p == 'leave_pad': + self.arms(a, grip=0) + if self.go(a, q, 1.45, 1.16, -math.pi/2, .2) or self.age > 350: + self.change('turn_home') + elif p == 'turn_home': + self.arms(a, grip=0) + if self.go(a, q, 1.45, 1.16, 0, .2) or self.age > 300: + self.change('west') + elif p == 'west': + self.arms(a, grip=0) + if self.go(a, q, .02, 1.16) or self.age > 600: + self.change('south') + elif p == 'south': + self.arms(a, grip=0) + if self.go(a, q, .02, 0) or self.age > 500: + self.trip += 1 + self.change('approach' if self.trip < 3 else 'hold') + else: + self.arms(a, grip=0) + return a diff --git a/policies/stack_blocks/kimi31pro-s1/episodes.csv b/policies/stack_blocks/kimi31pro-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..b18dcda0398a9ca18cd023f7e40916d2886e3fb1 --- /dev/null +++ b/policies/stack_blocks/kimi31pro-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,5820,terminated,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,4576,terminated,0 +620033,0,609,terminated,0 +620034,0,8750,timeout,0 +620035,0,528,terminated,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,6775,terminated,0 +620042,0,682,terminated,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,5270,terminated,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,710,terminated,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,2526,terminated,0 +620092,0,8750,timeout,0 +620093,0,6381,terminated,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,685,terminated,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/kimi31pro-s1/policy.py b/policies/stack_blocks/kimi31pro-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..c1c1137f6bf608abd4d539cd4a2ca2b011081719 --- /dev/null +++ b/policies/stack_blocks/kimi31pro-s1/policy.py @@ -0,0 +1,379 @@ +"""Deterministic hand-written controller for the three-block stacking task.""" + +import cv2 +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.hold[19:21] = 0.0 + self.action = self.hold.copy() + self.start_action = self.action.copy() + self.trip = 0 + self.phase = "pre_grasp" + self.phase_start = int(obs["t"]) + self.torso_pitch = 0.0 + self.hold_ref = None + self.prev = None + self.stable = 0 + self.lost = 0 + self.acquire_attempts = 0 + self.yaw_adjust = 0.0 + self.need_visual = False + self.retries = [0, 0, 0] + blocks = self._components(tools.image("head"), "red", 15) + blocks = sorted(blocks, key=lambda c: c[0][0]) + if len(blocks) >= 3: + self.initial_outer = blocks[1][0][0] > 40 + selected = blocks[0] if self.initial_outer else blocks[1] + else: + self.initial_outer = False + selected = blocks[len(blocks) // 2] if blocks else (np.array([36.0, 25.0]), 40) + self.initial_target = selected[0].copy() + cx = blocks[1][0][0] if len(blocks) >= 3 else 36.0 + self.initial_yaw = 0.3 if self.initial_outer else float(np.clip(-0.3 - (cx - 36) * 0.0167, -0.55, 0.1)) + self.initial_pitch = -0.1 if self.initial_outer else -0.2 + + @staticmethod + def _components(im, color, min_area=1): + im = np.asarray(im) + if color == "green": + mask = ((im[:, :, 1] > 120) & (im[:, :, 1] > 1.25 * im[:, :, 0]) + & (im[:, :, 1] > 1.15 * im[:, :, 2])) + else: + mask = ((im[:, :, 0] > 150) & (im[:, :, 0] > 1.5 * im[:, :, 1]) + & (im[:, :, 0] > 1.5 * im[:, :, 2])) + n, _, stats, cents = cv2.connectedComponentsWithStats(mask.astype(np.uint8)) + return [(np.asarray(cents[i]), int(stats[i, 4])) for i in range(1, n) + if stats[i, 4] >= min_area] + + def _go(self, name, obs): + self.phase = name + self.phase_start = int(obs["t"]) + self.start_action = self.action.copy() + self.stable = 0 + self.lost = 0 + self.prev = None + if name == "pre_grasp": + self.yaw_adjust = 0.0 + if name in ("sidestep", "turn_home"): + self.hold_ref = None + self.torso_pitch = 0.0 + if name == "acquire": + self.torso_pitch = -0.2 + self.acquire_attempts += 1 + if name == "approach_settle" and self.trip == 2: + pel = obs["low_dim_obs"][21:25] + self.hold_ref = np.array([pel[0], pel[1], pel[3]]) + if name == "place_base": + pel = obs["low_dim_obs"][21:25] + self.hold_ref = np.array([pel[0], pel[1], pel[3]]) + if name == "turn_home": + self.torso_pitch = 0.0 + print("phase", self.trip, name, "t", int(obs["t"]), + "pel", np.round(obs["low_dim_obs"][21:25], 3), flush=True) + + def _pose(self, p=-0.2, yaw=0.0, elbow=0.3, grip=0.0, height=0.74): + raw = self.hold.copy() + raw[2] = height + raw[4] = self.torso_pitch + raw[5:12] = [p, 0.0, yaw, elbow, 0.0, 0.0, 0.0] + raw[12:19] = 0.0 + raw[19] = grip + raw[20] = 0.0 + return raw + + def _carry(self, grip=1.0): + return self._pose(-0.55, -0.3, 0.2, grip, 0.8) + + def _grasp_pose(self, grip=0.0): + if self.trip == 1: + yaw = 0.15 + 0.1 * min(self.retries[1], 2) + self.yaw_adjust + return self._pose(-0.2, yaw, 0.3, grip, 0.74) + if self.trip == 2: + elbow = max(0.3, 0.4 - 0.05 * self.retries[2]) + return self._pose(-0.2, -0.3 + self.yaw_adjust, elbow, grip, 0.74) + return self._pose(self.initial_pitch, self.initial_yaw, 0.3, grip, 0.74) + + def _place_pose(self, grip=1.0): + # Later blocks are released progressively higher above the same pad. + p = (-0.2, -0.32, -0.44)[self.trip] + h = (0.74, 0.76, 0.78)[self.trip] + return self._pose(p, -0.3, 0.3, grip, h) + + def _apply_base_hold(self, obs, raw): + if self.hold_ref is None: + return raw + pel = obs["low_dim_obs"][21:25] + yaw = pel[3] + dx, dy = self.hold_ref[0] - pel[0], self.hold_ref[1] - pel[1] + ex = np.cos(yaw) * dx + np.sin(yaw) * dy + ey = -np.sin(yaw) * dx + np.cos(yaw) * dy + raw[0] = 0 if abs(ex) < 0.015 else np.clip(2 * ex, -0.15, 0.15) + raw[1] = 0 if abs(ey) < 0.015 else np.clip(2 * ey, -0.15, 0.15) + if 0 < abs(raw[0]) < 0.06: + raw[0] = np.sign(raw[0]) * 0.06 + if 0 < abs(raw[1]) < 0.06: + raw[1] = np.sign(raw[1]) * 0.06 + ye = (self.hold_ref[2] - yaw + np.pi) % (2 * np.pi) - np.pi + raw[3] = 0 if abs(ye) < 0.02 else np.clip(ye, -0.3, 0.3) + return raw + + def _interp(self, target, pt, duration): + alpha = min(1.0, (pt + 1) / float(duration)) + raw = self.start_action * (1 - alpha) + target * alpha + raw[0] = target[0] + raw[1] = target[1] + raw[3] = target[3] + return raw + + def act(self, obs, tools): + pt = int(obs["t"]) - self.phase_start + name = self.phase + raw = self.action.copy() + + if name == "pre_grasp": + raw = self._interp(self._pose(-0.2, 0, 0.3, 0, 0.74), pt, 40) + if pt >= 39: + self._go("visual_align" if self.need_visual or self.trip >= 1 else "approach", obs) + + elif name == "visual_align": + cs = self._components(tools.image("head"), "red", 15) + if self.prev is None: + if cs: + if self.trip == 0: + self.prev = min(cs, key=lambda c: abs(c[0][0] - self.initial_target[0]))[0] + else: + self.prev = (min if self.trip == 1 else max)(cs, key=lambda c: c[0][0])[0] + else: + self.prev = self.initial_target.copy() if self.trip == 0 else (np.array([13.0, 24.0]) if self.trip == 1 else np.array([67.0, 24.0])) + if cs: + c = min(cs, key=lambda c: np.linalg.norm(c[0] - self.prev)) + if np.linalg.norm(c[0] - self.prev) < 20: + self.prev = c[0] + target_x = self.initial_target[0] if self.trip == 0 else (13 if self.trip == 1 else 36) + target_y = self.initial_target[1] if self.trip == 0 else 25 + ex, ey = target_x - self.prev[0], target_y - self.prev[1] + self.stable = self.stable + 1 if abs(ex) < 2.5 and abs(ey) < 2.5 else 0 + raw = self._pose(-0.2, 0, 0.3, 0, 0.74) + raw[0] = 0 if abs(ey) < 1.2 else np.sign(ey) * min(0.16, max(0.06, abs(ey) * 0.025)) + raw[1] = 0 if abs(ex) < 1.2 else np.sign(ex) * min(0.3, max(0.06, abs(ex) * 0.02)) + raw[3] = np.clip(-0.5 * obs["low_dim_obs"][24], -0.25, 0.25) + if self.stable >= 10 or pt >= 239: + self._go("visual_settle", obs) + + elif name == "visual_settle": + raw = self._pose(-0.2, 0, 0.3, 0, 0.74) + if pt >= 19: + self._go("approach", obs) + + elif name == "approach": + raw = self._pose(-0.2, 0, 0.3, 0, 0.74) + raw[0] = 0.2 + if pt >= 29: + self._go("approach_settle", obs) + + elif name == "approach_settle": + raw = self._pose(-0.2, 0, 0.3, 0, 0.74) + raw = self._apply_base_hold(obs, raw) + if pt >= 19: + self._go("align", obs) + + elif name == "align": + raw = self._interp(self._grasp_pose(0), pt, 30) + raw = self._apply_base_hold(obs, raw) + if pt >= 29: + self._go("settle", obs) + + elif name == "settle": + raw = self._grasp_pose(0) + raw = self._apply_base_hold(obs, raw) + if pt >= 19: + self._go("close", obs) + + elif name == "close": + if pt == 0 and self.trip >= 1: + cs = self._components(tools.image("left_wrist"), "red", 30) + if cs: + c = max(cs, key=lambda c: c[1])[0] + self.yaw_adjust = float(np.clip(0.008 * (40 - c[0]), -0.15, 0.28)) + else: + self.yaw_adjust = 0.2 if self.trip == 1 else 0.15 + raw = self._interp(self._grasp_pose(1), pt, 30) + raw = self._apply_base_hold(obs, raw) + if pt >= 29: + self._go("close_settle", obs) + + elif name == "close_settle": + raw = self._grasp_pose(1) + raw = self._apply_base_hold(obs, raw) + if pt >= 19: + self._go("lift", obs) + + elif name == "lift": + raw = self._interp(self._carry(1), pt, 50) + raw = self._apply_base_hold(obs, raw) + if pt >= 49: + self._go("lift_settle", obs) + + elif name == "lift_settle": + raw = self._carry(1) + raw = self._apply_base_hold(obs, raw) + if pt >= 29: + if np.mean(obs["low_dim_obs"][10:12]) < -0.017: + self.retries[self.trip] += 1 + self.need_visual = True + print("retry empty grasp", self.trip, self.retries[self.trip], flush=True) + self._go("pre_grasp", obs) + else: + self._go("sidestep", obs) + + elif name == "sidestep": + raw = self._carry(1) + pel = obs["low_dim_obs"][21:25] + raw[1] = 0.5 + raw[3] = np.clip(-pel[3], -0.3, 0.3) + if pel[1] >= 0.82 or pt >= 299: + self._go("side_settle", obs) + + elif name == "side_settle": + raw = self._carry(1) + if pt >= 19: + self._go("pad_forward", obs) + + elif name == "pad_forward": + raw = self._carry(1) + pel = obs["low_dim_obs"][21:25] + raw[0] = 0.35 + raw[1] = np.clip(2 * (0.82 - pel[1]), -0.15, 0.15) + raw[3] = np.clip(-pel[3], -0.3, 0.3) + if pel[0] > 1.3 or pt >= 399: + self._go("acquire", obs) + + elif name == "acquire": + head_green = self._components(tools.image("head"), "green") + raw = self._carry(1) + if head_green: + self._go("green_servo", obs) + else: + cs = self._components(tools.image("right_wrist"), "green") + if cs: + c = max(cs, key=lambda c: c[1])[0] + raw[0] = 0.08 if c[1] < 18 else 0 + raw[3] = np.clip(-0.015 * (c[0] - 42), -0.3, 0.3) + else: + raw[3] = -0.5 + if pt >= 399: + self._go("green_servo", obs) + + elif name == "green_servo": + cs = self._components(tools.image("head"), "green") + self.lost = 0 if cs else self.lost + 1 + if cs: + self.prev = max(cs, key=lambda c: c[1])[0] + ex, ey = 36 - self.prev[0], 25 - self.prev[1] + elif self.prev is not None: + ex, ey = 36 - self.prev[0], 25 - self.prev[1] + else: + ex, ey = 0, 3 + self.stable = self.stable + 1 if cs and abs(ex) < 6 and abs(ey) < 12 else 0 + raw = self._carry(1) + if cs: + raw[0] = 0 if abs(ey) < 1.5 or abs(ex) > 8 else np.sign(ey) * min(0.18, max(0.06, abs(ey) * 0.025)) + raw[3] = np.clip(0.02 * ex, -0.3, 0.3) + else: + raw[0] = 0.06 if self.lost < 80 and self.prev is not None and self.prev[1] < 8 else 0 + raw[3] = np.clip(0.02 * ex, -0.15, 0.15) if self.prev is not None else -0.08 + if self.stable >= 20 or pt >= 179 or (self.lost >= 80 and self.prev is not None): + self._go("place_base", obs) + elif pt >= 599: + self._go("acquire", obs) + + elif name == "place_base": + raw = self._place_pose(1) + raw = self._apply_base_hold(obs, raw) + if pt >= 19: + self._go("lower", obs) + + elif name == "lower": + raw = self._interp(self._place_pose(1), pt, 30) + raw = self._apply_base_hold(obs, raw) + if pt >= 29: + self._go("place_settle", obs) + + elif name == "place_settle": + raw = self._place_pose(1) + raw = self._apply_base_hold(obs, raw) + if pt >= 19: + self._go("release", obs) + + elif name == "release": + raw = self._interp(self._place_pose(0), pt, 30) + raw = self._apply_base_hold(obs, raw) + if pt >= 29: + self._go("release_settle", obs) + + elif name == "release_settle": + raw = self._place_pose(0) + raw = self._apply_base_hold(obs, raw) + if pt >= 29: + self._go("retreat", obs) + + elif name == "retreat": + raw = self._interp(self._carry(0), pt, 50) + raw = self._apply_base_hold(obs, raw) + if pt >= 49: + self._go("retreat_settle", obs) + + elif name == "retreat_settle": + raw = self._carry(0) + raw = self._apply_base_hold(obs, raw) + if pt >= 29: + if self.trip < 2: + self._go("turn_home", obs) + else: + self._go("success_wait", obs) + + elif name == "turn_home": + raw = self._carry(0) + yaw = obs["low_dim_obs"][24] + err = (-yaw + np.pi) % (2 * np.pi) - np.pi + raw[3] = np.clip(1.5 * err, -0.8, 0.8) + if abs(err) < 0.035 or pt >= 399: + self._go("home_settle", obs) + + elif name == "home_settle": + raw = self._carry(0) + if pt >= 19: + self._go("back_source", obs) + + elif name == "back_source": + raw = self._carry(0) + pel = obs["low_dim_obs"][21:25] + raw[0] = -0.5 + raw[3] = np.clip(-pel[3], -0.3, 0.3) + if pel[0] <= 0.17 or pt >= 499: + self._go("source_lateral", obs) + + elif name == "source_lateral": + raw = self._carry(0) + pel = obs["low_dim_obs"][21:25] + raw[1] = np.clip(-3 * pel[1], -0.4, 0.4) + if 0 < abs(raw[1]) < 0.06: + raw[1] = np.sign(raw[1]) * 0.06 + raw[3] = np.clip(-pel[3], -0.3, 0.3) + if abs(pel[1]) < 0.05 or pt >= 299: + self._go("source_settle", obs) + + elif name == "source_settle": + raw = self._carry(0) + if pt >= 19: + self.trip += 1 + self._go("pre_grasp", obs) + + elif name == "success_wait": + raw = self._carry(0) + + self.action = np.asarray(raw, dtype=np.float32) + return self.action diff --git a/policies/stack_blocks/kimi31pro-s2/episodes.csv b/policies/stack_blocks/kimi31pro-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..6f1bbd793b17593285f86084015b9380236443fd --- /dev/null +++ b/policies/stack_blocks/kimi31pro-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8721,terminated,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,1308,terminated,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,7776,terminated,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,4680,terminated,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,7980,terminated,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8414,terminated,0 +620091,0,8750,timeout,0 +620092,0,2201,terminated,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/kimi31pro-s2/policy.py b/policies/stack_blocks/kimi31pro-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..c66bc241305d824822c752febf29d047c1693c09 --- /dev/null +++ b/policies/stack_blocks/kimi31pro-s2/policy.py @@ -0,0 +1,243 @@ +"""Deterministic hand-written controller for the G1 block-stacking task. + +The robot carries one block at a time. It uses proprioceptive waypoint control +in the open lane beside the tables and small, fixed arm motions for grasping +and releasing. Camera measurements are used only to check/adjust a grasp. +""" + +import cv2 +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.a = np.asarray(tools.hold_action(), dtype=np.float32).copy() + self.cycle = 0 + self.pick_y = 0.0 + self.retries = 0 + self.phase = "initial_walk" + self.n = 0 + self.goal = np.zeros(3) + self.next_phase = "" + self.duration = 1 + self.ramp_start = self.a.copy() + self.ramp_target = self.a.copy() + self.initial_x = float(obs["low_dim_obs"][21]) + self.walk_goal = self.initial_x + 0.065 + + def _start(self, name, tools): + self.phase = name + self.n = 0 + if name == "approach": + self.a[0:2] = 0 + self.a[3] = 0 + self.a[19:21] = 0 + target = self.a.copy() + target[2] = 0.60 + target[5] = target[12] = -0.35 + target[6] = 0 + target[7] = 0 + target[10] = 0 + target[13] = -0.45 + target[14] = 0 + target[17] = 0 + self._ramp(target, "wrist", 75) + elif name == "wrist": + target = self.a.copy() + target[10] = 0.22 + target[17] = 0.12 + self._ramp(target, "pick_adjust", 45) + elif name == "lift": + target = self.a.copy() + target[2] = 0.74 + self._ramp(target, "verify", 90) + elif name == "retract": + target = self.a.copy() + target[12] = 0 + target[13] = 0 + target[14] = 0 + target[17] = 0 + self._ramp(target, "side", 50) + elif name == "side": + self._go(-0.05, 0.90, 0.0, "far", 700) + elif name == "far": + self._go(1.63, 1.0, 0.0, "turn_dest", 800) + elif name == "turn_dest": + self._turn(-np.pi / 2, "preextend") + elif name == "preextend": + target = self.a.copy() + target[5] = -0.40 + target[6] = 0 + target[7] = 0 + self._ramp(target, "dest", 60) + elif name == "dest": + self._go(1.63, 0.64, -np.pi / 2, "deepplace", 180) + elif name == "deepplace": + target = self.a.copy() + target[2] = 0.82 + target[5] = -0.70 + target[7] = -0.10 + self._ramp(target, "release", 70) + elif name == "retreat": + target = self.a.copy() + target[2] = 0.74 + target[5] = 0 + target[6] = 0 + target[7] = 0 + target[10] = 0 + self._ramp(target, "after_place", 80) + elif name == "return_corridor": + self._go(1.63, 0.90, -np.pi / 2, "return_turn", 400) + elif name == "return_turn": + self._turn(0.0, "return_side") + elif name == "return_side": + self._go(-0.05, 0.90, 0.0, "return_lateral", 800) + elif name == "return_lateral": + self._go(-0.05, self.pick_y, 0.0, "source_x", 500) + elif name == "source_x": + self._go(0.175, self.pick_y, 0.0, "approach", 400) + elif name == "finish": + self.a[0:2] = 0 + self.a[3] = 0 + self.a[19:21] = 0 + + def _ramp(self, target, next_phase, duration): + self.ramp_start = self.a.copy() + self.ramp_target = np.asarray(target, dtype=np.float32).copy() + self.duration = int(duration) + self.next_phase = next_phase + self.phase = "ramp" + self.n = 0 + + def _go(self, x, y, yaw, next_phase, limit): + self.goal = np.array([x, y, yaw], dtype=float) + self.next_phase = next_phase + self.duration = int(limit) + self.phase = "go" + self.n = 0 + + def _turn(self, yaw, next_phase): + self.goal = np.array([yaw], dtype=float) + self.next_phase = next_phase + self.phase = "turn" + self.n = 0 + + @staticmethod + def _red_centroid(image): + r = image[:, :, 0].astype(np.float32) + g = image[:, :, 1].astype(np.float32) + b = image[:, :, 2].astype(np.float32) + mask = ((r > 110) & (r > 1.5 * g) & (r > 1.5 * b)).astype(np.uint8) + count, _, stats, cents = cv2.connectedComponentsWithStats(mask) + if count <= 1: + return None + j = 1 + int(np.argmax(stats[1:, cv2.CC_STAT_AREA])) + if stats[j, cv2.CC_STAT_AREA] < 20: + return None + return cents[j] + + def act(self, obs, tools): + self.n += 1 + p = obs["low_dim_obs"][21:25] + + if self.phase == "initial_walk": + err = self.walk_goal - p[0] + self.a[0] = np.sign(err) * max(0.06, min(0.12, 2 * abs(err))) if abs(err) > 0.006 else 0 + self.a[1] = np.clip(-p[1], -0.06, 0.06) if abs(p[1]) > 0.008 else 0 + self.a[3] = np.clip(-p[3], -0.2, 0.2) + if self.n >= 170: + self.a[0:2] = 0 + self.a[3] = 0 + self._start("approach", tools) + + elif self.phase == "ramp": + # The grasp timings deliberately match the calibrated contact motion. + den = 35 if self.duration == 45 else 70 if self.duration == 90 else self.duration * 0.8 + u = min(1.0, self.n / den) + self.a = self.ramp_start * (1 - u) + self.ramp_target * u + self.a[0:2] = 0 + self.a[3] = 0 + if self.n >= self.duration: + self._start(self.next_phase, tools) + + elif self.phase == "pick_adjust": + if self.cycle == 0 and self.retries == 0: + self._start("close", tools) + return np.asarray(self.a, dtype=np.float32) + image = tools.image("left_wrist") + center = self._red_centroid(image) + if center is not None: + dx, dy = float(center[0]) - 44.0, float(center[1]) - 64.0 + if abs(dx) > 6 or abs(dy) > 9: + target = self.a.copy() + target[6] = np.clip(target[6] + np.clip(0.005 * dx, -0.08, 0.08), -0.15, 0.15) + target[10] = np.clip(target[10] + np.clip(0.01 * dy, -0.10, 0.10), 0.05, 0.42) + self._ramp(target, "close", 20) + else: + self._start("close", tools) + else: + self._start("close", tools) + + elif self.phase == "close": + self.a[19:21] = min(1.0, self.n / 60.0) + if self.n >= 80: + self._start("lift", tools) + + elif self.phase == "verify": + fingers = obs["low_dim_obs"][10:12] + held = float(np.mean(fingers)) > -0.017 + if not held and self.retries < 1: + self.retries += 1 + self.pick_y += 0.05 + self.a[19:21] = 0 + self._start("source_x", tools) + else: + self._start("retract", tools) + + elif self.phase == "go": + dp = self.goal[:2] - p[:2] + dist = float(np.linalg.norm(dp)) + ye = (self.goal[2] - p[3] + np.pi) % (2 * np.pi) - np.pi + if dist < 0.05 or self.n >= self.duration: + self.a[0:2] = 0 + self.a[3] = 0 + self._start(self.next_phase, tools) + else: + speed_cap = 0.30 if self.next_phase == "deepplace" else 0.34 + speed = max(0.065, min(speed_cap, 0.65 * dist)) + vxw, vyw = dp / dist * speed + c, s = np.cos(p[3]), np.sin(p[3]) + self.a[0] = c * vxw + s * vyw + self.a[1] = -s * vxw + c * vyw + self.a[3] = np.clip(1.2 * ye, -0.15, 0.15) + + elif self.phase == "turn": + ye = (self.goal[0] - p[3] + np.pi) % (2 * np.pi) - np.pi + self.a[0:2] = 0 + self.a[3] = np.clip(1.2 * ye, -0.35, 0.35) + if abs(ye) < 0.03 or self.n >= 420: + self._start(self.next_phase, tools) + + elif self.phase == "release": + self.a[19] = max(0.0, 1.0 - self.n / 40.0) + if self.n >= 55: + self._start("retreat", tools) + + elif self.phase == "after_place": + if self.cycle >= 2: + self._start("finish", tools) + else: + self.cycle += 1 + self.pick_y = (0.0, -0.15, -0.35)[self.cycle] + self.retries = 0 + self._start("return_corridor", tools) + + elif self.phase == "finish": + self.a[0:2] = 0 + self.a[3] = 0 + self.a[19:21] = 0 + + if obs.get("fell", False): + self.a[0:2] = 0 + self.a[3] = 0 + return np.asarray(self.a, dtype=np.float32) diff --git a/policies/stack_blocks/kimi31pro-s3/episodes.csv b/policies/stack_blocks/kimi31pro-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..a3ea9a0ba9447dbf7430412d78976a9251da4070 --- /dev/null +++ b/policies/stack_blocks/kimi31pro-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/kimi31pro-s3/policy.py b/policies/stack_blocks/kimi31pro-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..841c71c3260a9ee9c29a9b85d5b993328b73c47f --- /dev/null +++ b/policies/stack_blocks/kimi31pro-s3/policy.py @@ -0,0 +1,247 @@ +"""Deterministic hand-written controller for the G1 block-stacking task.""" + +import cv2 +import numpy as np + + +class Policy: + PICK = np.array([-.40, 0., 0., .75, 0., -.30, 0.] + [0.] * 7) + CARRY = np.array([-.85, 0., 0., 1.20, 0., -.30, 0.] + [0.] * 7) + + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.arms = np.zeros(14, dtype=float) + self.arm_start = self.arms.copy() + self.arm_goal = self.arms.copy() + self.grip_l = 0. + self.height = .74 + self.pitch = 0. + self.tx = .15 + self.ty = 0. + self.tyaw = 0. + self.speed = .18 + self.phase = "aim" + self.k = 0 + self.stable = 0 + self.placed = 0 + self.retries = 0 + self.roll_goal = None + self._aim(obs, tools) + + def _go(self, phase): + self.phase = phase + self.k = 0 + self.stable = 0 + + def _aim(self, obs, tools): + """Choose the leftmost visible source cube and stand off from it.""" + im = tools.image("head") + r = im[:, :, 0].astype(np.float32) + g = im[:, :, 1].astype(np.float32) + b = im[:, :, 2].astype(np.float32) + mask = ((r > 150) & (r > 1.7 * g) & (r > 1.7 * b)).astype(np.uint8) + n, labels, stats, centers = cv2.connectedComponentsWithStats(mask, 8) + candidates = [] + for i in range(1, n): + area = int(stats[i, cv2.CC_STAT_AREA]) + cx, cy = centers[i] + if area >= 10 and cy < 65: + candidates.append((float(cx), float(cy), area)) + if candidates: + cx, cy, _ = min(candidates, key=lambda v: v[0]) + self.tx = float(np.clip(.15 + .008 * (22. - cy), .06, .28)) + self.ty = float(np.clip(.008 * (17. - cx), -.38, .22)) + else: + self.tx, self.ty = .15, 0. + self.tyaw = 0. + self.speed = .18 + + def _arm_move(self, goal, duration, next_phase): + if self.k == 0: + self.arm_start = self.arms.copy() + self.arm_goal = np.asarray(goal, dtype=float) + u = min(1., (self.k + 1) / float(duration)) + self.arms = self.arm_start + u * (self.arm_goal - self.arm_start) + if self.k + 1 >= duration: + self.arms = self.arm_goal.copy() + self._go(next_phase) + + def _goto(self, next_phase, max_steps, tolerance=.055): + q = self.low + yaw_err = (self.tyaw - float(q[24]) + np.pi) % (2 * np.pi) - np.pi + if (abs(self.tx - q[21]) < tolerance and + abs(self.ty - q[22]) < tolerance and abs(yaw_err) < .08): + self.stable += 1 + else: + self.stable = 0 + if self.stable > 12 or self.k + 1 >= max_steps: + self._go(next_phase) + + def _base_action(self): + q = self.low + x, y, yaw = float(q[21]), float(q[22]), float(q[24]) + err = (self.tyaw - yaw + np.pi) % (2 * np.pi) - np.pi + ex, ey = self.tx - x, self.ty - y + c, s = np.cos(yaw), np.sin(yaw) + bx, by = c * ex + s * ey, -s * ex + c * ey + a = self.hold.copy() + a[0] = np.clip(2.5 * bx, -self.speed, self.speed) if abs(bx) > .012 else 0. + a[1] = np.clip(2.5 * by, -self.speed, self.speed) if abs(by) > .015 else 0. + if 0 < abs(a[0]) < .06: + a[0] = np.sign(a[0]) * .06 + if 0 < abs(a[1]) < .06: + a[1] = np.sign(a[1]) * .06 + a[2] = self.height + a[3] = np.clip(1.4 * err, -.38, .38) if abs(err) > .04 else 0. + a[4] = self.pitch + if abs(err) > .25: + a[0] = a[1] = 0. + a[5:19] = self.arms + a[19] = self.grip_l + a[20] = 0. + return a + + def act(self, obs, tools): + self.low = np.asarray(obs["low_dim_obs"]) + phase = self.phase + self.grip_l = 0. if phase in ("aim", "reach", "home") else self.grip_l + + if phase == "aim": + self.arms = np.zeros(14) + self.grip_l = 0. + self.speed = .18 + if self.k + 1 >= 15: + self._go("reach") + + elif phase == "home": + self.grip_l = 0. + self.speed = .30 + self._arm_move(np.zeros(14), 50, "aim") + if self.phase == "aim": + self._aim(obs, tools) + + elif phase == "reach": + self.grip_l = 0. + self._arm_move(self.PICK, 100, "rolls") + + elif phase == "rolls": + k = self.k + if k < 300: + cycle = k // 100 + local = k % 100 + self.arms[4] = (-1.57, -1., -.5)[cycle] + self.grip_l = 0. if local < 40 or local >= 80 else 1. + else: + self.arms[4] = 0. + self.grip_l = 0. if k < 340 else 1. + if k + 1 >= 380: + self._go("check_grasp") + + elif phase == "check_grasp": + self.arms[4] = 0. + self.grip_l = 1. + fingers = self.low[[10, 11]] + if np.mean(fingers) < -.017 and self.retries < 1: + self.retries += 1 + self.tx = float(np.clip(self.tx + .025, .06, .29)) + self.ty = float(np.clip(self.ty - .02, -.40, .24)) + self._go("rolls") + else: + self.retries = 0 + self._go("lift") + + elif phase == "lift": + self.grip_l = 1. + self.height = .74 + .10 * min(1., (self.k + 1) / 60.) + if self.k + 1 >= 60: + self._go("back") + + elif phase == "back": + self.grip_l = 1. + self.height = .84 + self.tx = .05 + self.speed = .22 + self._goto("lane", 180) + + elif phase == "lane": + self.grip_l = 1. + self.height = .78 + self.speed = .30 + self.tx, self.ty, self.tyaw = .05, 1.0, 0. + self._goto("destination_x", 300) + + elif phase == "destination_x": + self.speed = .30 + self.tx, self.ty, self.tyaw = 1.55, 1.0, 0. + self._goto("turn_destination", 450) + + elif phase == "turn_destination": + self.speed = .20 + self.tx, self.ty, self.tyaw = 1.55, 1.0, -1.57 + self._goto("raise_carry", 250) + + elif phase == "raise_carry": + self.speed = .18 + self._arm_move(self.CARRY, 80, "approach") + + elif phase == "approach": + self.height = .74 + self.speed = .18 + self.tx, self.ty, self.tyaw = 1.55, .74, -1.57 + self._goto("pitch_place", 250) + + elif phase == "pitch_place": + self.tx = float(self.low[21]) + self.ty = float(self.low[22]) + self.speed = .12 + self.height = (.74, .80, .86)[min(self.placed, 2)] + self.pitch = 0. + if self.k + 1 >= 40: + self._go("release") + + elif phase == "release": + self.grip_l = 0. + self.pitch = 0. + if self.k + 1 >= 60: + self.placed += 1 + self._go("unpitch") + + elif phase == "unpitch": + self.grip_l = 0. + self.pitch = 0. + self.height = (.74, .80, .86)[min(self.placed - 1, 2)] + if self.k + 1 >= 60: + self._go("finish" if self.placed >= 3 else "retreat") + + elif phase == "retreat": + self.grip_l = 0. + self.height = .74 + self.pitch = 0. + self.speed = .30 + self.ty = 1.0 + self._goto("return_turn", 180) + + elif phase == "return_turn": + self.speed = .30 + self.tx, self.ty, self.tyaw = 1.55, 1.0, 0. + self._goto("return_x", 180) + + elif phase == "return_x": + self.speed = .40 + self.tx, self.ty, self.tyaw = .05, 1.0, 0. + self._goto("return_y", 300) + + elif phase == "return_y": + self.speed = .40 + self.tx, self.ty, self.tyaw = .05, 0., 0. + self._goto("home", 220) + + elif phase == "finish": + self.grip_l = 0. + self.height = .86 + self.pitch = 0. + self.speed = .12 + + action = self._base_action() + self.k += 1 + return action diff --git a/policies/stack_blocks/opus-s1/episodes.csv b/policies/stack_blocks/opus-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..c52a18146c98084ec62d38e7fc39ece1842384ac --- /dev/null +++ b/policies/stack_blocks/opus-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,5784,success,0 +620001,1,5761,success,0 +620002,1,5654,success,0 +620003,1,5789,success,0 +620004,1,5680,success,0 +620005,1,5713,success,0 +620006,1,5720,success,0 +620007,1,5674,success,0 +620008,1,5774,success,0 +620009,1,5683,success,0 +620010,1,5628,success,0 +620011,1,5734,success,0 +620012,1,5712,success,0 +620013,1,5712,success,0 +620014,1,5766,success,0 +620015,1,5798,success,0 +620016,1,5796,success,0 +620017,1,5736,success,0 +620018,1,5621,success,0 +620019,1,5664,success,0 +620020,1,5753,success,0 +620021,1,5665,success,0 +620022,1,5660,success,0 +620023,1,5638,success,0 +620024,1,5712,success,0 +620025,1,5657,success,0 +620026,1,5766,success,0 +620027,1,5631,success,0 +620028,1,5765,success,0 +620029,1,5688,success,0 +620030,1,5729,success,0 +620031,1,5644,success,0 +620032,1,5742,success,0 +620033,1,5758,success,0 +620034,1,5693,success,0 +620035,1,5783,success,0 +620036,1,5672,success,0 +620037,1,5599,success,0 +620038,1,5686,success,0 +620039,1,5810,success,0 +620040,1,5721,success,0 +620041,1,5640,success,0 +620042,1,5664,success,0 +620043,1,5752,success,0 +620044,1,5749,success,0 +620045,1,5704,success,0 +620046,1,5688,success,0 +620047,1,5725,success,0 +620048,1,5486,success,0 +620049,1,5672,success,0 +620050,1,5678,success,0 +620051,1,5726,success,0 +620052,1,5774,success,0 +620053,1,5785,success,0 +620054,1,5615,success,0 +620055,1,6185,success,0 +620056,1,5657,success,0 +620057,1,5604,success,0 +620058,1,5666,success,0 +620059,1,5684,success,0 +620060,1,5673,success,0 +620061,1,5770,success,0 +620062,1,5679,success,0 +620063,1,5710,success,0 +620064,1,5649,success,0 +620065,1,5626,success,0 +620066,1,5738,success,0 +620067,1,5661,success,0 +620068,1,5783,success,0 +620069,1,5773,success,0 +620070,1,5761,success,0 +620071,1,5794,success,0 +620072,1,5647,success,0 +620073,1,5756,success,0 +620074,1,5490,success,0 +620075,1,5699,success,0 +620076,1,5813,success,0 +620077,1,5701,success,0 +620078,1,5601,success,0 +620079,1,5709,success,0 +620080,1,5740,success,0 +620081,1,5646,success,0 +620082,1,5693,success,0 +620083,1,5660,success,0 +620084,1,5727,success,0 +620085,1,5731,success,0 +620086,1,5739,success,0 +620087,1,5755,success,0 +620088,1,5570,success,0 +620089,1,5711,success,0 +620090,1,5745,success,0 +620091,1,5698,success,0 +620092,1,5650,success,0 +620093,1,5646,success,0 +620094,1,5706,success,0 +620095,1,5665,success,0 +620096,1,5718,success,0 +620097,1,5791,success,0 +620098,1,5612,success,0 +620099,1,5809,success,0 diff --git a/policies/stack_blocks/opus-s1/g1kin.py b/policies/stack_blocks/opus-s1/g1kin.py new file mode 100644 index 0000000000000000000000000000000000000000..1e309599c877eaa55289c2ac3a9ce8f22bc48bf2 --- /dev/null +++ b/policies/stack_blocks/opus-s1/g1kin.py @@ -0,0 +1,97 @@ +"""Approximate G1 arm kinematics (pelvis frame), from the published G1 model.""" +import numpy as np + + +def rx(a): + c, s = np.cos(a), np.sin(a) + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + + +def ry(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + + +def rz(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def quat(w, x, y, z): + q = np.array([w, x, y, z]) / np.linalg.norm([w, x, y, z]) + w, x, y, z = q + return np.array([ + [1 - 2 * (y * y + z * z), 2 * (x * y - z * w), 2 * (x * z + y * w)], + [2 * (x * y + z * w), 1 - 2 * (x * x + z * z), 2 * (y * z - x * w)], + [2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y)], + ]) + + +HAND_OFF = np.array([0.0415 + 0.10, 0.0, 0.0]) # grasp point beyond wrist yaw link (to calibrate) + + +def torso_frame(waist): + """Torso pose in pelvis frame from waist (yaw, roll, pitch).""" + R = rz(waist[0]) + p = np.zeros(3) + p = p + R @ np.array([-0.0039635, 0, 0.035]) + R = R @ rx(waist[1]) + p = p + R @ np.array([0, 0, 0.019]) + R = R @ ry(waist[2]) + return p, R + + +def arm_chain(q, side, waist=(0, 0, 0), hand_off=None): + """Return list of (p, R) frames: torso, shoulder pitch..wrist yaw, hand point.""" + sgn = 1.0 if side == 'left' else -1.0 + p, R = torso_frame(waist) + frames = [] + def step(off, Rfix, axis, ang): + nonlocal p, R + p = p + R @ np.asarray(off) + R = R @ Rfix + R = R @ {'x': rx, 'y': ry, 'z': rz}[axis](ang) + frames.append((p.copy(), R.copy())) + I = np.eye(3) + step([0.0039563, sgn * 0.10022, 0.24778], quat(0.990264, sgn * 0.139201, 0, 0), 'y', q[0]) + step([0, sgn * 0.038, -0.013831], quat(0.990268, -sgn * 0.139172, 0, 0), 'x', q[1]) + step([0, sgn * 0.00624, -0.1032], I, 'z', q[2]) + step([0.015783, 0, -0.080518], I, 'y', q[3]) + step([0.1, sgn * 0.00188791, -0.01], I, 'x', q[4]) + step([0.038, 0, 0], I, 'y', q[5]) + step([0.046, 0, 0], I, 'z', q[6]) + ho = HAND_OFF if hand_off is None else hand_off + frames.append((p + R @ ho, R.copy())) + return frames + + +def hand_pose(q, side, waist=(0, 0, 0), hand_off=None): + return arm_chain(q, side, waist, hand_off)[-1] + + +# shoulder roll is limited by the arm hitting the torso (measured: about -0.15 / +0.15) +LIM_LO = {'left': np.array([-3.0, 0.03, -2.6, -1.0, -1.9, -1.6, -1.6]), + 'right': np.array([-3.0, -2.2, -2.6, -1.0, -1.9, -1.6, -1.6])} +LIM_HI = {'left': np.array([2.6, 2.2, 2.6, 2.0, 1.9, 1.6, 1.6]), + 'right': np.array([2.6, -0.03, 2.6, 2.0, 1.9, 1.6, 1.6])} + + +def ik(p_target, side, q0, waist=(0, 0, 0), xdir=None, ydir=None, wdir=0.3, + reg=0.01, qref=None, hand_off=None): + """Numeric IK for the hand point; xdir: desired gripper axis, ydir: desired jaw axis.""" + from scipy.optimize import least_squares + qref = q0 if qref is None else qref + def res(q): + p, R = hand_pose(q, side, waist, hand_off) + r = [p - p_target] + if xdir is not None: + r.append(wdir * (R[:, 0] - xdir)) + if ydir is not None: + r.append(wdir * (R[:, 1] - ydir)) + r.append(np.asarray(reg) * (q - qref)) + return np.concatenate(r) + lo, hi = LIM_LO[side], LIM_HI[side] + x0 = np.clip(q0, lo + 1e-3, hi - 1e-3) + sol = least_squares(res, x0, bounds=(lo, hi), xtol=1e-8, ftol=1e-10) + p, R = hand_pose(sol.x, side, waist, hand_off) + return sol.x, np.linalg.norm(p - p_target) diff --git a/policies/stack_blocks/opus-s1/headcam.py b/policies/stack_blocks/opus-s1/headcam.py new file mode 100644 index 0000000000000000000000000000000000000000..86cb7b4106c13ec7f8b47c3b38eb4049cfd873fc --- /dev/null +++ b/policies/stack_blocks/opus-s1/headcam.py @@ -0,0 +1,55 @@ +"""Head camera model (fitted constants) and helpers.""" +import numpy as np +from g1kin import rx, ry, rz, torso_frame + +W = H = 84 +R0 = np.column_stack([[0, -1, 0], [0, 0, 1], [-1, 0, 0]]) +HEAD = np.array([0.1131, 0.0043, 0.3301, 0.9779, -0.013, -0.0035, 1.0932, -0.0263]) + + +def pelvis_world(o, kp=HEAD[7]): + """Pelvis rotation and position in world from low_dim_obs.""" + Rp = rz(o[24]) @ ry(kp * o[2]) + return np.array([o[21], o[22], o[23]]), Rp + + +def cam_world(o, p=HEAD): + cx, cy, cz, th, ps, ph, fov, kp = p[:8] + tp, tR = torso_frame(o[0:3]) + pw, Rp = pelvis_world(o, kp) + Rc_t = ry(th) @ rz(ps) @ R0 @ rz(ph) + Rw = Rp @ tR @ Rc_t + cw = pw + Rp @ (tp + tR @ np.array([cx, cy, cz])) + return cw, Rw, fov + + +def project(o, X, p=HEAD): + cw, Rw, fov = cam_world(o, p) + xc = Rw.T @ (np.asarray(X) - cw) + f = (H / 2) / np.tan(fov / 2) + return np.array([W / 2 + f * xc[0] / -xc[2], H / 2 - f * xc[1] / -xc[2]]), -xc[2] + + +def ray(o, uv, p=HEAD): + """World ray (origin, unit dir) through pixel uv.""" + cw, Rw, fov = cam_world(o, p) + f = (H / 2) / np.tan(fov / 2) + d = np.array([(uv[0] - W / 2) / f, -(uv[1] - H / 2) / f, -1.0]) + d = Rw @ d + return cw, d / np.linalg.norm(d) + + +def pixel_to_plane(o, uv, z, p=HEAD): + c, d = ray(o, uv, p) + t = (z - c[2]) / d[2] + return c + t * d + + +def to_world(o, p_pelvis): + pw, Rp = pelvis_world(o) + return pw + Rp @ np.asarray(p_pelvis) + + +def to_pelvis(o, X): + pw, Rp = pelvis_world(o) + return Rp.T @ (np.asarray(X) - pw) diff --git a/policies/stack_blocks/opus-s1/percept.py b/policies/stack_blocks/opus-s1/percept.py new file mode 100644 index 0000000000000000000000000000000000000000..f00bab634ed1e682bdf292d8d3e6563c0e7d7843 --- /dev/null +++ b/policies/stack_blocks/opus-s1/percept.py @@ -0,0 +1,33 @@ +"""Image processing helpers.""" +import cv2 +import numpy as np + +W = H = 84 + + +def red_mask(im): + r, g, b = [im[..., i].astype(int) for i in range(3)] + return ((r > 110) & (g < 80) & (b < 80) & (r > 2 * g)).astype(np.uint8) + + +def top_mask(im): + """The brightly lit top face of a red block.""" + r, g, b = [im[..., i].astype(int) for i in range(3)] + return ((r > 225) & (g < 110) & (b < 110)).astype(np.uint8) + + +def green_mask(im): + r, g, b = [im[..., i].astype(int) for i in range(3)] + return ((g > 120) & (g > r + 40) & (g > b + 40)).astype(np.uint8) + + +def blobs(mask, min_area=4, border_ok=False): + n, lab, st, cen = cv2.connectedComponentsWithStats(mask) + out = [] + for i in range(1, n): + x, y, w, h, area = st[i] + touches = x == 0 or y == 0 or x + w >= mask.shape[1] or y + h >= mask.shape[0] + if area < min_area or (touches and not border_ok): + continue + out.append({'c': cen[i], 'area': int(area), 'bbox': (x, y, w, h), 'touch': bool(touches), 'mask': lab == i}) + return out diff --git a/policies/stack_blocks/opus-s1/policy.py b/policies/stack_blocks/opus-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..09bd8d23169bc9579585d3488ec9bd1adbb675ec --- /dev/null +++ b/policies/stack_blocks/opus-s1/policy.py @@ -0,0 +1,503 @@ +"""Scripted policy for the G1 stack-blocks task. + +Pipeline: detect blocks with the head camera, grasp one block per hand with a +tilted top-down approach, walk around the tables to the green pad, place one +block on the pad and stack the second on it, then fetch the third block. +""" + +import numpy as np + +import g1kin +import headcam +import percept + +TABLE_Z = 0.707 # table top (world z) +BLOCK = 0.05 # block edge +BLOCK_Z = TABLE_Z + BLOCK / 2 +HO_G = np.array([0.195, 0.0, 0.0]) # jaw centre beyond the wrist yaw link +TILT = 0.9 # gripper tilt from vertical during grasp/place +REACH = np.array([0.36, 0.20]) # target position in pelvis frame for grasping (y sign per side) +JAW_WIN = np.array([-47.0, 47.0]) # allowed jaw rotation (deg) for the right hand; mirrored for left +REG = np.array([0.006, 0.006, 0.015, 0.006, 0.015, 0.006, 0.015]) +QN_R = np.array([-0.5, -0.1, 0, 0.3, 0, 0.8, 0]) +TUCK_R = np.array([-0.2, -0.2, 0, -0.9, 0, 0, 0]) +N_BLOCKS = 3 +GRASP_DEPTH = 0.012 # jaw centre beyond block centre along the approach axis +GRIP_OK = (0.12, 0.6) # gripper state range of a square grasp on a block +LOOK = np.array([0.03, 0.14]) # wrist-camera look pose: back along heading, up +CARRY = np.array([0.33, 0.22, 0.24]) # held block position in pelvis frame while carrying +MIRROR = np.array([1, -1, -1, 1, -1, 1, -1]) +SL = {'left': slice(5, 12), 'right': slice(12, 19)} +OBS_SL = {'left': slice(3, 10), 'right': slice(12, 19)} +GRIP = {'left': 19, 'right': 20} +GRIP_OBS = {'left': 50, 'right': 51} + + +def wrap(x): + return (x + np.pi) % (2 * np.pi) - np.pi + + +def side_vec(side, v): + v = np.array(v, dtype=float) + return v if side == 'right' else v * MIRROR + + +class Policy: + def reset(self, obs, tools): + self.tools = tools + self.obs = obs + self.a = np.asarray(tools.hold_action(), dtype=np.float64) + self.a[0] = self.a[1] = self.a[3] = 0.0 + self.a[4] = 0.0 + self.gen = self.script() + self.log = [] + self.bias = {'left': np.zeros(7), 'right': np.zeros(7)} + self.ik_err = 0.0 + + def act(self, obs, tools): + self.obs = obs + try: + a = next(self.gen) + except StopIteration: + self.finished = True + self.gen = self.idle() + a = next(self.gen) + except Exception as exc: # never crash the episode: hold still instead + self.note('error', repr(exc)) + self.finished = True + self.gen = self.idle() + a = next(self.gen) + return np.asarray(a, dtype=np.float32) + + # ------------------------------------------------------------------ basics + def lo(self): + return np.asarray(self.obs['low_dim_obs'], dtype=np.float64) + + def idle(self): + while True: + self.a[0] = self.a[1] = self.a[3] = 0.0 + yield self.a.copy() + + def wait(self, n): + for _ in range(n): + yield self.a.copy() + + def note(self, *args): + self.log.append((int(self.obs['t']),) + args) + + def goto(self, x, y, yaw, tol=0.03, ytol=0.05, maxn=1500, vmax=0.5, settle=20): + a = self.a + for i in range(maxn): + o = self.lo() + px, py, pyaw = o[21], o[22], o[24] + dx, dy = x - px, y - py + c, s = np.cos(pyaw), np.sin(pyaw) + bx, by = c * dx + s * dy, -s * dx + c * dy + dyaw = wrap(yaw - pyaw) + d = np.hypot(bx, by) + if d < tol and abs(dyaw) < ytol: + break + v = np.array([bx, by]) * 1.5 + n = np.linalg.norm(v) + if n > vmax: + v *= vmax / n + if d >= tol and n < 0.07: + v *= 0.07 / max(n, 1e-6) + if d < tol: + v[:] = 0 + a[0], a[1] = v + a[3] = np.clip(2.0 * dyaw, -0.8, 0.8) + yield a.copy() + a[0] = a[1] = a[3] = 0.0 + yield from self.wait(settle) + + def walk_path(self, pts, vmax=0.5): + """Walk through waypoints facing the direction of travel, then final yaw.""" + a = self.a + for i, (x, y, yaw) in enumerate(pts): + last = i == len(pts) - 1 + for _ in range(1500): + o = self.lo() + dx, dy = x - o[21], y - o[22] + d = np.hypot(dx, dy) + if d < (0.25 if last else 0.15): + break + err = wrap(np.arctan2(dy, dx) - o[24]) + a[3] = np.clip(2.0 * err, -0.8, 0.8) + a[0] = vmax * max(0.0, np.cos(err)) ** 4 if abs(err) < 0.6 else 0.0 + if 0 < a[0] < 0.07: + a[0] = 0.0 + a[0] = min(a[0], 0.8 * d + 0.1) + a[1] = 0.0 + yield a.copy() + if last: + yield from self.goto(x, y, yaw, tol=0.04, ytol=0.05, vmax=0.25, settle=10) + + def turn_to(self, yaw): + a = self.a + for i in range(400): + dyaw = wrap(yaw - self.lo()[24]) + if abs(dyaw) < 0.1: + break + a[0] = a[1] = 0.0 + a[3] = np.clip(2.0 * dyaw, -0.8, 0.8) + yield a.copy() + a[3] = 0.0 + + # ------------------------------------------------------------------ arms + def fk_world(self, side, ho=HO_G): + o = self.lo() + fr = g1kin.arm_chain(o[OBS_SL[side]], side, o[0:3], ho) + return headcam.to_world(o, fr[-1][0]) + + def axis_world(self, jaw): + h = np.array([np.sin(jaw), -np.cos(jaw), 0.0]) + xd = np.sin(TILT) * h + np.array([0, 0, -np.cos(TILT)]) + yd = np.array([np.cos(jaw), np.sin(jaw), 0.0]) + return xd, yd + + def ik_world(self, Xw, side, jaw): + o = self.lo() + Xp = headcam.to_pelvis(o, Xw) + _, Rp = headcam.pelvis_world(o) + xd, yd = self.axis_world(jaw) + qn = side_vec(side, QN_R) + best = None + seeds = (self.a[SL[side]] - self.bias[side], qn, + side_vec(side, [-0.8, -0.3, 0.5, 0.8, 0, 0.8, 0.5]), + side_vec(side, [-0.8, -0.3, -0.5, 0.8, 0, 0.8, -0.5])) + for q0 in seeds: + q, e = g1kin.ik(Xp, side, q0, o[0:3], xdir=Rp.T @ xd, ydir=Rp.T @ yd, + reg=REG, qref=qn, hand_off=HO_G) + if best is None or e < best[1] - 3e-3: + best = (q, e) + return best + + def move_arm(self, side, q, n=40, steps=5): + sl = SL[side] + q0 = self.a[sl].copy() + k = max(1, n // steps) + for s in np.linspace(0, 1, steps + 1)[1:]: + self.a[sl] = (1 - s) * q0 + s * np.asarray(q) + yield from self.wait(k) + + def reach(self, side, X, jaw, n=40, iters=2, steps=5, maxcorr=0.12): + """Move the jaw centre to X; joint-space integral term removes gravity sag.""" + X = np.asarray(X, dtype=float) + q, e = self.ik_world(X, side, jaw) + bias = self.bias[side] + yield from self.move_arm(side, q + bias, n, steps) + for _ in range(iters): + yield from self.wait(8) + qm = self.lo()[OBS_SL[side]] + bias = np.clip(bias + (q - qm), -maxcorr, maxcorr) + yield from self.move_arm(side, q + bias, 16, 2) + self.bias[side] = bias + self.ik_err = e + + def tuck(self, side, n=40): + yield from self.move_arm(side, side_vec(side, TUCK_R), n) + + # ------------------------------------------------------------------ perception + def head_blobs_border(self, mask_fn, z): + return self.head_blobs(mask_fn, z, border_ok=True) + + def head_blobs(self, mask_fn, z, border_ok=False): + import cv2 + o = self.lo() + im = self.tools.image('head') + mask = mask_fn(im) + for side in ('left', 'right'): + gs = o[GRIP_OBS[side]] + if 0.05 < gs < 0.9: # holding a block: ignore it + uv, d = headcam.project(o, self.fk_world(side)) + if d > 0: + cv2.circle(mask, (int(round(uv[0])), int(round(uv[1]))), 11, 0, -1) + out = [] + for b in percept.blobs(mask, border_ok=border_ok): + X = headcam.pixel_to_plane(o, b['c'], z) + out.append({'X': X, 'uv': b['c'], 'area': b['area'], 'mask': b['mask'], 'im': im, + 'touch': b['touch']}) + return out + + def block_top(self, blob, ztop): + """Top-face centre (world) and yaw (mod pi/2) of a block blob.""" + import cv2 + o = self.lo() + top = percept.top_mask(blob['im']) & cv2.dilate(blob['mask'].astype(np.uint8), np.ones((3, 3), np.uint8)) + ys, xs = np.nonzero(top) + if len(xs) < 5: + return None, None + pts = np.array([headcam.pixel_to_plane(o, (u, v), ztop)[:2] for u, v in zip(xs, ys)]) + c = pts.mean(axis=0) + (cx, cy), (w, h), ang = cv2.minAreaRect((pts * 1000).astype(np.float32)) + return np.array([c[0], c[1], ztop - BLOCK / 2]), wrap(4 * np.deg2rad(ang)) / 4 + + # ------------------------------------------------------------------ skills + def wrist_top(self, side): + """Top face of the most prominent block in the wrist camera: (centre, angle mod 90 rad).""" + import cv2 + im = self.tools.image(side + '_wrist') + red = percept.red_mask(im) + top = percept.top_mask(im) + bl = percept.blobs(red, min_area=20, border_ok=True) + if not bl: + return None, None + b = max(bl, key=lambda b: b['area']) + m = (top & b['mask']).astype(np.uint8) + if m.sum() < 20: + return None, None + cnts, _ = cv2.findContours(m, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) + cnt = max(cnts, key=cv2.contourArea) + (cx, cy), _, ang = cv2.minAreaRect(cnt) + return np.array([cx, cy]), wrap(4 * np.deg2rad(ang)) / 4 + + def grasp(self, side, X, jaw=np.pi / 2): + """Tilted grasp of the block whose centre is X (world).""" + g = GRIP[side] + self.a[g] = 0.0 + jaw0 = jaw + for k in range(2): + h = np.array([np.sin(jaw), -np.cos(jaw), 0.0]) + look = X - LOOK[0] * h + np.array([0, 0, LOOK[1]]) + yield from self.reach(side, look, jaw, n=45 if k == 0 else 30) + yield from self.wait(8) + c, ang = self.wrist_top(side) + self.note('wrist', side, k, None if c is None else c.round(1).tolist(), + None if ang is None else round(float(np.rad2deg(ang)), 1)) + if ang is None or abs(ang) < np.deg2rad(6): + break + jaw = jaw - ang + lo, hi = np.deg2rad(JAW_WIN) if side == 'right' else -np.deg2rad(JAW_WIN[::-1]) + if jaw - jaw0 > hi: + jaw -= np.pi / 2 + elif jaw - jaw0 < lo: + jaw += np.pi / 2 + xd, _ = self.axis_world(jaw) + yield from self.reach(side, X - 0.08 * xd, jaw, n=30, iters=3) + yield from self.reach(side, X + GRASP_DEPTH * xd, jaw, n=30, iters=1) + at = self.fk_world(side) + self.note('at', side, at.round(3).tolist(), (at - X).round(3).tolist(), round(float(self.ik_err), 3)) + self.a[g] = 1.0 + yield from self.wait(30) + up = self.fk_world(side) + np.array([0, 0, 0.10]) + yield from self.reach(side, up, jaw, n=30, iters=0) + yield from self.wait(10) + gs = self.lo()[GRIP_OBS[side]] + held = GRIP_OK[0] <= gs <= GRIP_OK[1] + self.note('grasp', side, held, round(float(gs), 2)) + if not held: + # bad or empty grasp: put the block back down gently and back off + if gs < 0.95: + yield from self.reach(side, self.fk_world(side) - np.array([0, 0, 0.09]), jaw, n=30, iters=0) + self.a[g] = 0.0 + yield from self.wait(20) + yield from self.reach(side, self.fk_world(side) - 0.06 * xd + np.array([0, 0, 0.08]), jaw, n=30, iters=0) + return held + + def place(self, side, X, jaw=np.pi / 2): + """Lower the held block so its centre reaches X, release, retract.""" + g = GRIP[side] + xd, _ = self.axis_world(jaw) + X = X + GRASP_DEPTH * xd # the jaw centre sits this far beyond the block centre + above = X + np.array([0, 0, 0.05]) + yield from self.reach(side, above, jaw, n=40, iters=3) + self.note('above', side, self.fk_world(side).round(3).tolist(), (self.fk_world(side) - above).round(3).tolist()) + yield from self.reach(side, X + np.array([0, 0, 0.008]), jaw, n=40, iters=2, steps=8) + yield from self.wait(10) + self.note('release', side, self.fk_world(side).round(3).tolist()) + self.a[g] = 0.0 + yield from self.wait(25) + self.note('released', side) + back = self.fk_world(side) - 0.08 * xd + np.array([0, 0, 0.03]) + yield from self.reach(side, back, jaw, n=30, iters=0) + yield from self.reach(side, back + np.array([0, 0, 0.08]), jaw, n=25, iters=0) + + def stand_for(self, X, side, facing): + """Pelvis pose that puts world point X at the standard reach offset.""" + c, s = np.cos(facing), np.sin(facing) + ry = REACH[1] if side == 'left' else -REACH[1] + bx, by = REACH[0], ry + px = X[0] - (c * bx - s * by) + py = X[1] - (s * bx + c * by) + # do not walk into the tables + if abs(wrap(facing)) < 0.5: + px = min(px, 0.24) + else: + px = max(px, 1.92) + return px, py + + # ------------------------------------------------------------------ script + def script(self): + a = self.a + a[GRIP['left']] = a[GRIP['right']] = 1.0 + a[SL['left']] = side_vec('left', TUCK_R) + a[SL['right']] = side_vec('right', TUCK_R) + yield from self.wait(40) + self.level = 0 + yield from self.rescan([], expected=N_BLOCKS) + blocks = self.scan + while blocks: + if len(blocks) >= 2: + plan = [('right', blocks[0]), ('left', blocks[-1])] + else: + plan = [('right', blocks[0])] + held = [] + for side, X in plan: + ok = yield from self.fetch(side, X, 0.0) + if ok: + held.append(side) + blocks = [b for b in blocks if b is not X] + else: + yield from self.tuck(side) + if not held: + yield from self.rescan(blocks, expected=N_BLOCKS - self.level) + blocks = self.scan + continue + yield from self.to_table2() + for side in ['left', 'right']: + gs = self.lo()[GRIP_OBS[side]] + if side in held and GRIP_OK[0] - 0.05 <= gs <= GRIP_OK[1] + 0.2: + yield from self.put_on_stack(side, self.level) + self.level += 1 + yield from self.tuck(side) + if self.level < N_BLOCKS: + yield from self.to_table1() + yield from self.rescan(blocks, expected=N_BLOCKS - self.level) + blocks = self.scan + yield from self.wait(100) + + def rescan(self, guesses, expected): + """Look at table 1 (shifting sideways if needed) and list the blocks on it.""" + y0 = float(np.mean([g[1] for g in guesses])) if guesses else 0.0 + found = [] + for dy in (0.0, -0.25, 0.25): + yield from self.goto(0.1, y0 + dy, 0.0, tol=0.05, vmax=0.3) + for b in self.head_blobs_border(percept.red_mask, BLOCK_Z): + X = b['X'] + if X[0] < 0.45 or X[0] > 0.85 or b['area'] < 12: + continue + pri = 0 if not b['touch'] else 1 + for k, (Xf, pf) in enumerate(found): + if np.linalg.norm(Xf[:2] - X[:2]) < 0.06: + if pri < pf: + found[k] = (X, pri) + break + else: + found.append((X, pri)) + if len(found) >= expected: + break + found = [f[0] for f in found] + self.note('rescan', [f.round(3).tolist() for f in found]) + self.scan = sorted(found, key=lambda X: X[1]) + + def to_table1(self): + o = self.lo() + yield from self.goto(o[21] + 0.15, o[22], o[24], tol=0.08, ytol=0.2, vmax=0.3, settle=0) + pts = [(2.05, 1.2, np.pi / 2), (-0.1, 1.2, np.pi), (0.1, 0.0, 0.0)] + yield from self.walk_path(pts) + + def fetch(self, side, Xguess, facing): + px, py = self.stand_for(Xguess, side, facing) + yield from self.goto(px, py, facing, tol=0.03, vmax=0.25, maxn=500) + # re-detect, pick nearest blob to the guess + bl = self.head_blobs(percept.red_mask, BLOCK_Z) + yaw = 0.0 + if bl: + b = min(bl, key=lambda b: np.linalg.norm(b['X'][:2] - Xguess[:2])) + if np.linalg.norm(b['X'][:2] - Xguess[:2]) < 0.1: + Xguess = b['X'] + Xt, yt = self.block_top(b, TABLE_Z + BLOCK) + if Xt is not None: + Xguess, yaw = Xt, yt + jaw = facing + np.pi / 2 + self.note('fetch', side, Xguess.round(3).tolist(), round(float(yaw), 3), self.lo()[21:25].round(3).tolist()) + ok = yield from self.grasp(side, Xguess, jaw) + if not ok: + # second attempt with a fresh detection + yield from self.tuck(side, 30) + bl = self.head_blobs(percept.red_mask, BLOCK_Z) + if bl: + b = min(bl, key=lambda b: np.linalg.norm(b['X'][:2] - Xguess[:2])) + if np.linalg.norm(b['X'][:2] - Xguess[:2]) < 0.1: + Xt, _ = self.block_top(b, TABLE_Z + BLOCK) + Xguess = Xt if Xt is not None else b['X'] + ok = yield from self.grasp(side, Xguess, jaw) + if ok: + yield from self.carry(side) + return ok + + def carry(self, side): + """Lift the held block high, out of the head camera's view.""" + o = self.lo() + sy = 1.0 if side == 'left' else -1.0 + Xw = headcam.to_world(o, np.array([CARRY[0], sy * CARRY[1], CARRY[2]])) + jaw = o[24] + np.pi / 2 + yield from self.reach(side, Xw, jaw, n=40, iters=0) + + def to_table2(self): + o = self.lo() + yield from self.goto(o[21] - 0.25, o[22], o[24], tol=0.08, ytol=0.2, vmax=0.3, settle=0) + pts = [(o[21] - 0.25, 1.2, np.pi / 2), (2.05, 1.2, 0.0), (2.05, 0.0, np.pi)] + yield from self.walk_path(pts) + if not hasattr(self, 'pad'): + yield from self.find_pad() + + def find_pad(self): + """Locate the green pad from the arrival pose (fully in view).""" + self.pad = np.array([1.55, 0.0, TABLE_Z]) + for k in range(3): + g = [b for b in self.head_blobs_border(percept.green_mask, TABLE_Z) if b['area'] >= 15] + if not g: + break + b = max(g, key=lambda b: b['area']) + self.pad = b['X'] + if not b['touch']: + break + o = self.lo() + yield from self.goto(o[21], 0.5 * (o[22] + b['X'][1]), np.pi, tol=0.03, vmax=0.25) + self.note('pad', self.pad.round(3).tolist()) + + def stack_top(self, level): + """Top-face centre of the stack that currently has `level` blocks.""" + ztop = TABLE_Z + BLOCK * level + T = getattr(self, 'top', self.pad) + bl = self.head_blobs(percept.red_mask, ztop - BLOCK / 2) + best = None + for b in bl: + Xt, _ = self.block_top(b, ztop) + if Xt is None: + continue + d = np.linalg.norm(Xt[:2] - self.pad[:2]) + if d < 0.1 and (best is None or d < best[0]): + best = (d, Xt) + if best is not None: + T = best[1] + self.top = T + return T + + def put_on_stack(self, side, level): + facing = np.pi + if level == 0: + T = self.pad + else: + T = self.stack_top(level) + px, py = self.stand_for(T, side, facing) + yield from self.goto(px, py, facing, tol=0.03, vmax=0.25, maxn=500) + # refine target after moving + if level == 0: + g = self.head_blobs(percept.green_mask, TABLE_Z) + g = [b for b in g if b['area'] >= 30 and np.linalg.norm(b['X'][:2] - self.pad[:2]) < 0.05] + if g: + T = max(g, key=lambda b: b['area'])['X'] + else: + T = self.stack_top(level) + last = getattr(self, 'placed', None) + if last is not None and np.linalg.norm(T[:2] - last[:2]) < 0.04: + # the previous block sits where we put it; the head camera is less + # precise than the arm, so lean on the commanded position + T = 0.7 * last + 0.3 * T + X = np.array([T[0], T[1], BLOCK_Z + BLOCK * level]) + self.placed = X.copy() + self.note('place', side, level, X.round(3).tolist()) + yield from self.place(side, X, jaw=-np.pi / 2) diff --git a/policies/stack_blocks/opus-s2/episodes.csv b/policies/stack_blocks/opus-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..d7874526662f4fe95f182ca7f3fe5d86a5f2e22a --- /dev/null +++ b/policies/stack_blocks/opus-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,8750,timeout,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,8750,timeout,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,6953,terminated,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,0,8750,timeout,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,5937,terminated,0 +620052,0,8750,timeout,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,8750,timeout,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,8750,timeout,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,8750,timeout,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/opus-s2/policy.py b/policies/stack_blocks/opus-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..8c796882df65186d99be73a23a5f9e8808766001 --- /dev/null +++ b/policies/stack_blocks/opus-s2/policy.py @@ -0,0 +1,686 @@ +"""Stack-blocks policy for the G1: scripted state machine (no learned parts). + +Geometry: arm forward kinematics of the G1 (link offsets of the Unitree model), +a pinhole model of the head camera (hand-tuned constants), damped least-squares +IK, colour segmentation of the red blocks and the green pad, closed-loop base +navigation on the pelvis pose and wrist-camera centring before each grasp. +""" + +import cv2 +import numpy as np + +# ---------------------------------------------------------------------------- +# kinematics + + +def rx(a): + c, s = np.cos(a), np.sin(a) + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + + +def ry(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + + +def rz(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def quat(w, x, y, z): + q = np.array([w, x, y, z]) / np.linalg.norm([w, x, y, z]) + w, x, y, z = q + return np.array([[1 - 2 * (y * y + z * z), 2 * (x * y - z * w), 2 * (x * z + y * w)], + [2 * (x * y + z * w), 1 - 2 * (x * x + z * z), 2 * (y * z - x * w)], + [2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y)]]) + + +def T(R=None, p=(0, 0, 0)): + M = np.eye(4) + if R is not None: + M[:3, :3] = R + M[:3, 3] = p + return M + + +def torso_T(waist): + return (T(rz(waist[0])) @ T(None, (-0.0039635, 0, 0.035)) @ T(rx(waist[1])) + @ T(None, (0, 0, 0.019)) @ T(ry(waist[2]))) + + +_SH = {s: quat(0.990264, s * 0.139201, 0, 0) for s in (1, -1)} +_SR = {s: quat(0.990268, -s * 0.139172, 0, 0) for s in (1, -1)} +HAND = 0.24 # wrist_yaw_link -> centre of a grasped block, along the fingers +HAND_Z = 0.017 # ... and along the hand z axis (measured from a grasp) + + +def hand_pose(q, side, waist, hand=None): + if hand is None: + hand = HAND + s = side + M = torso_T(waist) + M = M @ T(_SH[s], (0.0039563, s * 0.10022, 0.23778)) @ T(ry(q[0])) + M = M @ T(_SR[s], (0, s * 0.038, -0.013831)) @ T(rx(q[1])) + M = M @ T(None, (0, s * 0.00624, -0.1032)) @ T(rz(q[2])) + M = M @ T(None, (0.015783, 0, -0.080518)) @ T(ry(q[3])) + M = M @ T(None, (0.1, s * 0.00188791, -0.01)) @ T(rx(q[4])) + M = M @ T(None, (0.038, 0, 0)) @ T(ry(q[5])) + M = M @ T(None, (0.046, 0, 0)) @ T(rz(q[6])) + return M @ T(None, (hand, 0, HAND_Z)) + + +QLO = np.array([-3.0892, -1.5882, -2.618, -1.0472, -1.97222, -1.61443, -1.61443]) +QHI = np.array([2.6704, 2.2515, 2.618, 2.0944, 1.97222, 1.61443, 1.61443]) + + +def rot_err(R, Rt): + E = Rt @ R.T + return 0.5 * np.array([E[2, 1] - E[1, 2], E[0, 2] - E[2, 0], E[1, 0] - E[0, 1]]) + + +def ik(p_t, R_t, side, waist, q0, iters=12, wrot=0.3): + q = np.clip(np.array(q0, float), QLO + 0.02, QHI - 0.02) + for _ in range(iters): + M = hand_pose(q, side, waist) + e = np.r_[p_t - M[:3, 3], wrot * rot_err(M[:3, :3], R_t)] + if np.linalg.norm(e) < 1e-4: + break + J = np.zeros((6, 7)) + for k in range(7): + dq = np.zeros(7) + dq[k] = 1e-4 + M2 = hand_pose(q + dq, side, waist) + J[:3, k] = (M2[:3, 3] - M[:3, 3]) / 1e-4 + J[3:, k] = -wrot * rot_err(M2[:3, :3], M[:3, :3]) / 1e-4 + Jp = J.T @ np.linalg.inv(J @ J.T + 0.02 * np.eye(6)) + dq = Jp @ e + # stay near a comfortable posture in the null space + rest = Q_REST * np.array([1, side, side, 1, side, 1, side]) + dq += (np.eye(7) - Jp @ J) @ (NS_GAIN * (rest - q)) + q = np.clip(q + dq, QLO + 0.02, QHI - 0.02) + return q + + +Q_REST = np.array([-0.5, 0.25, 0.0, 0.6, 0.0, 0.6, 0.0]) +NS_GAIN = 0.0 + + +# ---------------------------------------------------------------------------- +# head camera (torso frame), constants tuned against the robot's own arm + +CAMP = np.array([0.101472, 0.010612, 0.364666, 1.004299, -0.003941, 0.002519, 1.063025]) +CAM_R = rz(CAMP[4]) @ ry(CAMP[3]) @ rx(CAMP[5]) +CAM_F = 42.0 / np.tan(CAMP[6] / 2) + + +def pixel_ray(u, v, waist): + d_cam = np.array([1.0, -(u - 42) / CAM_F, -(v - 42) / CAM_F]) + Tt = torso_T(waist) + R = Tt[:3, :3] @ CAM_R + o = Tt[:3, :3] @ CAMP[:3] + Tt[:3, 3] + return o, R @ d_cam + + +def pixel_to_plane(u, v, waist, z): + o, d = pixel_ray(u, v, waist) + return o + (z - o[2]) / d[2] * d + + +def project(pp, waist): + Tt = torso_T(waist) + pt = Tt[:3, :3].T @ (pp - Tt[:3, 3]) + d = CAM_R.T @ (pt - CAMP[:3]) + return np.array([42 + CAM_F * (-d[1]) / d[0], 42 - CAM_F * d[2] / d[0]]) + + +# ---------------------------------------------------------------------------- +# vision + + +def red_mask(im): + r, g, b = [im[..., i].astype(int) for i in range(3)] + return ((r > 100) & (r > 2 * g + 20) & (r > 2 * b + 20)).astype(np.uint8) + + +def green_mask(im): + r, g, b = [im[..., i].astype(int) for i in range(3)] + return ((g > 120) & (g > r + 40) & (g > b + 40)).astype(np.uint8) + + +def blobs(mask, min_area=6): + n, lab, st, cen = cv2.connectedComponentsWithStats(mask) + out = [] + for i in range(1, n): + x, y, w, hh, area = st[i] + if area < min_area: + continue + edge = x == 0 or y == 0 or x + w >= mask.shape[1] or y + hh >= mask.shape[0] + out.append(dict(c=cen[i], area=int(area), bbox=(x, y, w, hh), edge=bool(edge))) + return out + + +def wrap(a): + return (a + np.pi) % (2 * np.pi) - np.pi + + +# ---------------------------------------------------------------------------- +# task constants (FK-world frame) + +Z_TABLE = 0.655 # table top +BLOCK = 0.05 # block edge +TILT = np.radians(45) # gripper pitch below horizontal while placing +GTILT = np.radians(45) # gripper pitch below horizontal while grasping +PITCH = 0.15 # torso pitch while manipulating +REACH = 0.42 # pelvis->target forward distance used to stand +SIDE_OFF = 0.15 # lateral offset of the hand used w.r.t. the pelvis +CAMS = {1: 'left_wrist', -1: 'right_wrist'} +DEBUG = False +PRE = 0.108 # height above the block of the wrist-camera reference view +REF_UV = (43.0, 37.3) # block centre in the wrist image, hand PRE above a good grasp +PAD_OFF = np.zeros(3) # pad centre vs. the wrist-servo estimate +SERVO_GAIN = 430.0 # wrist image px per metre of hand motion at PRE +CORR_GAIN = 0.07 # per-step integral gain of the gravity-sag correction + + +class Policy: + """Scripted policy: generator-based state machine.""" + + def reset(self, obs, tools): + self.tools = tools + self.obs = obs + self.a = np.asarray(tools.hold_action(), dtype=np.float64) + lo = obs['low_dim_obs'] + self.q = {1: lo[3:10].astype(float).copy(), -1: lo[12:19].astype(float).copy()} + self.corr = {1: np.zeros(3), -1: np.zeros(3)} + self.tgt = {1: None, -1: None} + self.frame = {1: 'world', -1: 'world'} + self.R = {1: ry(TILT), -1: ry(TILT)} + self.grip = {1: 0.0, -1: 0.0} + self.base_cmd = np.zeros(3) + self.held = {1: None, -1: None} + self.stack = [] # world positions of the placed blocks + self.log = [] + self.dbg = [] + self.gen = self.main() + self.done = False + + # ------------------------------------------------------------------ io + def act(self, obs, tools): + self.obs = obs + if not self.done: + try: + return next(self.gen) + except StopIteration: + self.done = True + except Exception as exc: # never crash the episode + self.log.append(('error', repr(exc))) + self.done = True + self.base_cmd = np.zeros(3) + try: + return self.compose() + except Exception: + return self.a.astype(np.float32).copy() + + @property + def lo(self): + return np.asarray(self.obs['low_dim_obs'], dtype=np.float64) + + def pose(self): + return self.lo[21:25] + + def w2p(self, pw): + x, y, z, yaw = self.pose() + d = np.asarray(pw) - np.array([x, y, z]) + c, s = np.cos(yaw), np.sin(yaw) + return np.array([c * d[0] + s * d[1], -s * d[0] + c * d[1], d[2]]) + + def p2w(self, pp): + x, y, z, yaw = self.pose() + c, s = np.cos(yaw), np.sin(yaw) + return np.array([x + c * pp[0] - s * pp[1], y + s * pp[0] + c * pp[1], z + pp[2]]) + + def hand_w(self, side): + lo = self.lo + q = lo[3:10] if side > 0 else lo[12:19] + return self.p2w(hand_pose(q, side, lo[0:3])[:3, 3]) + + def hand_p(self, side): + lo = self.lo + q = lo[3:10] if side > 0 else lo[12:19] + return hand_pose(q, side, lo[0:3])[:3, 3] + + # ------------------------------------------------------------- control + def compose(self): + lo = self.lo + yaw = lo[24] + for side in (1, -1): + t = self.tgt[side] + if t is None: + continue + if self.frame[side] == 'world': + cur = self.hand_w(side) + tp_frame = t + else: + cur = self.hand_p(side) + tp_frame = t + err = tp_frame - cur + if self.frame[side] == 'world': + # slow integral term against gravity sag (fast gains oscillate) + self.corr[side] = np.clip(self.corr[side] + CORR_GAIN * err, -0.05, 0.05) + pc = tp_frame + self.corr[side] + if self.frame[side] == 'world': + pp = self.w2p(pc) + Rp = rz(-yaw) @ self.R[side] + else: + pp = pc + Rp = self.R[side] + self.q[side] = ik(pp, Rp, side, lo[0:3], self.q[side]) + sl = slice(5, 12) if side > 0 else slice(12, 19) + self.a[sl] = self.q[side] + self.a[19] = self.grip[1] + self.a[20] = self.grip[-1] + self.a[0], self.a[1], self.a[3] = self.base_cmd + return self.a.astype(np.float32).copy() + + def hold(self, n): + for _ in range(n): + yield self.compose() + + def move(self, targets, n, frame=None): + """targets {side: point}; smooth interpolation in the side's frame.""" + start = {} + for s, p in targets.items(): + f = frame or self.frame[s] + if self.tgt[s] is None or f != self.frame[s]: + start[s] = self.hand_w(s) if f == 'world' else self.hand_p(s) + self.corr[s] = np.zeros(3) + else: + start[s] = self.tgt[s] + self.frame[s] = f + for k in range(n): + t = 0.5 - 0.5 * np.cos(np.pi * (k + 1) / n) + for s, p in targets.items(): + self.tgt[s] = start[s] + (np.asarray(p, float) - start[s]) * t + yield self.compose() + + def walk(self, x, y, yaw, maxn=900, tol=0.025, ytol=0.04, vmax=0.5, face=False): + """closed-loop walk to a world pose; with face=True turn toward the goal first.""" + # arms keep their pose relative to the pelvis while walking + yaw0 = self.pose()[3] + for s in (1, -1): + if self.tgt[s] is not None and self.frame[s] == 'world': + self.tgt[s] = self.w2p(self.tgt[s]) + self.R[s] = rz(-yaw0) @ self.R[s] + self.frame[s] = 'pelvis' + self.corr[s] = np.zeros(3) + best, best_i = 1e9, 0 + for i in range(maxn): + px, py, _, pyaw = self.pose() + dx, dy = x - px, y - py + dist = np.hypot(dx, dy) + if dist < tol and abs(wrap(yaw - pyaw)) < ytol: + break + tyaw = yaw + if face and dist > 0.3: + tyaw = np.arctan2(dy, dx) + prog = dist + 0.3 * abs(wrap(tyaw - pyaw)) + if prog < best - 0.01: + best, best_i = prog, i + elif i - best_i > 200: + self.log.append(('walk stalled', self.obs['t'], round(float(dist), 3))) + break + if face and dist > 0.3: + tyaw = np.arctan2(dy, dx) + c, s = np.cos(pyaw), np.sin(pyaw) + bx, by = c * dx + s * dy, -s * dx + c * dy + vx, vy = 1.5 * bx, 1.5 * by + n = np.hypot(vx, vy) + if n > vmax: + vx, vy = vx * vmax / n, vy * vmax / n + ey = wrap(tyaw - pyaw) + if face and dist > 0.3 and abs(ey) > 0.5: + vx, vy = 0.0, 0.0 + if np.hypot(vx, vy) < 0.06: + if dist > tol: + k = 0.06 / max(np.hypot(vx, vy), 1e-6) + vx, vy = vx * k, vy * k + else: + vx = vy = 0.0 + wz = np.clip(2.0 * ey, -0.8, 0.8) + if abs(wz) < 0.05: + wz = 0.0 + self.base_cmd = np.array([vx, vy, wz]) + yield self.compose() + self.base_cmd = np.zeros(3) + yield from self.hold(10) + + # ------------------------------------------------------------- vision + def head_blobs(self, mask_fn, z, min_area=6): + im = self.tools.image('head') + lo = self.lo + out = [] + for b in blobs(mask_fn(im), min_area): + p = pixel_to_plane(b['c'][0], b['c'][1], lo[0:3], z - lo[23]) + b['w'] = self.p2w(p) + out.append(b) + return out + + def wrist_block(self, side): + bl = blobs(red_mask(self.tools.image(CAMS[side])), 20) + return max(bl, key=lambda b: b['area']) if bl else None + + def wrist_block_angle(self, side): + """angle (rad, in [-pi/4, pi/4)) of the block's top face edges in the wrist image.""" + im = self.tools.image(CAMS[side]) + r, g, b = [im[..., i].astype(int) for i in range(3)] + m = red_mask(im) + n, lab, st, cen = cv2.connectedComponentsWithStats(m) + if n < 2: + return None + i = 1 + int(np.argmax(st[1:, 4])) + if st[i, 4] < 30: + return None + ys, xs = np.nonzero(lab == i) + pts = np.stack([xs, ys], 1).astype(np.float32) + (cx, cy), (w, hh), ang = cv2.minAreaRect(pts) + a = np.radians(ang) + return (a + np.pi / 4) % (np.pi / 2) - np.pi / 4 + + # ------------------------------------------------------------- skills + def tuck(self, sides, n=50): + """carry pose in the pelvis frame, reached by joint interpolation to a canonical + IK solution so that later IK always starts from the same arm branch.""" + lo = self.lo + goal, start, tg = {}, {}, {} + for s in sides: + tg[s] = np.array([0.38, 0.20 * s, 0.02]) + self.R[s] = ry(0.6) + seed = np.array([-0.3, 0.3 * s, 0.0, 0.9, 0.0, 0.3, 0.0]) + goal[s] = ik(tg[s], self.R[s], s, lo[0:3], seed, iters=150) + start[s] = self.q[s].copy() + self.tgt[s] = None + for k in range(n): + t = 0.5 - 0.5 * np.cos(np.pi * (k + 1) / n) + for s in sides: + self.q[s] = start[s] + (goal[s] - start[s]) * t + sl = slice(5, 12) if s > 0 else slice(12, 19) + self.a[sl] = self.q[s] + yield self.compose() + for s in sides: + self.tgt[s] = tg[s] + self.frame[s] = 'pelvis' + self.corr[s] = np.zeros(3) + + def settle(self, s, tol=0.008, nmax=80): + """hold until the hand is within tol of its target.""" + for k in range(nmax): + cur = self.hand_w(s) if self.frame[s] == 'world' else self.hand_p(s) + if np.linalg.norm(self.tgt[s] - cur) < tol and k >= 10: + break + yield self.compose() + + def wrist_target(self, side, mask_fn=red_mask): + """blob in the wrist image closest to the reference position.""" + bl = blobs(mask_fn(self.tools.image(CAMS[side])), 20) + if not bl: + return None + return min(bl, key=lambda b: np.hypot(b['c'][0] - REF_UV[0], b['c'][1] - REF_UV[1])) + + def servo(self, s, P, yaw, iters=8, mask_fn=red_mask, gain=SERVO_GAIN): + """move the hand (pre-grasp height) until the wrist view matches REF_UV.""" + c, sn = np.cos(yaw), np.sin(yaw) + for it in range(iters): + wb = self.wrist_target(s, mask_fn) + if wb is None: + break + du = REF_UV[0] - wb['c'][0] + dv = REF_UV[1] - wb['c'][1] + if abs(du) < 1.5 and abs(dv) < 1.5: + break + # hand +y -> block +u, hand +x -> block +v (hand frame, gripper yaw) + bx = np.clip(dv / gain, -0.03, 0.03) + by = np.clip(du / gain, -0.03, 0.03) + P = P + np.array([c * bx - sn * by, sn * bx + c * by, 0]) + yield from self.move({s: P}, 20) + yield from self.hold(12) + return P + + def locate(self, s, est, pad=False): + """precise FK-world centre of a block (or of the pad) seen by the free hand `s`.""" + yaw = self.pose()[3] + self.R[s] = rz(yaw) @ ry(GTILT) + dz = PRE + (BLOCK / 2 if pad else 0.0) + P = np.array(est, float) + [0, 0, dz] + yield from self.move({s: P}, 60, frame='world') + yield from self.hold(15) + yield from self.servo(s, P, yaw, mask_fn=green_mask if pad else red_mask) + yield from self.hold(10) + c = self.hand_w(s) - [0, 0, dz] + if pad: + c = c + PAD_OFF + self.log.append(('locate', s, pad, np.round(est, 3).tolist(), c.round(3).tolist())) + return c + + def grasp(self, side, B, pre=PRE): + """B: world estimate of the block centre; returns True if holding.""" + s = side + yaw = self.pose()[3] + self.R[s] = rz(yaw) @ ry(GTILT) + self.grip[s] = 0.0 + P = np.array(B, float) + [0, 0, pre] + yield from self.move({s: P}, 60, frame='world') + yield from self.hold(15) + if self.wrist_target(s) is None: + # block not in view: look from higher up (wider view), centre coarsely + P = P + [0, 0, 0.06] + yield from self.move({s: P}, 30) + yield from self.hold(10) + P = yield from self.servo(s, P, yaw, iters=4, gain=0.6 * SERVO_GAIN) + P = P - [0, 0, 0.06] + yield from self.move({s: P}, 30) + yield from self.hold(10) + P = yield from self.servo(s, P, yaw) + ang = self.wrist_block_angle(s) + self.log.append(('angle', s, None if ang is None else round(float(ang), 3))) + if ang is not None and abs(ang) > 0.12: + # turn the gripper onto the block faces; each wrist turns away from its + # yaw joint limit (the block is symmetric under 90 deg turns) + psi = -ang + if psi * s > 0.15: + psi -= s * np.pi / 2 + for k in range(50): + self.R[s] = rz(yaw + psi * (k + 1) / 50) @ ry(GTILT) + yield self.compose() + yield from self.hold(15) + P = yield from self.servo(s, P, yaw + psi) + if DEBUG: + wb = self.wrist_block(s) + self.dbg.append(('pre', s, None if wb is None else (wb['c'].round(1).tolist(), wb['area']), + (self.hand_w(s) - P).round(3).tolist(), + self.tools.image(CAMS[s]), self.tools.image('head'))) + # descend from where the hand actually is when the view matched the reference + G = self.hand_w(s) - [0, 0, pre] + yield from self.move({s: G}, 40) + yield from self.hold(10) + self.grip[s] = 1.0 + yield from self.hold(30) + lo = self.lo + f = lo[10:12] if s > 0 else lo[19:21] + self.log.append(('close', s, f.round(3).tolist())) + if DEBUG: + self.dbg.append(('close', s, f.round(3).tolist(), (self.hand_w(s) - G).round(3).tolist(), + self.tools.image(CAMS[s]), self.tools.image('head'))) + yield from self.move({s: G + [0, 0, 0.06]}, 40) + yield from self.hold(10) + lo = self.lo + f = lo[10:12] if s > 0 else lo[19:21] + wb = self.wrist_block(s) + area = 0 if wb is None else wb['area'] + ok = bool(np.all(f > -0.017)) and area > 1200 + self.log.append(('grasp', self.obs['t'], s, f.round(3).tolist(), area, ok)) + self.held[s] = ok + return ok + + def find_blocks(self, zc=None): + """blocks on a table (blobs of blocks held in a hand are dropped).""" + zc = Z_TABLE + BLOCK / 2 if zc is None else zc + bl = self.head_blobs(red_mask, zc) + lo = self.lo + hp = [project(self.hand_p(s), lo[0:3]) for s in (1, -1) if self.held[s]] + out = [] + for b in bl: + if any(np.hypot(*(b['c'] - p)) < 10 for p in hp): + continue + out.append(b['w']) + return out + + def pick(self, side, B): + """walk in front of block estimate B and grasp it with `side`.""" + for attempt in range(3): + yield from self.walk(B[0] - REACH, B[1] - side * SIDE_OFF, 0.0) + yield from self.hold(10) + cand = self.find_blocks() + if cand: + B = min(cand, key=lambda b: np.linalg.norm(b[:2] - B[:2])) + ok = yield from self.grasp(side, B) + if ok: + break + self.grip[side] = 0.0 + yield from self.move({side: B + [-0.12, 0, 0.12]}, 30) + yield from self.tuck([side]) + return ok + + def to_table2(self): + """table 1 (facing +x) -> viewing pose in front of table 2 (facing -x).""" + yield from self.walk(self.pose()[0] - 0.25, self.pose()[1], 0.0) + yield from self.walk(-0.25, 1.3, 0.0, face=True, tol=0.08, ytol=7) + yield from self.walk(2.6, 1.3, 0.0, face=True, tol=0.08, ytol=7) + yield from self.walk(2.6, 0.0, np.pi, face=True, tol=0.05, ytol=7) + yield from self.walk(2.35, 0.0, np.pi) + + def to_table1(self): + yield from self.walk(self.pose()[0] + 0.25, self.pose()[1], np.pi) + yield from self.walk(2.6, 1.3, np.pi, face=True, tol=0.08, ytol=7) + yield from self.walk(-0.25, 1.3, np.pi, face=True, tol=0.08, ytol=7) + yield from self.walk(-0.25, 0.0, 0.0, face=True, tol=0.05, ytol=7) + yield from self.walk(0.05, 0.0, 0.0) + + def find_pad(self): + bl = self.head_blobs(green_mask, Z_TABLE, min_area=4) + if not bl: + return None + b = max(bl, key=lambda b: b['area']) + return b['w'] + + def place(self, side, C): + """lower the block held by `side` until its centre is at world point C, release.""" + s = side + yaw = self.pose()[3] + self.R[s] = rz(yaw) @ ry(TILT) + C = np.array(C, float) + above = C + [0, 0, 0.07] + yield from self.move({s: above}, 60, frame='world') + yield from self.settle(s) + yield from self.move({s: C + [0, 0, 0.008]}, 40) + yield from self.settle(s, nmax=60) + top = self.hand_w(s) + self.grip[s] = 0.0 + yield from self.hold(25) + self.tgt[s] = self.hand_w(s) + self.corr[s] = np.zeros(3) + yield from self.move({s: self.tgt[s] + [0, 0, 0.08]}, 40) + self.held[s] = None + self.log.append(('placed', self.obs['t'], s, C.round(3).tolist(), top.round(3).tolist())) + return top + + def stand_for(self, side, target, yaw): + """walk so that world xy `target` sits at (REACH, side*SIDE_OFF) in the pelvis frame.""" + c, s_ = np.cos(yaw), np.sin(yaw) + rel = np.array([REACH, side * SIDE_OFF]) + bx = target[0] - (c * rel[0] - s_ * rel[1]) + by = target[1] - (s_ * rel[0] + c * rel[1]) + yield from self.walk(bx, by, yaw) + yield from self.hold(15) + + def stand_at(self, C, yaw, lateral=0.0): + """walk so that world xy C sits at (REACH, lateral) in the pelvis frame.""" + c, s_ = np.cos(yaw), np.sin(yaw) + bx = C[0] - (c * REACH - s_ * lateral) + by = C[1] - (s_ * REACH + c * lateral) + yield from self.walk(bx, by, yaw) + yield from self.hold(15) + + def view_pad(self): + """from the viewing pose, find the pad and stand in front of it (facing -x).""" + pad = self.find_pad() + if pad is None: + for dy in (0.4, -0.4): + yield from self.walk(2.35, dy, np.pi) + pad = self.find_pad() + if pad is not None: + break + if pad is None: + pad = np.array([1.55, 0.0, Z_TABLE]) + yield from self.stand_at(pad, np.pi) + p2 = self.find_pad() + if p2 is not None: + pad = p2 + self.log.append(('pad', self.obs['t'], pad.round(3).tolist())) + return pad + + def stack_trip1(self): + """both hands hold a block; robot stands with the pad at (REACH, 0).""" + pad = yield from self.view_pad() + PC = np.array([pad[0], pad[1], Z_TABLE + BLOCK / 2]) + # each hand works on its own side: pad in front of the left hand + yield from self.stand_at(PC, np.pi, lateral=SIDE_OFF) + # a. right block set down in front of the right hand, right arm out of the way + spot = self.p2w(np.array([REACH, -SIDE_OFF, 0.0])) + spot[2] = Z_TABLE + BLOCK / 2 + spot = yield from self.place(-1, spot) + yield from self.tuck([-1]) + # b. left block onto the pad; the hand position at release is where it sits + B1 = yield from self.place(1, PC) + yield from self.tuck([1]) + # c. right hand picks the set-down block up again + ok = yield from self.grasp(-1, spot) + if ok: + yield from self.tuck([-1]) + # d. step sideways so the stack is in front of the right hand + yield from self.stand_at(B1, np.pi, lateral=-SIDE_OFF) + yield from self.place(-1, B1 + [0, 0, BLOCK]) + yield from self.tuck([-1]) + return B1 + + def main(self): + self.a[4] = PITCH + yield from self.hold(40) + blocks = self.find_blocks() + self.log.append(('blocks', [b.round(3).tolist() for b in blocks])) + blocks = sorted(blocks, key=lambda b: -b[1]) + if len(blocks) < 2: + return + yield from self.pick(-1, blocks[-1]) + yield from self.pick(1, blocks[0]) + self.rest = blocks[1:-1] + yield from self.to_table2() + B1 = yield from self.stack_trip1() + self.B1 = B1 + yield from self.trip2(B1) + + def trip2(self, B1): + s = -1 + yield from self.to_table1() + cand = self.find_blocks() + if not cand: + return + B = min(cand, key=lambda b: abs(b[1])) + ok = yield from self.pick(s, B) + if not ok: + return + yield from self.to_table2() + yield from self.stand_at(B1, np.pi, lateral=s * SIDE_OFF) + yield from self.place(s, B1 + [0, 0, 2 * BLOCK]) + yield from self.tuck([s]) + yield from self.hold(100) diff --git a/policies/stack_blocks/opus-s3/cam.py b/policies/stack_blocks/opus-s3/cam.py new file mode 100644 index 0000000000000000000000000000000000000000..b73a7aff1865364c8d031632a1a017649446bb35 --- /dev/null +++ b/policies/stack_blocks/opus-s3/cam.py @@ -0,0 +1,51 @@ +"""Head camera model (fitted from robot-motion observations of static blocks).""" +import numpy as np +import fk + +CAM = np.array([0.0879, 0.0304, 0.3378, 0.8672, 0.0061, 0.0083, 66.0443]) +# head camera at the initial state (t=0), fitted to wrist-measured block positions +CAM0 = np.array([0.0862, 0.0096, 0.3415, 0.9988, -0.0457, -0.045, 74.1238]) +PEL0 = np.array([0.109, -0.003, 0.747, 0.001]) +WAIST0 = np.array([0.001, -0.009, 0.053]) +# wrist cameras in the hand (wrist-yaw) frame: x, y, z, roll, pitch, yaw, f +WCAM = { + 'left': np.array([0.1158, -0.0003, 0.0244, 0.0089, 0.6207, 0.0309, 70.3616]), + 'right': np.array([0.1158, 0.0003, 0.0244, -0.0089, 0.6207, -0.0309, 70.3616]), # mirror of left +} + + +def wrist_offset(side): + c = WCAM[side] + return fk.T(fk.rpy(c[3], c[4], c[5]), c[0:3]) + + +def wrist_point(side, depth): + """hand-frame point at `depth` along the wrist camera axis.""" + M = wrist_offset(side) + return M[:3, 3] + depth * M[:3, 0] + + +def wrist_ray(side, Thand, uv): + """origin and direction (frame of Thand) of the ray through pixel uv.""" + c = WCAM[side] + Tc = Thand @ wrist_offset(side) + d = np.array([c[6], 42 - uv[0], 42 - uv[1]]) + return Tc[:3, 3], Tc[:3, :3] @ d / np.linalg.norm(d) + + +def head_T(pel, waist, ppitch=0.0, c=CAM): + Wp = fk.T(fk.rot('z', pel[3]) @ fk.rot('y', ppitch), (pel[0], pel[1], pel[2])) + return Wp @ fk.torso_T(waist) @ fk.T(fk.rpy(c[5], c[3], c[4]), c[0:3]) + + +def project(Tc, P, f=CAM[6]): + d = Tc[:3, :3].T @ (np.asarray(P) - Tc[:3, 3]) + return np.array([42 - f * d[1] / d[0], 42 - f * d[2] / d[0]]) + + +def ray_plane(Tc, uv, z, f=CAM[6]): + """World point where the pixel ray hits the horizontal plane at height z.""" + d = np.array([f, 42 - uv[0], 42 - uv[1]]) + dw = Tc[:3, :3] @ d + t = (z - Tc[2, 3]) / dw[2] + return Tc[:3, 3] + t * dw diff --git a/policies/stack_blocks/opus-s3/episodes.csv b/policies/stack_blocks/opus-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..a6f5be377f993eff10791964c6459e07791d7bfb --- /dev/null +++ b/policies/stack_blocks/opus-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,8750,timeout,0 +620001,0,8750,timeout,0 +620002,0,8750,timeout,0 +620003,0,8750,timeout,0 +620004,0,8750,timeout,0 +620005,0,8750,timeout,0 +620006,0,8750,timeout,0 +620007,0,8750,timeout,0 +620008,0,2987,terminated,0 +620009,0,8750,timeout,0 +620010,0,8750,timeout,0 +620011,0,3065,terminated,0 +620012,0,8750,timeout,0 +620013,0,8750,timeout,0 +620014,0,8750,timeout,0 +620015,0,8750,timeout,0 +620016,0,8750,timeout,0 +620017,0,8750,timeout,0 +620018,0,8750,timeout,0 +620019,0,8750,timeout,0 +620020,0,8750,timeout,0 +620021,0,8750,timeout,0 +620022,0,8750,timeout,0 +620023,0,8750,timeout,0 +620024,0,8750,timeout,0 +620025,0,8750,timeout,0 +620026,0,8750,timeout,0 +620027,0,8750,timeout,0 +620028,0,8750,timeout,0 +620029,0,8750,timeout,0 +620030,0,8750,timeout,0 +620031,0,8750,timeout,0 +620032,0,8750,timeout,0 +620033,0,8750,timeout,0 +620034,0,8750,timeout,0 +620035,0,8750,timeout,0 +620036,0,8750,timeout,0 +620037,0,8750,timeout,0 +620038,0,8750,timeout,0 +620039,0,8750,timeout,0 +620040,0,8750,timeout,0 +620041,0,8750,timeout,0 +620042,0,8750,timeout,0 +620043,0,8750,timeout,0 +620044,1,6263,success,0 +620045,0,8750,timeout,0 +620046,0,8750,timeout,0 +620047,0,8750,timeout,0 +620048,0,8750,timeout,0 +620049,0,8750,timeout,0 +620050,0,8750,timeout,0 +620051,0,8750,timeout,0 +620052,0,3155,terminated,0 +620053,0,8750,timeout,0 +620054,0,8750,timeout,0 +620055,0,8750,timeout,0 +620056,0,8750,timeout,0 +620057,0,8750,timeout,0 +620058,0,8750,timeout,0 +620059,0,8750,timeout,0 +620060,0,8750,timeout,0 +620061,0,8750,timeout,0 +620062,0,8750,timeout,0 +620063,0,8750,timeout,0 +620064,0,8750,timeout,0 +620065,0,8750,timeout,0 +620066,0,8750,timeout,0 +620067,0,8750,timeout,0 +620068,0,8750,timeout,0 +620069,0,6399,terminated,0 +620070,0,8750,timeout,0 +620071,0,8750,timeout,0 +620072,0,8750,timeout,0 +620073,0,3037,terminated,0 +620074,0,8750,timeout,0 +620075,0,8750,timeout,0 +620076,0,8750,timeout,0 +620077,0,8750,timeout,0 +620078,0,8750,timeout,0 +620079,0,8750,timeout,0 +620080,0,8750,timeout,0 +620081,0,8750,timeout,0 +620082,0,8750,timeout,0 +620083,0,8750,timeout,0 +620084,0,8750,timeout,0 +620085,0,8750,timeout,0 +620086,0,8750,timeout,0 +620087,0,8750,timeout,0 +620088,0,8750,timeout,0 +620089,0,6365,terminated,0 +620090,0,8750,timeout,0 +620091,0,8750,timeout,0 +620092,0,8750,timeout,0 +620093,0,8750,timeout,0 +620094,0,8750,timeout,0 +620095,0,8750,timeout,0 +620096,0,8750,timeout,0 +620097,0,8750,timeout,0 +620098,0,8750,timeout,0 +620099,0,8750,timeout,0 diff --git a/policies/stack_blocks/opus-s3/fk.py b/policies/stack_blocks/opus-s3/fk.py new file mode 100644 index 0000000000000000000000000000000000000000..81414b8771ca49f4c8b6fa655889675096fd274f --- /dev/null +++ b/policies/stack_blocks/opus-s3/fk.py @@ -0,0 +1,132 @@ +"""Forward kinematics of the G1 upper body (URDF geometry), pelvis frame.""" +import numpy as np + + +def rot(axis, a): + c, s = np.cos(a), np.sin(a) + if axis == 'x': + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + if axis == 'y': + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def rpy(r, p, y): + return rot('z', y) @ rot('y', p) @ rot('x', r) + + +def T(R=None, p=(0, 0, 0)): + M = np.eye(4) + if R is not None: + M[:3, :3] = R + M[:3, 3] = p + return M + + +def torso_T(waist): + """pelvis -> torso_link given waist (yaw, roll, pitch).""" + M = T(rot('z', waist[0])) + M = M @ T(rot('x', waist[1]), (-0.0039635, 0, 0.035)) + M = M @ T(rot('y', waist[2]), (0, 0, 0.019)) + return M + + +# (origin xyz, origin rpy, axis) for the left arm; right arm mirrors y. +LEFT_CHAIN = [ + ((0.0039563, 0.10022, 0.23778), (0.27931, 5.4949e-05, -0.00019159), 'y'), + ((0, 0.038, -0.013831), (-0.27925, 0, 0), 'x'), + ((0, 0.00624, -0.1032), (0, 0, 0), 'z'), + ((0.015783, 0, -0.080518), (0, 0, 0), 'y'), + ((0.100, 0.00188791, -0.010), (0, 0, 0), 'x'), + ((0.038, 0, 0), (0, 0, 0), 'y'), + ((0.046, 0, 0), (0, 0, 0), 'z'), +] + + +def arm_chain(side): + if side == 'left': + return LEFT_CHAIN + out = [] + for (x, y, z), (r, p, yw), ax in LEFT_CHAIN: + out.append(((x, -y, z), (-r, p, -yw), ax)) + return out + + +def arm_T(side, q, waist=(0, 0, 0), tool=(0.0, 0, 0)): + """pelvis -> hand frame (after wrist yaw, translated by tool offset).""" + M = torso_T(waist) + for (p, r, ax), qi in zip(arm_chain(side), q): + M = M @ T(rpy(*r), p) @ T(rot(ax, qi)) + return M @ T(None, tool) + + +# joint box used by the IK: the action limits narrowed to postures that keep the +# arm on its own side of the body (left arm; the right arm mirrors roll/yaw) +SANE_LO = np.array([-2.6, 0.0, -1.3, -1.0, -1.6, -1.55, -1.55]) +SANE_HI = np.array([1.0, 1.6, 1.3, 2.0, 1.6, 1.55, 1.55]) +Q_NOM = [np.array([-0.4, 0.15, 0.0, 0.9, 0.0, 0.4, 0.0]), + np.array([-0.9, 0.2, 0.0, 0.4, 0.0, 0.9, 0.0]), + np.array([0.0, 0.15, 0.0, 1.2, 0.0, 0.0, 0.0])] + + +def limits(side): + lo, hi = SANE_LO.copy(), SANE_HI.copy() + if side == 'right': + for i in (1, 2, 4, 6): + lo[i], hi[i] = -SANE_HI[i], -SANE_LO[i] + return lo, hi + + +def mirror(q, side): + q = np.array(q, float) + if side == 'right': + q[[1, 2, 4, 6]] *= -1 + return q + + +def _ik1(side, p, xdir, ydir, q0, waist, tool, w_ori, w_reg, lo, hi): + from scipy.optimize import least_squares + q0 = np.clip(np.asarray(q0, float), lo + 1e-3, hi - 1e-3) + qref = q0.copy() + + def res(q): + M = arm_T(side, q, waist, tool) + r = [M[:3, 3] - p] + if xdir is not None: + r.append(w_ori * (M[:3, 0] - xdir)) + if ydir is not None: + r.append(w_ori * (M[:3, 1] - ydir)) + r.append(w_reg * (q - qref)) + return np.concatenate(r) + + sol = least_squares(res, q0, bounds=(lo, hi)) + M = arm_T(side, sol.x, waist, tool) + e = np.linalg.norm(M[:3, 3] - p) + eo = 0.0 + if xdir is not None: + eo += np.linalg.norm(M[:3, 0] - xdir) + if ydir is not None: + eo += np.linalg.norm(M[:3, 1] - ydir) + return sol.x, e, eo + + +def ik(side, p, xdir=None, ydir=None, q0=None, waist=(0, 0, 0), tool=(0.12, 0, 0), + w_ori=1.0, w_reg=0.01, multi=True): + """Least-squares IK: tool point to p, hand x axis to xdir, hand y axis to ydir. + Tries the given start and nominal postures; returns (q, position error).""" + lo, hi = limits(side) + p = np.asarray(p, float) + starts = [] if q0 is None else [np.asarray(q0, float)] + best = None + if starts: + q, e, eo = _ik1(side, p, xdir, ydir, starts[0], waist, tool, w_ori, w_reg, lo, hi) + best = (e + 0.1 * eo, q, e) + if e < 0.003 and eo < 0.03: + return q, e + if multi or not starts: + for qn in Q_NOM: + q, e, eo = _ik1(side, p, xdir, ydir, mirror(qn, side), waist, tool, w_ori, w_reg, lo, hi) + c = e + 0.1 * eo + 0.002 + if best is None or c < best[0]: + best = (c, q, e) + return best[1], best[2] diff --git a/policies/stack_blocks/opus-s3/policy.py b/policies/stack_blocks/opus-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..6e604d1a7330443e85bb1c0aceae1677c8691653 --- /dev/null +++ b/policies/stack_blocks/opus-s3/policy.py @@ -0,0 +1,718 @@ +"""Stack-blocks policy for the G1: hand-written state machine. + +Plan: grasp two blocks on table 1 (one per hand, wrist-camera visual servo), +walk around to table 2, put the first on the green pad and the second on top, +walk back for the third block and stack it. + +Geometry: fk.py holds the G1 arm kinematics (URDF dimensions) and a bounded IK; +cam.py holds the head / wrist camera models, calibrated from the robot's own +camera views of static and held blocks. Blocks are located with the head camera +at t=0 and refined with a wrist camera; placements close the loop on the +forward-kinematic position of the held block in world coordinates. +""" + +import os +import sys + +import numpy as np +import scipy.ndimage as ndi + +sys.path.append(os.path.dirname(os.path.abspath(__file__))) +import fk # noqa: E402 +import cam # noqa: E402 + +PELVIS_H = 0.74 +BLOCK_Z = 0.718 # block centre height on a table (world) +TABLE_Z = 0.70 # table top (world) +BLOCK = 0.05 # block edge +CAM_PITCH = 0.68 # gripper / wrist camera axis, below the hand x axis (rad) +GRASP_OFF = (0.183, 0.0, -0.005) # grasp centre in the hand frame (m) +WRIST_F = 68.0 # wrist camera focal length (px) +ALPHA = 0.9 # gripper axis below horizontal while grasping (rad) +# wrist camera appearance of a block at the moment of closing (demo, left wrist) +WRIST_UV = np.array([43.0, 36.0]) +WRIST_AREA = 5000.0 + +# route between the tables (world) +HELD_OFF = np.array([0.200, 0.0, 0.008]) # held block centre in the hand frame (measured) +PAD_SIZE = 0.11 # green pad edge (wrist-camera measurement) +PAD_CHECKS = 0 # wrist-camera pad re-check of block 1 (disabled: not validated) +PAD_TOL = 0.012 # re-place block 1 if its head-image offset from the pad exceeds this +PLACE_DZ = 0.006 # release height of the block bottom above its support +VIEW_ALPHA = 0.95 +VIEW_DIST = 0.20 +STAND_X_MAX = 0.20 # closest pelvis x in front of table 1 (edge at x=0.385) +PAD_DEFAULT = np.array([1.60, 0.0, TABLE_Z]) +T2_DX = 0.40 # pelvis stands this far (+x) from the pad, facing -x +T2_STAND = np.array([1.95, 0.0, np.pi]) +VIA = [np.array([-0.05, 1.05]), np.array([2.45, 1.05]), np.array([2.45, 0.0])] + +ARM_REST = { + 'left': np.array([0.0, 0.15, 0.0, 1.5, 0.0, 0.0, 0.0]), + 'right': np.array([0.0, -0.15, 0.0, 1.5, 0.0, 0.0, 0.0]), +} + + +def wrap(a): + return (a + np.pi) % (2 * np.pi) - np.pi + + +def red_mask(im): + r, g, b = [im[..., i].astype(int) for i in range(3)] + return (r > 100) & (g < 70) & (b < 70) & (r > 2 * g) + + +def green_mask(im): + r, g, b = [im[..., i].astype(int) for i in range(3)] + return (g > 150) & (g > r + 40) & (g > b + 40) + + +def components(mask, min_px=8): + lab, k = ndi.label(mask) + out = [] + for i in range(1, k + 1): + ys, xs = np.nonzero(lab == i) + if len(xs) >= min_px: + out.append(dict(u=xs.mean(), v=ys.mean(), n=len(xs), + box=(xs.min(), xs.max(), ys.min(), ys.max()))) + return out + + +class Policy: + """The control policy that is scored on the hidden seeds.""" + + def reset(self, obs, tools): + self.tools = tools + self.obs = obs + self.A = np.zeros(21) + self.A[2] = PELVIS_H + o = obs['low_dim_obs'] + self.A[5:12] = o[3:10] + self.A[12:19] = o[12:19] + self.A[19] = self.A[20] = 0.0 + self.q = {'left': o[3:10].astype(float).copy(), 'right': o[12:19].astype(float).copy()} + self.held = {'left': False, 'right': False} + self.grip_pose = {'left': (0.0, 1.0), 'right': (0.0, 1.0)} + self.stack = [] # world positions of placed blocks + self.log = [] + self.phase = 'start' + self.gen = self.script() + + # ------------------------------------------------------------------ utils + @property + def o(self): + return self.obs['low_dim_obs'] + + def note(self, *a): + self.log.append((int(self.obs['t']), self.phase) + a) + + def w2p(self, P): + """world point -> pelvis yaw frame (z relative to pelvis).""" + o = self.o + d = np.asarray(P, float) - o[21:24] + c, s = np.cos(o[24]), np.sin(o[24]) + return np.array([c * d[0] + s * d[1], -s * d[0] + c * d[1], d[2]]) + + def p2w(self, p): + o = self.o + c, s = np.cos(o[24]), np.sin(o[24]) + return np.array([o[21] + c * p[0] - s * p[1], o[22] + s * p[0] + c * p[1], o[23] + p[2]]) + + def act(self, obs, tools): + self.obs = obs + try: + a = next(self.gen) + except StopIteration: + a = None + except Exception: + # never crash an episode: freeze in place + self.gen = iter(()) + a = None + if a is None: + self.A[0] = self.A[1] = self.A[3] = 0.0 + a = self.A + return np.asarray(a, dtype=np.float32).copy() + + def wait(self, n): + for _ in range(n): + yield self.A + + # ------------------------------------------------------------- base motion + def walk_to(self, x, y, yaw=None, tol=0.03, ytol=0.05, n=1500, speed=0.4, final=True): + A = self.A + for i in range(n): + o = self.o + px, py, pyaw = o[21], o[22], o[24] + dx, dy = x - px, y - py + dist = np.hypot(dx, dy) + c, s = np.cos(pyaw), np.sin(pyaw) + fx, fy = c * dx + s * dy, -s * dx + c * dy + if dist > 0.25 or (not final and dist > 0.12): + hd = wrap(np.arctan2(dy, dx) - pyaw) + if yaw is not None and dist < 0.6: + # close to the goal: keep the final heading, side-step + hd2 = wrap(yaw - pyaw) + wz = np.clip(1.5 * hd2, -0.6, 0.6) + vx, vy = np.clip(1.2 * fx, -speed, speed), np.clip(1.2 * fy, -0.3, 0.3) + else: + wz = np.clip(1.5 * hd, -0.8, 0.8) + vx = speed * max(0.0, np.cos(hd)) ** 4 if abs(hd) < 0.6 else 0.0 + vx = min(vx, 0.6 * dist + 0.1) + vy = np.clip(1.0 * fy, -0.2, 0.2) if abs(hd) < 0.6 else 0.0 + else: + if not final: + return + yf = yaw if yaw is not None else pyaw + hd = wrap(yf - pyaw) + wz = np.clip(1.5 * hd, -0.6, 0.6) + vx, vy = np.clip(1.5 * fx, -0.2, 0.2), np.clip(1.5 * fy, -0.2, 0.2) + if abs(fx) < tol and abs(fy) < tol and abs(hd) < ytol: + break + sp = np.hypot(vx, vy) + if 0 < sp < 0.065: + vx, vy = vx / sp * 0.065, vy / sp * 0.065 + if abs(wz) < 0.06 and abs(wz) > 0.005 and sp < 0.065: + wz = 0.06 * np.sign(wz) + A[0], A[1], A[3] = vx, vy, wz + yield A + A[0] = A[1] = A[3] = 0.0 + yield from self.wait(25) + + # -------------------------------------------------------------- arm motion + def arm_to(self, side, q, n=40, grip=None): + """linear joint interpolation to q over n steps.""" + sl = slice(5, 12) if side == 'left' else slice(12, 19) + q0 = self.A[sl].copy() + q = np.asarray(q, float) + for i in range(1, n + 1): + self.A[sl] = q0 + (q - q0) * i / n + if grip is not None: + self.A[19 if side == 'left' else 20] = grip + yield self.A + self.q[side] = q.copy() + + def grip(self, side, g, n=30): + self.A[19 if side == 'left' else 20] = g + yield from self.wait(n) + + def azimuth(self, side, p): + sh = np.array([0.0, 0.10 if side == 'left' else -0.10]) + yaw = np.arctan2(p[1] - sh[1], max(p[0] - sh[0], 0.05)) + return float(np.clip(yaw, -0.8, 0.8)) + + @staticmethod + def frame(psi, alpha): + """gripper axis a (azimuth psi, alpha below horizontal), closing axis y, + camera-up n, and the hand x/y axes that realise it.""" + a = np.array([np.cos(alpha) * np.cos(psi), np.cos(alpha) * np.sin(psi), -np.sin(alpha)]) + y = np.array([-np.sin(psi), np.cos(psi), 0.0]) + n = np.cross(a, y) + x = np.cos(CAM_PITCH) * a + np.sin(CAM_PITCH) * n + return a, y, n, x + + def solve(self, side, p, xd, yd, tool=GRASP_OFF, q0=None, multi=True): + q0 = self.q[side] if q0 is None else q0 + q, err = fk.ik(side, np.asarray(p, float), xdir=xd, ydir=yd, q0=q0, + waist=self.o[0:3], tool=tool, multi=multi) + return q, err + + def hand_pose(self, side, tool=GRASP_OFF): + o = self.o + q = o[3:10] if side == 'left' else o[12:19] + return fk.arm_T(side, q, o[0:3], tool) + + # -------------------------------------------------------------- perception + def head_blocks(self, ppitch=0.0): + im = self.tools.image('head') + o = self.o + Tc = cam.head_T(o[21:25], o[0:3], ppitch) + out = [] + for c in components(red_mask(im), 15): + P = cam.ray_plane(Tc, (c['u'], c['v']), BLOCK_Z) + out.append(dict(c, P=P)) + return out + + def head_pad(self, ppitch=0.0): + im = self.tools.image('head') + o = self.o + Tc = cam.head_T(o[21:25], o[0:3], ppitch) + cs = components(green_mask(im), 10) + if not cs: + return None + c = max(cs, key=lambda c: c['n']) + return dict(c, P=cam.ray_plane(Tc, (c['u'], c['v']), TABLE_Z)) + + def wrist_blob(self, side): + im = self.tools.image('left_wrist' if side == 'left' else 'right_wrist') + cs = components(red_mask(im), 20) + if not cs: + return None + return max(cs, key=lambda c: c['n']) + + # ------------------------------------------------------------------ grasp + def set_arm(self, side, q): + sl = slice(5, 12) if side == 'left' else slice(12, 19) + self.A[sl] = q + self.q[side] = np.asarray(q, float).copy() + + @staticmethod + def grasp_point(side): + return tuple(cam.wrist_point(side, 0.05 * cam.WCAM[side][6] / 62.0)) + + def wrist_locate(self, side, near=None, zw=BLOCK_Z, color='red'): + """blobs seen by a wrist camera -> pelvis-frame positions on plane zw.""" + im = self.tools.image(side + '_wrist') + mask = red_mask(im) if color == 'red' else green_mask(im) + lab, k = ndi.label(mask) + o = self.o + Th = fk.arm_T(side, o[3:10] if side == 'left' else o[12:19], o[0:3]) + zp = zw - o[23] + out = [] + for i in range(1, k + 1): + ys, xs = np.nonzero(lab == i) + if len(xs) < 30: + continue + org, d = cam.wrist_ray(side, Th, (xs.mean(), ys.mean())) + if d[2] > -0.05: + continue + P = org + d * (zp - org[2]) / d[2] + # yaw of the top face: project pixels onto the top plane, min-area rectangle + yaw = None + try: + import cv2 + c = cam.WCAM[side] + Tc = Th @ cam.wrist_offset(side) + D = np.stack([np.full(len(xs), c[6]), 42.0 - xs, 42.0 - ys], 1) @ Tc[:3, :3].T + zt = zp + BLOCK / 2 + t = (zt - Tc[2, 3]) / D[:, 2] + pts = (Tc[:3, 3][None, :2] + D[:, :2] * t[:, None]).astype(np.float32) * 1000 + (cx, cy), (w, h), ang = cv2.minAreaRect(pts) + yaw = np.radians(ang) % (np.pi / 2) + except Exception: + pass + out.append(dict(P=P, n=len(xs), u=xs.mean(), v=ys.mean(), yaw=yaw, + box=(xs.min(), xs.max(), ys.min(), ys.max()))) + if near is not None and out: + out.sort(key=lambda b: np.hypot(*(b['P'][:2] - near[:2]))) + return out + + def grasp(self, side, Pw, alpha=1.0): + """Pick the block near world point Pw with one hand.""" + self.phase = 'grasp_' + side + p = self.w2p(Pw) + psi = self.azimuth(side, p) + a, y, n, x = self.frame(psi, VIEW_ALPHA) + tv = tuple(cam.wrist_point(side, VIEW_DIST)) + q, err = self.solve(side, p + [0, 0, 0.10], x, y, tool=tv) + yield from self.arm_to(side, q, 40, grip=0.0) + q, err = self.solve(side, p, x, y, tool=tv, q0=q) + yield from self.arm_to(side, q, 25, grip=0.0) + yield from self.wait(12) + seen = self.wrist_locate(side, near=p) + if seen and np.hypot(*(seen[0]['P'][:2] - p[:2])) < 0.12: + b = seen[0] + p = b['P'] + self.note('view', np.round(p, 3), b['n'], None if b['yaw'] is None else round(float(b['yaw']), 3)) + yaw = b['yaw'] + else: + self.note('view-miss', len(seen)) + yaw = None + psi0 = self.azimuth(side, p) + cands = [psi0] + if yaw is not None: + # closing axis perpendicular to a pair of faces + cands = [yaw + k * np.pi / 2 for k in range(-3, 4)] + cands = [c for c in cands if abs(wrap(c - psi0)) < 0.9] + tg = self.grasp_point(side) + best = None + for psi in cands: + for al in (1.0, 1.2, 0.8): + a, y, n, x = self.frame(psi, al) + q1, e1 = self.solve(side, p - 0.09 * a, x, y, tool=tg) + q2, e2 = self.solve(side, p, x, y, tool=tg, q0=q1) + cost = e1 + 3 * e2 + 0.01 * abs(wrap(psi - psi0)) + if best is None or cost < best[0]: + best = (cost, psi, al, q1, q2, e2) + _, psi, al, q1, q2, e2 = best + self.note('grasp-pose', round(float(psi), 3), al, round(float(e2), 4)) + a, y, n, x = self.frame(psi, al) + yield from self.arm_to(side, q1, 30, grip=0.0) + tgt = p - 0.09 * a + q = q1 + f = cam.WCAM[side][6] + best_n, stall = 0, 0 + for it in range(40): + yield from self.wait(4) + b = self.wrist_blob(side) + if b is None: + self.note('servo-lost', it) + break + eu, ev = b['u'] - WRIST_UV[0], b['v'] - WRIST_UV[1] + depth = 0.052 * np.sqrt(WRIST_AREA / max(b['n'], 50)) + if b['n'] > 0.9 * WRIST_AREA and abs(eu) < 6 and abs(ev) < 7: + break + if b['n'] > best_n: + best_n, stall = b['n'], 0 + else: + stall += 1 + if best_n > 0.75 * WRIST_AREA and stall >= 3 and abs(eu) < 14 and abs(ev) < 14: + break + k = 0.6 * min(depth, 0.15) / f + fwd = float(np.clip(0.5 * (depth - 0.052), 0.0, 0.012)) if abs(eu) < 12 and abs(ev) < 12 else 0.0 + tgt = tgt + fwd * a - k * eu * y - k * ev * n + q, err = self.solve(side, tgt, x, y, tool=tg, q0=q, multi=False) + self.set_arm(side, q) + self.note('servo', it, round(b['u'], 1), round(b['v'], 1), b['n'], round(err, 3)) + yield from self.wait(4) + b = self.wrist_blob(side) + self.note('pregrip', None if b is None else (round(b['u'], 1), round(b['v'], 1), b['n']), np.round(tgt - p, 3)) + yield from self.grip(side, 1.0, 30) + g = self.o[50 if side == 'left' else 51] + self.held[side] = 0.08 < g < 0.85 + self.note('closed', round(float(g), 3)) + self.grasp_p = p + self.grip_pose[side] = (psi, al) + q, err = self.solve(side, p + [0, 0, 0.12], x, y, tool=tg, q0=q) + yield from self.arm_to(side, q, 40) + + def held_point(self, side): + """hand-frame position of the centre of a held block.""" + return tuple(HELD_OFF) + + def place(self, side, Pw, release=True): + """Put the held block with its centre at world point Pw (lowering until contact).""" + self.phase = 'place_' + side + psi, al = self.grip_pose[side] + p = self.w2p(Pw) + tg = self.held_point(side) + best = None + az = self.azimuth(side, p) + cands = [psi + k * np.pi / 2 for k in range(-4, 5)] + cands = [ps for ps in cands if abs(wrap(ps - az)) < 0.8] + for ps in cands: + for a_ in (1.0, 1.2, 0.8, 1.4): + a, y, n, x = self.frame(ps, a_) + q1, e1 = self.solve(side, p + [0, 0, 0.07], x, y, tool=tg) + q2, e2 = self.solve(side, p, x, y, tool=tg, q0=q1) + c = e1 + 3 * e2 + 0.004 * abs(wrap(ps - az)) + 0.004 * abs(a_ - 1.0) + if best is None or c < best[0]: + best = (c, ps, a_, q1, e2) + _, psi, al, q1, e2 = best + a, y, n, x = self.frame(psi, al) + self.note('place-pose', np.round(p, 3), round(float(psi), 3), al, round(float(e2), 4)) + yield from self.arm_to(side, q1, 45) + yield from self.wait(10) + q = q1 + # descend in stages, closing the loop on the measured (FK) block position + corr = np.zeros(3) + contact = False + # xy is corrected while the block is still clear of the support (no friction), + # then the block goes straight down with z-only corrections + stages = [(0.07, 15, False), (0.07, 15, False), (0.035, 15, False)] + \ + [(0.035, 8, False)] * 8 + [(PLACE_DZ, 18, True), (PLACE_DZ, 12, True)] + for z, n_wait, low in stages: + p = self.w2p(Pw) # the base drifts while standing: track the world target + m = self.hand_pose(side, tg)[:3, 3] + err = (p + [0, 0, z]) - m + if not low: + if z < 0.05 and np.hypot(err[0], err[1]) < 0.005: + continue + corr[:2] = np.clip(corr[:2] + np.clip(err[:2], -0.03, 0.03), -0.07, 0.07) + else: + corr[2] = np.clip(corr[2] + np.clip(err[2], -0.02, 0.02), -0.04, 0.04) + q, e = self.solve(side, p + [0, 0, z] + corr, x, y, tool=tg, q0=q, multi=False) + if low: + q0_ = self.q[side] + for i in range(1, 7): + self.set_arm(side, q0_ + (q - q0_) * i / 6) + yield from self.wait(2) + self.set_arm(side, q) + yield from self.wait(n_wait) + p = self.w2p(Pw) + m = self.hand_pose(side, tg)[:3, 3] + self.note('pre-release', np.round(m - p, 3), np.round(corr, 3)) + z = PLACE_DZ + Ph = self.p2w(m) + self.note('placed', contact, round(z, 3), np.round(Ph, 3)) + if release: + yield from self.grip(side, 0.0, 25) + self.held[side] = False + q, e = self.solve(side, p + [0, 0, z] - 0.06 * a, x, y, tool=tg, q0=q) + yield from self.arm_to(side, q, 20) + q, e = self.solve(side, p + [0, 0, z + 0.06] - 0.08 * a, x, y, tool=tg, q0=q) + yield from self.arm_to(side, q, 20) + return Ph + + def carry_pose(self, side): + p = np.array([0.30, 0.20 if side == 'left' else -0.20, 0.10]) + a, y, n, x = self.frame(0.0, 0.5) + q, err = self.solve(side, p, x, y) + return q + + # ------------------------------------------------------------------ script + def head_blocks0(self): + """blocks on table 1 from the head camera at the initial state.""" + im = self.tools.image('head') + Tc = cam.head_T(cam.PEL0, cam.WAIST0, 0.0, cam.CAM0) + found = [] + for c in components(red_mask(im), 12): + found.append([cam.ray_plane(Tc, (c['u'], c['v']), BLOCK_Z, cam.CAM0[6]), c['n']]) + # a block split by a gripper finger in front of it shows up as two blobs: merge + out = [] + for P, n in sorted(found, key=lambda f: -f[1]): + for o in out: + if np.hypot(*(o[0][:2] - P[:2])) < 0.045: + o[0] = (o[0] * o[1] + P * n) / (o[1] + n) + o[1] += n + break + else: + out.append([P, n]) + return [o[0] for o in out] + + def approach_block(self, side, Pw): + """stand so that block Pw is in comfortable reach of `side`.""" + self.phase = 'approach_' + side + sg = 1.0 if side == 'left' else -1.0 + x = float(np.clip(Pw[0] - 0.36, 0.0, STAND_X_MAX)) + y = float(Pw[1] - sg * 0.17) + yield from self.walk_to(x, y, 0.0, tol=0.02, ytol=0.04, speed=0.2) + + def park_pose(self, side): + sg = 1.0 if side == 'left' else -1.0 + p = np.array([0.16, sg * 0.36, 0.10]) + a, y, n, x = self.frame(sg * 0.6, 0.6) + q, err = self.solve(side, p, x, y) + return q + + def view_locate(self, side, Pw, zw, color='red', dist=VIEW_DIST): + """look at world point Pw with a wrist camera; return world position of the + nearest blob on plane zw (or None).""" + p = self.w2p(Pw) + p[2] = zw - self.o[23] + psi = self.azimuth(side, p) + a, y, n, x = self.frame(psi, VIEW_ALPHA) + tv = tuple(cam.wrist_point(side, dist)) + q, err = self.solve(side, p + [0, 0, 0.06], x, y, tool=tv) + yield from self.arm_to(side, q, 30) + q, err = self.solve(side, p, x, y, tool=tv, q0=q) + yield from self.arm_to(side, q, 20) + yield from self.wait(12) + seen = self.wrist_locate(side, near=p, zw=zw, color=color) + if seen and np.hypot(*(seen[0]['P'][:2] - p[:2])) < 0.10: + P = self.p2w(seen[0]['P']) + P[2] = zw + self.note('view_locate', side, color, np.round(P, 3)) + return P + self.note('view_locate-miss', side, color, len(seen)) + return None + + def wrist_project(self, side, mask, zw): + """world points where the pixels of `mask` hit the plane z = zw.""" + o = self.o + Th = fk.arm_T(side, o[3:10] if side == 'left' else o[12:19], o[0:3]) + c = cam.WCAM[side] + Tc = Th @ cam.wrist_offset(side) + ys, xs = np.nonzero(mask) + D = np.stack([np.full(len(xs), c[6]), 42.0 - xs, 42.0 - ys], 1) @ Tc[:3, :3].T + D = D[D[:, 2] < -1e-3] + t = ((zw - o[23]) - Tc[2, 3]) / D[:, 2] + pts = Tc[:3, 3][None, :] + D * t[:, None] + cy, sy = np.cos(o[24]), np.sin(o[24]) + wx = o[21] + cy * pts[:, 0] - sy * pts[:, 1] + wy = o[22] + sy * pts[:, 0] + cy * pts[:, 1] + return np.stack([wx, wy], 1) + + def wrist_pad_offset(self, side, b1): + """look down at block b1 on the pad; return pad centre minus block centre (xy).""" + p = self.w2p(b1) + psi = self.azimuth(side, p) + a, y, n, x = self.frame(psi, 1.1) + q, err = self.solve(side, p, x, y, tool=tuple(cam.wrist_point(side, 0.24))) + yield from self.arm_to(side, q, 30) + yield from self.wait(15) + im = self.tools.image(side + '_wrist') + g = green_mask(im) + lab, k = ndi.label(red_mask(im)) + if g.sum() < 40 or k == 0: + return None + sizes = ndi.sum(np.ones_like(lab), lab, range(1, k + 1)) + rb = self.wrist_project(side, lab == (1 + int(np.argmax(sizes))), BLOCK_Z).mean(0) + gp = self.wrist_project(side, g, TABLE_Z - 0.008) + lo, hi = gp.min(0), gp.max(0) + c = (lo + hi) / 2 + for i in range(2): + if hi[i] - lo[i] < PAD_SIZE - 0.01: + # one side hidden under the block: trust the far edge + c[i] = hi[i] - PAD_SIZE / 2 if abs(rb[i] - lo[i]) < abs(rb[i] - hi[i]) else lo[i] + PAD_SIZE / 2 + off = c - rb + nrm = np.hypot(*off) + if nrm > 0.05: + off = off * 0.05 / nrm + self.note('pad-view', np.round(c, 3), np.round(rb, 3), np.round(hi - lo, 3)) + return off + + def head_block_near(self, Pw, maxd=0.08): + """head-camera estimate (CAM0 model) of the block nearest world point Pw.""" + im = self.tools.image('head') + o = self.o + Tc = cam.head_T(o[21:25], o[0:3], 0.0, cam.CAM0) + best = None + for c in components(red_mask(im), 12): + P = cam.ray_plane(Tc, (c['u'], c['v']), BLOCK_Z, cam.CAM0[6]) + d = np.hypot(*(P[:2] - Pw[:2])) + if d < maxd and (best is None or d < best[0]): + best = (d, P) + return None if best is None else best[1] + + def head_pad(self): + im = self.tools.image('head') + o = self.o + Tc = cam.head_T(o[21:25], o[0:3], 0.0, cam.CAM0) + cs = components(green_mask(im), 10) + if not cs: + return None + c = max(cs, key=lambda c: c['n']) + return cam.ray_plane(Tc, (c['u'], c['v']), TABLE_Z, cam.CAM0[6]) + + def run_place(self, side, Pw): + g = self.place(side, Pw) + while True: + try: + yield next(g) + except StopIteration as e: + self.last_placed = e.value + return + + def run_view(self, side, Pw, zw, color='red'): + g = self.view_locate(side, Pw, zw, color) + while True: + try: + yield next(g) + except StopIteration as e: + self.last_seen = e.value + return + + def get_block(self, side, Pw, tries=3): + """approach and grasp the block near Pw, retrying on a miss.""" + for k in range(tries): + yield from self.approach_block(side, Pw) + yield from self.grasp(side, Pw) + if self.held[side]: + break + # missed: open, back off and look again + yield from self.grip(side, 0.0, 10) + yield from self.arm_to(side, self.carry_pose(side), 30) + self.phase = 'regrasp' + yield from self.run_view(side, Pw, BLOCK_Z) + if self.last_seen is not None: + Pw = self.last_seen + yield from self.arm_to(side, self.carry_pose(side), 30) + + def script(self): + self.phase = 'look0' + blocks = self.head_blocks0() + blocks.sort(key=lambda P: -P[1]) + self.note('blocks', [np.round(P, 3) for P in blocks]) + while len(blocks) < 3: + blocks.append(np.array([0.55, 0.0, BLOCK_Z])) + self.blocks0 = blocks + # raise both hands out of the way, gripper open + for side in ('left', 'right'): + yield from self.arm_to(side, self.carry_pose(side), 30, grip=0.0) + right_b, left_b = blocks[-1], blocks[0] + third = blocks[1] + yield from self.get_block('right', right_b) + yield from self.get_block('left', left_b) + + self.phase = 'trip1' + yield from self.go_table2() + pad = self.head_pad() + self.note('pad0', None if pad is None else np.round(pad, 3)) + if pad is None: + pad = PAD_DEFAULT.copy() + yield from self.walk_to(pad[0] + T2_DX, pad[1], np.pi, tol=0.02, ytol=0.04, speed=0.15) + p2 = self.head_pad() + if p2 is not None and np.hypot(*(p2[:2] - pad[:2])) < 0.1: + pad = p2 + self.note('pad', np.round(pad, 3)) + yield from self.stack_two(pad) + + self.phase = 'return' + side = 'left' if third[1] > 0.0 else 'right' + sg = 1.0 if side == 'left' else -1.0 + yield from self.go_table1(float(np.clip(third[0] - 0.36, 0.0, STAND_X_MAX)), float(third[1] - sg * 0.17)) + yield from self.wait(20) + seen = self.head_block_near(third, maxd=0.25) + if seen is not None: + third = seen + self.note('third', np.round(third, 3)) + yield from self.get_block(side, third) + + self.phase = 'trip2' + yield from self.go_table2() + top = self.stack_top + yield from self.walk_to(top[0] + T2_DX, top[1], np.pi, tol=0.02, ytol=0.04, speed=0.15) + other = 'right' if side == 'left' else 'left' + yield from self.arm_to(other, self.park_pose(other), 30) + yield from self.align_for(side, top) + yield from self.run_place(side, top + [0, 0, BLOCK]) + yield from self.arm_to(side, self.park_pose(side), 40) + self.phase = 'done' + yield None + + def align_for(self, side, Pw): + """stand facing -x with world point Pw in comfortable reach of `side`.""" + sg = 1.0 if side == 'left' else -1.0 + yield from self.walk_to(Pw[0] + T2_DX, Pw[1] + sg * 0.05, np.pi, tol=0.02, ytol=0.05, speed=0.15, n=400) + + def stack_two(self, pad): + """left block on the pad, right block on top of it.""" + yield from self.arm_to('right', self.park_pose('right'), 30) + target = np.array([pad[0], pad[1], BLOCK_Z]) + yield from self.align_for('left', target) + yield from self.run_place('left', target) + b1 = np.array([self.last_placed[0], self.last_placed[1], BLOCK_Z]) + yield from self.arm_to('left', self.park_pose('left'), 30) + # check block 1 against the pad with the free wrist camera (same image, bias cancels) + for attempt in range(PAD_CHECKS): + g = self.wrist_pad_offset('left', b1) + while True: + try: + yield next(g) + except StopIteration as e: + off = e.value + break + yield from self.arm_to('left', self.park_pose('left'), 30) + if off is None: + break + self.note('pad-check', np.round(off, 3)) + if np.hypot(*off) < PAD_TOL: + break + yield from self.grasp('left', b1) + if not self.held['left']: + yield from self.grip('left', 0.0, 10) + yield from self.arm_to('left', self.park_pose('left'), 30) + break + yield from self.arm_to('left', self.carry_pose('left'), 25) + new = b1 + [off[0], off[1], 0.0] + yield from self.align_for('left', new) + yield from self.run_place('left', new) + b1 = np.array([self.last_placed[0], self.last_placed[1], BLOCK_Z]) + yield from self.arm_to('left', self.park_pose('left'), 30) + yield from self.align_for('right', b1) + yield from self.run_place('right', b1 + [0, 0, BLOCK]) + top = self.last_placed + self.stack_top = np.array([top[0], top[1], BLOCK_Z + BLOCK]) + yield from self.arm_to('right', self.park_pose('right'), 30) + + def go_table2(self): + yield from self.walk_to(0.0, self.o[22], None, final=False, speed=0.25) # back off table 1 + for w in VIA: + yield from self.walk_to(w[0], w[1], None, final=False) + yield from self.walk_to(T2_STAND[0], T2_STAND[1], T2_STAND[2], tol=0.03, ytol=0.05, speed=0.2) + + def go_table1(self, x, y): + yield from self.walk_to(T2_STAND[0] + 0.15, self.o[22], None, final=False, speed=0.25) + for w in VIA[::-1]: + yield from self.walk_to(w[0], w[1], None, final=False) + yield from self.walk_to(x, y, 0.0, tol=0.02, ytol=0.04, speed=0.2) diff --git a/policies/wall_cupboard_close/astra-s1/episodes.csv b/policies/wall_cupboard_close/astra-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..607e5eab6955e7df1e33579f8adaa31b745f7b0e --- /dev/null +++ b/policies/wall_cupboard_close/astra-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,465,success,0 +620001,1,465,success,0 +620002,1,465,success,0 +620003,1,465,success,0 +620004,1,465,success,0 +620005,1,465,success,0 +620006,1,465,success,0 +620007,1,465,success,0 +620008,1,465,success,0 +620009,1,465,success,0 +620010,1,465,success,0 +620011,1,465,success,0 +620012,1,465,success,0 +620013,1,465,success,0 +620014,1,465,success,0 +620015,1,465,success,0 +620016,1,465,success,0 +620017,1,465,success,0 +620018,1,465,success,0 +620019,1,465,success,0 +620020,1,465,success,0 +620021,1,465,success,0 +620022,1,465,success,0 +620023,1,465,success,0 +620024,1,465,success,0 +620025,1,465,success,0 +620026,1,465,success,0 +620027,1,465,success,0 +620028,1,465,success,0 +620029,1,465,success,0 +620030,1,465,success,0 +620031,1,465,success,0 +620032,1,465,success,0 +620033,1,465,success,0 +620034,1,465,success,0 +620035,1,465,success,0 +620036,1,465,success,0 +620037,1,465,success,0 +620038,1,465,success,0 +620039,1,465,success,0 +620040,1,465,success,0 +620041,1,465,success,0 +620042,1,465,success,0 +620043,1,465,success,0 +620044,1,465,success,0 +620045,1,465,success,0 +620046,1,465,success,0 +620047,1,465,success,0 +620048,1,465,success,0 +620049,1,465,success,0 +620050,1,465,success,0 +620051,1,465,success,0 +620052,1,465,success,0 +620053,1,465,success,0 +620054,1,465,success,0 +620055,1,465,success,0 +620056,1,465,success,0 +620057,1,465,success,0 +620058,1,465,success,0 +620059,1,465,success,0 +620060,1,465,success,0 +620061,1,465,success,0 +620062,1,465,success,0 +620063,1,465,success,0 +620064,1,465,success,0 +620065,1,465,success,0 +620066,1,465,success,0 +620067,1,465,success,0 +620068,1,465,success,0 +620069,1,465,success,0 +620070,1,465,success,0 +620071,1,465,success,0 +620072,1,465,success,0 +620073,1,465,success,0 +620074,1,465,success,0 +620075,1,465,success,0 +620076,1,465,success,0 +620077,1,465,success,0 +620078,1,465,success,0 +620079,1,465,success,0 +620080,1,465,success,0 +620081,1,465,success,0 +620082,1,465,success,0 +620083,1,465,success,0 +620084,1,465,success,0 +620085,1,465,success,0 +620086,1,465,success,0 +620087,1,465,success,0 +620088,1,465,success,0 +620089,1,465,success,0 +620090,1,465,success,0 +620091,1,465,success,0 +620092,1,465,success,0 +620093,1,465,success,0 +620094,1,465,success,0 +620095,1,465,success,0 +620096,1,465,success,0 +620097,1,465,success,0 +620098,1,465,success,0 +620099,1,465,success,0 diff --git a/policies/wall_cupboard_close/astra-s1/policy.py b/policies/wall_cupboard_close/astra-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..d408742f75307cbd5665ca9131eecdb096b4cdbe --- /dev/null +++ b/policies/wall_cupboard_close/astra-s1/policy.py @@ -0,0 +1,37 @@ +"""Hand-written cabinet closing motion with closed-loop base positioning. + +The arms first clear the open leaves, then sweep inward together while +forward pressure seats the doors. All motion is indexed by simulation steps. +""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + + def act(self, obs, tools): + t = obs["t"] + action = self.hold.copy() + + # Raise the hands outside the doors, approach, and sweep inward. + roll = 0.9 if t < 280 else max(0.2, 0.9 - (t - 280) * 0.003) + action[5:12] = [-1.3, roll, 0, 0.8, 0, 0, 0] + action[12:19] = [-1.3, -roll, 0, 0.8, 0, 0, 0] + action[19:] = 0 + + # Pose feedback compensates for walking lag and contact-induced drift. + x, y, _, yaw = obs["low_dim_obs"][21:25] + target_x = -0.27 if t < 80 else 0.45 + error = target_x - x + action[0] = ( + 0 if abs(error) < 0.015 + else np.sign(error) * min(0.25, max(0.065, abs(error) * 1.5)) + ) + action[1] = ( + 0 if abs(y) < 0.015 + else -np.sign(y) * min(0.15, max(0.065, abs(y) * 1.5)) + ) + action[3] = np.clip(-yaw * 2, -0.2, 0.2) + return action diff --git a/policies/wall_cupboard_close/astra-s2/episodes.csv b/policies/wall_cupboard_close/astra-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..6b4fa0184bd0f94facee7d9958f6db7a5b212ca4 --- /dev/null +++ b/policies/wall_cupboard_close/astra-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1388,success,0 +620001,1,1388,success,0 +620002,1,1388,success,0 +620003,1,1388,success,0 +620004,1,1388,success,0 +620005,1,1388,success,0 +620006,1,1388,success,0 +620007,1,1388,success,0 +620008,1,1388,success,0 +620009,1,1388,success,0 +620010,1,1388,success,0 +620011,1,1388,success,0 +620012,1,1388,success,0 +620013,1,1388,success,0 +620014,1,1388,success,0 +620015,1,1388,success,0 +620016,1,1388,success,0 +620017,1,1388,success,0 +620018,1,1388,success,0 +620019,1,1388,success,0 +620020,1,1388,success,0 +620021,1,1388,success,0 +620022,1,1388,success,0 +620023,1,1388,success,0 +620024,1,1388,success,0 +620025,1,1388,success,0 +620026,1,1388,success,0 +620027,1,1388,success,0 +620028,1,1388,success,0 +620029,1,1388,success,0 +620030,1,1388,success,0 +620031,1,1388,success,0 +620032,1,1388,success,0 +620033,1,1388,success,0 +620034,1,1388,success,0 +620035,1,1388,success,0 +620036,1,1388,success,0 +620037,1,1388,success,0 +620038,1,1388,success,0 +620039,1,1388,success,0 +620040,1,1388,success,0 +620041,1,1388,success,0 +620042,1,1388,success,0 +620043,1,1388,success,0 +620044,1,1388,success,0 +620045,1,1388,success,0 +620046,1,1388,success,0 +620047,1,1388,success,0 +620048,1,1388,success,0 +620049,1,1388,success,0 +620050,1,1388,success,0 +620051,1,1388,success,0 +620052,1,1388,success,0 +620053,1,1388,success,0 +620054,1,1388,success,0 +620055,1,1388,success,0 +620056,1,1388,success,0 +620057,1,1388,success,0 +620058,1,1388,success,0 +620059,1,1388,success,0 +620060,1,1388,success,0 +620061,1,1388,success,0 +620062,1,1388,success,0 +620063,1,1388,success,0 +620064,1,1388,success,0 +620065,1,1388,success,0 +620066,1,1388,success,0 +620067,1,1388,success,0 +620068,1,1388,success,0 +620069,1,1388,success,0 +620070,1,1388,success,0 +620071,1,1388,success,0 +620072,1,1388,success,0 +620073,1,1388,success,0 +620074,1,1388,success,0 +620075,1,1388,success,0 +620076,1,1388,success,0 +620077,1,1388,success,0 +620078,1,1388,success,0 +620079,1,1388,success,0 +620080,1,1388,success,0 +620081,1,1388,success,0 +620082,1,1388,success,0 +620083,1,1388,success,0 +620084,1,1388,success,0 +620085,1,1388,success,0 +620086,1,1388,success,0 +620087,1,1388,success,0 +620088,1,1388,success,0 +620089,1,1388,success,0 +620090,1,1388,success,0 +620091,1,1388,success,0 +620092,1,1388,success,0 +620093,1,1388,success,0 +620094,1,1388,success,0 +620095,1,1388,success,0 +620096,1,1388,success,0 +620097,1,1388,success,0 +620098,1,1388,success,0 +620099,1,1388,success,0 diff --git a/policies/wall_cupboard_close/astra-s2/policy.py b/policies/wall_cupboard_close/astra-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..3f68c28c5dc8956cbb2d7fa550c58bf48ae36105 --- /dev/null +++ b/policies/wall_cupboard_close/astra-s2/policy.py @@ -0,0 +1,32 @@ +"""Deterministic sequential cabinet-door pushing controller.""" +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + + def act(self, obs, tools): + # Approach the outside of each door, sweep towards the middle, then + # follow through towards the wall. Keep the unused hand below the doors. + sequence = [ + (-.10, .50, 0), (.05, .50, 1), (.05, .15, 1), + (.25, .00, 1), (.25, .00, 0), (-.10, -.50, 0), + (.05, -.50, 2), (.05, -.15, 2), (.25, .00, 2), + (.25, .00, 0), + ] + stage = min(int(obs['t']) // 160, len(sequence)-1) + x, y, side = sequence[stage] + a = self.hold.copy() + a[5:19] = 0 + a[19:] = 0 + if side: + k = 5 if side == 1 else 12 + s = 1 if side == 1 else -1 + a[k:k+7] = [-2.2, s*.2, 0, .6, 0, .9, 0] + pos = obs['low_dim_obs'][21:25] + dx, dy = x-pos[0], y-pos[1] + a[0] = np.clip(dx*2, -.22, .22) if abs(dx) > .02 else 0 + a[1] = np.clip(dy*2, -.22, .22) if abs(dy) > .02 else 0 + a[3] = -pos[3]*2 + return a diff --git a/policies/wall_cupboard_close/astra-s3/episodes.csv b/policies/wall_cupboard_close/astra-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..2e148884a571c5a3f63c0cbc2d74fa70ef8823ef --- /dev/null +++ b/policies/wall_cupboard_close/astra-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1274,success,0 +620001,1,1274,success,0 +620002,1,1274,success,0 +620003,1,1274,success,0 +620004,1,1274,success,0 +620005,1,1274,success,0 +620006,1,1274,success,0 +620007,1,1274,success,0 +620008,1,1274,success,0 +620009,1,1274,success,0 +620010,1,1274,success,0 +620011,1,1274,success,0 +620012,1,1274,success,0 +620013,1,1274,success,0 +620014,1,1274,success,0 +620015,1,1274,success,0 +620016,1,1274,success,0 +620017,1,1274,success,0 +620018,1,1274,success,0 +620019,1,1274,success,0 +620020,1,1274,success,0 +620021,1,1274,success,0 +620022,1,1274,success,0 +620023,1,1274,success,0 +620024,1,1274,success,0 +620025,1,1274,success,0 +620026,1,1274,success,0 +620027,1,1274,success,0 +620028,1,1274,success,0 +620029,1,1274,success,0 +620030,1,1274,success,0 +620031,1,1274,success,0 +620032,1,1274,success,0 +620033,1,1274,success,0 +620034,1,1274,success,0 +620035,1,1274,success,0 +620036,1,1274,success,0 +620037,1,1274,success,0 +620038,1,1274,success,0 +620039,1,1274,success,0 +620040,1,1274,success,0 +620041,1,1274,success,0 +620042,1,1274,success,0 +620043,1,1274,success,0 +620044,1,1274,success,0 +620045,1,1274,success,0 +620046,1,1274,success,0 +620047,1,1274,success,0 +620048,1,1274,success,0 +620049,1,1274,success,0 +620050,1,1274,success,0 +620051,1,1274,success,0 +620052,1,1274,success,0 +620053,1,1274,success,0 +620054,1,1274,success,0 +620055,1,1274,success,0 +620056,1,1274,success,0 +620057,1,1274,success,0 +620058,1,1274,success,0 +620059,1,1274,success,0 +620060,1,1274,success,0 +620061,1,1274,success,0 +620062,1,1274,success,0 +620063,1,1274,success,0 +620064,1,1274,success,0 +620065,1,1274,success,0 +620066,1,1274,success,0 +620067,1,1274,success,0 +620068,1,1274,success,0 +620069,1,1274,success,0 +620070,1,1274,success,0 +620071,1,1274,success,0 +620072,1,1274,success,0 +620073,1,1274,success,0 +620074,1,1274,success,0 +620075,1,1274,success,0 +620076,1,1274,success,0 +620077,1,1274,success,0 +620078,1,1274,success,0 +620079,1,1274,success,0 +620080,1,1274,success,0 +620081,1,1274,success,0 +620082,1,1274,success,0 +620083,1,1274,success,0 +620084,1,1274,success,0 +620085,1,1274,success,0 +620086,1,1274,success,0 +620087,1,1274,success,0 +620088,1,1274,success,0 +620089,1,1274,success,0 +620090,1,1274,success,0 +620091,1,1274,success,0 +620092,1,1274,success,0 +620093,1,1274,success,0 +620094,1,1274,success,0 +620095,1,1274,success,0 +620096,1,1274,success,0 +620097,1,1274,success,0 +620098,1,1274,success,0 +620099,1,1274,success,0 diff --git a/policies/wall_cupboard_close/astra-s3/policy.py b/policies/wall_cupboard_close/astra-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..c64145151e718460dffbcf845108755d42b1f304 --- /dev/null +++ b/policies/wall_cupboard_close/astra-s3/policy.py @@ -0,0 +1,34 @@ +"""Deterministic cabinet closing with symmetric, gradual arm sweeps.""" +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.action = np.asarray(tools.hold_action(), dtype=np.float32) + self.action[19:] = 0 + self.stages = [(130,-.27,1.1),(180,.05,1.1),(180,.05,-.2), + (130,.05,1.1),(130,.22,1.1),(180,.22,-.2), + (130,.22,1.1),(130,.4,1.1),(180,.4,-.2)] + self.stage=0 + self.start=0 + self.initial=self.action.copy() + + def act(self, obs, tools): + t=obs['t'] + if self.stage=self.stages[self.stage][0]: + self.stage+=1 + self.start=t + self.initial=self.action.copy() + _,x,roll=self.stages[self.stage] + q=obs['low_dim_obs'] + a=self.action.copy() + dx=x-q[21]; dy=-q[22] + a[0]=np.clip(1.5*dx,-.18,.18) if abs(dx)>.015 else 0 + a[1]=np.clip(1.5*dy,-.12,.12) if abs(dy)>.015 else 0 + speed=np.linalg.norm(a[:2]) + if 0= t1: + return float(b) + f = (t - t0) / float(t1 - t0) + return float(a + (b - a) * f) + + def _arm_targets(self, t): + """Return (shoulder_pitch, roll, yaw, elbow) for the current step.""" + if t < 120: + sp = self._ramp(t, 0, 120, 0.0, -1.60) + sr = self._ramp(t, 0, 120, 0.0, 0.45) + el = self._ramp(t, 0, 120, 0.0, 0.70) + return sp, sr, 0.0, el + if t < 210: + sp = self._ramp(t, 120, 210, -1.60, -2.60) + el = self._ramp(t, 120, 210, 0.70, 0.40) + return sp, 0.45, 0.0, el + if t < 300: + return -2.00, 0.25, 0.0, 1.00 + if t < 390: + return -2.00, self._ramp(t, 300, 390, 0.25, 1.55), 0.0, 1.00 + if t < 480: + return -2.00, self._ramp(t, 390, 480, 1.55, -0.20), 0.0, 1.00 + if t < 570: + sp = self._ramp(t, 480, 570, -2.00, -0.80) + el = self._ramp(t, 480, 570, 1.00, 0.30) + return sp, 0.30, 0.0, el + if t < 660: + sp = self._ramp(t, 570, 660, -1.70, -2.75) + el = self._ramp(t, 570, 660, 0.60, 0.10) + return sp, 0.20, 0.0, el + if t < 780: + return -1.90, 0.20, 0.0, 0.15 + if t < 900: + sp = self._ramp(t, 780, 900, -0.60, -2.60) + el = self._ramp(t, 780, 900, 1.80, 0.20) + sr = self._ramp(t, 780, 900, 0.00, 0.30) + return sp, sr, 0.0, el + if t < 1000: + el = self._ramp(t, 900, 1000, 0.20, 0.90) + sr = self._ramp(t, 900, 1000, 0.30, 1.40) + return -2.40, sr, 0.0, el + if t < 1120: + sp = self._ramp(t, 1000, 1120, -2.40, 0.0) + el = self._ramp(t, 1000, 1120, 0.90, 0.0) + sr = self._ramp(t, 1000, 1120, 1.40, 0.0) + return sp, sr, 0.0, el + if t < 1300: + # second attempt: walk in again with the hands in front + sp = self._ramp(t, 1200, 1300, 0.0, -1.70) + sr = self._ramp(t, 1200, 1300, 0.0, 0.35) + el = self._ramp(t, 1200, 1300, 0.0, 0.90) + return sp, sr, 0.0, el + if t < 1420: + sp = self._ramp(t, 1300, 1420, -1.70, -2.70) + el = self._ramp(t, 1300, 1420, 0.90, 0.20) + return sp, 0.30, 0.0, el + if t < 1520: + return -1.90, self._ramp(t, 1420, 1520, 0.30, 1.40), 0.0, 0.80 + if t < 1600: + return -1.90, self._ramp(t, 1520, 1600, 1.40, -0.10), 0.0, 0.80 + if t < 1700: + sp = self._ramp(t, 1600, 1700, -1.90, -2.70) + el = self._ramp(t, 1600, 1700, 0.80, 0.10) + return sp, 0.30, 0.0, el + return 0.0, 0.0, 0.0, 0.0 + + def act(self, obs, tools): + """Return the 21-float physical action for this control step.""" + t = int(obs.get("t", self.t)) + self.t = t + a = self.hold.copy() + + # ---- base ------------------------------------------------------ + if t < 150: + vx = 0.30 + elif t < 240: + vx = 0.15 + elif t < 340: + vx = 0.35 + elif t < 520: + vx = 0.12 + elif t < 620: + vx = 0.30 + elif t < 700: + vx = 0.15 + elif t < 760: + vx = -0.25 + elif t < 900: + vx = 0.30 + elif t < 1000: + vx = 0.10 + elif t < 1120: + vx = -0.30 + elif t < 1300: + vx = 0.28 + elif t < 1420: + vx = 0.15 + elif t < 1520: + vx = 0.25 + elif t < 1600: + vx = 0.10 + elif t < 1680: + vx = 0.25 + else: + vx = -0.25 + a[0] = vx + a[1] = 0.0 + a[2] = 0.74 + a[3] = 0.0 + a[4] = 0.0 + + # ---- arms ------------------------------------------------------ + sp, sr, sy, el = self._arm_targets(t) + a[5:12] = np.array([sp, sr, sy, el, 0.0, 0.0, 0.0], np.float32) + a[12:19] = np.array([sp, -sr, -sy, el, 0.0, 0.0, 0.0], np.float32) + a[19] = 0.85 + a[20] = 0.85 + return a diff --git a/policies/wall_cupboard_close/deepseek1017-s2/episodes.csv b/policies/wall_cupboard_close/deepseek1017-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..2a2668a20c78fc62600c80f353df2598ec3e4333 --- /dev/null +++ b/policies/wall_cupboard_close/deepseek1017-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1170,success,0 +620001,1,1170,success,0 +620002,1,1170,success,0 +620003,1,1170,success,0 +620004,1,1170,success,0 +620005,1,1170,success,0 +620006,1,1170,success,0 +620007,1,1170,success,0 +620008,1,1170,success,0 +620009,1,1170,success,0 +620010,1,1170,success,0 +620011,1,1170,success,0 +620012,1,1170,success,0 +620013,1,1170,success,0 +620014,1,1170,success,0 +620015,1,1170,success,0 +620016,1,1170,success,0 +620017,1,1170,success,0 +620018,1,1170,success,0 +620019,1,1170,success,0 +620020,1,1170,success,0 +620021,1,1170,success,0 +620022,1,1170,success,0 +620023,1,1170,success,0 +620024,1,1170,success,0 +620025,1,1170,success,0 +620026,1,1170,success,0 +620027,1,1170,success,0 +620028,1,1170,success,0 +620029,1,1170,success,0 +620030,1,1170,success,0 +620031,1,1170,success,0 +620032,1,1170,success,0 +620033,1,1170,success,0 +620034,1,1170,success,0 +620035,1,1170,success,0 +620036,1,1170,success,0 +620037,1,1170,success,0 +620038,1,1170,success,0 +620039,1,1170,success,0 +620040,1,1170,success,0 +620041,1,1170,success,0 +620042,1,1170,success,0 +620043,1,1170,success,0 +620044,1,1170,success,0 +620045,1,1170,success,0 +620046,1,1170,success,0 +620047,1,1170,success,0 +620048,1,1170,success,0 +620049,1,1170,success,0 +620050,1,1170,success,0 +620051,1,1170,success,0 +620052,1,1170,success,0 +620053,1,1170,success,0 +620054,1,1170,success,0 +620055,1,1170,success,0 +620056,1,1170,success,0 +620057,1,1170,success,0 +620058,1,1170,success,0 +620059,1,1170,success,0 +620060,1,1170,success,0 +620061,1,1170,success,0 +620062,1,1170,success,0 +620063,1,1170,success,0 +620064,1,1170,success,0 +620065,1,1170,success,0 +620066,1,1170,success,0 +620067,1,1170,success,0 +620068,1,1170,success,0 +620069,1,1170,success,0 +620070,1,1170,success,0 +620071,1,1170,success,0 +620072,1,1170,success,0 +620073,1,1170,success,0 +620074,1,1170,success,0 +620075,1,1170,success,0 +620076,1,1170,success,0 +620077,1,1170,success,0 +620078,1,1170,success,0 +620079,1,1170,success,0 +620080,1,1170,success,0 +620081,1,1170,success,0 +620082,1,1170,success,0 +620083,1,1170,success,0 +620084,1,1170,success,0 +620085,1,1170,success,0 +620086,1,1170,success,0 +620087,1,1170,success,0 +620088,1,1170,success,0 +620089,1,1170,success,0 +620090,1,1170,success,0 +620091,1,1170,success,0 +620092,1,1170,success,0 +620093,1,1170,success,0 +620094,1,1170,success,0 +620095,1,1170,success,0 +620096,1,1170,success,0 +620097,1,1170,success,0 +620098,1,1170,success,0 +620099,1,1170,success,0 diff --git a/policies/wall_cupboard_close/deepseek1017-s2/policy.py b/policies/wall_cupboard_close/deepseek1017-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..1d4d81a989f6d8d6e88e814e2feaec50e2737041 --- /dev/null +++ b/policies/wall_cupboard_close/deepseek1017-s2/policy.py @@ -0,0 +1,122 @@ +"""Close both open doors of the wall cabinet. + +The policy is a hand-written, open-loop upper-body trajectory with a small +base-position feedback term. It was tuned by running episodes on the +development seeds; there is no learned component and no data lookup table. + +Behaviour + 1. Step 0-249: bring both hands up in front of the wall cupboard and creep + towards the counter while keeping the pelvis near x = 0.10 m. + 2. Step 250 onwards: apply a slow multi-frequency sweep of the shoulder + pitch / yaw and elbow, plus small wrist-roll and gripper oscillations, + while nudging the base into the doors. The different periods make the + two hands sweep the door faces in a quasi-periodic pattern, which pushes + both doors shut. Occasional firmer shoves (t % 400 < 30) help seat the + doors in their latches. + +The motion only uses proprioception (pelvis x from low_dim_obs) for feedback, +so it is deterministic and needs no image processing at run time. +""" + +import numpy as np + + +class Policy: + """Deterministic scripted controller for the wall-cabinet task.""" + + def reset(self, obs, tools): + """Capture the initial hold action and reset the step counter. + + Args: + obs: The first observation. + tools: The tools described in docs/api.md. + """ + # Keep the reset-pose targets (arms down, height/pitch/velocity zero, + # half-closed grippers) as the base of every command. + self.hold = np.asarray(tools.hold_action(), dtype=np.float32).copy() + self.step = 0 + self.two_pi = 2.0 * np.pi + + def act(self, obs, tools): + """Return the physical action for this control step. + + Args: + obs: The current observation. + tools: The tools described in docs/api.md. + + Returns: + The 21-float physical action. + """ + i = self.step + self.step += 1 + x = float(obs["low_dim_obs"][21]) + a = self.hold.copy() + + if i < 250: + # Reach: hands up at the cupboard height, walking slowly in. + self._arm(a, pitch=-1.2, roll=0.2, elbow=0.4, yaw=0.0, + wrist_roll=0.0, wrist_pitch=0.0, grip=0.5) + err = 0.10 - x + a[0] = float(np.clip(1.5 * err, -0.15, 0.15)) if abs(err) > 0.02 else 0.0 + return a + + t = i - 250 + w = self.two_pi + # Quasi-periodic sweep of the arms over the door faces. + pitch = -1.3 + 0.45 * np.sin(w * t / 150.0) + 0.1 * np.sin(w * t / 53.0) + yaw = 0.55 * np.sin(w * t / 230.0) + roll = 0.2 + elbow = 0.45 + 0.25 * np.sin(w * t / 110.0) + wrist_roll = 0.7 * np.sin(w * t / 190.0) + grip = 0.5 + 0.5 * np.sin(w * t / 300.0) + + self._arm(a, pitch=pitch, roll=roll, elbow=elbow, yaw=yaw, + wrist_roll=wrist_roll, wrist_pitch=0.0, grip=grip) + + # Lean into the cupboard and keep the pelvis at the counter. + err = 0.10 - x + a[0] = float(np.clip(1.2 * err, -0.08, 0.08)) if abs(err) > 0.02 else 0.05 + a[4] = 0.15 * np.sin(w * t / 170.0) + + # Periodic firmer shove: drive the torso forward and step in. + if t % 400 < 30: + a[0] = 0.25 + a[4] = 0.6 + + return a + + @staticmethod + def _arm(a, pitch, roll, elbow, yaw, wrist_roll, wrist_pitch, grip): + """Write symmetric arm and gripper targets into ``a`` in place. + + Args: + a: 21-float action buffer. + pitch: Shoulder pitch for both arms, rad. + roll: Left shoulder roll, rad (right arm mirrors it). + elbow: Elbow flexion for both arms, rad. + yaw: Left shoulder yaw, rad (right arm mirrors it). + wrist_roll: Left wrist roll, rad (right arm mirrors it). + wrist_pitch: Wrist pitch for both arms, rad. + grip: Gripper command for both hands, 0 open .. 1 closed. + + Returns: + The same action buffer ``a``. + """ + a[5] = pitch + a[6] = roll + a[7] = yaw + a[8] = elbow + a[9] = wrist_roll + a[10] = wrist_pitch + a[11] = 0.0 + a[19] = grip + + a[12] = pitch + a[13] = -roll + a[14] = -yaw + a[15] = elbow + a[16] = -wrist_roll + a[17] = wrist_pitch + a[18] = 0.0 + a[20] = grip + return a diff --git a/policies/wall_cupboard_close/deepseek1017-s3/episodes.csv b/policies/wall_cupboard_close/deepseek1017-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..04b2b4953b3e4f0822f177c9ca1e963a8abffd41 --- /dev/null +++ b/policies/wall_cupboard_close/deepseek1017-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1700,timeout,0 +620001,0,1700,timeout,0 +620002,0,1700,timeout,0 +620003,0,1700,timeout,0 +620004,0,1700,timeout,0 +620005,0,1700,timeout,0 +620006,0,1700,timeout,0 +620007,0,1700,timeout,0 +620008,0,1700,timeout,0 +620009,0,1700,timeout,0 +620010,0,1700,timeout,0 +620011,0,1700,timeout,0 +620012,0,1700,timeout,0 +620013,0,1700,timeout,0 +620014,0,1700,timeout,0 +620015,0,1700,timeout,0 +620016,0,1700,timeout,0 +620017,0,1700,timeout,0 +620018,0,1700,timeout,0 +620019,0,1700,timeout,0 +620020,0,1700,timeout,0 +620021,0,1700,timeout,0 +620022,0,1700,timeout,0 +620023,0,1700,timeout,0 +620024,0,1700,timeout,0 +620025,0,1700,timeout,0 +620026,0,1700,timeout,0 +620027,0,1700,timeout,0 +620028,0,1700,timeout,0 +620029,0,1700,timeout,0 +620030,0,1700,timeout,0 +620031,0,1700,timeout,0 +620032,0,1700,timeout,0 +620033,0,1700,timeout,0 +620034,0,1700,timeout,0 +620035,0,1700,timeout,0 +620036,0,1700,timeout,0 +620037,0,1700,timeout,0 +620038,0,1700,timeout,0 +620039,0,1700,timeout,0 +620040,0,1700,timeout,0 +620041,0,1700,timeout,0 +620042,0,1700,timeout,0 +620043,0,1700,timeout,0 +620044,0,1700,timeout,0 +620045,0,1700,timeout,0 +620046,0,1700,timeout,0 +620047,0,1700,timeout,0 +620048,0,1700,timeout,0 +620049,0,1700,timeout,0 +620050,0,1700,timeout,0 +620051,0,1700,timeout,0 +620052,0,1700,timeout,0 +620053,0,1700,timeout,0 +620054,0,1700,timeout,0 +620055,0,1700,timeout,0 +620056,0,1700,timeout,0 +620057,0,1700,timeout,0 +620058,0,1700,timeout,0 +620059,0,1700,timeout,0 +620060,0,1700,timeout,0 +620061,0,1700,timeout,0 +620062,0,1700,timeout,0 +620063,0,1700,timeout,0 +620064,0,1700,timeout,0 +620065,0,1700,timeout,0 +620066,0,1700,timeout,0 +620067,0,1700,timeout,0 +620068,0,1700,timeout,0 +620069,0,1700,timeout,0 +620070,0,1700,timeout,0 +620071,0,1700,timeout,0 +620072,0,1700,timeout,0 +620073,0,1700,timeout,0 +620074,0,1700,timeout,0 +620075,0,1700,timeout,0 +620076,0,1700,timeout,0 +620077,0,1700,timeout,0 +620078,0,1700,timeout,0 +620079,0,1700,timeout,0 +620080,0,1700,timeout,0 +620081,0,1700,timeout,0 +620082,0,1700,timeout,0 +620083,0,1700,timeout,0 +620084,0,1700,timeout,0 +620085,0,1700,timeout,0 +620086,0,1700,timeout,0 +620087,0,1700,timeout,0 +620088,0,1700,timeout,0 +620089,0,1700,timeout,0 +620090,0,1700,timeout,0 +620091,0,1700,timeout,0 +620092,0,1700,timeout,0 +620093,0,1700,timeout,0 +620094,0,1700,timeout,0 +620095,0,1700,timeout,0 +620096,0,1700,timeout,0 +620097,0,1700,timeout,0 +620098,0,1700,timeout,0 +620099,0,1700,timeout,0 diff --git a/policies/wall_cupboard_close/deepseek1017-s3/policy.py b/policies/wall_cupboard_close/deepseek1017-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..23a0d2a9b91701247dfd25364e0d0e4dd4dd11d9 --- /dev/null +++ b/policies/wall_cupboard_close/deepseek1017-s3/policy.py @@ -0,0 +1,182 @@ +"""Hand-written control policy: close both open doors of the wall cabinet. + +The robot is a Unitree G1 whose walking / balance is handled by a frozen +whole-body controller; we only command the base and both arms at 50 Hz. + +The robot's cameras all look forward and slightly down, so the open doors of +the wall cupboard are only partly visible. From the cameras the cabinet +shows a white face with horizontal handle bars, a light band above it and the +checkered floor below; the robot's hands (hanging at hip height) are stopped +by the cupboard at roughly the same height as the lowest visible panel, and +the base can step noticeably closer when the arms are held forward. Since +the hinge geometry cannot be observed reliably, the policy approaches the +cupboard and then runs a family of closing gestures that covers the plausible +cases: + + * high inward sweeps - side-hinged doors that open towards the robot, + * forward presses - doors that are only ajar, + * low lateral slides - sliding doors / drawers, + * rising sweeps - lift-up (flap) doors, + * overhead reaches - high doors, push their lower edge, + * low squat presses - low doors behind the counter edge, + +interleaved with short retreats so a door that has been pushed shut is +released and the success condition can latch. The working distance is +alternated between cycles so the hands sweep different depth slices. + +The pelvis pose in ``low_dim_obs`` is used to hold the working distance with +a P controller (the base controller has lag and wobble, so open-loop +odometry is not used). Everything is deterministic: the gesture program is +driven only by the step counter and the observed body state. +""" + +from __future__ import annotations + +import numpy as np + +# --------------------------------------------------------------------------- +# Gesture program: (duration, tx, sp, roll, yaw, elbow, wrist_pitch, grip, +# torso_pitch, height) +# --------------------------------------------------------------------------- +KEYFRAMES = [ + # approach with the arms held forward (lets the base step close) + dict(dur=28, tx=0.42, sp=1.55, roll=0.00, yaw=0.00, el=0.05, wp=0.00, + grip=0.0, pitch=0.10, height=0.74), + # high inward sweep (side-hinged doors opening towards the robot) + dict(dur=16, tx=0.24, sp=2.20, roll=0.95, yaw=0.05, el=0.00, wp=-0.20, + grip=0.0, pitch=0.00, height=0.74), + dict(dur=24, tx=0.24, sp=2.20, roll=-0.20, yaw=-0.05, el=0.00, wp=-0.50, + grip=1.0, pitch=0.15, height=0.74), + # forward press at chest height + dict(dur=14, tx=0.40, sp=1.15, roll=0.55, yaw=0.00, el=0.55, wp=0.00, + grip=0.0, pitch=0.20, height=0.74), + dict(dur=22, tx=0.45, sp=1.10, roll=0.10, yaw=0.00, el=0.60, wp=0.00, + grip=1.0, pitch=0.55, height=0.74), + # low lateral slide across the front + dict(dur=14, tx=0.26, sp=0.30, roll=1.10, yaw=0.00, el=0.30, wp=0.00, + grip=0.0, pitch=0.10, height=0.70), + dict(dur=22, tx=0.28, sp=0.30, roll=-0.15, yaw=0.00, el=0.30, wp=-0.30, + grip=1.0, pitch=0.30, height=0.70), + # rising sweep (flap doors) + dict(dur=14, tx=0.24, sp=0.45, roll=0.45, yaw=0.00, el=0.85, wp=0.00, + grip=0.0, pitch=0.10, height=0.74), + dict(dur=18, tx=0.24, sp=1.90, roll=0.20, yaw=0.00, el=0.10, wp=0.35, + grip=1.0, pitch=0.40, height=0.74), + # very wide + high inward sweep (doors opening out to the sides) + dict(dur=16, tx=0.22, sp=2.55, roll=1.45, yaw=0.00, el=0.00, wp=-0.30, + grip=0.0, pitch=-0.15, height=0.82), + dict(dur=20, tx=0.22, sp=2.55, roll=-0.05, yaw=0.00, el=0.00, wp=-0.50, + grip=1.0, pitch=0.10, height=0.82), + # bent-elbow press close to the body + dict(dur=16, tx=0.30, sp=1.40, roll=0.90, yaw=0.00, el=1.80, wp=-0.20, + grip=0.0, pitch=0.10, height=0.74), + dict(dur=18, tx=0.34, sp=1.40, roll=-0.15, yaw=0.00, el=1.80, wp=-0.30, + grip=1.0, pitch=0.35, height=0.74), + # low squat press (low doors just above the counter edge) + dict(dur=18, tx=0.30, sp=0.35, roll=0.30, yaw=0.00, el=0.80, wp=0.00, + grip=0.0, pitch=0.20, height=0.48), + dict(dur=20, tx=0.32, sp=0.35, roll=0.10, yaw=0.00, el=0.80, wp=0.00, + grip=1.0, pitch=0.55, height=0.48), + dict(dur=12, tx=0.40, sp=0.60, roll=0.10, yaw=0.00, el=0.60, wp=0.30, + grip=1.0, pitch=0.60, height=0.74), + # release, step back, let the doors settle + dict(dur=18, tx=0.08, sp=0.30, roll=0.00, yaw=0.00, el=0.30, wp=0.00, + grip=0.0, pitch=0.00, height=0.74), + dict(dur=24, tx=0.05, sp=0.10, roll=0.00, yaw=0.00, el=0.10, wp=0.00, + grip=0.0, pitch=0.00, height=0.74), +] + +_TOTAL = sum(k["dur"] for k in KEYFRAMES) +# Depth slices tried on successive cycles (added to the keyframe x targets). +_TX_OFFSETS = (-0.06, 0.04, -0.02, 0.08, 0.00, -0.08) + + +def _smooth(f: float) -> float: + f = 0.0 if f < 0.0 else (1.0 if f > 1.0 else f) + return f * f * (3.0 - 2.0 * f) + + +class Policy: + """Deterministic scripted policy for the wall-cupboard closing task.""" + + def reset(self, obs, tools): + self.start_t = int(obs["t"]) + + def _key(self, t: int): + t = t % _TOTAL + for i, k in enumerate(KEYFRAMES): + if t < k["dur"]: + return i, t / max(1, k["dur"] - 1) + t -= k["dur"] + return len(KEYFRAMES) - 1, 1.0 + + def act(self, obs, tools): + raw = np.asarray(tools.hold_action(), dtype=np.float32) + if bool(obs.get("fell", False)): + # The episode is already lost; freeze so nothing worse happens. + return raw + + lo = np.asarray(obs["low_dim_obs"], dtype=np.float32) + x, y, yaw = float(lo[21]), float(lo[22]), float(lo[24]) + t = int(obs["t"]) - self.start_t + + i, f = self._key(t) + a = KEYFRAMES[i] + b = KEYFRAMES[(i + 1) % len(KEYFRAMES)] + s = _smooth(f) + + def v(name): + return a[name] + (b[name] - a[name]) * s + + cycle = t // _TOTAL + tx = v("tx") + _TX_OFFSETS[cycle % len(_TX_OFFSETS)] + + # ---- base position control -------------------------------------- + vx = 2.5 * (tx - x) + if abs(vx) < 0.07: + vx = 0.0 + if a["pitch"] > 0.35 and vx >= 0.0: + vx = max(vx, 0.20) # keep pressing while leaning in + vx = float(np.clip(vx, -0.45, 0.85)) + + vy = -1.4 * y + if abs(vy) < 0.07: + vy = 0.0 + vy = float(np.clip(vy, -0.30, 0.30)) + + wz = -1.0 * yaw + if abs(wz) < 0.07: + wz = 0.0 + wz = float(np.clip(wz, -0.30, 0.30)) + + raw[0] = vx + raw[1] = vy + raw[2] = float(np.clip(v("height"), 0.40, 1.00)) + raw[3] = wz + raw[4] = float(np.clip(v("pitch"), -0.20, 0.80)) + + # ---- arms ------------------------------------------------------- + sp = float(np.clip(v("sp"), -3.0, 2.60)) + roll = float(np.clip(v("roll"), -1.40, 2.10)) + yawn = float(np.clip(v("yaw"), -1.20, 1.20)) + el = float(np.clip(v("el"), -1.00, 2.00)) + wp = float(np.clip(v("wp"), -0.50, 0.55)) + grip = float(np.clip(v("grip"), 0.0, 1.0)) + + raw[5] = sp + raw[6] = roll + raw[7] = yawn + raw[8] = el + raw[9] = 0.0 + raw[10] = wp + raw[11] = 0.0 + raw[12] = sp + raw[13] = -roll + raw[14] = -yawn + raw[15] = el + raw[16] = 0.0 + raw[17] = wp + raw[18] = 0.0 + raw[19] = grip + raw[20] = grip + return raw diff --git a/policies/wall_cupboard_close/gpt61sol-s1/episodes.csv b/policies/wall_cupboard_close/gpt61sol-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..ab0f6bfd05f5869012b16ecbae10333d40fbf32c --- /dev/null +++ b/policies/wall_cupboard_close/gpt61sol-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,450,success,0 +620001,1,450,success,0 +620002,1,450,success,0 +620003,1,450,success,0 +620004,1,450,success,0 +620005,1,450,success,0 +620006,1,450,success,0 +620007,1,450,success,0 +620008,1,450,success,0 +620009,1,450,success,0 +620010,1,450,success,0 +620011,1,450,success,0 +620012,1,450,success,0 +620013,1,450,success,0 +620014,1,450,success,0 +620015,1,450,success,0 +620016,1,450,success,0 +620017,1,450,success,0 +620018,1,450,success,0 +620019,1,450,success,0 +620020,1,450,success,0 +620021,1,450,success,0 +620022,1,450,success,0 +620023,1,450,success,0 +620024,1,450,success,0 +620025,1,450,success,0 +620026,1,450,success,0 +620027,1,450,success,0 +620028,1,450,success,0 +620029,1,450,success,0 +620030,1,450,success,0 +620031,1,450,success,0 +620032,1,450,success,0 +620033,1,450,success,0 +620034,1,450,success,0 +620035,1,450,success,0 +620036,1,450,success,0 +620037,1,450,success,0 +620038,1,450,success,0 +620039,1,450,success,0 +620040,1,450,success,0 +620041,1,450,success,0 +620042,1,450,success,0 +620043,1,450,success,0 +620044,1,450,success,0 +620045,1,450,success,0 +620046,1,450,success,0 +620047,1,450,success,0 +620048,1,450,success,0 +620049,1,450,success,0 +620050,1,450,success,0 +620051,1,450,success,0 +620052,1,450,success,0 +620053,1,450,success,0 +620054,1,450,success,0 +620055,1,450,success,0 +620056,1,450,success,0 +620057,1,450,success,0 +620058,1,450,success,0 +620059,1,450,success,0 +620060,1,450,success,0 +620061,1,450,success,0 +620062,1,450,success,0 +620063,1,450,success,0 +620064,1,450,success,0 +620065,1,450,success,0 +620066,1,450,success,0 +620067,1,450,success,0 +620068,1,450,success,0 +620069,1,450,success,0 +620070,1,450,success,0 +620071,1,450,success,0 +620072,1,450,success,0 +620073,1,450,success,0 +620074,1,450,success,0 +620075,1,450,success,0 +620076,1,450,success,0 +620077,1,450,success,0 +620078,1,450,success,0 +620079,1,450,success,0 +620080,1,450,success,0 +620081,1,450,success,0 +620082,1,450,success,0 +620083,1,450,success,0 +620084,1,450,success,0 +620085,1,450,success,0 +620086,1,450,success,0 +620087,1,450,success,0 +620088,1,450,success,0 +620089,1,450,success,0 +620090,1,450,success,0 +620091,1,450,success,0 +620092,1,450,success,0 +620093,1,450,success,0 +620094,1,450,success,0 +620095,1,450,success,0 +620096,1,450,success,0 +620097,1,450,success,0 +620098,1,450,success,0 +620099,1,450,success,0 diff --git a/policies/wall_cupboard_close/gpt61sol-s1/policy.py b/policies/wall_cupboard_close/gpt61sol-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..b3798fb607933301587d5c530e822cc0722e3d6f --- /dev/null +++ b/policies/wall_cupboard_close/gpt61sol-s1/policy.py @@ -0,0 +1,34 @@ +"""Deterministic cabinet closing controller.""" +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + + def act(self, obs, tools): + a = self.hold.copy() + t = obs['t'] + # Reach around the open leaves, then sweep both hands inward. + if t < 100: + x, roll = -.1, .8 + elif t < 250: + x, roll = .25, .8 + elif t < 350: + x, roll = .25, .5 + elif t < 450: + x, roll = .25, .2 + elif t < 550: + x, roll = .35, 0. + else: + x, roll = .4, 0. + a[4] = .5 + a[5:12] = [-2.3, roll, 0, .2, 0, 1.4, 0] + a[12:19] = [-2.3, -roll, 0, .2, 0, 1.4, 0] + a[19:] = 0 + # Correct walking drift using measured pelvis position and heading. + q = obs['low_dim_obs'] + err = x-q[21] + a[0] = np.clip(2*err, -.15, .15) if abs(err)>.015 else 0 + a[1] = np.clip(-2*q[22], -.12, .12) if abs(q[22])>.015 else 0 + a[3] = np.clip(-2*q[24], -.2, .2) + return a diff --git a/policies/wall_cupboard_close/gpt61sol-s2/episodes.csv b/policies/wall_cupboard_close/gpt61sol-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..11abec76b6b39e2e577393e3fccfe16d4897ea72 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61sol-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,765,success,0 +620001,1,765,success,0 +620002,1,765,success,0 +620003,1,765,success,0 +620004,1,765,success,0 +620005,1,765,success,0 +620006,1,765,success,0 +620007,1,765,success,0 +620008,1,765,success,0 +620009,1,765,success,0 +620010,1,765,success,0 +620011,1,765,success,0 +620012,1,765,success,0 +620013,1,765,success,0 +620014,1,765,success,0 +620015,1,765,success,0 +620016,1,765,success,0 +620017,1,765,success,0 +620018,1,765,success,0 +620019,1,765,success,0 +620020,1,765,success,0 +620021,1,765,success,0 +620022,1,765,success,0 +620023,1,765,success,0 +620024,1,765,success,0 +620025,1,765,success,0 +620026,1,765,success,0 +620027,1,765,success,0 +620028,1,765,success,0 +620029,1,765,success,0 +620030,1,765,success,0 +620031,1,765,success,0 +620032,1,765,success,0 +620033,1,765,success,0 +620034,1,765,success,0 +620035,1,765,success,0 +620036,1,765,success,0 +620037,1,765,success,0 +620038,1,765,success,0 +620039,1,765,success,0 +620040,1,765,success,0 +620041,1,765,success,0 +620042,1,765,success,0 +620043,1,765,success,0 +620044,1,765,success,0 +620045,1,765,success,0 +620046,1,765,success,0 +620047,1,765,success,0 +620048,1,765,success,0 +620049,1,765,success,0 +620050,1,765,success,0 +620051,1,765,success,0 +620052,1,765,success,0 +620053,1,765,success,0 +620054,1,765,success,0 +620055,1,765,success,0 +620056,1,765,success,0 +620057,1,765,success,0 +620058,1,765,success,0 +620059,1,765,success,0 +620060,1,765,success,0 +620061,1,765,success,0 +620062,1,765,success,0 +620063,1,765,success,0 +620064,1,765,success,0 +620065,1,765,success,0 +620066,1,765,success,0 +620067,1,765,success,0 +620068,1,765,success,0 +620069,1,765,success,0 +620070,1,765,success,0 +620071,1,765,success,0 +620072,1,765,success,0 +620073,1,765,success,0 +620074,1,765,success,0 +620075,1,765,success,0 +620076,1,765,success,0 +620077,1,765,success,0 +620078,1,765,success,0 +620079,1,765,success,0 +620080,1,765,success,0 +620081,1,765,success,0 +620082,1,765,success,0 +620083,1,765,success,0 +620084,1,765,success,0 +620085,1,765,success,0 +620086,1,765,success,0 +620087,1,765,success,0 +620088,1,765,success,0 +620089,1,765,success,0 +620090,1,765,success,0 +620091,1,765,success,0 +620092,1,765,success,0 +620093,1,765,success,0 +620094,1,765,success,0 +620095,1,765,success,0 +620096,1,765,success,0 +620097,1,765,success,0 +620098,1,765,success,0 +620099,1,765,success,0 diff --git a/policies/wall_cupboard_close/gpt61sol-s2/policy.py b/policies/wall_cupboard_close/gpt61sol-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..240f30669437835ec82f52ded9a327c4e4d6bfc2 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61sol-s2/policy.py @@ -0,0 +1,36 @@ +"""Deterministic two-handed cabinet closing controller.""" +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.y = float(obs['low_dim_obs'][22]) + self.yaw = float(obs['low_dim_obs'][24]) + + def act(self, obs, tools): + a = self.hold.copy() + t = obs['t'] + if t < 180: + sr = 1.3 + target_x = .28 + elif t < 680: + sr = 1.3 - (t - 180) / 500. + target_x = .28 + else: + sr = max(.2, .3 - (t - 680) / 500.) + target_x = .39 + a[5:12] = [-2.3, sr, 0., 0., 0., 1.3, 0.] + a[12:19] = [-2.3, -sr, 0., 0., 0., 1.3, 0.] + a[19:21] = 0. + p = obs['low_dim_obs'] + dx = target_x - float(p[21]) + dy = self.y - float(p[22]) + yaw = float(p[24]) + vx = np.clip(1.5 * dx, -.18, .18) if abs(dx) > .025 else 0. + vy = np.clip(1.5 * dy, -.10, .10) if abs(dy) > .035 else 0. + if vx and abs(vx) < .06: vx = np.sign(vx) * .06 + if vy and abs(vy) < .06: vy = np.sign(vy) * .06 + a[0] = np.cos(yaw)*vx + np.sin(yaw)*vy + a[1] = -np.sin(yaw)*vx + np.cos(yaw)*vy + a[3] = np.clip(2. * (self.yaw - yaw), -.25, .25) + return a diff --git a/policies/wall_cupboard_close/gpt61sol-s3/episodes.csv b/policies/wall_cupboard_close/gpt61sol-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..7ed6c627337edc538f28e548731520f571eea6a4 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61sol-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,811,success,0 +620001,1,811,success,0 +620002,1,811,success,0 +620003,1,811,success,0 +620004,1,811,success,0 +620005,1,811,success,0 +620006,1,811,success,0 +620007,1,811,success,0 +620008,1,811,success,0 +620009,1,811,success,0 +620010,1,811,success,0 +620011,1,811,success,0 +620012,1,811,success,0 +620013,1,811,success,0 +620014,1,811,success,0 +620015,1,811,success,0 +620016,1,811,success,0 +620017,1,811,success,0 +620018,1,811,success,0 +620019,1,811,success,0 +620020,1,811,success,0 +620021,1,811,success,0 +620022,1,811,success,0 +620023,1,811,success,0 +620024,1,811,success,0 +620025,1,811,success,0 +620026,1,811,success,0 +620027,1,811,success,0 +620028,1,811,success,0 +620029,1,811,success,0 +620030,1,811,success,0 +620031,1,811,success,0 +620032,1,811,success,0 +620033,1,811,success,0 +620034,1,811,success,0 +620035,1,811,success,0 +620036,1,811,success,0 +620037,1,811,success,0 +620038,1,811,success,0 +620039,1,811,success,0 +620040,1,811,success,0 +620041,1,811,success,0 +620042,1,811,success,0 +620043,1,811,success,0 +620044,1,811,success,0 +620045,1,811,success,0 +620046,1,811,success,0 +620047,1,811,success,0 +620048,1,811,success,0 +620049,1,811,success,0 +620050,1,811,success,0 +620051,1,811,success,0 +620052,1,811,success,0 +620053,1,811,success,0 +620054,1,811,success,0 +620055,1,811,success,0 +620056,1,811,success,0 +620057,1,811,success,0 +620058,1,811,success,0 +620059,1,811,success,0 +620060,1,811,success,0 +620061,1,811,success,0 +620062,1,811,success,0 +620063,1,811,success,0 +620064,1,811,success,0 +620065,1,811,success,0 +620066,1,811,success,0 +620067,1,811,success,0 +620068,1,811,success,0 +620069,1,811,success,0 +620070,1,811,success,0 +620071,1,811,success,0 +620072,1,811,success,0 +620073,1,811,success,0 +620074,1,811,success,0 +620075,1,811,success,0 +620076,1,811,success,0 +620077,1,811,success,0 +620078,1,811,success,0 +620079,1,811,success,0 +620080,1,811,success,0 +620081,1,811,success,0 +620082,1,811,success,0 +620083,1,811,success,0 +620084,1,811,success,0 +620085,1,811,success,0 +620086,1,811,success,0 +620087,1,811,success,0 +620088,1,811,success,0 +620089,1,811,success,0 +620090,1,811,success,0 +620091,1,811,success,0 +620092,1,811,success,0 +620093,1,811,success,0 +620094,1,811,success,0 +620095,1,811,success,0 +620096,1,811,success,0 +620097,1,811,success,0 +620098,1,811,success,0 +620099,1,811,success,0 diff --git a/policies/wall_cupboard_close/gpt61sol-s3/policy.py b/policies/wall_cupboard_close/gpt61sol-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..3317613ea580acf20a85aac7bcadb3a433485811 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61sol-s3/policy.py @@ -0,0 +1,44 @@ +"""Deterministic cabinet-door pushing controller.""" +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + + def act(self, obs, tools): + a = self.hold.copy() + t = int(obs['t']) + # Raise the hands outside the doors, approach, then sweep inward. + stages = [(100,-2.5,2.0,1.0,-.2), + (350,-2.5,2.0,1.0,.38), + (450,-2.5,2.0,.7,.38), + (550,-2.5,2.0,.4,.38), + (650,-2.5,2.0,.1,.38), + (750,-2.8,2.0,.7,.38), + (850,-2.8,2.0,.4,.38), + (1000,-2.8,2.0,0.,.38)] + if t < 1000: + stage = next(s for s in stages if t < s[0]) + _,sp,el,sr,x = stage + else: + # A second pass catches a door that slipped around a hand. + u = (t - 1000) % 500 + sp,el,x = -2.8,2.0,.38 + sr = .8 if u < 100 else .5 if u < 200 else .2 if u < 300 else 0. + ld = obs['low_dim_obs'] + yaw = float(ld[24]) + v = np.array([x-float(ld[21]), -float(ld[22])])*1.8 + norm = np.linalg.norm(v) + if norm > .15: + v *= .15/norm + if norm < .025: + v *= 0 + elif np.linalg.norm(v) < .065: + v *= .065/np.linalg.norm(v) + a[0] = v[0]*np.cos(yaw)+v[1]*np.sin(yaw) + a[1] = -v[0]*np.sin(yaw)+v[1]*np.cos(yaw) + a[3] = np.clip(-yaw*2,-.3,.3) + a[5:12] = [sp,sr,0,el,0,-.7,0] + a[12:19] = [sp,-sr,0,el,0,-.7,0] + a[19:21] = 0 + return a diff --git a/policies/wall_cupboard_close/gpt61terra-s1/episodes.csv b/policies/wall_cupboard_close/gpt61terra-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..04b2b4953b3e4f0822f177c9ca1e963a8abffd41 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61terra-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1700,timeout,0 +620001,0,1700,timeout,0 +620002,0,1700,timeout,0 +620003,0,1700,timeout,0 +620004,0,1700,timeout,0 +620005,0,1700,timeout,0 +620006,0,1700,timeout,0 +620007,0,1700,timeout,0 +620008,0,1700,timeout,0 +620009,0,1700,timeout,0 +620010,0,1700,timeout,0 +620011,0,1700,timeout,0 +620012,0,1700,timeout,0 +620013,0,1700,timeout,0 +620014,0,1700,timeout,0 +620015,0,1700,timeout,0 +620016,0,1700,timeout,0 +620017,0,1700,timeout,0 +620018,0,1700,timeout,0 +620019,0,1700,timeout,0 +620020,0,1700,timeout,0 +620021,0,1700,timeout,0 +620022,0,1700,timeout,0 +620023,0,1700,timeout,0 +620024,0,1700,timeout,0 +620025,0,1700,timeout,0 +620026,0,1700,timeout,0 +620027,0,1700,timeout,0 +620028,0,1700,timeout,0 +620029,0,1700,timeout,0 +620030,0,1700,timeout,0 +620031,0,1700,timeout,0 +620032,0,1700,timeout,0 +620033,0,1700,timeout,0 +620034,0,1700,timeout,0 +620035,0,1700,timeout,0 +620036,0,1700,timeout,0 +620037,0,1700,timeout,0 +620038,0,1700,timeout,0 +620039,0,1700,timeout,0 +620040,0,1700,timeout,0 +620041,0,1700,timeout,0 +620042,0,1700,timeout,0 +620043,0,1700,timeout,0 +620044,0,1700,timeout,0 +620045,0,1700,timeout,0 +620046,0,1700,timeout,0 +620047,0,1700,timeout,0 +620048,0,1700,timeout,0 +620049,0,1700,timeout,0 +620050,0,1700,timeout,0 +620051,0,1700,timeout,0 +620052,0,1700,timeout,0 +620053,0,1700,timeout,0 +620054,0,1700,timeout,0 +620055,0,1700,timeout,0 +620056,0,1700,timeout,0 +620057,0,1700,timeout,0 +620058,0,1700,timeout,0 +620059,0,1700,timeout,0 +620060,0,1700,timeout,0 +620061,0,1700,timeout,0 +620062,0,1700,timeout,0 +620063,0,1700,timeout,0 +620064,0,1700,timeout,0 +620065,0,1700,timeout,0 +620066,0,1700,timeout,0 +620067,0,1700,timeout,0 +620068,0,1700,timeout,0 +620069,0,1700,timeout,0 +620070,0,1700,timeout,0 +620071,0,1700,timeout,0 +620072,0,1700,timeout,0 +620073,0,1700,timeout,0 +620074,0,1700,timeout,0 +620075,0,1700,timeout,0 +620076,0,1700,timeout,0 +620077,0,1700,timeout,0 +620078,0,1700,timeout,0 +620079,0,1700,timeout,0 +620080,0,1700,timeout,0 +620081,0,1700,timeout,0 +620082,0,1700,timeout,0 +620083,0,1700,timeout,0 +620084,0,1700,timeout,0 +620085,0,1700,timeout,0 +620086,0,1700,timeout,0 +620087,0,1700,timeout,0 +620088,0,1700,timeout,0 +620089,0,1700,timeout,0 +620090,0,1700,timeout,0 +620091,0,1700,timeout,0 +620092,0,1700,timeout,0 +620093,0,1700,timeout,0 +620094,0,1700,timeout,0 +620095,0,1700,timeout,0 +620096,0,1700,timeout,0 +620097,0,1700,timeout,0 +620098,0,1700,timeout,0 +620099,0,1700,timeout,0 diff --git a/policies/wall_cupboard_close/gpt61terra-s1/policy.py b/policies/wall_cupboard_close/gpt61terra-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..8c7ae20bfa3c8c02377a34009be36242361b9af5 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61terra-s1/policy.py @@ -0,0 +1,48 @@ +"""Deterministic upper-body controller for closing the wall cabinet.""" +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.start_x = float(obs['low_dim_obs'][21]) + self.start_y = float(obs['low_dim_obs'][22]) + self.start_yaw = float(obs['low_dim_obs'][24]) + + def act(self, obs, tools): + t = int(obs['t']) + q = obs['low_dim_obs'] + a = self.hold.copy() + a[2] = .74 + a[4] = 0 + a[19:21] = 0 + # Raise the hands to either side of the open doors, sweep inward, + # then repeat the push from closer to the cabinet. + if t < 150: + p, roll, elbow, wrist = -2.4, .85, 1.0, 1.0 + elif t < 470: + f = (t-150)/320.0 + p, roll, elbow, wrist = -2.4, .85-.65*f, 1.0, 1.0 + elif t < 620: + p, roll, elbow, wrist = -2.1, .75, .3, 0.0 + elif t < 980: + f = (t-620)/360.0 + p, roll, elbow, wrist = -2.1, .75-.65*f, .3, 0.0 + elif t < 1100: + p, roll, elbow, wrist = -2.5, .85, .8, .4 + elif t < 1500: + f = (t-1100)/400.0 + p, roll, elbow, wrist = -2.5, .85-.75*f, .8, .4 + else: + p, roll, elbow, wrist = -2.5, .1, .8, .4 + a[5:12] = [p, roll, 0, elbow, 0, wrist, 0] + a[12:19] = [p, -roll, 0, elbow, 0, wrist, 0] + if 470 <= t < 620: + dx = self.start_x + .12 - float(q[21]) + if abs(dx) > .025: + a[0] = np.clip(dx*2, -.18, .18) + dy = self.start_y - float(q[22]) + if abs(dy) > .035: + a[1] = np.clip(dy, -.1, .1) + yaw = self.start_yaw - float(q[24]) + a[3] = np.clip(yaw, -.15, .15) + return a diff --git a/policies/wall_cupboard_close/gpt61terra-s2/episodes.csv b/policies/wall_cupboard_close/gpt61terra-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..8c348501bbc491bf655783de0c0a833720fa8ab2 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61terra-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,428,success,0 +620001,1,428,success,0 +620002,1,428,success,0 +620003,1,428,success,0 +620004,1,428,success,0 +620005,1,428,success,0 +620006,1,428,success,0 +620007,1,428,success,0 +620008,1,428,success,0 +620009,1,428,success,0 +620010,1,428,success,0 +620011,1,428,success,0 +620012,1,428,success,0 +620013,1,428,success,0 +620014,1,428,success,0 +620015,1,428,success,0 +620016,1,428,success,0 +620017,1,428,success,0 +620018,1,428,success,0 +620019,1,428,success,0 +620020,1,428,success,0 +620021,1,428,success,0 +620022,1,428,success,0 +620023,1,428,success,0 +620024,1,428,success,0 +620025,1,428,success,0 +620026,1,428,success,0 +620027,1,428,success,0 +620028,1,428,success,0 +620029,1,428,success,0 +620030,1,428,success,0 +620031,1,428,success,0 +620032,1,428,success,0 +620033,1,428,success,0 +620034,1,428,success,0 +620035,1,428,success,0 +620036,1,428,success,0 +620037,1,428,success,0 +620038,1,428,success,0 +620039,1,428,success,0 +620040,1,428,success,0 +620041,1,428,success,0 +620042,1,428,success,0 +620043,1,428,success,0 +620044,1,428,success,0 +620045,1,428,success,0 +620046,1,428,success,0 +620047,1,428,success,0 +620048,1,428,success,0 +620049,1,428,success,0 +620050,1,428,success,0 +620051,1,428,success,0 +620052,1,428,success,0 +620053,1,428,success,0 +620054,1,428,success,0 +620055,1,428,success,0 +620056,1,428,success,0 +620057,1,428,success,0 +620058,1,428,success,0 +620059,1,428,success,0 +620060,1,428,success,0 +620061,1,428,success,0 +620062,1,428,success,0 +620063,1,428,success,0 +620064,1,428,success,0 +620065,1,428,success,0 +620066,1,428,success,0 +620067,1,428,success,0 +620068,1,428,success,0 +620069,1,428,success,0 +620070,1,428,success,0 +620071,1,428,success,0 +620072,1,428,success,0 +620073,1,428,success,0 +620074,1,428,success,0 +620075,1,428,success,0 +620076,1,428,success,0 +620077,1,428,success,0 +620078,1,428,success,0 +620079,1,428,success,0 +620080,1,428,success,0 +620081,1,428,success,0 +620082,1,428,success,0 +620083,1,428,success,0 +620084,1,428,success,0 +620085,1,428,success,0 +620086,1,428,success,0 +620087,1,428,success,0 +620088,1,428,success,0 +620089,1,428,success,0 +620090,1,428,success,0 +620091,1,428,success,0 +620092,1,428,success,0 +620093,1,428,success,0 +620094,1,428,success,0 +620095,1,428,success,0 +620096,1,428,success,0 +620097,1,428,success,0 +620098,1,428,success,0 +620099,1,428,success,0 diff --git a/policies/wall_cupboard_close/gpt61terra-s2/policy.py b/policies/wall_cupboard_close/gpt61terra-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..451081fefd03be4a9e4ae285a048f86cd31f71f1 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61terra-s2/policy.py @@ -0,0 +1,17 @@ +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(),dtype=np.float32) + + def act(self, obs, tools): + t=obs['t']; a=self.hold.copy() + x,y,z,yaw=obs['low_dim_obs'][21:25] + roll=1.0 if t<350 else max(-0.1, 1.0-(t-350)/150*1.1) + a[5:12]=[-1.7,roll,0,0.8,0,0,0] + a[12:19]=[-1.7,-roll,0,0.8,0,0,0] + a[19:21]=0 + a[0]=0.22 if t>80 and x<0.30 else 0 + a[1]=np.clip(-y*1.5,-.15,.15) if abs(y)>.04 else 0 + a[3]=np.clip(-yaw*1.5,-.2,.2) + return a diff --git a/policies/wall_cupboard_close/gpt61terra-s3/episodes.csv b/policies/wall_cupboard_close/gpt61terra-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..04b2b4953b3e4f0822f177c9ca1e963a8abffd41 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61terra-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1700,timeout,0 +620001,0,1700,timeout,0 +620002,0,1700,timeout,0 +620003,0,1700,timeout,0 +620004,0,1700,timeout,0 +620005,0,1700,timeout,0 +620006,0,1700,timeout,0 +620007,0,1700,timeout,0 +620008,0,1700,timeout,0 +620009,0,1700,timeout,0 +620010,0,1700,timeout,0 +620011,0,1700,timeout,0 +620012,0,1700,timeout,0 +620013,0,1700,timeout,0 +620014,0,1700,timeout,0 +620015,0,1700,timeout,0 +620016,0,1700,timeout,0 +620017,0,1700,timeout,0 +620018,0,1700,timeout,0 +620019,0,1700,timeout,0 +620020,0,1700,timeout,0 +620021,0,1700,timeout,0 +620022,0,1700,timeout,0 +620023,0,1700,timeout,0 +620024,0,1700,timeout,0 +620025,0,1700,timeout,0 +620026,0,1700,timeout,0 +620027,0,1700,timeout,0 +620028,0,1700,timeout,0 +620029,0,1700,timeout,0 +620030,0,1700,timeout,0 +620031,0,1700,timeout,0 +620032,0,1700,timeout,0 +620033,0,1700,timeout,0 +620034,0,1700,timeout,0 +620035,0,1700,timeout,0 +620036,0,1700,timeout,0 +620037,0,1700,timeout,0 +620038,0,1700,timeout,0 +620039,0,1700,timeout,0 +620040,0,1700,timeout,0 +620041,0,1700,timeout,0 +620042,0,1700,timeout,0 +620043,0,1700,timeout,0 +620044,0,1700,timeout,0 +620045,0,1700,timeout,0 +620046,0,1700,timeout,0 +620047,0,1700,timeout,0 +620048,0,1700,timeout,0 +620049,0,1700,timeout,0 +620050,0,1700,timeout,0 +620051,0,1700,timeout,0 +620052,0,1700,timeout,0 +620053,0,1700,timeout,0 +620054,0,1700,timeout,0 +620055,0,1700,timeout,0 +620056,0,1700,timeout,0 +620057,0,1700,timeout,0 +620058,0,1700,timeout,0 +620059,0,1700,timeout,0 +620060,0,1700,timeout,0 +620061,0,1700,timeout,0 +620062,0,1700,timeout,0 +620063,0,1700,timeout,0 +620064,0,1700,timeout,0 +620065,0,1700,timeout,0 +620066,0,1700,timeout,0 +620067,0,1700,timeout,0 +620068,0,1700,timeout,0 +620069,0,1700,timeout,0 +620070,0,1700,timeout,0 +620071,0,1700,timeout,0 +620072,0,1700,timeout,0 +620073,0,1700,timeout,0 +620074,0,1700,timeout,0 +620075,0,1700,timeout,0 +620076,0,1700,timeout,0 +620077,0,1700,timeout,0 +620078,0,1700,timeout,0 +620079,0,1700,timeout,0 +620080,0,1700,timeout,0 +620081,0,1700,timeout,0 +620082,0,1700,timeout,0 +620083,0,1700,timeout,0 +620084,0,1700,timeout,0 +620085,0,1700,timeout,0 +620086,0,1700,timeout,0 +620087,0,1700,timeout,0 +620088,0,1700,timeout,0 +620089,0,1700,timeout,0 +620090,0,1700,timeout,0 +620091,0,1700,timeout,0 +620092,0,1700,timeout,0 +620093,0,1700,timeout,0 +620094,0,1700,timeout,0 +620095,0,1700,timeout,0 +620096,0,1700,timeout,0 +620097,0,1700,timeout,0 +620098,0,1700,timeout,0 +620099,0,1700,timeout,0 diff --git a/policies/wall_cupboard_close/gpt61terra-s3/policy.py b/policies/wall_cupboard_close/gpt61terra-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..0ef98d04afa2a1b8ca7056082383d60430a060a8 --- /dev/null +++ b/policies/wall_cupboard_close/gpt61terra-s3/policy.py @@ -0,0 +1,41 @@ +import math +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.initial = np.asarray(tools.hold_action(), dtype=np.float32) + self.y0 = float(obs['low_dim_obs'][22]) + self.yaw0 = float(obs['low_dim_obs'][24]) + + def act(self, obs, tools): + t = int(obs['t']) + q = obs['low_dim_obs'] + a = self.initial.copy() + a[2] = 0.74 + a[19:21] = 0.0 + # Raise both hands to the bottom of the wall cabinet before walking. + f = min(t / 130.0, 1.0) + if t < 600: + p, elbow, roll, yaw = -2.4, .8, .25, 0.0 + elif t < 1050: + p, elbow = -2.4, .8 + u = min((t-600)/220.0, 1.0) + roll, yaw = .65 - 1.15*u, .7*u + else: + u = min((t-1050)/150.0, 1.0) + p = -2.4 + .65*u + elbow = .8*(1-u) + roll = -.4 + .8*(.5+.5*math.sin((t-1050)*math.pi/180)) + yaw = .7*(1-u) + a[5] = a[12] = p*f + a[6], a[13] = roll*f, -roll*f + a[7], a[14] = yaw*f, -yaw*f + a[8] = a[15] = elbow*f + a[10] = a[17] = 1.2*f + if 160 < t < 520 and q[21] < .30: + a[0] = .14 + dy = self.y0 - float(q[22]) + if abs(dy) > .025: + a[1] = np.clip(2*dy, -.12, .12) + a[3] = np.clip(2*(self.yaw0-float(q[24])), -.25, .25) + return a diff --git a/policies/wall_cupboard_close/gpt6sol-s1/episodes.csv b/policies/wall_cupboard_close/gpt6sol-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..48ef16e949cd3228fca2e15ffff4dafac8179d30 --- /dev/null +++ b/policies/wall_cupboard_close/gpt6sol-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,352,success,0 +620001,1,352,success,0 +620002,1,352,success,0 +620003,1,352,success,0 +620004,1,352,success,0 +620005,1,352,success,0 +620006,1,352,success,0 +620007,1,352,success,0 +620008,1,352,success,0 +620009,1,352,success,0 +620010,1,352,success,0 +620011,1,352,success,0 +620012,1,352,success,0 +620013,1,352,success,0 +620014,1,352,success,0 +620015,1,352,success,0 +620016,1,352,success,0 +620017,1,352,success,0 +620018,1,352,success,0 +620019,1,352,success,0 +620020,1,352,success,0 +620021,1,352,success,0 +620022,1,352,success,0 +620023,1,352,success,0 +620024,1,352,success,0 +620025,1,352,success,0 +620026,1,352,success,0 +620027,1,352,success,0 +620028,1,352,success,0 +620029,1,352,success,0 +620030,1,352,success,0 +620031,1,352,success,0 +620032,1,352,success,0 +620033,1,352,success,0 +620034,1,352,success,0 +620035,1,352,success,0 +620036,1,352,success,0 +620037,1,352,success,0 +620038,1,352,success,0 +620039,1,352,success,0 +620040,1,352,success,0 +620041,1,352,success,0 +620042,1,352,success,0 +620043,1,352,success,0 +620044,1,352,success,0 +620045,1,352,success,0 +620046,1,352,success,0 +620047,1,352,success,0 +620048,1,352,success,0 +620049,1,352,success,0 +620050,1,352,success,0 +620051,1,352,success,0 +620052,1,352,success,0 +620053,1,352,success,0 +620054,1,352,success,0 +620055,1,352,success,0 +620056,1,352,success,0 +620057,1,352,success,0 +620058,1,352,success,0 +620059,1,352,success,0 +620060,1,352,success,0 +620061,1,352,success,0 +620062,1,352,success,0 +620063,1,352,success,0 +620064,1,352,success,0 +620065,1,352,success,0 +620066,1,352,success,0 +620067,1,352,success,0 +620068,1,352,success,0 +620069,1,352,success,0 +620070,1,352,success,0 +620071,1,352,success,0 +620072,1,352,success,0 +620073,1,352,success,0 +620074,1,352,success,0 +620075,1,352,success,0 +620076,1,352,success,0 +620077,1,352,success,0 +620078,1,352,success,0 +620079,1,352,success,0 +620080,1,352,success,0 +620081,1,352,success,0 +620082,1,352,success,0 +620083,1,352,success,0 +620084,1,352,success,0 +620085,1,352,success,0 +620086,1,352,success,0 +620087,1,352,success,0 +620088,1,352,success,0 +620089,1,352,success,0 +620090,1,352,success,0 +620091,1,352,success,0 +620092,1,352,success,0 +620093,1,352,success,0 +620094,1,352,success,0 +620095,1,352,success,0 +620096,1,352,success,0 +620097,1,352,success,0 +620098,1,352,success,0 +620099,1,352,success,0 diff --git a/policies/wall_cupboard_close/gpt6sol-s1/policy.py b/policies/wall_cupboard_close/gpt6sol-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..236bb0819068290285ef022ba05926ced55b4bdb --- /dev/null +++ b/policies/wall_cupboard_close/gpt6sol-s1/policy.py @@ -0,0 +1,43 @@ +"""Deterministic cabinet door closing policy for the G1.""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.initial_y = float(obs["low_dim_obs"][22]) + self.initial_yaw = float(obs["low_dim_obs"][24]) + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + + def act(self, obs, tools): + t = int(obs["t"]) + p = obs["low_dim_obs"][21:25] + a = self.hold.copy() + a[0] = a[1] = a[3] = 0.0 + a[2] = 0.74 + a[4] = 0.0 + a[5] = a[12] = -1.0 + a[7] = 0.6 + a[14] = -0.6 + + if t < 80: + roll = 0.45 + elif t < 180: + roll = 0.45 + if p[0] < -0.02: + a[0] = 0.2 + elif t < 500: + roll = 0.45 - 0.85 * (t - 180) / 320.0 + if p[0] < 0.38: + a[0] = 0.2 + else: + roll = -0.4 + if p[0] < 0.38: + a[0] = 0.2 + a[6] = roll + a[13] = -roll + + if a[0]: + a[1] = np.clip(-2.0 * (p[1] - self.initial_y), -0.25, 0.25) + a[3] = np.clip(-2.0 * (p[3] - self.initial_yaw), -0.4, 0.4) + return a diff --git a/policies/wall_cupboard_close/gpt6sol-s2/episodes.csv b/policies/wall_cupboard_close/gpt6sol-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..b9cd972eef14021bd29c815eaefc80990834fd2b --- /dev/null +++ b/policies/wall_cupboard_close/gpt6sol-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,285,success,0 +620001,1,285,success,0 +620002,1,285,success,0 +620003,1,285,success,0 +620004,1,285,success,0 +620005,1,285,success,0 +620006,1,285,success,0 +620007,1,285,success,0 +620008,1,285,success,0 +620009,1,285,success,0 +620010,1,285,success,0 +620011,1,285,success,0 +620012,1,285,success,0 +620013,1,285,success,0 +620014,1,285,success,0 +620015,1,285,success,0 +620016,1,285,success,0 +620017,1,285,success,0 +620018,1,285,success,0 +620019,1,285,success,0 +620020,1,285,success,0 +620021,1,285,success,0 +620022,1,285,success,0 +620023,1,285,success,0 +620024,1,285,success,0 +620025,1,285,success,0 +620026,1,285,success,0 +620027,1,285,success,0 +620028,1,285,success,0 +620029,1,285,success,0 +620030,1,285,success,0 +620031,1,285,success,0 +620032,1,285,success,0 +620033,1,285,success,0 +620034,1,285,success,0 +620035,1,285,success,0 +620036,1,285,success,0 +620037,1,285,success,0 +620038,1,285,success,0 +620039,1,285,success,0 +620040,1,285,success,0 +620041,1,285,success,0 +620042,1,285,success,0 +620043,1,285,success,0 +620044,1,285,success,0 +620045,1,285,success,0 +620046,1,285,success,0 +620047,1,285,success,0 +620048,1,285,success,0 +620049,1,285,success,0 +620050,1,285,success,0 +620051,1,285,success,0 +620052,1,285,success,0 +620053,1,285,success,0 +620054,1,285,success,0 +620055,1,285,success,0 +620056,1,285,success,0 +620057,1,285,success,0 +620058,1,285,success,0 +620059,1,285,success,0 +620060,1,285,success,0 +620061,1,285,success,0 +620062,1,285,success,0 +620063,1,285,success,0 +620064,1,285,success,0 +620065,1,285,success,0 +620066,1,285,success,0 +620067,1,285,success,0 +620068,1,285,success,0 +620069,1,285,success,0 +620070,1,285,success,0 +620071,1,285,success,0 +620072,1,285,success,0 +620073,1,285,success,0 +620074,1,285,success,0 +620075,1,285,success,0 +620076,1,285,success,0 +620077,1,285,success,0 +620078,1,285,success,0 +620079,1,285,success,0 +620080,1,285,success,0 +620081,1,285,success,0 +620082,1,285,success,0 +620083,1,285,success,0 +620084,1,285,success,0 +620085,1,285,success,0 +620086,1,285,success,0 +620087,1,285,success,0 +620088,1,285,success,0 +620089,1,285,success,0 +620090,1,285,success,0 +620091,1,285,success,0 +620092,1,285,success,0 +620093,1,285,success,0 +620094,1,285,success,0 +620095,1,285,success,0 +620096,1,285,success,0 +620097,1,285,success,0 +620098,1,285,success,0 +620099,1,285,success,0 diff --git a/policies/wall_cupboard_close/gpt6sol-s2/policy.py b/policies/wall_cupboard_close/gpt6sol-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..7881c8d86307488bd081bf29f9cc01291474c7fa --- /dev/null +++ b/policies/wall_cupboard_close/gpt6sol-s2/policy.py @@ -0,0 +1,32 @@ +"""Deterministic controller for closing the two wall cupboard doors.""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.initial = np.asarray(tools.hold_action(), dtype=np.float32) + + def act(self, obs, tools): + t = int(obs["t"]) + a = self.initial.copy() + a[0:5] = [0, 0, 0.74, 0, 0] + a[19:21] = 0 + + if t < 40: + vx, pitch, roll, yaw = 0, -0.8, 0.3, 0.8 + elif t < 140: + vx, pitch, roll, yaw = 0.18, -0.8, 0.3, 0.8 + elif t < 220: + vx, pitch, roll, yaw = 0.18, -0.8, 0.3, 0.5 + elif t < 310: + vx, pitch, roll, yaw = 0.12, -0.8, 0.2, 0 + elif t < 390: + vx, pitch, roll, yaw = 0, -0.8, 0, -0.3 + else: + vx, pitch, roll, yaw = 0, -0.8, 0, 0 + + a[0] = vx + a[5:12] = [pitch, roll, yaw, 0, 0, 0, 0] + a[12:19] = [pitch, -roll, -yaw, 0, 0, 0, 0] + return a diff --git a/policies/wall_cupboard_close/gpt6sol-s3/episodes.csv b/policies/wall_cupboard_close/gpt6sol-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..04b2b4953b3e4f0822f177c9ca1e963a8abffd41 --- /dev/null +++ b/policies/wall_cupboard_close/gpt6sol-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1700,timeout,0 +620001,0,1700,timeout,0 +620002,0,1700,timeout,0 +620003,0,1700,timeout,0 +620004,0,1700,timeout,0 +620005,0,1700,timeout,0 +620006,0,1700,timeout,0 +620007,0,1700,timeout,0 +620008,0,1700,timeout,0 +620009,0,1700,timeout,0 +620010,0,1700,timeout,0 +620011,0,1700,timeout,0 +620012,0,1700,timeout,0 +620013,0,1700,timeout,0 +620014,0,1700,timeout,0 +620015,0,1700,timeout,0 +620016,0,1700,timeout,0 +620017,0,1700,timeout,0 +620018,0,1700,timeout,0 +620019,0,1700,timeout,0 +620020,0,1700,timeout,0 +620021,0,1700,timeout,0 +620022,0,1700,timeout,0 +620023,0,1700,timeout,0 +620024,0,1700,timeout,0 +620025,0,1700,timeout,0 +620026,0,1700,timeout,0 +620027,0,1700,timeout,0 +620028,0,1700,timeout,0 +620029,0,1700,timeout,0 +620030,0,1700,timeout,0 +620031,0,1700,timeout,0 +620032,0,1700,timeout,0 +620033,0,1700,timeout,0 +620034,0,1700,timeout,0 +620035,0,1700,timeout,0 +620036,0,1700,timeout,0 +620037,0,1700,timeout,0 +620038,0,1700,timeout,0 +620039,0,1700,timeout,0 +620040,0,1700,timeout,0 +620041,0,1700,timeout,0 +620042,0,1700,timeout,0 +620043,0,1700,timeout,0 +620044,0,1700,timeout,0 +620045,0,1700,timeout,0 +620046,0,1700,timeout,0 +620047,0,1700,timeout,0 +620048,0,1700,timeout,0 +620049,0,1700,timeout,0 +620050,0,1700,timeout,0 +620051,0,1700,timeout,0 +620052,0,1700,timeout,0 +620053,0,1700,timeout,0 +620054,0,1700,timeout,0 +620055,0,1700,timeout,0 +620056,0,1700,timeout,0 +620057,0,1700,timeout,0 +620058,0,1700,timeout,0 +620059,0,1700,timeout,0 +620060,0,1700,timeout,0 +620061,0,1700,timeout,0 +620062,0,1700,timeout,0 +620063,0,1700,timeout,0 +620064,0,1700,timeout,0 +620065,0,1700,timeout,0 +620066,0,1700,timeout,0 +620067,0,1700,timeout,0 +620068,0,1700,timeout,0 +620069,0,1700,timeout,0 +620070,0,1700,timeout,0 +620071,0,1700,timeout,0 +620072,0,1700,timeout,0 +620073,0,1700,timeout,0 +620074,0,1700,timeout,0 +620075,0,1700,timeout,0 +620076,0,1700,timeout,0 +620077,0,1700,timeout,0 +620078,0,1700,timeout,0 +620079,0,1700,timeout,0 +620080,0,1700,timeout,0 +620081,0,1700,timeout,0 +620082,0,1700,timeout,0 +620083,0,1700,timeout,0 +620084,0,1700,timeout,0 +620085,0,1700,timeout,0 +620086,0,1700,timeout,0 +620087,0,1700,timeout,0 +620088,0,1700,timeout,0 +620089,0,1700,timeout,0 +620090,0,1700,timeout,0 +620091,0,1700,timeout,0 +620092,0,1700,timeout,0 +620093,0,1700,timeout,0 +620094,0,1700,timeout,0 +620095,0,1700,timeout,0 +620096,0,1700,timeout,0 +620097,0,1700,timeout,0 +620098,0,1700,timeout,0 +620099,0,1700,timeout,0 diff --git a/policies/wall_cupboard_close/gpt6sol-s3/policy.py b/policies/wall_cupboard_close/gpt6sol-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..702344456f55e28df5be99e67f1fac3992824d96 --- /dev/null +++ b/policies/wall_cupboard_close/gpt6sol-s3/policy.py @@ -0,0 +1,95 @@ +"""Deterministic whole-body cabinet-door closing controller. + +The hands first rise above the counter, then make several forward and inward +strokes across the faces of the two outward-opening doors. Pelvis position +feedback keeps the strokes centered despite walking drift and contact forces. +""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.rest = np.asarray(tools.hold_action(), dtype=np.float32) + + @staticmethod + def _blend(a, b, u): + u = float(np.clip(u, 0.0, 1.0)) + u = u * u * (3.0 - 2.0 * u) + return (1.0 - u) * a + u * b + + def act(self, obs, tools): + t = int(obs["t"]) + state = obs["low_dim_obs"] + x, y, yaw = map(float, (state[21], state[22], state[24])) + raw = self.rest.copy() + raw[2] = 0.74 + raw[19:21] = 1.0 + + if t < 90: + target_x, target_y = -0.27, 0.0 + pitch, roll, elbow, lean = -2.15, 0.55, 0.8, 0.0 + elif t < 270: + target_x, target_y = 0.12, 0.0 + pitch, roll, elbow, lean = -2.15, 0.55, 0.8, 0.0 + elif t < 570: + u = (t - 270) / 300.0 + target_x, target_y = 0.25, 0.0 + pitch = self._blend(-2.15, -1.55, u) + roll = self._blend(0.55, 0.12, u) + elbow = self._blend(0.8, 0.25, u) + lean = self._blend(0.0, 0.25, u) + elif t < 660: + target_x, target_y = 0.25, 0.0 + pitch, roll, elbow, lean = -1.55, 0.12, 0.25, 0.25 + elif t < 790: + u = (t - 660) / 130.0 + target_x, target_y = self._blend(0.25, -0.08, u), 0.0 + pitch = self._blend(-1.55, -1.9, u) + roll = self._blend(0.12, 0.7, u) + elbow = self._blend(0.25, 1.0, u) + lean = self._blend(0.25, 0.0, u) + elif t < 1130: + u = (t - 790) / 340.0 + target_x, target_y = 0.15, 0.0 + pitch = self._blend(-1.9, -1.65, u) + roll = self._blend(0.7, -0.25, u) + elbow = self._blend(1.0, 0.4, u) + lean = 0.0 + elif t < 1230: + target_x, target_y = 0.18, 0.0 + pitch, roll, elbow, lean = -1.65, -0.25, 0.4, 0.0 + elif t < 1480: + u = (t - 1230) / 250.0 + target_x, target_y = 0.27, self._blend(-0.18, 0.18, u) + pitch, roll, elbow, lean = -1.8, 0.15, 0.5, 0.0 + elif t < 1570: + u = (t - 1480) / 90.0 + target_x, target_y = 0.33, 0.0 + pitch = self._blend(-1.8, -1.55, u) + roll = self._blend(0.15, -0.05, u) + elbow = self._blend(0.5, 0.3, u) + lean = self._blend(0.0, 0.3, u) + elif t < 1640: + u = (t - 1570) / 70.0 + target_x, target_y = 0.25, 0.0 + pitch = self._blend(-1.55, -0.2, u) + roll = self._blend(-0.05, 0.0, u) + elbow = self._blend(0.3, 0.1, u) + lean = self._blend(0.3, 0.0, u) + else: + target_x, target_y = 0.17, 0.0 + pitch, roll, elbow, lean = -0.2, 0.0, 0.1, 0.0 + + # Convert world-frame pose errors into robot-frame velocity commands. + dx, dy = target_x - x, target_y - y + cy, sy = np.cos(yaw), np.sin(yaw) + forward = cy * dx + sy * dy + lateral = -sy * dx + cy * dy + raw[0] = np.clip(1.5 * forward, -0.30, 0.35) + raw[1] = np.clip(2.0 * lateral, -0.30, 0.30) + raw[3] = np.clip(-2.0 * yaw, -0.35, 0.35) + raw[4] = lean + raw[5:12] = (pitch, roll, 0.0, elbow, 0.0, -0.3, 0.0) + raw[12:19] = (pitch, -roll, 0.0, elbow, 0.0, -0.3, 0.0) + return raw diff --git a/policies/wall_cupboard_close/kimi31pro-s1/episodes.csv b/policies/wall_cupboard_close/kimi31pro-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..eb878a43ee08ccf8f8380ca26fdc5e09154890e3 --- /dev/null +++ b/policies/wall_cupboard_close/kimi31pro-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,755,success,0 +620001,1,755,success,0 +620002,1,755,success,0 +620003,1,755,success,0 +620004,1,755,success,0 +620005,1,755,success,0 +620006,1,755,success,0 +620007,1,755,success,0 +620008,1,755,success,0 +620009,1,755,success,0 +620010,1,755,success,0 +620011,1,755,success,0 +620012,1,755,success,0 +620013,1,755,success,0 +620014,1,755,success,0 +620015,1,755,success,0 +620016,1,755,success,0 +620017,1,755,success,0 +620018,1,755,success,0 +620019,1,755,success,0 +620020,1,755,success,0 +620021,1,755,success,0 +620022,1,755,success,0 +620023,1,755,success,0 +620024,1,755,success,0 +620025,1,755,success,0 +620026,1,755,success,0 +620027,1,755,success,0 +620028,1,755,success,0 +620029,1,755,success,0 +620030,1,755,success,0 +620031,1,755,success,0 +620032,1,755,success,0 +620033,1,755,success,0 +620034,1,755,success,0 +620035,1,755,success,0 +620036,1,755,success,0 +620037,1,755,success,0 +620038,1,755,success,0 +620039,1,755,success,0 +620040,1,755,success,0 +620041,1,755,success,0 +620042,1,755,success,0 +620043,1,755,success,0 +620044,1,755,success,0 +620045,1,755,success,0 +620046,1,755,success,0 +620047,1,755,success,0 +620048,1,755,success,0 +620049,1,755,success,0 +620050,1,755,success,0 +620051,1,755,success,0 +620052,1,755,success,0 +620053,1,755,success,0 +620054,1,755,success,0 +620055,1,755,success,0 +620056,1,755,success,0 +620057,1,755,success,0 +620058,1,755,success,0 +620059,1,755,success,0 +620060,1,755,success,0 +620061,1,755,success,0 +620062,1,755,success,0 +620063,1,755,success,0 +620064,1,755,success,0 +620065,1,755,success,0 +620066,1,755,success,0 +620067,1,755,success,0 +620068,1,755,success,0 +620069,1,755,success,0 +620070,1,755,success,0 +620071,1,755,success,0 +620072,1,755,success,0 +620073,1,755,success,0 +620074,1,755,success,0 +620075,1,755,success,0 +620076,1,755,success,0 +620077,1,755,success,0 +620078,1,755,success,0 +620079,1,755,success,0 +620080,1,755,success,0 +620081,1,755,success,0 +620082,1,755,success,0 +620083,1,755,success,0 +620084,1,755,success,0 +620085,1,755,success,0 +620086,1,755,success,0 +620087,1,755,success,0 +620088,1,755,success,0 +620089,1,755,success,0 +620090,1,755,success,0 +620091,1,755,success,0 +620092,1,755,success,0 +620093,1,755,success,0 +620094,1,755,success,0 +620095,1,755,success,0 +620096,1,755,success,0 +620097,1,755,success,0 +620098,1,755,success,0 +620099,1,755,success,0 diff --git a/policies/wall_cupboard_close/kimi31pro-s1/policy.py b/policies/wall_cupboard_close/kimi31pro-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..0a27dffcbd6a9f087b3cb1571d3d372aab68980f --- /dev/null +++ b/policies/wall_cupboard_close/kimi31pro-s1/policy.py @@ -0,0 +1,87 @@ +"""Deterministic two-arm controller for closing the wall-cupboard doors.""" + +import numpy as np + + +class Policy: + """Drive to the cupboard, then rotate both doors with symmetric arm sweeps.""" + + # (shoulder pitch, outward shoulder roll, outward shoulder yaw, duration) + _STAGES = ( + (-1.2, 1.0, 0.6, 85), + (-1.2, 1.0, -0.6, 155), + (-1.2, 1.0, -0.6, 55), + (-1.6, 1.0, 0.6, 85), + (-1.6, 1.0, -0.6, 155), + (-1.6, 1.0, -0.6, 55), + (-1.6, 1.0, -1.0, 90), + ) + + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32).copy() + self.step = 0 + self.base_target = np.array([0.10, 0.0, 0.0], dtype=np.float64) + + def _base_servo(self, action, obs, max_speed): + """Hold the measured pelvis pose near the cupboard working position.""" + low = obs["low_dim_obs"] + x, y, yaw = float(low[21]), float(low[22]), float(low[24]) + dx = self.base_target[0] - x + dy = self.base_target[1] - y + c, s = np.cos(yaw), np.sin(yaw) + vx = np.clip(2.5 * (c * dx + s * dy), -max_speed, max_speed) + vy = np.clip(2.5 * (-s * dx + c * dy), -max_speed, max_speed) + speed = np.hypot(vx, vy) + if speed < 0.015: + action[0] = 0.0 + action[1] = 0.0 + else: + # The base controller treats smaller planar commands as standing still. + if speed < 0.06: + scale = 0.06 / speed + vx *= scale + vy *= scale + action[0] = vx + action[1] = vy + yaw_error = (self.base_target[2] - yaw + np.pi) % (2.0 * np.pi) - np.pi + action[3] = ( + np.clip(1.5 * yaw_error, -0.35, 0.35) + if abs(yaw_error) > 0.012 + else 0.0 + ) + + def act(self, obs, tools): + action = self.hold.copy() + n = self.step + self._base_servo(action, obs, 0.16 if n < 150 else 0.10) + action[19:21] = 0.0 + + if n < 150: + # Approach with the arms clear of the cupboard. + action[5:19] = 0.0 + else: + start = 150 + previous = np.zeros(3, dtype=np.float64) + target = previous + local = 0 + ramp = 1 + for pitch, roll, yaw, duration in self._STAGES: + if n < start + duration: + target = np.array([pitch, roll, yaw], dtype=np.float64) + local = n - start + ramp = duration - 12 + break + previous = np.array([pitch, roll, yaw], dtype=np.float64) + start += duration + else: + target = previous + local = ramp + ramp = 1 + + alpha = min(1.0, float(local + 1) / float(ramp)) + pitch, roll, yaw = previous + alpha * (target - previous) + action[5:12] = [pitch, roll, yaw, 0.0, 0.0, 0.0, 0.0] + action[12:19] = [pitch, -roll, -yaw, 0.0, 0.0, 0.0, 0.0] + + self.step += 1 + return action diff --git a/policies/wall_cupboard_close/kimi31pro-s2/episodes.csv b/policies/wall_cupboard_close/kimi31pro-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..d3753172bce0c5ac02dac0c6f9ded2ca599636cb --- /dev/null +++ b/policies/wall_cupboard_close/kimi31pro-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1600,success,0 +620001,1,1600,success,0 +620002,1,1600,success,0 +620003,1,1600,success,0 +620004,1,1600,success,0 +620005,1,1600,success,0 +620006,1,1600,success,0 +620007,1,1600,success,0 +620008,1,1600,success,0 +620009,1,1600,success,0 +620010,1,1600,success,0 +620011,1,1600,success,0 +620012,1,1600,success,0 +620013,1,1600,success,0 +620014,1,1600,success,0 +620015,1,1600,success,0 +620016,1,1600,success,0 +620017,1,1600,success,0 +620018,1,1600,success,0 +620019,1,1600,success,0 +620020,1,1600,success,0 +620021,1,1600,success,0 +620022,1,1600,success,0 +620023,1,1600,success,0 +620024,1,1600,success,0 +620025,1,1600,success,0 +620026,1,1600,success,0 +620027,1,1600,success,0 +620028,1,1600,success,0 +620029,1,1600,success,0 +620030,1,1600,success,0 +620031,1,1600,success,0 +620032,1,1600,success,0 +620033,1,1600,success,0 +620034,1,1600,success,0 +620035,1,1600,success,0 +620036,1,1600,success,0 +620037,1,1600,success,0 +620038,1,1600,success,0 +620039,1,1600,success,0 +620040,1,1600,success,0 +620041,1,1600,success,0 +620042,1,1600,success,0 +620043,1,1600,success,0 +620044,1,1600,success,0 +620045,1,1600,success,0 +620046,1,1600,success,0 +620047,1,1600,success,0 +620048,1,1600,success,0 +620049,1,1600,success,0 +620050,1,1600,success,0 +620051,1,1600,success,0 +620052,1,1600,success,0 +620053,1,1600,success,0 +620054,1,1600,success,0 +620055,1,1600,success,0 +620056,1,1600,success,0 +620057,1,1600,success,0 +620058,1,1600,success,0 +620059,1,1600,success,0 +620060,1,1600,success,0 +620061,1,1600,success,0 +620062,1,1600,success,0 +620063,1,1600,success,0 +620064,1,1600,success,0 +620065,1,1600,success,0 +620066,1,1600,success,0 +620067,1,1600,success,0 +620068,1,1600,success,0 +620069,1,1600,success,0 +620070,1,1600,success,0 +620071,1,1600,success,0 +620072,1,1600,success,0 +620073,1,1600,success,0 +620074,1,1600,success,0 +620075,1,1600,success,0 +620076,1,1600,success,0 +620077,1,1600,success,0 +620078,1,1600,success,0 +620079,1,1600,success,0 +620080,1,1600,success,0 +620081,1,1600,success,0 +620082,1,1600,success,0 +620083,1,1600,success,0 +620084,1,1600,success,0 +620085,1,1600,success,0 +620086,1,1600,success,0 +620087,1,1600,success,0 +620088,1,1600,success,0 +620089,1,1600,success,0 +620090,1,1600,success,0 +620091,1,1600,success,0 +620092,1,1600,success,0 +620093,1,1600,success,0 +620094,1,1600,success,0 +620095,1,1600,success,0 +620096,1,1600,success,0 +620097,1,1600,success,0 +620098,1,1600,success,0 +620099,1,1600,success,0 diff --git a/policies/wall_cupboard_close/kimi31pro-s2/policy.py b/policies/wall_cupboard_close/kimi31pro-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..25c45cdaf9b46afeb5250594455265ff4faa4864 --- /dev/null +++ b/policies/wall_cupboard_close/kimi31pro-s2/policy.py @@ -0,0 +1,107 @@ +"""Deterministic joint-space controller for the two wall-cabinet doors.""" + +import numpy as np + + +class Policy: + """Reach, close the right door, reposition, then close the left door.""" + + def reset(self, obs, tools): + self.action = np.asarray(tools.hold_action(), dtype=np.float32).copy() + self.start = np.asarray(obs["low_dim_obs"][21:25], dtype=np.float32).copy() + self.t = 0 + self.phase = "approach" + self.phase_start = 0 + + def act(self, obs, tools): + t = self.t + q = np.asarray(obs["low_dim_obs"], dtype=np.float32) + a = self.action.copy() + a[0:2] = 0.0 + a[3] = 0.0 + + sp, el, wp, wy = -1.8, 1.8, -0.6, 0.3 + lroll, rroll = 0.4, -0.4 + lgrip = rgrip = 0.0 + + if self.phase == "approach": + u = min(1.0, t / 100.0) + sp, el, wp, wy = sp * u, el * u, wp * u, wy * u + lroll, rroll = lroll * u, rroll * u + if t >= 110: + a[0] = 0.1 + a[1] = np.clip(1.2 * (self.start[1] - q[22]), -0.08, 0.08) + a[3] = np.clip(-q[24], -0.15, 0.15) + if t >= 140 and (q[21] > self.start[0] + 0.18 or t > 550): + self.phase, self.phase_start = "right", t + + elif self.phase == "right": + s = t - self.phase_start + a[0] = 0.06 + a[1] = np.clip(1.2 * (self.start[1] - q[22]), -0.06, 0.06) + a[3] = np.clip(-q[24], -0.12, 0.12) + lgrip = rgrip = float(s >= 30) + if s < 90: + rroll = -0.4 + elif s < 240: + rroll = -0.4 + 0.4 * (s - 90) / 150.0 + else: + rroll = 0.0 + if s >= 240: + self.phase, self.phase_start = "reposition", t + + elif self.phase == "reposition": + s = t - self.phase_start + rroll = -0.6 + a[0] = 0.12 + a[1] = np.clip(2.0 * (self.start[1] + 0.05 - q[22]), -0.1, 0.1) + a[3] = np.clip(-q[24], -0.12, 0.12) + if q[21] > self.start[0] + 0.30: + a[0] = 0.0 + if s >= 220: + self.phase, self.phase_start = "left_grasp", t + + elif self.phase == "left_grasp": + s = t - self.phase_start + rroll = -0.6 + lgrip = float(s >= 25) + a[0] = 0.06 + a[1] = np.clip(2.0 * (self.start[1] + 0.05 - q[22]), -0.08, 0.08) + a[3] = np.clip(-q[24], -0.12, 0.12) + if s >= 70: + self.phase, self.phase_start = "left_pull", t + + elif self.phase == "left_pull": + s = t - self.phase_start + rroll = -0.6 + lgrip = 1.0 + lroll = 0.4 - 0.7 * min(1.0, s / 250.0) + a[0] = 0.06 + a[1] = np.clip(2.0 * (self.start[1] + 0.05 - q[22]), -0.08, 0.08) + a[3] = np.clip(-q[24], -0.12, 0.12) + if s >= 260: + self.phase, self.phase_start = "right_return", t + + elif self.phase == "right_return": + s = t - self.phase_start + lroll = -0.3 + lgrip = rgrip = 1.0 + rroll = -0.6 + 0.9 * min(1.0, s / 250.0) + a[0] = 0.06 + a[1] = np.clip(2.0 * (self.start[1] + 0.05 - q[22]), -0.08, 0.08) + a[3] = np.clip(-q[24], -0.12, 0.12) + if s >= 260: + self.phase, self.phase_start = "hold", t + + else: + lroll, rroll = -0.3, 0.3 + lgrip = rgrip = 1.0 + + a[2] = 0.74 + a[4] = 0.0 + a[5:12] = [sp, lroll, 0.0, el, 0.0, wp, wy] + a[12:19] = [sp, rroll, 0.0, el, 0.0, wp, -wy] + a[19] = lgrip + a[20] = rgrip + self.t += 1 + return a diff --git a/policies/wall_cupboard_close/kimi31pro-s3/episodes.csv b/policies/wall_cupboard_close/kimi31pro-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..04b2b4953b3e4f0822f177c9ca1e963a8abffd41 --- /dev/null +++ b/policies/wall_cupboard_close/kimi31pro-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1700,timeout,0 +620001,0,1700,timeout,0 +620002,0,1700,timeout,0 +620003,0,1700,timeout,0 +620004,0,1700,timeout,0 +620005,0,1700,timeout,0 +620006,0,1700,timeout,0 +620007,0,1700,timeout,0 +620008,0,1700,timeout,0 +620009,0,1700,timeout,0 +620010,0,1700,timeout,0 +620011,0,1700,timeout,0 +620012,0,1700,timeout,0 +620013,0,1700,timeout,0 +620014,0,1700,timeout,0 +620015,0,1700,timeout,0 +620016,0,1700,timeout,0 +620017,0,1700,timeout,0 +620018,0,1700,timeout,0 +620019,0,1700,timeout,0 +620020,0,1700,timeout,0 +620021,0,1700,timeout,0 +620022,0,1700,timeout,0 +620023,0,1700,timeout,0 +620024,0,1700,timeout,0 +620025,0,1700,timeout,0 +620026,0,1700,timeout,0 +620027,0,1700,timeout,0 +620028,0,1700,timeout,0 +620029,0,1700,timeout,0 +620030,0,1700,timeout,0 +620031,0,1700,timeout,0 +620032,0,1700,timeout,0 +620033,0,1700,timeout,0 +620034,0,1700,timeout,0 +620035,0,1700,timeout,0 +620036,0,1700,timeout,0 +620037,0,1700,timeout,0 +620038,0,1700,timeout,0 +620039,0,1700,timeout,0 +620040,0,1700,timeout,0 +620041,0,1700,timeout,0 +620042,0,1700,timeout,0 +620043,0,1700,timeout,0 +620044,0,1700,timeout,0 +620045,0,1700,timeout,0 +620046,0,1700,timeout,0 +620047,0,1700,timeout,0 +620048,0,1700,timeout,0 +620049,0,1700,timeout,0 +620050,0,1700,timeout,0 +620051,0,1700,timeout,0 +620052,0,1700,timeout,0 +620053,0,1700,timeout,0 +620054,0,1700,timeout,0 +620055,0,1700,timeout,0 +620056,0,1700,timeout,0 +620057,0,1700,timeout,0 +620058,0,1700,timeout,0 +620059,0,1700,timeout,0 +620060,0,1700,timeout,0 +620061,0,1700,timeout,0 +620062,0,1700,timeout,0 +620063,0,1700,timeout,0 +620064,0,1700,timeout,0 +620065,0,1700,timeout,0 +620066,0,1700,timeout,0 +620067,0,1700,timeout,0 +620068,0,1700,timeout,0 +620069,0,1700,timeout,0 +620070,0,1700,timeout,0 +620071,0,1700,timeout,0 +620072,0,1700,timeout,0 +620073,0,1700,timeout,0 +620074,0,1700,timeout,0 +620075,0,1700,timeout,0 +620076,0,1700,timeout,0 +620077,0,1700,timeout,0 +620078,0,1700,timeout,0 +620079,0,1700,timeout,0 +620080,0,1700,timeout,0 +620081,0,1700,timeout,0 +620082,0,1700,timeout,0 +620083,0,1700,timeout,0 +620084,0,1700,timeout,0 +620085,0,1700,timeout,0 +620086,0,1700,timeout,0 +620087,0,1700,timeout,0 +620088,0,1700,timeout,0 +620089,0,1700,timeout,0 +620090,0,1700,timeout,0 +620091,0,1700,timeout,0 +620092,0,1700,timeout,0 +620093,0,1700,timeout,0 +620094,0,1700,timeout,0 +620095,0,1700,timeout,0 +620096,0,1700,timeout,0 +620097,0,1700,timeout,0 +620098,0,1700,timeout,0 +620099,0,1700,timeout,0 diff --git a/policies/wall_cupboard_close/kimi31pro-s3/policy.py b/policies/wall_cupboard_close/kimi31pro-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..c47e1540506f43042fdb6f56dcf38735bea11042 --- /dev/null +++ b/policies/wall_cupboard_close/kimi31pro-s3/policy.py @@ -0,0 +1,60 @@ +"""Deterministic, hand-written cabinet-door closing policy. + +The controller tries three non-learned contact motions. Each attempt releases +and recentres before the next one, and every attempt leaves time for the +one-second closed-door condition to be evaluated. +""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.yaw0 = float(obs["low_dim_obs"][24]) + + def _base(self, act, q, target_x): + """Closed-loop planar positioning; never integrate commanded velocity.""" + ex = target_x - float(q[21]) + ey = -float(q[22]) + act[0] = np.clip(3.0 * ex, -0.35, 0.35) if abs(ex) > 0.015 else 0.0 + act[1] = np.clip(2.5 * ey, -0.25, 0.25) if abs(ey) > 0.02 else 0.0 + act[3] = np.clip(-1.8 * (float(q[24]) - self.yaw0), -0.45, 0.45) + + def act(self, obs, tools): + t = int(obs["t"]) + q = obs["low_dim_obs"] + act = self.hold.copy() + act[5:19] = 0.0 + act[19:21] = 0.0 # open palms; no grasp or learned state is required + + if t < 550: + # Demonstration-inspired raised, bent-arm forward push. + local = t + f = min(1.0, local / 80.0) + release = max(0.0, 1.0 - (local - 320) / 150.0) if local >= 320 else 1.0 + target_x = 0.10 if local < 160 else (0.38 if local < 320 else -0.27) + act[5] = act[12] = -2.0 * f * release + act[8] = act[15] = 0.8 * f * release + act[10] = act[17] = 0.8 * f * release + elif t < 1100: + # Approach above the panels, then make a downward contact sweep. + local = t - 550 + f = min(1.0, local / 90.0) + g = min(1.0, max(0.0, (local - 170) / 140.0)) + release = max(0.0, 1.0 - (local - 400) / 150.0) if local >= 400 else 1.0 + target_x = 0.32 if local < 170 else (0.45 if local < 400 else -0.27) + act[5] = act[12] = (-3.0 + 1.7 * g) * f * release + act[10] = act[17] = f * release + else: + # Low handle-height inward sweep, followed by a full release. + local = t - 1100 + f = min(1.0, local / 80.0) + g = min(1.0, max(0.0, (local - 160) / 150.0)) + release = max(0.0, 1.0 - (local - 400) / 150.0) if local >= 400 else 1.0 + target_x = 0.10 if local < 160 else (0.38 if local < 400 else -0.27) + act[5] = act[12] = -0.25 * f * release + act[7], act[14] = -0.8 * g * f * release, 0.8 * g * f * release + + self._base(act, q, target_x) + return act diff --git a/policies/wall_cupboard_close/opus-s1/episodes.csv b/policies/wall_cupboard_close/opus-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..049dc48d034311333a50bd3585977bc68c9e4801 --- /dev/null +++ b/policies/wall_cupboard_close/opus-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,489,success,0 +620001,1,489,success,0 +620002,1,489,success,0 +620003,1,489,success,0 +620004,1,489,success,0 +620005,1,489,success,0 +620006,1,489,success,0 +620007,1,489,success,0 +620008,1,489,success,0 +620009,1,489,success,0 +620010,1,489,success,0 +620011,1,489,success,0 +620012,1,489,success,0 +620013,1,489,success,0 +620014,1,489,success,0 +620015,1,489,success,0 +620016,1,489,success,0 +620017,1,489,success,0 +620018,1,489,success,0 +620019,1,489,success,0 +620020,1,489,success,0 +620021,1,489,success,0 +620022,1,489,success,0 +620023,1,489,success,0 +620024,1,489,success,0 +620025,1,489,success,0 +620026,1,489,success,0 +620027,1,489,success,0 +620028,1,489,success,0 +620029,1,489,success,0 +620030,1,489,success,0 +620031,1,489,success,0 +620032,1,489,success,0 +620033,1,489,success,0 +620034,1,489,success,0 +620035,1,489,success,0 +620036,1,489,success,0 +620037,1,489,success,0 +620038,1,489,success,0 +620039,1,489,success,0 +620040,1,489,success,0 +620041,1,489,success,0 +620042,1,489,success,0 +620043,1,489,success,0 +620044,1,489,success,0 +620045,1,489,success,0 +620046,1,489,success,0 +620047,1,489,success,0 +620048,1,489,success,0 +620049,1,489,success,0 +620050,1,489,success,0 +620051,1,489,success,0 +620052,1,489,success,0 +620053,1,489,success,0 +620054,1,489,success,0 +620055,1,489,success,0 +620056,1,489,success,0 +620057,1,489,success,0 +620058,1,489,success,0 +620059,1,489,success,0 +620060,1,489,success,0 +620061,1,489,success,0 +620062,1,489,success,0 +620063,1,489,success,0 +620064,1,489,success,0 +620065,1,489,success,0 +620066,1,489,success,0 +620067,1,489,success,0 +620068,1,489,success,0 +620069,1,489,success,0 +620070,1,489,success,0 +620071,1,489,success,0 +620072,1,489,success,0 +620073,1,489,success,0 +620074,1,489,success,0 +620075,1,489,success,0 +620076,1,489,success,0 +620077,1,489,success,0 +620078,1,489,success,0 +620079,1,489,success,0 +620080,1,489,success,0 +620081,1,489,success,0 +620082,1,489,success,0 +620083,1,489,success,0 +620084,1,489,success,0 +620085,1,489,success,0 +620086,1,489,success,0 +620087,1,489,success,0 +620088,1,489,success,0 +620089,1,489,success,0 +620090,1,489,success,0 +620091,1,489,success,0 +620092,1,489,success,0 +620093,1,489,success,0 +620094,1,489,success,0 +620095,1,489,success,0 +620096,1,489,success,0 +620097,1,489,success,0 +620098,1,489,success,0 +620099,1,489,success,0 diff --git a/policies/wall_cupboard_close/opus-s1/policy.py b/policies/wall_cupboard_close/opus-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..fa91f42c816c7ce0a42689ed78f77a240045f296 --- /dev/null +++ b/policies/wall_cupboard_close/opus-s1/policy.py @@ -0,0 +1,227 @@ +"""Close both open doors of the wall cabinet. + +The scene layout is the same on every seed (checked from the wrist cameras): +the wall cabinet hangs ahead of the robot above the counter, both doors open +~90 degrees and stick out towards the robot. The policy walks up to the +counter (closed loop on the pelvis pose), then sweeps each hand from outside +its door inwards along the door's closing arc. Hand targets are world points +converted to joint angles with a hand-written G1 arm kinematic model. +""" + +import numpy as np + +# ---- G1 arm kinematics (approximate, from the G1 URDF) ---- + +def _rx(a): + c, s = np.cos(a), np.sin(a) + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + + +def _ry(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + + +def _rz(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def _rpy(r, p, y): + return _rz(y) @ _ry(p) @ _rx(r) + + +TORSO = np.array([-0.0039635, 0.0, 0.054]) +HAND_LEN = 0.12 # wrist yaw link -> grasp point along the hand + + +def fk(q, side, torso_pitch=0.0, hand_len=HAND_LEN): + """q: 7 joint angles. side: +1 left, -1 right. Returns (pos, R) of the hand + point relative to the pelvis (yaw-aligned frame).""" + s = side + R = _ry(torso_pitch) + p = R @ TORSO + # shoulder pitch joint frame + p = p + R @ np.array([0.0039563, s * 0.10022, 0.23778]) + R = R @ _rpy(s * 0.27931, 0, 0) + R = R @ _ry(q[0]) + p = p + R @ np.array([0, s * 0.038, -0.013831]) + R = R @ _rpy(-s * 0.27925, 0, 0) + R = R @ _rx(q[1]) + p = p + R @ np.array([0, s * 0.00624, -0.1032]) + R = R @ _rz(q[2]) + p = p + R @ np.array([0.015783, 0, -0.080518]) + R = R @ _ry(q[3]) + p = p + R @ np.array([0.1, s * 0.00188791, -0.01]) + R = R @ _rx(q[4]) + p = p + R @ np.array([0.038, 0, 0]) + R = R @ _ry(q[5]) + p = p + R @ np.array([0.046, 0, 0]) + R = R @ _rz(q[6]) + p = p + R @ np.array([hand_len, 0, 0]) + return p, R + + +LO = np.array([-3.0892, -1.5882, -2.618, -1.0472, -1.9722, -1.6144, -1.6144]) +HI = np.array([2.6704, 2.2515, 2.618, 2.0944, 1.9722, 1.6144, 1.6144]) + + +def limits(side): + if side > 0: + return LO.copy(), HI.copy() + lo, hi = LO.copy(), HI.copy() + # mirrored roll / yaw limits for the right arm + lo[1], hi[1] = -HI[1], -LO[1] + return lo, hi + + +def ik(target, side, q0, torso_pitch=0.0, iters=60, w_rest=0.002, rest=None, damp=0.01, + dirn=None, w_dir=0.0, joints=(0, 1, 2, 3)): + """Position IK over the given joints (others kept from q0).""" + q = np.array(q0, dtype=float) + lo, hi = limits(side) + rest = q.copy() if rest is None else np.asarray(rest, float) + J_idx = list(joints) + for _ in range(iters): + p, R = fk(q, side, torso_pitch) + err = target - p + rows = [err] + if dirn is not None and w_dir > 0: + rows.append(w_dir * (dirn - R[:, 0])) + e = np.concatenate(rows) + if np.linalg.norm(err) < 1e-4: + break + J = np.zeros((len(e), len(J_idx))) + for k, j in enumerate(J_idx): + dq = q.copy() + dq[j] += 1e-5 + p2, R2 = fk(dq, side, torso_pitch) + col = [(p2 - p) / 1e-5] + if dirn is not None and w_dir > 0: + col.append(w_dir * (R2[:, 0] - R[:, 0]) / 1e-5) + J[:, k] = np.concatenate(col) + A = J.T @ J + damp * np.eye(len(J_idx)) + b = J.T @ e + w_rest * (rest[J_idx] - q[J_idx]) + dq = np.linalg.solve(A, b) + q[J_idx] = np.clip(q[J_idx] + np.clip(dq, -0.3, 0.3), lo[J_idx], hi[J_idx]) + return q + + +# ---- geometry / tuning constants (world frame, metres) ---- +STAND_X = 0.22 # pelvis x to walk to +STAND_Y = 0.0 +Z_PUSH = 1.22 # hand height while pushing the doors +OFF_X = OFF_Y = OFF_Z = 0.0 # global shift of all hand targets (sensitivity tests) + +HINGE_X, HINGE_Y = 0.61, 0.28 # left door hinge (estimated from wrist-camera views) +ARC_R = 0.19 # push radius along the door, from the hinge + + +def _arc(phi_deg, r=ARC_R): + p = np.radians(phi_deg) + return (HINGE_X - r * np.sin(p), HINGE_Y - r * np.cos(p)) + + +# left-hand waypoints (x, y, z, duration_steps); right hand mirrors y +WAYPOINTS = [ + (0.45, 0.20, 1.00, 50), + (0.40, 0.50, 1.00, 50), + (0.40, 0.50, Z_PUSH, 40), + (*_arc(120), Z_PUSH, 30), + (*_arc(90), Z_PUSH, 40), + (*_arc(60), Z_PUSH, 40), + (*_arc(30), Z_PUSH, 40), + (*_arc(5), Z_PUSH, 40), + (*_arc(-5), Z_PUSH, 40), + (*_arc(-5), Z_PUSH, 100), +] +CARRY = np.array([-0.2, 0.25, 0.0, -0.9, 0.0, 0.0, 0.0]) # left arm while walking +REST = np.array([-1.3, 0.3, 0.0, 0.8, 0.0, 0.0, 0.0]) # IK posture bias (left) + + +def mirror(q): + return np.asarray(q, float) * np.array([1, -1, -1, 1, -1, 1, -1]) + + +class Policy: + """The control policy that is scored on the hidden seeds.""" + + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float64) + self.phase = "walk" + self.t_phase = 0 + self.settle = 0 + self.qL = CARRY.copy() + self.qR = mirror(CARRY) + self.wp_i = 0 + self.wp_t = 0 + self.prev = None + + def _base(self, lo): + x, y, yaw = lo[21], lo[22], lo[24] + ex, ey = STAND_X - x, STAND_Y - y + c, s = np.cos(yaw), np.sin(yaw) + bx, by = c * ex + s * ey, -s * ex + c * ey + vx = np.clip(1.5 * bx, -0.3, 0.3) + vy = np.clip(1.5 * by, -0.2, 0.2) + if np.hypot(vx, vy) < 0.06: + if np.hypot(bx, by) > 0.025: + k = 0.06 / max(np.hypot(vx, vy), 1e-6) + vx, vy = vx * k, vy * k + else: + vx, vy = 0.0, 0.0 + wz = np.clip(-2.0 * yaw, -0.5, 0.5) + return vx, vy, wz, np.hypot(bx, by) + + def _hand_target(self, wp, lo, side): + x, y, yaw = lo[21], lo[22], lo[24] + pz = lo[23] + wx, wy, wz = wp[0] + OFF_X, side * wp[1] + OFF_Y, wp[2] + OFF_Z + dx, dy = wx - x, wy - y + c, s = np.cos(yaw), np.sin(yaw) + return np.array([c * dx + s * dy, -s * dx + c * dy, wz - pz]) + + def act(self, obs, tools): + lo = np.asarray(obs["low_dim_obs"], dtype=np.float64) + raw = self.hold.copy() + raw[19] = raw[20] = 0.0 + raw[2] = 0.74 + raw[4] = 0.0 + self.t_phase += 1 + if self.phase == "walk": + vx, vy, wz, d = self._base(lo) + raw[0], raw[1], raw[3] = vx, vy, wz + if d < 0.03 and abs(lo[24]) < 0.03: + self.settle += 1 + else: + self.settle = 0 + if self.settle > 15 or self.t_phase > 400: + self.phase = "reach" + self.t_phase = 0 + elif self.phase == "reach": + vx, vy, wz, d = self._base(lo) + # small corrections only + if d > 0.05: + raw[0], raw[1] = vx, vy + raw[3] = wz if abs(lo[24]) > 0.02 else 0.0 + # interpolate waypoints + if self.wp_i < len(WAYPOINTS): + wp = WAYPOINTS[self.wp_i] + if self.prev is None: + self.prev = np.array(wp[:3]) + f = min(1.0, (self.wp_t + 1) / wp[3]) + tgt = self.prev + (np.array(wp[:3]) - self.prev) * f + self.wp_t += 1 + if self.wp_t >= wp[3]: + self.prev = np.array(wp[:3]) + self.wp_i += 1 + self.wp_t = 0 + else: + tgt = self.prev + pl = self._hand_target(tgt, lo, +1) + pr = self._hand_target(tgt, lo, -1) + self.qL = ik(pl, +1, self.qL, iters=10, rest=REST) + self.qR = ik(pr, -1, self.qR, iters=10, rest=mirror(REST)) + raw[5:12] = self.qL + raw[12:19] = self.qR + return raw diff --git a/policies/wall_cupboard_close/opus-s2/episodes.csv b/policies/wall_cupboard_close/opus-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..1fe1df79f60ea16d5fe1fcba842af2e5a8f38ecc --- /dev/null +++ b/policies/wall_cupboard_close/opus-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,617,success,0 +620001,1,617,success,0 +620002,1,617,success,0 +620003,1,617,success,0 +620004,1,617,success,0 +620005,1,617,success,0 +620006,1,617,success,0 +620007,1,617,success,0 +620008,1,617,success,0 +620009,1,617,success,0 +620010,1,617,success,0 +620011,1,617,success,0 +620012,1,617,success,0 +620013,1,617,success,0 +620014,1,617,success,0 +620015,1,617,success,0 +620016,1,617,success,0 +620017,1,617,success,0 +620018,1,617,success,0 +620019,1,617,success,0 +620020,1,617,success,0 +620021,1,617,success,0 +620022,1,617,success,0 +620023,1,617,success,0 +620024,1,617,success,0 +620025,1,617,success,0 +620026,1,617,success,0 +620027,1,617,success,0 +620028,1,617,success,0 +620029,1,617,success,0 +620030,1,617,success,0 +620031,1,617,success,0 +620032,1,617,success,0 +620033,1,617,success,0 +620034,1,617,success,0 +620035,1,617,success,0 +620036,1,617,success,0 +620037,1,617,success,0 +620038,1,617,success,0 +620039,1,617,success,0 +620040,1,617,success,0 +620041,1,617,success,0 +620042,1,617,success,0 +620043,1,617,success,0 +620044,1,617,success,0 +620045,1,617,success,0 +620046,1,617,success,0 +620047,1,617,success,0 +620048,1,617,success,0 +620049,1,617,success,0 +620050,1,617,success,0 +620051,1,617,success,0 +620052,1,617,success,0 +620053,1,617,success,0 +620054,1,617,success,0 +620055,1,617,success,0 +620056,1,617,success,0 +620057,1,617,success,0 +620058,1,617,success,0 +620059,1,617,success,0 +620060,1,617,success,0 +620061,1,617,success,0 +620062,1,617,success,0 +620063,1,617,success,0 +620064,1,617,success,0 +620065,1,617,success,0 +620066,1,617,success,0 +620067,1,617,success,0 +620068,1,617,success,0 +620069,1,617,success,0 +620070,1,617,success,0 +620071,1,617,success,0 +620072,1,617,success,0 +620073,1,617,success,0 +620074,1,617,success,0 +620075,1,617,success,0 +620076,1,617,success,0 +620077,1,617,success,0 +620078,1,617,success,0 +620079,1,617,success,0 +620080,1,617,success,0 +620081,1,617,success,0 +620082,1,617,success,0 +620083,1,617,success,0 +620084,1,617,success,0 +620085,1,617,success,0 +620086,1,617,success,0 +620087,1,617,success,0 +620088,1,617,success,0 +620089,1,617,success,0 +620090,1,617,success,0 +620091,1,617,success,0 +620092,1,617,success,0 +620093,1,617,success,0 +620094,1,617,success,0 +620095,1,617,success,0 +620096,1,617,success,0 +620097,1,617,success,0 +620098,1,617,success,0 +620099,1,617,success,0 diff --git a/policies/wall_cupboard_close/opus-s2/policy.py b/policies/wall_cupboard_close/opus-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..7d1eb11639697c9ab2ab19034f0252e6b52cd28b --- /dev/null +++ b/policies/wall_cupboard_close/opus-s2/policy.py @@ -0,0 +1,215 @@ +"""Wall cabinet door closing policy for the G1. + +Strategy (from the demonstration and probing): + 1. Raise the pelvis, walk ~0.4 m forward to stand in front of the counter. + 2. Lift both hands outside the two open doors (doors open ~90 deg, hinged on + the outer edges of the wall cabinet, free edges pointing at the robot). + 3. Sweep each hand along an arc around its door hinge, pushing the outer face + of the door until it is shut. Then hold. + +Arm motion uses a hand-written forward-kinematics model of the G1 arm and a +small numerical IK (scipy least squares) for hand positions; targets are given +in the world frame and converted with the measured pelvis pose every step. +""" + +import cv2 # noqa: F401 +import numpy as np +from scipy.optimize import least_squares + + +# ---------------------------------------------------------------- kinematics +def _rx(a): + c, s = np.cos(a), np.sin(a) + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + + +def _ry(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + + +def _rz(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def _T(R=None, p=(0, 0, 0)): + M = np.eye(4) + if R is not None: + M[:3, :3] = R + M[:3, 3] = p + return M + + +def hand_pos(q, side, waist=(0.0, 0.0, 0.0), hand_len=0.12): + """Hand point in the pelvis frame for 4 arm joints (wrist joints at 0).""" + s = 1 if side == "left" else -1 + M = _T(_rz(waist[0])) + M = M @ _T(_rx(waist[1]), (-0.0039635, 0, 0.035)) + M = M @ _T(_ry(waist[2]), (0, 0, 0.019)) + M = M @ _T(_rz(0) @ _ry(0) @ _rx(s * 0.27931), (0.0039563, s * 0.10022, 0.24778)) @ _T(_ry(q[0])) + M = M @ _T(_rx(-s * 0.27925), (0, s * 0.038, -0.013831)) @ _T(_rx(q[1])) + M = M @ _T(None, (0, s * 0.00624, -0.1032)) @ _T(_rz(q[2])) + M = M @ _T(None, (0.015783, 0, -0.080518)) @ _T(_ry(q[3])) + M = M @ _T(None, (0.100 + 0.038 + 0.046 + hand_len, s * 0.00188791, -0.010)) + return M[:3, 3] + + +_LO = np.array([-3.0892, -1.5882, -2.618, -1.0472]) +_HI = np.array([2.6704, 2.2515, 2.618, 2.0944]) + + +def solve_ik(target, side, q0): + s = 1 if side == "left" else -1 + lo, hi = _LO.copy(), _HI.copy() + if s < 0: + lo[1], hi[1] = -_HI[1], -_LO[1] + lo[2], hi[2] = -_HI[2], -_LO[2] + nominal = np.array([-1.5, 0.4 * s, 0.0, 1.0]) + q0 = np.clip(q0, lo + 1e-3, hi - 1e-3) + + def res(q): + return np.r_[hand_pos(q, side) - target, 0.01 * (q - nominal)] + + return least_squares(res, q0, bounds=(lo, hi)).x + + +# gravity sag feed-forward on (shoulder pitch, roll, yaw, elbow) +FF = np.array([-0.045, 0.0, 0.0, -0.03]) + +# ---------------------------------------------------------------- scene plan +STAND = np.array([0.18, 0.0]) # pelvis target in front of the counter +PRESS = 0.03 # final push past the closed door plane +HEIGHT = 0.85 +HINGE = (0.63, 0.30) # left door hinge (x, y); right door mirrored +Z = 1.27 # sweep height (world) +RADIUS = 0.24 # push radius from the hinge +STANDOFF = 0.04 # hand offset from the door's outer face + + +def door_pt(th_deg): + th = np.deg2rad(th_deg) + x = HINGE[0] - RADIUS * np.sin(th) - STANDOFF * np.cos(th) + y = HINGE[1] - RADIUS * np.cos(th) + STANDOFF * np.sin(th) + return np.array([x, y, Z]) + + +def build_waypoints(): + """List of (left world point, steps to reach it); right hand mirrored.""" + wps = [(np.array([0.27, 0.50, 1.15]), 60), + (np.array([0.33, 0.50, Z]), 60)] + for th in [100, 80, 60, 40, 25, 12, 0]: + wps.append((door_pt(th), 45)) + # final press into the closed doors + wps.append((np.array([HINGE[0] + PRESS, HINGE[1] - RADIUS, Z]), 40)) + return wps + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float64) + self.phase = "walk" + self.t_phase = 0 + self.wps = build_waypoints() + self.wp_i = 0 + self.wp_t = 0 + lo = obs["low_dim_obs"] + self.prev_l = hand_pos(lo[3:7], "left") + self.prev_r = hand_pos(lo[12:16], "right") + self.prev_l_world = None + self.ql = np.array([-1.5, 0.3, 0.0, 1.0]) + self.qr = np.array([-1.5, -0.3, 0.0, 1.0]) + self.settle = 0 + + # ---------------------------------------------------------- helpers + def _base(self, a, lo, target_xy, max_v=0.25): + yaw = lo[24] + a[3] = np.clip(-2.0 * yaw, -0.5, 0.5) + dx, dy = target_xy[0] - lo[21], target_xy[1] - lo[22] + c, s = np.cos(yaw), np.sin(yaw) + bx, by = c * dx + s * dy, -s * dx + c * dy + dist = np.hypot(bx, by) + a[0] = a[1] = 0.0 + if dist > 0.03: + v = np.array([bx, by]) * 1.5 + sp = np.linalg.norm(v) + v *= np.clip(sp, 0.06, max_v) / sp + a[0], a[1] = v + return dist + + @staticmethod + def _to_rel(pw, lo): + yaw = lo[24] + d = pw[:2] - lo[21:23] + c, s = np.cos(yaw), np.sin(yaw) + return np.array([c * d[0] + s * d[1], -s * d[0] + c * d[1], pw[2] - lo[23]]) + + @staticmethod + def _to_world(pr, lo): + yaw = lo[24] + c, s = np.cos(yaw), np.sin(yaw) + return np.array([lo[21] + c * pr[0] - s * pr[1], lo[22] + s * pr[0] + c * pr[1], pr[2] + lo[23]]) + + def _arms(self, a, lo, pl_world): + pr_world = pl_world * np.array([1, -1, 1]) + self.ql = solve_ik(self._to_rel(pl_world, lo), "left", self.ql) + self.qr = solve_ik(self._to_rel(pr_world, lo), "right", + self.ql * np.array([1, -1, -1, 1])) + a[5:9] = self.ql + FF + a[12:16] = self.qr + FF * np.array([1, -1, -1, 1]) + a[9:12] = 0.0 + a[16:19] = 0.0 + + # ---------------------------------------------------------- main + def act(self, obs, tools): + lo = np.asarray(obs["low_dim_obs"], dtype=np.float64) + a = self.hold.copy() + a[2] = HEIGHT + a[4] = 0.0 + self.t_phase += 1 + + if self.phase == "walk": + dist = self._base(a, lo, STAND) + if dist < 0.03: + self.settle += 1 + else: + self.settle = 0 + if self.settle >= 10 or self.t_phase > 400: + self.phase = "lift" + self.t_phase = 0 + # joint-space move to the first waypoint + p0 = self.wps[0][0] + self.ql = solve_ik(self._to_rel(p0, lo), "left", np.array([-1.5, 0.3, 0.0, 1.0])) + self.qr = solve_ik(self._to_rel(p0 * np.array([1, -1, 1]), lo), "right", + self.ql * np.array([1, -1, -1, 1])) + self.q_start = np.r_[lo[3:7], lo[12:16]] + self.prev_l_world = p0 + self.wp_i = 1 + return a + + self._base(a, lo, STAND, max_v=0.2) + if self.phase == "lift": + t = min(1.0, self.t_phase / 50.0) + q_goal = np.r_[self.ql + FF, self.qr + FF * np.array([1, -1, -1, 1])] + q = (1 - t) * self.q_start + t * q_goal + a[5:9], a[12:16] = q[:4], q[4:] + a[9:12] = 0.0 + a[16:19] = 0.0 + if self.t_phase >= 60: + self.phase = "arms" + self.hold[5:19] = a[5:19] + return a + if self.wp_i < len(self.wps): + target, n = self.wps[self.wp_i] + self.wp_t += 1 + t = min(1.0, self.wp_t / n) + p = (1 - t) * self.prev_l_world + t * target + if self.wp_t >= n: + self.prev_l_world = target + self.wp_i += 1 + self.wp_t = 0 + else: + p = self.prev_l_world + self._arms(a, lo, p) + self.hold[5:19] = a[5:19] + return a diff --git a/policies/wall_cupboard_close/opus-s3/episodes.csv b/policies/wall_cupboard_close/opus-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..7f9ef050abf0c3d3b616027c5312276344aa4bde --- /dev/null +++ b/policies/wall_cupboard_close/opus-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1509,success,0 +620001,1,1509,success,0 +620002,1,1509,success,0 +620003,1,1509,success,0 +620004,1,1509,success,0 +620005,1,1509,success,0 +620006,1,1509,success,0 +620007,1,1509,success,0 +620008,1,1509,success,0 +620009,1,1509,success,0 +620010,1,1509,success,0 +620011,1,1509,success,0 +620012,1,1509,success,0 +620013,1,1509,success,0 +620014,1,1509,success,0 +620015,1,1509,success,0 +620016,1,1509,success,0 +620017,1,1509,success,0 +620018,1,1509,success,0 +620019,1,1509,success,0 +620020,1,1509,success,0 +620021,1,1509,success,0 +620022,1,1509,success,0 +620023,1,1509,success,0 +620024,1,1509,success,0 +620025,1,1509,success,0 +620026,1,1509,success,0 +620027,1,1509,success,0 +620028,1,1509,success,0 +620029,1,1509,success,0 +620030,1,1509,success,0 +620031,1,1509,success,0 +620032,1,1509,success,0 +620033,1,1509,success,0 +620034,1,1509,success,0 +620035,1,1509,success,0 +620036,1,1509,success,0 +620037,1,1509,success,0 +620038,1,1509,success,0 +620039,1,1509,success,0 +620040,1,1509,success,0 +620041,1,1509,success,0 +620042,1,1509,success,0 +620043,1,1509,success,0 +620044,1,1509,success,0 +620045,1,1509,success,0 +620046,1,1509,success,0 +620047,1,1509,success,0 +620048,1,1509,success,0 +620049,1,1509,success,0 +620050,1,1509,success,0 +620051,1,1509,success,0 +620052,1,1509,success,0 +620053,1,1509,success,0 +620054,1,1509,success,0 +620055,1,1509,success,0 +620056,1,1509,success,0 +620057,1,1509,success,0 +620058,1,1509,success,0 +620059,1,1509,success,0 +620060,1,1509,success,0 +620061,1,1509,success,0 +620062,1,1509,success,0 +620063,1,1509,success,0 +620064,1,1509,success,0 +620065,1,1509,success,0 +620066,1,1509,success,0 +620067,1,1509,success,0 +620068,1,1509,success,0 +620069,1,1509,success,0 +620070,1,1509,success,0 +620071,1,1509,success,0 +620072,1,1509,success,0 +620073,1,1509,success,0 +620074,1,1509,success,0 +620075,1,1509,success,0 +620076,1,1509,success,0 +620077,1,1509,success,0 +620078,1,1509,success,0 +620079,1,1509,success,0 +620080,1,1509,success,0 +620081,1,1509,success,0 +620082,1,1509,success,0 +620083,1,1509,success,0 +620084,1,1509,success,0 +620085,1,1509,success,0 +620086,1,1509,success,0 +620087,1,1509,success,0 +620088,1,1509,success,0 +620089,1,1509,success,0 +620090,1,1509,success,0 +620091,1,1509,success,0 +620092,1,1509,success,0 +620093,1,1509,success,0 +620094,1,1509,success,0 +620095,1,1509,success,0 +620096,1,1509,success,0 +620097,1,1509,success,0 +620098,1,1509,success,0 +620099,1,1509,success,0 diff --git a/policies/wall_cupboard_close/opus-s3/policy.py b/policies/wall_cupboard_close/opus-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..c9815a02745aea978bff5dc1dd865befcedeaabb --- /dev/null +++ b/policies/wall_cupboard_close/opus-s3/policy.py @@ -0,0 +1,308 @@ +"""Close both open doors of the wall cabinet (Unitree G1). + +Hand-written scripted controller: + 1. walk in front of the left door, reach around the outside of the open door + with the left hand and sweep it inwards (door ends ~30 deg open); + 2. same with the right hand for the right door; + 3. step up close to the counter with the arms tucked, then swing both arms + forward/up through the doorway to push both doors shut, and keep pushing. + +Hand targets are given in the world frame and converted to joint targets with a +small numerical IK on an analytic model of the G1 arm (MuJoCo menagerie link +offsets). The measured waist joints are fed into the kinematics so the hands +stay put while the whole-body controller leans the torso; the torso pitch +command is integrated to keep the waist pitch near a target. +""" + +import cv2 # noqa: F401 +import numpy as np +import scipy # noqa: F401 +from scipy.optimize import least_squares + +# ---------------------------------------------------------------------------- +# Arm kinematics +# ---------------------------------------------------------------------------- + + +def _rx(a): + c, s = np.cos(a), np.sin(a) + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + + +def _ry(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + + +def _rz(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def _quat(w, x, y, z): + q = np.array([w, x, y, z]) / np.linalg.norm([w, x, y, z]) + w, x, y, z = q + return np.array([ + [1 - 2 * (y * y + z * z), 2 * (x * y - z * w), 2 * (x * z + y * w)], + [2 * (x * y + z * w), 1 - 2 * (x * x + z * z), 2 * (y * z - x * w)], + [2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y)]]) + + +_QS = _quat(0.990264, 0.139201, 0, 0) +_QR = _quat(0.990268, -0.139172, 0, 0) +TOOL = 0.10 # hand point beyond the wrist yaw joint + +MIR = np.array([1, -1, -1, 1, -1, 1, -1]) +_LO = np.array([-3.0892, -1.5882, -2.618, -1.0472, -1.97222, -1.61443, -1.61443]) +_HI = np.array([2.6704, 2.2515, 2.618, 2.0944, 1.97222, 1.61443, 1.61443]) + + +def arm_fk(q, side, waist): + """Hand point and orientation in the pelvis frame (pelvis assumed level). + + side=+1 left arm, -1 right arm; waist = (yaw, roll, pitch) joint angles.""" + sp, sr, sy, el, wr, wp, wy = q + R = _rz(waist[0]) @ _rx(waist[1]) @ _ry(waist[2]) + p = R @ np.array([0.0, 0, 0.054]) + p = p + R @ np.array([0.0039563, side * 0.10022, 0.24778]) + qs = _QS if side == 1 else _QS.T + qr = _QR if side == 1 else _QR.T + R = R @ qs @ _ry(sp) + p = p + R @ np.array([0, side * 0.038, -0.013831]) + R = R @ qr @ _rx(sr) + p = p + R @ np.array([0, side * 0.00624, -0.1032]) + R = R @ _rz(sy) + p = p + R @ np.array([0.015783, 0, -0.080518]) + R = R @ _ry(el) + p = p + R @ np.array([0.1, side * 0.00188791, -0.01]) + R = R @ _rx(wr) + p = p + R @ np.array([0.038, 0, 0]) + R = R @ _ry(wp) + p = p + R @ np.array([0.046, 0, 0]) + R = R @ _rz(wy) + p = p + R @ np.array([TOOL, 0, 0]) + return p, R + + +def _limits(side): + if side == 1: + return _LO, _HI + lo, hi = _LO * MIR, _HI * MIR + return np.minimum(lo, hi), np.maximum(lo, hi) + + +def arm_ik(target, side, q0, dirn, waist, wdir=0.1, reg=0.02): + """Hand point to target (pelvis frame), hand x-axis softly along dirn.""" + lo, hi = _limits(side) + q0 = np.clip(np.asarray(q0, float), lo + 1e-3, hi - 1e-3) + + def res(q): + p, R = arm_fk(q, side, waist) + return np.concatenate([p - target, wdir * (R[:, 0] - dirn), reg * (q - q0)]) + + sol = least_squares(res, q0, bounds=(lo, hi)) + return sol.x + + +# ---------------------------------------------------------------------------- +# Script +# ---------------------------------------------------------------------------- + +Z = 1.32 # pushing height (world z); door bottoms are at ~1.22 +TUCK = [0.0, 0.15, 0, -1.0, 0, 0, 0] +PRE = [-1.2, 0.3, 0.0, 0.6, 0.0, 0.0, 0.0] + + +def _mir(q): + return list(np.asarray(q) * MIR) + + +SWEEP_T = (60, 60, 40, 120, 30) + + +def _door(s, T=SWEEP_T): + """Segments that sweep one door (s=+1 left, -1 right) from its outer side.""" + left = s > 0 + + def arm(n, p): + p = (p[0], s * p[1], p[2]) + return ('arms', n, p, None) if left else ('arms', n, None, p) + return [ + ('walk', 0.0, s * 0.15, 0.025, 250), + ('height', 20, 0.85), + arm(T[0], (0.15, 0.22, Z)), # in front of the door's free edge + arm(T[1], (0.15, 0.48, Z)), # out past the door + arm(T[2], (0.32, 0.48, Z)), # forward, outside the door + arm(T[3], (0.32, 0.05, Z)), # sweep inwards + arm(T[4], (0.20, 0.12, Z)), + ('joints', 30, TUCK, None) if left else ('joints', 30, None, _mir(TUCK)), + ('height', 15, 0.74), + ] + + +def _both(n, p): + return ('arms', n, p, (p[0], -p[1], p[2])) + + +def _push(): + return [ + ('joints', 30, PRE, _mir(PRE)), # swing up: pushes both doors shut + _both(30, (0.30, 0.15, 1.12)), + _both(30, (0.30, 0.15, Z)), + ('set', 'waist_target', 0.30), + _both(80, (0.68, 0.15, Z)), + ('hold', 60), + ('set', 'waist_target', 0.05), + _both(30, (0.35, 0.15, Z)), + ('joints', 30, TUCK, _mir(TUCK)), + ] + + +def _swing(pre, x=0.12): + """Step up to the cabinet with tucked arms and swing both arms up/forward.""" + return [ + ('joints', 20, TUCK, _mir(TUCK)), + ('height', 15, 0.74), + ('walk', x, 0.0, 0.025, 120), + ('height', 20, 0.85), + ('joints', 30, pre, _mir(pre)), + ('hold', 10), + ] + + +def make_script(T=SWEEP_T): + return _door(1, T) + _door(-1, T) + _swing(PRE) + _swing(PRE) + \ + _swing([-1.2, 0.2, 0.0, 0.5, 0.0, 0.0, 0.0], 0.14) + _swing(PRE) + _swing(PRE) + \ + _swing(PRE) + [('joints', 20, TUCK, _mir(TUCK)), ('hold', 10000)] + + +SCRIPT = make_script() + + +class Policy: + """The control policy that is scored on the hidden seeds.""" + + GRIP = 0.0 + RATE = 0.04 # max joint target change per step (rad) + HAND_DIR = np.array([1.0, 0.0, 0.0]) + + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.seg = 0 + self.tseg = 0 + self.qL = np.zeros(7) + self.qR = np.zeros(7) + self.tgtL = self.tgtR = None + self.startL = self.startR = None + self.height = 0.74 + self.pcmd = 0.0 + self.waist_target = 0.05 + self.j0 = None + self.h0 = 0.74 + + # -- helpers + @staticmethod + def _base(lo, a, goal): + x, y, yaw = lo[21], lo[22], lo[24] + ex, ey = goal[0] - x, goal[1] - y + c, s = np.cos(yaw), np.sin(yaw) + bx, by = c * ex + s * ey, -s * ex + c * ey + vx = np.clip(1.2 * bx, -0.2, 0.2) + vy = np.clip(1.2 * by, -0.2, 0.2) + sp = np.hypot(vx, vy) + close = np.hypot(bx, by) <= goal[2] + if sp < 0.06: + if not close: + vx, vy = vx / max(sp, 1e-6) * 0.07, vy / max(sp, 1e-6) * 0.07 + else: + vx = vy = 0.0 + a[0], a[1] = vx, vy + a[3] = np.clip(-1.5 * yaw, -0.4, 0.4) + return close + + @staticmethod + def _to_pelvis(pw, lo): + rel = np.asarray(pw, float) - np.array([lo[21], lo[22], lo[23]]) + return _rz(-lo[24]) @ rel + + def _solve(self, tgt, side, qcur, waist): + dirn = self.HAND_DIR if side == 1 else self.HAND_DIR * np.array([1, -1, 1]) + q = arm_ik(tgt, side, qcur, dirn, waist) + return qcur + np.clip(q - qcur, -self.RATE, self.RATE) + + def _step_script(self, lo, a): + """Advance the current segment; returns True while walking.""" + if self.seg >= len(SCRIPT): + return False + s = SCRIPT[self.seg] + kind = s[0] + fin = False + walking = False + if kind == 'walk': + walking = True + fin = self._base(lo, a, s[1:4]) and self.tseg > 20 + if self.tseg > s[4]: + fin = True + elif kind == 'arms': + n = s[1] + if self.tseg == 0: + self.startL, self.startR = self.tgtL, self.tgtR + f = min(1.0, (self.tseg + 1) / n) + for side, goal in (('L', s[2]), ('R', s[3])): + if goal is None: + continue + goal = np.asarray(goal, float) + start = self.startL if side == 'L' else self.startR + cur = goal if start is None else start + (goal - start) * f + if side == 'L': + self.tgtL = cur + else: + self.tgtR = cur + fin = self.tseg + 1 >= n + elif kind == 'joints': + n = s[1] + if self.tseg == 0: + self.j0 = (self.qL.copy(), self.qR.copy()) + f = min(1.0, (self.tseg + 1) / n) + if s[2] is not None: + self.qL = self.j0[0] + (np.asarray(s[2]) - self.j0[0]) * f + self.tgtL = None + if s[3] is not None: + self.qR = self.j0[1] + (np.asarray(s[3]) - self.j0[1]) * f + self.tgtR = None + fin = self.tseg + 1 >= n + elif kind == 'height': + n, h = s[1], s[2] + if self.tseg == 0: + self.h0 = self.height + self.height = self.h0 + (h - self.h0) * min(1.0, (self.tseg + 1) / n) + fin = self.tseg + 1 >= n + elif kind == 'set': + setattr(self, s[1], s[2]) + fin = True + elif kind == 'hold': + fin = self.tseg + 1 >= s[1] + self.tseg += 1 + if fin: + self.seg += 1 + self.tseg = 0 + return walking + + def act(self, obs, tools): + lo = np.asarray(obs['low_dim_obs'], dtype=float) + a = self.hold.copy() + a[19] = a[20] = self.GRIP + # keep the torso near the waist-pitch target + self.pcmd = float(np.clip(self.pcmd - 0.03 * (lo[2] - self.waist_target), -0.2, 0.4)) + a[4] = self.pcmd + walking = self._step_script(lo, a) + a[2] = self.height + if not walking: + waist = lo[0:3] + if self.tgtL is not None: + self.qL = self._solve(self._to_pelvis(self.tgtL, lo), 1, self.qL, waist) + if self.tgtR is not None: + self.qR = self._solve(self._to_pelvis(self.tgtR, lo), -1, self.qR, waist) + a[5:12] = self.qL + a[12:19] = self.qR + return a diff --git a/policies/wall_cupboard_open/astra-s1/episodes.csv b/policies/wall_cupboard_open/astra-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/astra-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/astra-s1/policy.py b/policies/wall_cupboard_open/astra-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..ba9f7702969c6005c134fde2a0a9dc8e7914d2f5 --- /dev/null +++ b/policies/wall_cupboard_open/astra-s1/policy.py @@ -0,0 +1,74 @@ +"""Deterministic visual alignment and coordinated cabinet-door pull.""" +import cv2 +import numpy as np +from scipy.spatial.transform import Rotation + + +def handle_column(image): + value = image.mean(axis=2) + chroma = image.max(axis=2).astype(float) - image.min(axis=2) + mask = ((value > 45) & (value < 140) & (chroma < 18)).astype(np.uint8) + mask[28:] = 0 + _, _, components, _ = cv2.connectedComponentsWithStats(mask) + candidates = [] + for x, y, width, height, area in components[1:]: + if height >= 12 and 4 <= width < 35 and area > height * 3: + candidates.append((int(area), float(x + width / 2))) + return max(candidates)[1] if candidates else None + + +class Policy: + def reset(self, obs, tools): + self.action = np.asarray(tools.hold_action(), dtype=np.float64) + self.wrist_yaw = [0.0, 0.0] + + def act(self, obs, tools): + t = int(obs['t']) + q = obs['low_dim_obs'] + a = self.action.copy() + a[2] = .74 + a[4] = 0.0 + if t < 100: + x_goal, grip = .12, .6 + elif t < 300: + x_goal, grip = .29, .6 + elif t < 380: + x_goal, grip = .29, .9 + else: + f = np.clip((t - 380) / 400., 0., 1.) + x_goal, grip = .29 - .27 * f, .9 + + if 160 < t < 290 and t % 10 == 0: + for side, camera in enumerate(('left_wrist', 'right_wrist')): + column = handle_column(tools.image(camera)) + if column is not None: + self.wrist_yaw[side] = float(np.clip( + self.wrist_yaw[side] - .002 * (column - 42), -.4, .4)) + + for side, start in enumerate((5, 12)): + sign = 1 if side == 0 else -1 + a[start:start+7] = [-.9, 0, 0, -.3, 0, .2, self.wrist_yaw[side]] + if t >= 380: + f = np.clip((t - 380) / 400., 0., 1.) + extension = np.clip((t - 780) / 350., 0., 1.) + pitch = -.9 - .4 * extension + roll = sign * (.65 * f + .45 * extension) + yaw = sign * (.3 * f + .7 * extension) + elbow = -.3 + .8 * extension + a[start:start+4] = [pitch, roll, yaw, elbow] + forearm = (Rotation.from_euler('Y', pitch) + * Rotation.from_euler('X', roll) + * Rotation.from_euler('Z', yaw) + * Rotation.from_euler('Y', elbow)) + orientation = (Rotation.from_euler('Z', -sign * (1.1*f + .45*extension)) + * Rotation.from_euler('Y', -1.0)) + angles = (forearm.inv() * orientation).as_euler('XYZ') + a[start+4:start+7] = np.clip(angles, [-1.95, -1.60, -1.60], [1.95, 1.60, 1.60]) + x_goal -= .03 * extension + a[19:21] = grip + x, y, z, yaw = q[21:25] + a[0] = np.clip(2 * (x_goal - x), -.12, .12) + a[1] = np.clip(-2 * y, -.12, .12) + a[3] = np.clip(-2 * yaw, -1., 1.) + self.action = a + return a.astype(np.float32) diff --git a/policies/wall_cupboard_open/astra-s2/episodes.csv b/policies/wall_cupboard_open/astra-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..518de7f0d9cc18ff0c162dddf669c560bc3cf829 --- /dev/null +++ b/policies/wall_cupboard_open/astra-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1115,success,0 +620001,1,1115,success,0 +620002,1,1115,success,0 +620003,1,1115,success,0 +620004,1,1115,success,0 +620005,1,1115,success,0 +620006,1,1115,success,0 +620007,1,1115,success,0 +620008,1,1115,success,0 +620009,1,1115,success,0 +620010,1,1115,success,0 +620011,1,1115,success,0 +620012,1,1115,success,0 +620013,1,1115,success,0 +620014,1,1115,success,0 +620015,1,1115,success,0 +620016,1,1115,success,0 +620017,1,1115,success,0 +620018,1,1115,success,0 +620019,1,1115,success,0 +620020,1,1115,success,0 +620021,1,1115,success,0 +620022,1,1115,success,0 +620023,1,1115,success,0 +620024,1,1115,success,0 +620025,1,1115,success,0 +620026,1,1115,success,0 +620027,1,1115,success,0 +620028,1,1115,success,0 +620029,1,1115,success,0 +620030,1,1115,success,0 +620031,1,1115,success,0 +620032,1,1115,success,0 +620033,1,1115,success,0 +620034,1,1115,success,0 +620035,1,1115,success,0 +620036,1,1115,success,0 +620037,1,1115,success,0 +620038,1,1115,success,0 +620039,1,1115,success,0 +620040,1,1115,success,0 +620041,1,1115,success,0 +620042,1,1115,success,0 +620043,1,1115,success,0 +620044,1,1115,success,0 +620045,1,1115,success,0 +620046,1,1115,success,0 +620047,1,1115,success,0 +620048,1,1115,success,0 +620049,1,1115,success,0 +620050,1,1115,success,0 +620051,1,1115,success,0 +620052,1,1115,success,0 +620053,1,1115,success,0 +620054,1,1115,success,0 +620055,1,1115,success,0 +620056,1,1115,success,0 +620057,1,1115,success,0 +620058,1,1115,success,0 +620059,1,1115,success,0 +620060,1,1115,success,0 +620061,1,1115,success,0 +620062,1,1115,success,0 +620063,1,1115,success,0 +620064,1,1115,success,0 +620065,1,1115,success,0 +620066,1,1115,success,0 +620067,1,1115,success,0 +620068,1,1115,success,0 +620069,1,1115,success,0 +620070,1,1115,success,0 +620071,1,1115,success,0 +620072,1,1115,success,0 +620073,1,1115,success,0 +620074,1,1115,success,0 +620075,1,1115,success,0 +620076,1,1115,success,0 +620077,1,1115,success,0 +620078,1,1115,success,0 +620079,1,1115,success,0 +620080,1,1115,success,0 +620081,1,1115,success,0 +620082,1,1115,success,0 +620083,1,1115,success,0 +620084,1,1115,success,0 +620085,1,1115,success,0 +620086,1,1115,success,0 +620087,1,1115,success,0 +620088,1,1115,success,0 +620089,1,1115,success,0 +620090,1,1115,success,0 +620091,1,1115,success,0 +620092,1,1115,success,0 +620093,1,1115,success,0 +620094,1,1115,success,0 +620095,1,1115,success,0 +620096,1,1115,success,0 +620097,1,1115,success,0 +620098,1,1115,success,0 +620099,1,1115,success,0 diff --git a/policies/wall_cupboard_open/astra-s2/policy.py b/policies/wall_cupboard_open/astra-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..e68057e26824c510cf52b1e2e4789bd59cb19fff --- /dev/null +++ b/policies/wall_cupboard_open/astra-s2/policy.py @@ -0,0 +1,58 @@ +"""Hand-written cabinet-opening motion with pelvis pose feedback. + +Arm targets interpolate over 80 control steps. Base translation and heading +are corrected from proprioception throughout the reach and door-opening arc. +""" +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.action = np.asarray(tools.hold_action(),dtype=np.float64) + self.index = 0 + self.begin = 0 + self.start = self.action.copy() + self.stages = [] + a=self.action.copy() + def stage(n,x,y): + self.stages.append((n,x,y,a.copy())) + # Retreat before raising the hands to clear the countertop. + stage(120,-.25,0) + a[5]=a[12]=-1.8; a[8]=a[15]=-.2 + a[10]=a[17]=1.5; a[6]=.2; a[13]=-.2 + a[11]=-.4; a[18]=.4; a[19:]=0 + stage(120,-.25,0) + # Bring the raised hands inward, then approach the handles. + a[6]=a[13]=0 + stage(100,-.25,0) + stage(180,.14,0) + stage(120,.24,0) + # Close and keep both grippers engaged throughout the pull. + a[19:]=1 + stage(80,.24,0) + stage(100,.09,0) + # Spread along the door arcs, rotating the wrists as the doors turn. + a[6]=.4;a[13]=-.4;a[11]=a[18]=0;a[5]=a[12]=-1.95 + stage(100,-.01,0) + a[6]=.8;a[13]=-.8;a[11]=.5;a[18]=-.5;a[5]=a[12]=-2.1 + stage(100,-.11,0) + # Flex the elbows to complete the opening, then hold for success. + a[6]=1.5;a[13]=-1.5;a[11]=1.4;a[18]=-1.4 + a[5]=a[12]=-2.5;a[8]=a[15]=.6;a[10]=a[17]=.7 + stage(1000,-.26,0) + + def act(self, obs, tools): + t=int(obs['t']) + n,x,y,target=self.stages[self.index] + if t-self.begin>=n and self.index 65) & (gray < 145)).astype(np.uint8) + count, labels, stats, _ = cv2.connectedComponentsWithStats(mask) + candidates = [] + for component in range(1, count): + x, y, w, h, area = stats[component] + if h < 18 or h < 1.4 * w or area < 30: + continue + rows, columns = np.where(labels == component) + middle = (rows >= 25) & (rows <= 45) + if middle.sum() < 5: + continue + center = float(np.median(columns[middle])) + width = float(np.median([ + np.sum(labels[row] == component) + for row in range(max(5, y), min(75, y + h)) + ])) + if 6 < center < 78: + candidates.append((center, width, x, y, w, h)) + if candidates: + minimum_width = max(item[1] for item in candidates) * .65 + candidates = [item for item in candidates if item[1] >= minimum_width] + return sorted(candidates) + + +class Policy: + def reset(self, obs, tools): + self.action = np.asarray(tools.hold_action(), dtype=np.float32) + self.roll = np.array([.25, -.25], dtype=float) + self.pull_x = float(obs['low_dim_obs'][21]) + + def act(self, obs, tools): + t = int(obs['t']) + q = obs['low_dim_obs'] + action = self.action.copy() + action[2] = .74 + action[4] = 0 + shoulder, elbow = -1.8, 1.2 + grip = 0 + if t < 60: + shoulder, elbow = -1.4, 0 + roll = np.array([.25, -.25]) + target_x = .16 + elif t < 160: + roll = self.roll + target_x = -.08 + elif t < 650: + if t % 20 == 0: + for side, camera in enumerate(('left_wrist', 'right_wrist')): + candidates = handle_candidates(tools.image(camera)) + if candidates: + candidate = candidates[0 if side == 0 else -1] + self.roll[side] += np.clip( + (42 - candidate[0]) * .001, -.015, .015) + roll = self.roll + target_x = -.08 if t < 340 else .20 + elif t < 720: + roll = self.roll + target_x = .20 + grip = 1 + else: + if t == 720: + self.pull_x = float(q[21]) + elapsed = t - 720 + roll = self.roll + np.array([1, -1]) * min(elapsed * .002, 1.55) + target_x = self.pull_x - min(elapsed * .0005, .15) + action[2] = .74 + .055 * min(elapsed / 500, 1.) + grip = 1 + turn = min(max(t - 720, 0) * .002, 1.5) + for side in range(2): + action[5 + 7 * side:12 + 7 * side] = [ + shoulder, roll[side], 0, elbow, -roll[side], 0, + (-1 if side == 0 else 1) * turn, + ] + action[19:] = grip + error = np.array([target_x, 0]) - q[21:23] + velocity = np.clip(error * 2, -.2, .2) + velocity[np.abs(error) < .025] = 0 + for axis in range(2): + if 0 < abs(velocity[axis]) < .06: + velocity[axis] = np.sign(velocity[axis]) * .06 + yaw = q[24] + action[0] = np.cos(yaw) * velocity[0] + np.sin(yaw) * velocity[1] + action[1] = -np.sin(yaw) * velocity[0] + np.cos(yaw) * velocity[1] + action[3] = np.clip(-yaw * 2, -.4, .4) + if 160 <= t < 340 or 530 <= t < 720: + action[:2] = 0 + return action diff --git a/policies/wall_cupboard_open/deepseek1017-s1/episodes.csv b/policies/wall_cupboard_open/deepseek1017-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/deepseek1017-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/deepseek1017-s1/policy.py b/policies/wall_cupboard_open/deepseek1017-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..a16129bf2cc18da04a176ba12c054dedb9cacd74 --- /dev/null +++ b/policies/wall_cupboard_open/deepseek1017-s1/policy.py @@ -0,0 +1,225 @@ +"""Control policy for the G1 wall-cabinet task. + +Hand-written scripted controller. The scene is fixed: the robot stands in +front of a low white cupboard whose two doors have vertical handles. The +policy raises both arms, walks up to the cupboard with the arms clear of the +counter, lowers the hands onto the handles, closes the grippers and pulls the +doors open with a down / back / outward arc. Several variants are tried in +sequence so that small misalignments do not end the attempt. + +The base is closed-loop controlled with the pelvis pose from low_dim_obs. +""" + +import numpy as np + +# --------------------------------------------------------------------------- +# joint helpers: action = [vx, vy, h, wz, pitch, L(7), R(7), gripL, gripR] +# arm order: shoulder_pitch, shoulder_roll, shoulder_yaw, elbow, +# wrist_roll, wrist_pitch, wrist_yaw +# --------------------------------------------------------------------------- + +DEFAULT_H = 0.74 + + +def _mirror(L): + """Mirror a left-arm joint vector for the right arm.""" + return [L[0], -L[1], -L[2], L[3], -L[4], -L[5], -L[6]] + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32).copy() + self.t = 0 + self.phase = 0 + self.phase_step = 0 + self.phase_len = 0 + self.phases = self._build_phases() + self._start_phase(0) + self._last_obs = obs + + # -- phase machine ------------------------------------------------------ + def _build_phases(self): + """Return a list of phase dictionaries. + + kind: + arm - drive arms to (L, grip) while holding the base + walk - walk forward with arms held high + hold - hold the current pose while regulating the base + pull - interpolate arms to (L, grip) while pulling the base back + """ + ph = [] + + # 1. raise the arms, clear of the counter + up = [-1.60, 0.0, 0.06, 0.0, 0.0, 0.0, 0.0] + ph.append(dict(kind="arm", n=22, L=up, grip=0.0, + xt=0.17, yt=0.0, yawt=0.0, pitch=0.0, h=DEFAULT_H)) + + # 2. walk forward with the arms up (body can pass the counter) + ph.append(dict(kind="walk", n=70, L=up, grip=0.0, + xt=0.38, yt=0.0, yawt=0.0, pitch=0.0, h=DEFAULT_H, + vx=0.25)) + + # 3. grasp + open attempts. The demonstration lifts the hands high + # after closing on the handles, so lift-type pulls are included + # alongside downward / backward pulls. + # (sp, yaw, wp, roll, base_x, pitch, dsp, dyaw, droll, dvx) + attempts = [ + (-1.00, 0.00, 0.00, 0.0, 0.20, 0.00, -0.90, 0.10, 0.15, 0.10), + (-1.10, 0.08, 0.10, 0.0, 0.28, 0.10, -0.70, 0.15, 0.25, -0.10), + (-1.00, -0.06, 0.00, 0.0, 0.24, 0.00, 0.55, 0.25, 0.45, -0.18), + (-1.15, 0.04, 0.20, 0.1, 0.29, 0.15, -0.75, 0.20, 0.30, 0.04), + (-0.95, 0.06, 0.00, 0.0, 0.27, 0.05, 0.60, 0.20, 0.40, -0.15), + ] + for (sp, yaw, wp, roll, bx, pitch, dsp, dyaw, droll, dvx) in attempts: + Lg = [sp, roll, yaw, 0.0, 0.0, wp, 0.0] + # approach / descend from the high arms + ph.append(dict(kind="pull", n=24, L=Lg, grip=0.0, + xt=bx, yt=0.0, yawt=0.0, pitch=pitch, + h=DEFAULT_H, vx=0.0)) + # settle and seat the fingers on the handle + ph.append(dict(kind="hold", n=12, L=Lg, grip=0.0, + xt=bx, yt=0.0, yawt=0.0, pitch=pitch, + h=DEFAULT_H, vx=0.05)) + ph.append(dict(kind="hold", n=12, L=Lg, grip=1.0, + xt=bx, yt=0.0, yawt=0.0, pitch=pitch, + h=DEFAULT_H, vx=0.0)) + # the pull itself + Lp = [sp + dsp, roll + droll, yaw + dyaw, 0.35, 0.0, + wp - 0.25, 0.0] + ph.append(dict(kind="pull", n=50, L=Lp, grip=1.0, + xt=bx + dvx, yt=0.0, yawt=0.0, + pitch=max(-0.15, pitch - 0.20), + h=DEFAULT_H, vx=-0.10)) + # hold the doors where they are for at least one second + ph.append(dict(kind="hold", n=60, L=Lp, grip=1.0, + xt=bx + dvx, yt=0.0, yawt=0.0, + pitch=max(-0.15, pitch - 0.20), + h=DEFAULT_H, vx=0.0)) + # release and return the arms high for the next attempt + ph.append(dict(kind="arm", n=16, L=up, grip=0.0, + xt=bx + 0.02, yt=0.0, yawt=0.0, pitch=0.0, + h=DEFAULT_H)) + + # 4. single right-arm attempts (the right hand gave the clearest + # handle contact during development) + down = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] + singles = [ + (-1.00, 0.00, 0.00, 0.20, -1.90, 0.0, 0.0), + (-1.08, -0.08, 0.10, 0.24, -1.75, 0.2, 0.5), + ] + for (sp, yaw, wp, bx, tsp, tyaw, troll) in singles: + Rg = [sp, 0.0, yaw, 0.0, 0.0, wp, 0.0] + ph.append(dict(kind="pull", n=20, L=down, R=Rg, grip=0.0, + xt=bx, yt=0.0, yawt=0.0, pitch=0.0, + h=DEFAULT_H, vx=0.0)) + ph.append(dict(kind="hold", n=12, L=down, R=Rg, grip=0.0, + xt=bx, yt=0.0, yawt=0.0, pitch=0.0, + h=DEFAULT_H, vx=0.04, grip_r=1.0)) + Rp = [tsp, troll, yaw + tyaw, 0.30, 0.0, wp - 0.2, 0.0] + ph.append(dict(kind="pull", n=45, L=down, R=Rp, grip=0.0, + grip_r=1.0, xt=bx - 0.05, yt=0.0, yawt=0.0, + pitch=0.0, h=DEFAULT_H, vx=-0.08)) + ph.append(dict(kind="hold", n=50, L=down, R=Rp, grip=0.0, + grip_r=1.0, xt=bx - 0.05, yt=0.0, yawt=0.0, + pitch=0.0, h=DEFAULT_H, vx=0.0)) + ph.append(dict(kind="arm", n=14, L=up, grip=0.0, + xt=bx, yt=0.0, yawt=0.0, pitch=0.0, + h=DEFAULT_H)) + return ph + + def _start_phase(self, i): + self.phase = i + self.phase_step = 0 + if i < len(self.phases): + p = self.phases[i] + self.phase_len = p["n"] + self.xt = p["xt"] + self.yt = p["yt"] + self.yawt = p["yawt"] + self._from = None + if p["kind"] == "pull": + self._from = np.asarray(self._cur_arm, dtype=np.float32).copy() + self._from_r = np.asarray(self._cur_arm_r, dtype=np.float32).copy() + + def _base_cmd(self, ld): + """P controller on the pelvis pose with a minimum-velocity deadband.""" + x, y, yaw = float(ld[21]), float(ld[22]), float(ld[24]) + ex, ey, eyaw = self.xt - x, self.yt - y, self.yawt - yaw + vx = np.clip(1.6 * ex, -0.28, 0.28) + vy = np.clip(1.6 * ey, -0.18, 0.18) + wz = np.clip(1.8 * eyaw, -0.25, 0.25) + # the controller treats speeds below ~0.055 m/s as stand still; use a + # small pulse so it keeps converging without walking in place. + if abs(vx) < 0.06 and abs(ex) > 0.012: + vx = 0.06 * np.sign(ex) + if abs(vy) < 0.06 and abs(ey) > 0.02: + vy = 0.06 * np.sign(ey) + if abs(wz) < 0.06 and abs(eyaw) > 0.04: + wz = 0.06 * np.sign(eyaw) + return vx, vy, wz + + # -- main --------------------------------------------------------------- + def act(self, obs, tools): + ld = np.asarray(obs["low_dim_obs"], dtype=np.float32) + self._last_obs = obs + if not hasattr(self, "_cur_arm"): + # first call: use the measured joint positions as current targets + self._cur_arm = np.asarray(ld[3:10], dtype=np.float32).copy() + self._cur_arm_r = np.asarray(ld[12:19], dtype=np.float32).copy() + + if self.phase >= len(self.phases): + # stay put (holding the last pose) for the rest of the episode + a = self.hold.copy() + vx, vy, wz = self._base_cmd(ld) + a[0], a[1], a[3] = vx, vy, wz + a[2] = DEFAULT_H + return a + + p = self.phases[self.phase] + n = max(1, p["n"]) + t = min(1.0, (self.phase_step + 1) / n) + L = np.asarray(p["L"], dtype=np.float32) + grip = float(p["grip"]) + grip_r = float(p.get("grip_r", grip)) + + # the "pull" phase interpolates from the arm targets of the previous + # phase to the new targets + if p["kind"] == "pull" and self._from is not None: + cur = self._from + (L - self._from) * t + else: + cur = L.copy() + self._cur_arm = cur.copy() + if "R" in p: + R = np.asarray(p["R"], dtype=np.float32) + if p["kind"] == "pull" and self._from_r is not None: + cur_r = self._from_r + (R - self._from_r) * t + else: + cur_r = R.copy() + self._cur_arm_r = cur_r.copy() + else: + self._cur_arm_r = np.asarray(_mirror(list(cur)), dtype=np.float32) + + vx, vy, wz = self._base_cmd(ld) + if p["kind"] == "walk": + vx = float(p.get("vx", 0.25)) + vy = 0.0 + elif p["kind"] == "pull": + vx = float(p.get("vx", 0.0)) + 0.6 * vx + elif p["kind"] == "hold": + vx = float(p.get("vx", 0.0)) + 0.5 * vx + + a = self.hold.copy() + a[0] = float(np.clip(vx, -1.0, 1.0)) + a[1] = float(np.clip(vy, -1.0, 1.0)) + a[2] = float(p["h"]) + a[3] = float(np.clip(wz, -1.0, 1.0)) + a[4] = float(np.clip(p["pitch"], -0.2, 0.8)) + a[5:12] = self._cur_arm + a[12:19] = self._cur_arm_r + a[19] = grip + a[20] = grip_r + + self.phase_step += 1 + if self.phase_step >= n: + self._start_phase(self.phase + 1) + return a diff --git a/policies/wall_cupboard_open/deepseek1017-s2/episodes.csv b/policies/wall_cupboard_open/deepseek1017-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/deepseek1017-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/deepseek1017-s2/policy.py b/policies/wall_cupboard_open/deepseek1017-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..0909f522dd1ed273b7567bdfb2fe8b0148da52f1 --- /dev/null +++ b/policies/wall_cupboard_open/deepseek1017-s2/policy.py @@ -0,0 +1,119 @@ +"""Hand-written control policy for the "open both doors of the wall cupboard" +task with a Unitree G1 humanoid. + +The policy is a deterministic scripted controller. It walks up to the +cupboard, holds the arms in a reach pose so that the palm cameras look at the +handles, closes the grippers and drags the doors open, trying several +heights / pull directions (standing and squatting) before retreating. +No learned components, no randomness, no wall-clock dependence. +""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.t = 0 + self.segments = self._build_segments() + self.seg = 0 + self.seg_start = 0 + + # ------------------------------------------------------------------ + def _build_segments(self): + S = [] + + def add(dur, base=None, L=None, R=None, gL=None, gR=None): + S.append((dur, base or {}, L, R, gL, gR)) + + # Reach pose: arms forward at handle height, wrists rolled so the + # closing axis of the fingers crosses the handle bars. + P = [0.15, 0.25, 0.0, 0.35, 1.5, -1.0, 0.0] + Pm = [P[0], -P[1], P[2], P[3], -P[4], P[5], P[6]] + zero = [0, 0, 0, 0.05, 0, 0.04, 0] + + add(22, None, P, Pm, 0.0, 0.0) # settle + add(46, {"vx": 0.6, "pitch": 0.2}, P, Pm, 0.0, 0.0) # walk in + + # -- standing grab / pull at several heights + variants = [ + (-0.08, 0.15, 0.32, -0.35, 0.30, 0.30), + (-0.26, 0.03, 0.28, -0.40, 0.25, 0.30), + (0.15, 0.25, 0.35, -0.35, 0.30, 0.30), + (0.00, 0.20, 0.20, -0.30, 0.25, 0.35), + ] + for sp, sr, el, back, dsp, dele in variants: + Lg = [sp, sr, 0.0, el, 1.5, -1.0, 0.0] + Rg = [sp, -sr, 0.0, el, -1.5, -1.0, 0.0] + add(14, None, Lg, Rg, 0.0, 0.0) + add(14, None, Lg, Rg, 1.0, 1.0) + Lp = [sp + dsp, sr, 0.0, el + dele, 1.5, -1.0, 0.0] + Rp = [sp + dsp, -sr, 0.0, el + dele, -1.5, -1.0, 0.0] + add(35, {"vx": back, "pitch": -0.15}, Lp, Rp, 1.0, 1.0) + Lo = [min(1.6, sp + dsp + 0.35), sr, 0.0, el + dele, 1.5, -1.0, 0.0] + Ro = [min(1.6, sp + dsp + 0.35), -sr, 0.0, el + dele, -1.5, -1.0, 0.0] + add(20, {"vx": back * 0.5}, Lo, Ro, 1.0, 1.0) + add(8, None, Lg, Rg, 0.0, 0.0) + add(30, {"vx": 0.6, "pitch": 0.2}, P, Pm, 0.0, 0.0) + + # -- low (squatting) grab / pull of the lower door handles + for sp, el, wp, back in [(-0.15, 0.40, 0.30, -0.45), + (0.10, 0.55, 0.20, -0.55), + (-0.30, 0.60, 0.45, -0.40)]: + Lq = [sp, 0.15, 0.0, el, 0.0, wp, 0.0] + Rq = [sp, -0.15, 0.0, el, 0.0, wp, 0.0] + add(28, {"height": 0.48}, Lq, Rq, 0.0, 0.0) + add(16, {"height": 0.48}, Lq, Rq, 1.0, 1.0) + add(40, {"height": 0.60, "vx": back, "pitch": 0.25}, + [sp + 0.35, 0.15, 0.0, el + 0.2, 0.0, wp, 0.0], + [sp + 0.35, -0.15, 0.0, el + 0.2, 0.0, wp, 0.0], 1.0, 1.0) + add(12, {"height": 0.74}, Lq, Rq, 0.0, 0.0) + + # -- sideways sweep with closed grippers at handle height + for vy in (0.35, -0.35): + LS = [0.55, 0.15, 0.0, 0.35, 0.0, -0.7, 0.0] + RS = [0.55, -0.15, 0.0, 0.35, 0.0, -0.7, 0.0] + add(16, {"vx": 0.30}, LS, RS, 1.0, 1.0) + add(40, {"vy": vy}, LS, RS, 1.0, 1.0) + add(14, {"vx": 0.0}, LS, RS, 0.0, 0.0) + + # -- retreat, arms down + add(55, {"vx": -0.45}, zero, zero, 0.0, 0.0) + add(400, None, zero, zero, 0.0, 0.0) + return S + + # ------------------------------------------------------------------ + def act(self, obs, tools): + self.t += 1 + dur, base, L, R, gL, gR = self.segments[self.seg] + while self.t - self.seg_start > dur and self.seg < len(self.segments) - 1: + self.seg_start = self.t + self.seg += 1 + dur, base, L, R, gL, gR = self.segments[self.seg] + + raw = np.asarray(tools.hold_action(), dtype=np.float32).copy() + raw[0] = 0.0 + raw[1] = 0.0 + raw[3] = 0.0 + raw[2] = 0.74 + raw[4] = 0.0 + for k, v in base.items(): + if k == "vx": + raw[0] = v + elif k == "vy": + raw[1] = v + elif k == "pitch": + raw[4] = v + elif k == "height": + raw[2] = v + elif k == "wz": + raw[3] = v + if L is not None: + raw[5:12] = L + if R is not None: + raw[12:19] = R + if gL is not None: + raw[19] = gL + if gR is not None: + raw[20] = gR + return raw diff --git a/policies/wall_cupboard_open/deepseek1017-s3/episodes.csv b/policies/wall_cupboard_open/deepseek1017-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/deepseek1017-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/deepseek1017-s3/policy.py b/policies/wall_cupboard_open/deepseek1017-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..3a249885dbfb19a2df2b1ad27d5cd6e5956ede71 --- /dev/null +++ b/policies/wall_cupboard_open/deepseek1017-s3/policy.py @@ -0,0 +1,119 @@ +"""Open both doors of the wall cupboard. + +Hand-written scripted control logic (no learned components). + +The robot stands in front of a kitchen counter whose cupboard has two doors +with vertical bar handles. The policy walks up to the counter (closed loop on +the pelvis position) and then runs a fixed list of reach / grasp / pull +attempts with both arms. The episode terminates as soon as the task is solved, +so trying many attempts is harmless: every attempt that does not solve the task +is simply followed by the next one. + +The only feedback used is the proprioceptive state: it keeps the torso upright +and the pelvis at a normal height, and it ends the approach walk at the right +distance from the counter. +""" + +import numpy as np + + +class Policy: + """Scripted multi-attempt grasp-and-pull sequence.""" + + # distance from the counter (pelvis x) at which the reach attempts start + STAND_X = 0.42 + + @staticmethod + def _mk(sp, el, sy, wr, wp=0.0, sr=0.0): + """Symmetric arm joint targets (left 5..11, right 12..18).""" + return { + 5: sp, 6: sr, 7: sy, 8: el, 9: wr, 10: wp, + 12: sp, 13: -sr, 14: -sy, 15: el, 16: -wr, 17: wp, + } + + def _attempts(self): + """List of (reach, push, pull, n_reach, n_push, n_close, n_pull).""" + A = [] + # --- cupboard doors at hip height, gripper rolled onto the handle --- + for sp, el, sy, wr, wp in ( + (0.50, 0.10, 0.05, -1.57, -0.20), + (0.60, 0.00, 0.10, -1.57, -0.20), + (0.45, 0.15, 0.00, 1.57, -0.20), + (0.55, 0.05, 0.15, 0.00, 0.00), + (0.65, 0.00, 0.00, 1.57, 0.00), + ): + reach = self._mk(sp, el, sy, wr, wp) + push = self._mk(sp + 0.15, el, sy, wr, wp) + pull = self._mk(0.05, 1.45, sy - 0.25, wr, 0.15) + A.append((reach, push, pull, 16, 12, 12, 45)) + # --- same doors, pull outwards as the door swings ------------------- + for sp, el, sy, wr in ( + (0.55, 0.05, 0.10, 0.0), + (0.50, 0.10, 0.00, -1.57), + ): + reach = self._mk(sp, el, sy, wr, 0.0) + push = self._mk(sp + 0.15, el, sy, wr, 0.0) + pull = self._mk(0.35, 0.90, sy + 0.60, wr, 0.0) + A.append((reach, push, pull, 16, 12, 12, 45)) + # --- wall cupboard above the counter (leaning in) ------------------- + for sp, el, sy, pitch in ( + (2.00, 0.20, 0.20, 0.30), + (2.30, 0.15, 0.00, 0.40), + (1.70, 0.50, 0.20, 0.30), + ): + reach = self._mk(sp, el, sy, 0.0, 0.0) + push = self._mk(sp + 0.15, el, sy, 0.0, 0.0) + pull = self._mk(0.90, 1.30, sy, 0.0, 0.0) + reach[4] = pitch + push[4] = pitch + pull[4] = pitch + A.append((reach, push, pull, 16, 10, 12, 40)) + return A + + # ------------------------------------------------------------------ hooks + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.base = self.hold.copy() + self.base[19] = 0.0 # gripper open + self.base[20] = 0.0 + self.plan = [] + for reach, push, pull, nr, npush, nclose, npull in self._attempts(): + self.plan.append({"move": reach, "grip": 0.0, "n": nr}) + self.plan.append({"move": push, "grip": 0.0, "n": npush}) + self.plan.append({"move": push, "grip": 1.0, "n": nclose}) + self.plan.append({"move": pull, "grip": 1.0, "n": npull}) + self.plan.append({"move": {5: 0.30, 8: 0.45, 12: 0.30, 15: 0.45}, + "grip": 0.0, "n": 12}) + self.idx = 0 + self.step = 0 + self.walk_steps = 0 + + def act(self, obs, tools): + x = float(obs["low_dim_obs"][21]) + raw = self.base.copy() + raw[2] = 0.74 + raw[4] = 0.0 + # --- phase 0: walk up to the counter, arms raised out of the way --- + if self.walk_steps < 90 and x < self.STAND_X: + self.walk_steps += 1 + raw[0] = 0.28 + raw[5] = 2.20 + raw[8] = 0.20 + raw[12] = 2.20 + raw[15] = 0.20 + return raw + # --- phase 1: scripted attempts ------------------------------------ + while self.idx < len(self.plan) and self.step >= self.plan[self.idx]["n"]: + self.idx += 1 + self.step = 0 + if self.idx >= len(self.plan): + return raw + st = self.plan[self.idx] + for k, v in st["move"].items(): + raw[k] = float(v) + raw[19] = st["grip"] + raw[20] = st["grip"] + if 4 not in st["move"]: + raw[4] = 0.0 + self.step += 1 + return raw diff --git a/policies/wall_cupboard_open/gpt61sol-s1/episodes.csv b/policies/wall_cupboard_open/gpt61sol-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..8d4a525519b8c812a33063924ae25a3745cabd55 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61sol-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,938,success,0 +620001,1,938,success,0 +620002,1,938,success,0 +620003,1,938,success,0 +620004,1,938,success,0 +620005,1,938,success,0 +620006,1,938,success,0 +620007,1,938,success,0 +620008,1,938,success,0 +620009,1,938,success,0 +620010,1,938,success,0 +620011,1,938,success,0 +620012,1,938,success,0 +620013,1,938,success,0 +620014,1,938,success,0 +620015,1,938,success,0 +620016,1,938,success,0 +620017,1,938,success,0 +620018,1,938,success,0 +620019,1,938,success,0 +620020,1,938,success,0 +620021,1,938,success,0 +620022,1,938,success,0 +620023,1,938,success,0 +620024,1,938,success,0 +620025,1,938,success,0 +620026,1,938,success,0 +620027,1,938,success,0 +620028,1,938,success,0 +620029,1,938,success,0 +620030,1,938,success,0 +620031,1,938,success,0 +620032,1,938,success,0 +620033,1,938,success,0 +620034,1,938,success,0 +620035,1,938,success,0 +620036,1,938,success,0 +620037,1,938,success,0 +620038,1,938,success,0 +620039,1,938,success,0 +620040,1,938,success,0 +620041,1,938,success,0 +620042,1,938,success,0 +620043,1,938,success,0 +620044,1,938,success,0 +620045,1,938,success,0 +620046,1,938,success,0 +620047,1,938,success,0 +620048,1,938,success,0 +620049,1,938,success,0 +620050,1,938,success,0 +620051,1,938,success,0 +620052,1,938,success,0 +620053,1,938,success,0 +620054,1,938,success,0 +620055,1,938,success,0 +620056,1,938,success,0 +620057,1,938,success,0 +620058,1,938,success,0 +620059,1,938,success,0 +620060,1,938,success,0 +620061,1,938,success,0 +620062,1,938,success,0 +620063,1,938,success,0 +620064,1,938,success,0 +620065,1,938,success,0 +620066,1,938,success,0 +620067,1,938,success,0 +620068,1,938,success,0 +620069,1,938,success,0 +620070,1,938,success,0 +620071,1,938,success,0 +620072,1,938,success,0 +620073,1,938,success,0 +620074,1,938,success,0 +620075,1,938,success,0 +620076,1,938,success,0 +620077,1,938,success,0 +620078,1,938,success,0 +620079,1,938,success,0 +620080,1,938,success,0 +620081,1,938,success,0 +620082,1,938,success,0 +620083,1,938,success,0 +620084,1,938,success,0 +620085,1,938,success,0 +620086,1,938,success,0 +620087,1,938,success,0 +620088,1,938,success,0 +620089,1,938,success,0 +620090,1,938,success,0 +620091,1,938,success,0 +620092,1,938,success,0 +620093,1,938,success,0 +620094,1,938,success,0 +620095,1,938,success,0 +620096,1,938,success,0 +620097,1,938,success,0 +620098,1,938,success,0 +620099,1,938,success,0 diff --git a/policies/wall_cupboard_open/gpt61sol-s1/policy.py b/policies/wall_cupboard_open/gpt61sol-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..d3dd6db114e37401bf9b9081afc53de2bb8986ef --- /dev/null +++ b/policies/wall_cupboard_open/gpt61sol-s1/policy.py @@ -0,0 +1,92 @@ +"""Hand-written, deterministic cabinet controller. + +The arm planner solves a small geometric inverse-kinematics problem. Its +segment lengths and door radius are control constants; it contains no learned +parameters or demonstration data. The base closes its loop on proprioception. +""" + +import numpy as np +from scipy.optimize import least_squares +from scipy.spatial.transform import Rotation + +def rot(axis,t): + # Elementary joint rotations for the approximate arm chain. + c=np.cos(t);s=np.sin(t) + if axis==0:return np.array([[1,0,0],[0,c,-s],[0,s,c]]) + if axis==1:return np.array([[c,0,s],[0,1,0],[-s,0,c]]) + return np.array([[c,-s,0],[s,c,0],[0,0,1]]) +def fk(q,lens=(.18,.18,.09)): + # Shoulder, upper arm, forearm, and wrist; return palm pose. + R=rot(1,q[0])@rot(0,q[1])@rot(2,q[2]);p=R@np.array([0,0,-lens[0]]) + R=R@rot(1,q[3]);p+=R@np.array([0,0,-lens[1]]) + R=R@rot(1,np.pi/2)@rot(0,q[4])@rot(1,q[5])@rot(2,q[6]);p+=R@np.array([lens[2],0,0]) + return p,R +class ArmPlanner: + """Follow a hinge arc while keeping the hand oriented with the door.""" + def __init__(self,radius=.3,back=.18,lens=(.18,.18,.09)): + self.q0=np.array([-1.3,-.15,0,-1,0,1.6,0]);self.q=self.q0.copy();self.lens=lens;self.p0,self.R0=fk(self.q0,lens);self.radius=radius;self.back=back + def solve(self,th): + P=self.p0+np.array([-(self.radius-self.back)*np.sin(th),self.radius*(1-np.cos(th)),0]);R=rot(2,-th)@self.R0;prev=self.q.copy() + def fun(q): + p,r=fk(q,self.lens) + return np.r_[5*(p-P),.45*Rotation.from_matrix(R.T@r).as_rotvec(),.008*(q-prev)] + self.q=least_squares(fun,self.q,bounds=([-3,-.7,-2.6,-1.047,-1.97,-1.61,-1.61],[1,2.2,2.6,2.09,1.97,1.614,1.61]),max_nfev=25,ftol=1e-5,xtol=1e-5,gtol=1e-5).x + return self.q + + +class Policy: + """Reach, pinch, and follow the two cabinet doors with geometric arm control.""" + def reset(self, obs, tools): + self.hold=np.asarray(tools.hold_action(),dtype=np.float32) + self.planner=ArmPlanner(.30,.20) + self.initial=self.planner.q0.copy() + self.reach=np.array([-2.,-.15,0.,.3,0.,1.,0.]) + self.shift=fk(self.reach)[0]-fk(self.initial)[0] + self.mirror=np.array([1.,-1.,-1.,1.,-1.,1.,-1.]) + self.anchor=.17 + self.arm=self.initial.copy() + + @staticmethod + def velocity(error, maximum, minimum=.06): + if abs(error)<=.012: + return 0. + return np.sign(error)*max(minimum,min(maximum,abs(error)*2.)) + + def act(self, obs, tools): + t=int(obs['t']);q=obs['low_dim_obs'];a=self.hold.copy() + a[2]=.74;a[4]=0.;a[19:]=0. + if t<280: + self.arm=self.initial*min(1.,t/70.) + target=-.15 if t<120 else .32 + a[0]=self.velocity(target-q[21],.30,.07) + a[1]=self.velocity(-q[22],.20) + a[3]=np.clip(-q[24]*2.,-.3,.3) + elif t<350: + # Let the fingers settle around both handles. + self.arm=self.initial.copy() + a[19:]=1. + elif t<500: + # Unfold the wrists before the pull, avoiding their singular pose. + u=min(1.,(t-350)/120.) + self.arm=(1.-u)*self.initial+u*self.reach + a[19:]=1. + a[0]=self.velocity(.32-self.shift[0]*u-q[21],.12) + a[3]=np.clip(-q[24]*2.,-.3,.3) + if t==499: + self.anchor=float(q[21]) + self.planner.q0=self.reach.copy() + self.planner.q=self.reach.copy() + self.planner.p0,self.planner.R0=fk(self.reach) + else: + k=t-500 + angle=1.9*min(1.,k/600.) + # Warm-start deterministic numerical IK at 10 Hz. + if k%5==0: + self.arm=self.planner.solve(angle).copy() + a[19:]=1. + a[0]=self.velocity(self.anchor-.20*np.sin(angle)-q[21],.15) + a[1]=self.velocity(-q[22],.15) + a[3]=np.clip(-q[24]*2.,-.3,.3) + a[5:12]=self.arm + a[12:19]=self.arm*self.mirror + return a diff --git a/policies/wall_cupboard_open/gpt61sol-s2/episodes.csv b/policies/wall_cupboard_open/gpt61sol-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..c6ee39a1fee51d132a27a2b06b4f4547ba0c1b09 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61sol-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1104,success,0 +620001,1,1104,success,0 +620002,1,1104,success,0 +620003,1,1104,success,0 +620004,1,1104,success,0 +620005,1,1104,success,0 +620006,1,1104,success,0 +620007,1,1104,success,0 +620008,1,1104,success,0 +620009,1,1104,success,0 +620010,1,1104,success,0 +620011,1,1104,success,0 +620012,1,1104,success,0 +620013,1,1104,success,0 +620014,1,1104,success,0 +620015,1,1104,success,0 +620016,1,1104,success,0 +620017,1,1104,success,0 +620018,1,1104,success,0 +620019,1,1104,success,0 +620020,1,1104,success,0 +620021,1,1104,success,0 +620022,1,1104,success,0 +620023,1,1104,success,0 +620024,1,1104,success,0 +620025,1,1104,success,0 +620026,1,1104,success,0 +620027,1,1104,success,0 +620028,1,1104,success,0 +620029,1,1104,success,0 +620030,1,1104,success,0 +620031,1,1104,success,0 +620032,1,1104,success,0 +620033,1,1104,success,0 +620034,1,1104,success,0 +620035,1,1104,success,0 +620036,1,1104,success,0 +620037,1,1104,success,0 +620038,1,1104,success,0 +620039,1,1104,success,0 +620040,1,1104,success,0 +620041,1,1104,success,0 +620042,1,1104,success,0 +620043,1,1104,success,0 +620044,1,1104,success,0 +620045,1,1104,success,0 +620046,1,1104,success,0 +620047,1,1104,success,0 +620048,1,1104,success,0 +620049,1,1104,success,0 +620050,1,1104,success,0 +620051,1,1104,success,0 +620052,1,1104,success,0 +620053,1,1104,success,0 +620054,1,1104,success,0 +620055,1,1104,success,0 +620056,1,1104,success,0 +620057,1,1104,success,0 +620058,1,1104,success,0 +620059,1,1104,success,0 +620060,1,1104,success,0 +620061,1,1104,success,0 +620062,1,1104,success,0 +620063,1,1104,success,0 +620064,1,1104,success,0 +620065,1,1104,success,0 +620066,1,1104,success,0 +620067,1,1104,success,0 +620068,1,1104,success,0 +620069,1,1104,success,0 +620070,1,1104,success,0 +620071,1,1104,success,0 +620072,1,1104,success,0 +620073,1,1104,success,0 +620074,1,1104,success,0 +620075,1,1104,success,0 +620076,1,1104,success,0 +620077,1,1104,success,0 +620078,1,1104,success,0 +620079,1,1104,success,0 +620080,1,1104,success,0 +620081,1,1104,success,0 +620082,1,1104,success,0 +620083,1,1104,success,0 +620084,1,1104,success,0 +620085,1,1104,success,0 +620086,1,1104,success,0 +620087,1,1104,success,0 +620088,1,1104,success,0 +620089,1,1104,success,0 +620090,1,1104,success,0 +620091,1,1104,success,0 +620092,1,1104,success,0 +620093,1,1104,success,0 +620094,1,1104,success,0 +620095,1,1104,success,0 +620096,1,1104,success,0 +620097,1,1104,success,0 +620098,1,1104,success,0 +620099,1,1104,success,0 diff --git a/policies/wall_cupboard_open/gpt61sol-s2/policy.py b/policies/wall_cupboard_open/gpt61sol-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..a48408240db3ec79dcda30843dc301ccd23c2465 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61sol-s2/policy.py @@ -0,0 +1,59 @@ +"""Deterministic cabinet control using joint targets and pelvis feedback.""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=float) + + @staticmethod + def velocity(error): + # Commands below the walking threshold are ignored by the controller. + if abs(error) <= 0.015: + return 0.0 + return np.sign(error) * max(0.065, min(0.12, 2.0 * abs(error))) + + def act(self, obs, tools): + step = obs['t'] + body = obs['low_dim_obs'] + action = self.hold.copy() + + # Lift outside the torso, then bring the open fingers to the handles. + lift = min(1.0, step / 65.0) + roll = 0.2 - 0.35 * np.clip((step - 100) / 70.0, 0.0, 1.0) + pitch = -1.1 * lift + grip = 0.6 if step < 370 else 1.0 + wrist_roll = wrist_pitch = 0.0 + + if step >= 450: + # Spread the arms along the door arcs. Preserve the vertical arm + # projection, and counter-rotate the wrists to retain the grips. + roll = float(np.interp( + step, [450, 600, 750, 950, 1100], + [-0.15, 0.25, 0.55, 0.95, 1.15], + )) + vertical = np.cos(1.1) * np.cos(0.15) + pitch = -np.arccos(np.clip(vertical / np.cos(roll), 0.0, 0.99)) + wrist_roll = -(roll + 0.15) + wrist_pitch = -1.1 - pitch + action[2] = 0.74 + min(0.0, 0.5 * (np.cos(roll) - vertical)) + + action[5:12] = [pitch, roll, 0, 0, wrist_roll, wrist_pitch, 0] + action[12:19] = [pitch, -roll, 0, 0, -wrist_roll, wrist_pitch, 0] + action[19:21] = grip + + if step < 150: + target_x = 0.16 + elif step < 450: + target_x = 0.31 + else: + target_x = float(np.interp( + step, [450, 600, 750, 950, 1100], + [0.28, 0.14, 0.1, 0.27, 0.34], + )) + + action[0] = self.velocity(target_x - body[21]) + action[1] = self.velocity(-body[22]) + action[3] = np.clip(-2.0 * body[24], -0.3, 0.3) + return action diff --git a/policies/wall_cupboard_open/gpt61sol-s3/episodes.csv b/policies/wall_cupboard_open/gpt61sol-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..0b833436eabbf1ead69679acb178e86427a428ae --- /dev/null +++ b/policies/wall_cupboard_open/gpt61sol-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1123,success,0 +620001,1,1123,success,0 +620002,1,1123,success,0 +620003,1,1123,success,0 +620004,1,1123,success,0 +620005,1,1123,success,0 +620006,1,1123,success,0 +620007,1,1123,success,0 +620008,1,1123,success,0 +620009,1,1123,success,0 +620010,1,1123,success,0 +620011,1,1123,success,0 +620012,1,1123,success,0 +620013,1,1123,success,0 +620014,1,1123,success,0 +620015,1,1123,success,0 +620016,1,1123,success,0 +620017,1,1123,success,0 +620018,1,1123,success,0 +620019,1,1123,success,0 +620020,1,1123,success,0 +620021,1,1123,success,0 +620022,1,1123,success,0 +620023,1,1123,success,0 +620024,1,1123,success,0 +620025,1,1123,success,0 +620026,1,1123,success,0 +620027,1,1123,success,0 +620028,1,1123,success,0 +620029,1,1123,success,0 +620030,1,1123,success,0 +620031,1,1123,success,0 +620032,1,1123,success,0 +620033,1,1123,success,0 +620034,1,1123,success,0 +620035,1,1123,success,0 +620036,1,1123,success,0 +620037,1,1123,success,0 +620038,1,1123,success,0 +620039,1,1123,success,0 +620040,1,1123,success,0 +620041,1,1123,success,0 +620042,1,1123,success,0 +620043,1,1123,success,0 +620044,1,1123,success,0 +620045,1,1123,success,0 +620046,1,1123,success,0 +620047,1,1123,success,0 +620048,1,1123,success,0 +620049,1,1123,success,0 +620050,1,1123,success,0 +620051,1,1123,success,0 +620052,1,1123,success,0 +620053,1,1123,success,0 +620054,1,1123,success,0 +620055,1,1123,success,0 +620056,1,1123,success,0 +620057,1,1123,success,0 +620058,1,1123,success,0 +620059,1,1123,success,0 +620060,1,1123,success,0 +620061,1,1123,success,0 +620062,1,1123,success,0 +620063,1,1123,success,0 +620064,1,1123,success,0 +620065,1,1123,success,0 +620066,1,1123,success,0 +620067,1,1123,success,0 +620068,1,1123,success,0 +620069,1,1123,success,0 +620070,1,1123,success,0 +620071,1,1123,success,0 +620072,1,1123,success,0 +620073,1,1123,success,0 +620074,1,1123,success,0 +620075,1,1123,success,0 +620076,1,1123,success,0 +620077,1,1123,success,0 +620078,1,1123,success,0 +620079,1,1123,success,0 +620080,1,1123,success,0 +620081,1,1123,success,0 +620082,1,1123,success,0 +620083,1,1123,success,0 +620084,1,1123,success,0 +620085,1,1123,success,0 +620086,1,1123,success,0 +620087,1,1123,success,0 +620088,1,1123,success,0 +620089,1,1123,success,0 +620090,1,1123,success,0 +620091,1,1123,success,0 +620092,1,1123,success,0 +620093,1,1123,success,0 +620094,1,1123,success,0 +620095,1,1123,success,0 +620096,1,1123,success,0 +620097,1,1123,success,0 +620098,1,1123,success,0 +620099,1,1123,success,0 diff --git a/policies/wall_cupboard_open/gpt61sol-s3/policy.py b/policies/wall_cupboard_open/gpt61sol-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..059d58e02b8dfbfe0bd2ef4cff31c719ff73c4d8 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61sol-s3/policy.py @@ -0,0 +1,67 @@ +"""Deterministic two-handed cabinet opening controller.""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.action = np.asarray(tools.hold_action(), dtype=float).copy() + + def act(self, obs, tools): + step = int(obs["t"]) + target = self.action.copy() + target[:2] = 0.0 + target[2] = 0.74 + target[3:5] = 0.0 + + # Raise the hands before bending the elbows toward the handles. + if step < 230: + pitch, elbow, yaw, roll = -1.8, 0.0, 0.0, 0.0 + wrist_pitch, wrist_roll, wrist_yaw = 0.0, 0.0, 0.0 + grip, base_x = 0.6, 0.16 + elif step < 550: + pitch, elbow, yaw, roll = -1.8, 0.8, -0.2, 0.0 + wrist_pitch, wrist_roll, wrist_yaw = 0.3, -0.4, 0.2 + grip, base_x = 0.3, 0.18 + elif step < 650: + pitch, elbow, yaw, roll = -1.8, 0.8, -0.2, 0.0 + wrist_pitch, wrist_roll, wrist_yaw = 0.3, -0.4, 0.2 + grip, base_x = 1.0, 0.18 + # Pull the handles away from the cabinet, then follow their arcs. + elif step < 850: + pitch, elbow, yaw, roll = -1.8, 0.8, 0.0, 0.25 + wrist_pitch, wrist_roll, wrist_yaw = 0.3, -0.6, 0.0 + grip, base_x = 1.0, -0.02 + elif step < 1050: + pitch, elbow, yaw, roll = -1.8, 0.8, 0.6, 0.45 + wrist_pitch, wrist_roll, wrist_yaw = 0.3, -0.7, -0.4 + grip, base_x = 1.0, 0.05 + elif step < 1250: + pitch, elbow, yaw, roll = -1.8, 0.8, 1.0, 0.75 + wrist_pitch, wrist_roll, wrist_yaw = 0.3, -0.7, -0.8 + grip, base_x = 1.0, 0.18 + else: + pitch, elbow, yaw, roll = -1.8, 0.8, 1.2, 1.1 + wrist_pitch, wrist_roll, wrist_yaw = 0.3, -0.7, -1.0 + grip, base_x = 1.0, 0.3 + + target[5:12] = [ + pitch, roll, yaw, elbow, wrist_roll, wrist_pitch, wrist_yaw + ] + target[12:19] = [ + pitch, -roll, -yaw, elbow, -wrist_roll, wrist_pitch, -wrist_yaw + ] + target[19:21] = grip + self.action += np.clip(target - self.action, -0.012, 0.012) + + # Close the walking loop with the measured pelvis pose. + pose = np.asarray(obs["low_dim_obs"])[21:25] + velocity = np.clip( + (np.array([base_x, 0.0]) - pose[:2]) * 3.0, -0.3, 0.3 + ) + velocity[np.abs(velocity) < 0.055] = 0.0 + cosine, sine = np.cos(pose[3]), np.sin(pose[3]) + self.action[0] = velocity[0] * cosine + velocity[1] * sine + self.action[1] = -velocity[0] * sine + velocity[1] * cosine + self.action[3] = np.clip(-pose[3] * 3.0, -0.3, 0.3) + return self.action.copy() diff --git a/policies/wall_cupboard_open/gpt61terra-s1/episodes.csv b/policies/wall_cupboard_open/gpt61terra-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61terra-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/gpt61terra-s1/policy.py b/policies/wall_cupboard_open/gpt61terra-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..d7464b2c649d1bc1b557809059c8fe6ad05af7fc --- /dev/null +++ b/policies/wall_cupboard_open/gpt61terra-s1/policy.py @@ -0,0 +1,50 @@ +"""Deterministic two-handed cabinet opening controller.""" +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.initial_x = float(obs['low_dim_obs'][21]) + self.state = 0 + self.entered = int(obs['t']) + self.attempt = 0 + + def act(self, obs, tools): + t = int(obs['t']) + elapsed = t - self.entered + q = obs['low_dim_obs'] + a = np.zeros(21, dtype=np.float32) + a[2] = .74 + a[5:12] = [-1.0, -.10, 0, 0, 0, 0, 0] + a[12:19] = [-1.0, .10, 0, 0, 0, 0, 0] + a[19:21] = 0 + if self.state == 0: + if elapsed >= 100: + self.state, self.entered = 1, t + elif self.state == 1: + a[0] = .30 + if elapsed >= 25: + self.state, self.entered = 2, t + elif self.state == 2: + a[0] = .30 + a[19:21] = 1 + if elapsed >= 40: + self.state, self.entered = 3, t + elif self.state == 3: + a[0] = -.10 + a[19:21] = 1 + f = min(1., elapsed / 350.) + a[6] = -.10 + .40 * f + a[13] = -a[6] + if elapsed >= 400: + self.state, self.entered = 4, t + elif self.state == 4: + # Reset the hands and return to the handles for a second pull. + if elapsed < 25: + a[0] = 0 + else: + a[0] = .25 if q[21] < self.initial_x + .10 else 0 + if elapsed >= 130: + self.state, self.entered = 1, t + self.attempt += 1 + return a diff --git a/policies/wall_cupboard_open/gpt61terra-s2/episodes.csv b/policies/wall_cupboard_open/gpt61terra-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61terra-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/gpt61terra-s2/policy.py b/policies/wall_cupboard_open/gpt61terra-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..6c4180d98df3834d62f5b86825aa967f4ca54257 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61terra-s2/policy.py @@ -0,0 +1,59 @@ +import math +import numpy as np + +class Policy: + def reset(self, obs, tools): + self.initial = np.asarray(tools.hold_action(), dtype=np.float32) + z = obs['low_dim_obs'] + self.x0, self.y0, self.yaw0 = map(float, (z[21], z[22], z[24])) + + def act(self, obs, tools): + t = int(obs['t']) + z = obs['low_dim_obs'] + a = self.initial.copy() + a[19:21] = 0.0 + a[5:19] = 0.0 + x, y = self.x0, self.y0 + if t < 510: + a[5] = -1.0 + if t < 160: + x += .10 + elif t < 220: + x += .10 + a[19] = 1.0 + else: + a[19] = 1.0 + q = min(1.0, (t - 220) / 270.0) + theta = 1.25 * q + x += .10 - .39 * math.sin(theta) + y += .39 * (1.0 - math.cos(theta)) + elif t < 640: + pass + elif t < 1400: + a[12] = -1.0 + a[13] = -.2 + if t < 800: + x += .10 + elif t < 860: + x += .10 + a[20] = 1.0 + elif t < 1150: + a[20] = 1.0 + q = min(1.0, (t - 860) / 270.0) + theta = 1.25 * q + x += .10 - .39 * math.sin(theta) + y -= .39 * (1.0 - math.cos(theta)) + else: + a[20] = 1.0 + x += .10 - .39 * math.sin(1.25) + y -= .39 * (1.0 - math.cos(1.25)) + yaw = float(z[24]) + dx, dy = x - float(z[21]), y - float(z[22]) + c, s = math.cos(yaw), math.sin(yaw) + a[0] = np.clip(2 * (c * dx + s * dy), -.25, .25) + a[1] = np.clip(2 * (-s * dx + c * dy), -.25, .25) + if math.hypot(dx, dy) < .018: + a[0] = a[1] = 0 + error = (self.yaw0 - yaw + math.pi) % (2 * math.pi) - math.pi + a[3] = np.clip(2 * error, -.3, .3) + return a diff --git a/policies/wall_cupboard_open/gpt61terra-s3/episodes.csv b/policies/wall_cupboard_open/gpt61terra-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61terra-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/gpt61terra-s3/policy.py b/policies/wall_cupboard_open/gpt61terra-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..82e01480a73d7c71469d588f489b0e15d9b83d96 --- /dev/null +++ b/policies/wall_cupboard_open/gpt61terra-s3/policy.py @@ -0,0 +1,28 @@ +import numpy as np + +class Policy: + def reset(self,obs,tools): + self.hold=np.asarray(tools.hold_action(),dtype=np.float32) + def act(self,obs,tools): + t=obs['t']; z=obs['low_dim_obs']; a=self.hold.copy();a[19:21]=0 + def goto(x,y): + ex=x-z[21];ey=y-z[22] + a[0]=np.clip(ex*1.5,-.18,.18) if abs(ex)>.03 else 0 + a[1]=np.clip(ey*1.5,-.18,.18) if abs(ey)>.03 else 0 + a[3]=np.clip(-2*z[24],-.2,.2) + if t<180: goto(-.03,.1) + elif t<640: + a[12:19]=[-1.7,-.2,-.3,1,0,0,0] + if t<280: pass + elif t<400:a[0]=.12 + elif t<480:a[20]=1 + else: a[20]=1;a[0]=-.1;a[1]=-.07 + elif t<800: goto(-.03,.1) + elif t<1450: + a[5:12]=[-1.7,.2,.1,1,0,0,0] + if t<890: pass + elif t<1010:a[0]=.12 + elif t<1090:a[19]=1 + elif t<1290:a[19]=1;a[0]=-.1;a[1]=.05 + else:a[19]=1 + return a diff --git a/policies/wall_cupboard_open/gpt6sol-s1/episodes.csv b/policies/wall_cupboard_open/gpt6sol-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/gpt6sol-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/gpt6sol-s1/policy.py b/policies/wall_cupboard_open/gpt6sol-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..716d7454e5e4163d3e9f5d4f7dfd6858de6e22c4 --- /dev/null +++ b/policies/wall_cupboard_open/gpt6sol-s1/policy.py @@ -0,0 +1,72 @@ +"""Deterministic hand-written controller for the two cabinet doors.""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.neutral = np.asarray(tools.hold_action(), dtype=np.float32) + self.phase = "pose" + self.age = 0 + + def _next(self, phase): + self.phase = phase + self.age = 0 + + def act(self, obs, tools): + x = float(obs["low_dim_obs"][21]) + a = self.neutral.copy() + a[5] = a[12] = -1.1 + a[6], a[13] = 0.1, -0.1 + a[19:21] = 0.3 + + if self.phase == "pose": + if self.age >= 60: + self._next("approach") + elif self.phase == "approach": + if x < 0.22 and self.age < 125: + a[0] = 0.1 + else: + self._next("settle") + elif self.phase == "settle": + if self.age >= 20: + self._next("grasp") + elif self.phase == "grasp": + a[19:21] = 1.0 + if self.age >= 35: + self._next("pull") + elif self.phase == "pull": + a[19:21] = 1.0 + a[0] = -0.15 + if self.age >= 80: + self._next("sweep") + elif self.phase == "sweep": + a[19:21] = 1.0 + fraction = min(1.0, self.age / 180.0) + roll = 0.1 + 0.6 * fraction + a[6], a[13] = roll, -roll + if self.age >= 180: + self._next("hold") + elif self.phase == "hold": + a[19:21] = 1.0 + a[6], a[13] = 0.7, -0.7 + if self.age >= 90: + self._next("spread") + elif self.phase == "spread": + a[19:21] = 1.0 + fraction = min(1.0, self.age / 110.0) + roll = 0.7 + 0.35 * fraction + a[6], a[13] = roll, -roll + if self.age >= 110: + self._next("hold_wide") + elif self.phase == "hold_wide": + a[19:21] = 1.0 + a[6], a[13] = 1.05, -1.05 + if self.age >= 90: + self._next("release") + elif self.phase == "release": + if self.age >= 55: + self._next("approach") + + self.age += 1 + return a diff --git a/policies/wall_cupboard_open/gpt6sol-s2/episodes.csv b/policies/wall_cupboard_open/gpt6sol-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/gpt6sol-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/gpt6sol-s2/policy.py b/policies/wall_cupboard_open/gpt6sol-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..ce6537ea5c3f38e01a2a2280ee37e98c11ed3c3e --- /dev/null +++ b/policies/wall_cupboard_open/gpt6sol-s2/policy.py @@ -0,0 +1,36 @@ +"""Hand-written controller for opening both wall-cabinet doors.""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.action = np.asarray(tools.hold_action(), dtype=np.float32) + + def act(self, obs, tools): + t = int(obs["t"]) + q = obs["low_dim_obs"] + a = self.action + + if t < 140: + a[4] = 0.4 + a[5] = a[12] = -1.2 + a[6], a[13] = 0.0, -0.2 + a[19] = a[20] = 0.6 + x, y, _, yaw = q[21:25] + dx, dy = 0.215 - x, -y + c, s = np.cos(yaw), np.sin(yaw) + a[0] = np.clip(3.0 * (c * dx + s * dy), -0.25, 0.25) + a[1] = np.clip(3.0 * (-s * dx + c * dy), -0.25, 0.25) + a[3] = np.clip(-3.0 * yaw, -0.5, 0.5) + if abs(a[0]) < 0.06: + a[0] = 0.0 + if abs(a[1]) < 0.06: + a[1] = 0.0 + elif t < 190: + a[0] = a[1] = a[3] = 0.0 + a[19] = a[20] = 1.0 + else: + a[7], a[14] = 0.8, -0.8 + + return a diff --git a/policies/wall_cupboard_open/gpt6sol-s3/episodes.csv b/policies/wall_cupboard_open/gpt6sol-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/gpt6sol-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/gpt6sol-s3/policy.py b/policies/wall_cupboard_open/gpt6sol-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..8b03c93d9b8c07e36e22ab7795c03a687d06a2f7 --- /dev/null +++ b/policies/wall_cupboard_open/gpt6sol-s3/policy.py @@ -0,0 +1,17 @@ +import math +import numpy as np +class Policy: + def reset(self,obs,tools): self.base=np.asarray(tools.hold_action(),np.float32) + def act(self,obs,tools): + t=int(obs['t']);p=obs['low_dim_obs'][21:25];x,y,yaw=float(p[0]),float(p[1]),float(p[3]);a=self.base.copy();a[5:19]=0;a[5]=a[12]=-1;a[6]=-.2;a[13]=.2;a[19:21]=0 + if t<190: + dx,dy=.31-x,-.02-y;f=math.cos(yaw)*dx+math.sin(yaw)*dy;l=-math.sin(yaw)*dx+math.cos(yaw)*dy + for i,v in ((0,f),(1,l)): + z=float(np.clip(2*v,-.27,.27));a[i]=z if abs(z)>=.06 else 0 + a[3]=float(np.clip(2*(.3-yaw),-.25,.25)) + if t>=190:a[19:21]=1 + if t>=300: + q=min((t-300)/500,1.);a[8]=a[15]=1.0*q;a[6]=-.2+.5*q;a[13]=.2-.5*q;a[11]=-.3*q;a[18]=.3*q + if t>=800: + q=min((t-800)/350,1.);a[5]=a[12]=-1+.5*q;a[6]=.3+.5*q;a[13]=-.3-.5*q + return a diff --git a/policies/wall_cupboard_open/kimi31pro-s1/episodes.csv b/policies/wall_cupboard_open/kimi31pro-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/kimi31pro-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/kimi31pro-s1/policy.py b/policies/wall_cupboard_open/kimi31pro-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..af31450afb85d915d69cc8e9e60399cffaf4e0d0 --- /dev/null +++ b/policies/wall_cupboard_open/kimi31pro-s1/policy.py @@ -0,0 +1,211 @@ +"""Hand-written camera-guided controller for the two wall-cabinet doors.""" + +import cv2 +import numpy as np + + +class Policy: + """Deterministic joint/base state machine with wrist-camera handle alignment.""" + + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + self.current = self.hold[5:19].copy() + self.left = np.array([-2.0, .3, 0, .3, 0, 1.5, 0]) + self.right = np.array([-2.0, -.3, 0, .3, 0, 1.5, 0]) + self.aligned_right = self.right.copy() + self.stage = "reach08" + self.n = 0 + self.iteration = 0 + self.move_start = self.current.copy() + self.move_target = self.current.copy() + self.right_pose = np.zeros(3) + + @staticmethod + def handle_point(im): + """Locate the large vertical grey pull handle near finger height.""" + gray = cv2.cvtColor(im, cv2.COLOR_RGB2GRAY) + mask = cv2.inRange(gray, 60, 155) + count, labels, stats, cents = cv2.connectedComponentsWithStats(mask) + candidates = [] + for i in range(1, count): + x, y, w, h, area = stats[i] + if y <= 5 and h >= 35 and w <= 45 and area >= 150: + yy, xx = np.where(labels[max(0, 35-y):max(0, 52-y), x:x+w] == i) + if len(xx): + px = float(x + xx.mean()) + py = float(max(0, 35-y) + yy.mean()) + else: + px, py = map(float, cents[i]) + candidates.append((area, px, py)) + if not candidates: + return None + return max(candidates) + + def action(self, base=(0, 0, .74, 0, 0), grips=(0, 0)): + a = self.hold.copy() + a[:5] = base + a[5:19] = self.current + a[19:21] = grips + return a + + def advance(self, stage): + self.stage = stage + self.n = 0 + + def move(self, target, duration, next_stage, base=(0, 0, .74, 0, 0), grips=(0, 0)): + if self.n == 0: + self.move_start = self.current.copy() + self.move_target = np.asarray(target, dtype=float).reshape(14) + if self.n < duration: + alpha = min(1.0, (self.n + 1) / max(1, duration - 20)) + self.current = self.move_start + (self.move_target - self.move_start) * alpha + else: + self.current = self.move_target.copy() + a = self.action(base, grips) + self.n += 1 + if self.n >= duration + 1: + self.advance(next_stage) + return a + + def apply(self, duration, next_stage, base=(0, 0, .74, 0, 0), grips=(0, 0)): + a = self.action(base, grips) + self.n += 1 + if self.n >= duration: + self.advance(next_stage) + return a + + def act(self, obs, tools): + s = self.stage + both = np.r_[self.left, self.right] + aligned = np.r_[self.left, self.aligned_right] + + if s == "reach08": + pose = np.r_[[-2, 0, 0, .2, 0, .8, 0], [-2, 0, 0, .2, 0, .8, 0]] + return self.move(pose, 100, "reach15") + if s == "reach15": + pose = np.r_[[-2, 0, 0, .2, 0, 1.5, 0], [-2, 0, 0, .2, 0, 1.5, 0]] + return self.move(pose, 80, "outward") + if s == "outward": + return self.move(both, 60, "settle") + if s == "settle": + return self.apply(20, "shift_right") + if s == "shift_right": + return self.apply(35, "settle_shift", (0, -.08, .74, 0, 0)) + if s == "settle_shift": + return self.apply(60, "forward") + if s == "forward": + return self.apply(30, "settle_forward", (.12, 0, .74, 0, 0)) + if s == "settle_forward": + return self.apply(30, "close_left") + if s == "close_left": + return self.apply(60, "hold_left", grips=(1, 0)) + if s == "hold_left": + return self.apply(30, "reposition", grips=(1, 0)) + + if s == "reposition": + q = obs["low_dim_obs"] + yaw = float(q[24]) + dx, dy = .196 - float(q[21]), .041 - float(q[22]) + yaw_error = .025 - yaw + if dx*dx + dy*dy < .008**2 and abs(yaw_error) < .02: + vx = vy = wz = 0.0 + else: + wx, wy = 1.8*dx, 1.8*dy + vx = np.cos(yaw)*wx + np.sin(yaw)*wy + vy = -np.sin(yaw)*wx + np.cos(yaw)*wy + vx = float(np.clip(vx, -.20, .20)) + vy = float(np.clip(vy, -.12, .12)) + wz = float(np.clip(yaw_error, -.3, .3)) + if abs(vx) < .06 and abs(vy) < .06: + if abs(vx) > abs(vy): + vx = .06*np.sign(vx) + else: + vy = .06*np.sign(vy) + a = self.action((vx, vy, .74, wz, 0), (1, 0)) + self.n += 1 + if self.n >= 190: + self.aligned_right = self.right.copy() + self.aligned_right[1] = -.18 + self.advance("right_align") + return a + + if s == "right_align": + return self.move(aligned, 40, "right_settle", grips=(1, 0)) + if s == "right_settle": + return self.apply(30, "fine_measure", grips=(1, 0)) + + if s in ("fine_measure", "depth_measure"): + hp = self.handle_point(tools.image("right_wrist")) + prefix = "fine" if s == "fine_measure" else "depth" + limit = 8 if prefix == "fine" else 3 + if hp is not None and abs(hp[1] - 46) < 5: + self.advance("right_depth" if prefix == "fine" else "capture_right") + return self.act(obs, tools) + if self.iteration >= limit: + self.advance("right_depth" if prefix == "fine" else "capture_right") + return self.act(obs, tools) + dr = float(np.clip((46-hp[1])/60., -.08, .08)) if hp is not None else .08 + self.aligned_right[1] = float(np.clip(self.aligned_right[1] + dr, -.6, .6)) + self.iteration += 1 + self.advance(prefix + "_move") + return self.act(obs, tools) + + if s == "fine_move": + return self.move(aligned, 20, "fine_settle", grips=(1, 0)) + if s == "fine_settle": + return self.apply(10, "fine_measure", grips=(1, 0)) + if s == "right_depth": + self.aligned_right[0] = -1.9 + self.iteration = 0 + return self.move(np.r_[self.left, self.aligned_right], 30, "depth_settle", grips=(1, 0)) + if s == "depth_settle": + return self.apply(10, "depth_measure", grips=(1, 0)) + if s == "depth_move": + return self.move(aligned, 20, "depth_align_settle", grips=(1, 0)) + if s == "depth_align_settle": + return self.apply(10, "depth_measure", grips=(1, 0)) + + if s == "capture_right": + q = obs["low_dim_obs"] + self.right_pose = np.array([q[21], q[22], q[24]], dtype=float) + self.advance("close_right") + return self.act(obs, tools) + + if s in ("close_right", "hold_right"): + q = obs["low_dim_obs"] + yaw = float(q[24]) + dx = self.right_pose[0] - float(q[21]) + dy = self.right_pose[1] - float(q[22]) + yaw_error = self.right_pose[2] - yaw + wx, wy = 1.8*dx, 1.8*dy + vx = np.cos(yaw)*wx + np.sin(yaw)*wy + vy = -np.sin(yaw)*wx + np.cos(yaw)*wy + vx = float(np.clip(vx, -.12, .12)) + vy = float(np.clip(vy, -.10, .10)) + wz = float(np.clip(1.5*yaw_error, -.2, .2)) + if dx*dx + dy*dy < .008**2: + vx = vy = 0.0 + elif abs(vx) < .06 and abs(vy) < .06: + if abs(vx) > abs(vy): + vx = .06*np.sign(vx) + else: + vy = .06*np.sign(vy) + a = self.action((vx, vy, .74, wz, 0), (1, 1)) + self.n += 1 + if s == "close_right" and self.n >= 60: + self.advance("hold_right") + elif s == "hold_right" and self.n >= 30: + self.advance("right_arc1") + return a + + if s == "right_arc1": + return self.apply(45, "right_arc2", (-.25, -.12, .74, 0, 0), (1, 1)) + if s == "right_arc2": + return self.apply(85, "pull_left", (-.08, -.22, .74, 0, 0), (1, 1)) + if s == "pull_left": + pull_left = self.left.copy() + pull_left[0], pull_left[5] = -1.2, .7 + return self.move(np.r_[pull_left, self.aligned_right], 80, "final_retract", grips=(1, 1)) + if s == "final_retract": + return self.move(np.zeros(14), 80, "hold_open", grips=(1, 1)) + return self.action((0, 0, .74, 0, 0), (1, 1)) diff --git a/policies/wall_cupboard_open/kimi31pro-s2/episodes.csv b/policies/wall_cupboard_open/kimi31pro-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..c20ad92247caa83f45ccd5b079a4f67ebf10ca1a --- /dev/null +++ b/policies/wall_cupboard_open/kimi31pro-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,660,success,0 +620001,1,660,success,0 +620002,1,660,success,0 +620003,1,660,success,0 +620004,1,660,success,0 +620005,1,660,success,0 +620006,1,660,success,0 +620007,1,660,success,0 +620008,1,660,success,0 +620009,1,660,success,0 +620010,1,660,success,0 +620011,1,660,success,0 +620012,1,660,success,0 +620013,1,660,success,0 +620014,1,660,success,0 +620015,1,660,success,0 +620016,1,660,success,0 +620017,1,660,success,0 +620018,1,660,success,0 +620019,1,660,success,0 +620020,1,660,success,0 +620021,1,660,success,0 +620022,1,660,success,0 +620023,1,660,success,0 +620024,1,660,success,0 +620025,1,660,success,0 +620026,1,660,success,0 +620027,1,660,success,0 +620028,1,660,success,0 +620029,1,660,success,0 +620030,1,660,success,0 +620031,1,660,success,0 +620032,1,660,success,0 +620033,1,660,success,0 +620034,1,660,success,0 +620035,1,660,success,0 +620036,1,660,success,0 +620037,1,660,success,0 +620038,1,660,success,0 +620039,1,660,success,0 +620040,1,660,success,0 +620041,1,660,success,0 +620042,1,660,success,0 +620043,1,660,success,0 +620044,1,660,success,0 +620045,1,660,success,0 +620046,1,660,success,0 +620047,1,660,success,0 +620048,1,660,success,0 +620049,1,660,success,0 +620050,1,660,success,0 +620051,1,660,success,0 +620052,1,660,success,0 +620053,1,660,success,0 +620054,1,660,success,0 +620055,1,660,success,0 +620056,1,660,success,0 +620057,1,660,success,0 +620058,1,660,success,0 +620059,1,660,success,0 +620060,1,660,success,0 +620061,1,660,success,0 +620062,1,660,success,0 +620063,1,660,success,0 +620064,1,660,success,0 +620065,1,660,success,0 +620066,1,660,success,0 +620067,1,660,success,0 +620068,1,660,success,0 +620069,1,660,success,0 +620070,1,660,success,0 +620071,1,660,success,0 +620072,1,660,success,0 +620073,1,660,success,0 +620074,1,660,success,0 +620075,1,660,success,0 +620076,1,660,success,0 +620077,1,660,success,0 +620078,1,660,success,0 +620079,1,660,success,0 +620080,1,660,success,0 +620081,1,660,success,0 +620082,1,660,success,0 +620083,1,660,success,0 +620084,1,660,success,0 +620085,1,660,success,0 +620086,1,660,success,0 +620087,1,660,success,0 +620088,1,660,success,0 +620089,1,660,success,0 +620090,1,660,success,0 +620091,1,660,success,0 +620092,1,660,success,0 +620093,1,660,success,0 +620094,1,660,success,0 +620095,1,660,success,0 +620096,1,660,success,0 +620097,1,660,success,0 +620098,1,660,success,0 +620099,1,660,success,0 diff --git a/policies/wall_cupboard_open/kimi31pro-s2/policy.py b/policies/wall_cupboard_open/kimi31pro-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..a316558d2aba36bf8a9eb0d4a0f0c6cb77e91894 --- /dev/null +++ b/policies/wall_cupboard_open/kimi31pro-s2/policy.py @@ -0,0 +1,130 @@ +"""Deterministic hand-written controller for the two-door wall cabinet.""" + +import numpy as np + + +P0 = np.array([-1.0, -0.2, 0.0, 0.4, 0.0, -0.4, 0.0]) +L1 = np.array([-1.03, 0.28, 0.0, 0.4, -0.2, -0.4, 0.0]) + + +def mirror(p): + return np.array([p[0], -p[1], -p[2], p[3], -p[4], p[5], -p[6]]) + + +R0 = mirror(P0) +R1 = mirror(L1) + np.array([0.0, 0.08, 0.0, 0.0, 0.0, 0.0, 0.0]) +L2 = L1.copy() +L2[1] = -0.15 +L2[0] = -1.11 +L2[5] = -0.32 +R2 = R1.copy() +R2[1] = 0.05 +LD = np.array([-0.47, 0.7, 0.0, 1.4, 0.0, -0.93, 0.0]) +RD = np.array([-0.47, -0.7, 0.0, 1.4, 0.0, -0.93, 0.0]) +LF = L2 + LD +RF = R2 + RD + + +def wrap(x): + return (x + np.pi) % (2 * np.pi) - np.pi + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + + def base_servo(self, a, obs, target): + q = obs["low_dim_obs"] + x, y, _, yaw = q[21:25] + ex, ey = target[0] - x, target[1] - y + dx = np.cos(yaw) * ex + np.sin(yaw) * ey + dy = -np.sin(yaw) * ex + np.cos(yaw) * ey + vx = float(np.clip(1.4 * dx, -0.3, 0.3)) + vy = float(np.clip(1.4 * dy, -0.3, 0.3)) + if np.hypot(ex, ey) < 0.015: + vx = vy = 0.0 + elif np.hypot(vx, vy) < 0.06: + scale = 0.06 / max(np.hypot(vx, vy), 1e-6) + vx *= scale + vy *= scale + ye = wrap(target[2] - yaw) + a[0], a[1], a[2] = vx, vy, 0.74 + a[3] = float(np.clip(1.2 * ye, -0.3, 0.3)) if abs(ye) > 0.02 else 0.0 + a[4] = 0.0 + return a + + def act(self, obs, tools): + t = int(obs["t"]) + a = self.hold.copy() + a[19:21] = 0.0 + + if t < 350: + if t < 100: + left, right = P0, R0 + elif t < 150: + u = (t - 100) / 50.0 + left = (1 - u) * P0 + u * L1 + right = (1 - u) * R0 + u * R1 + elif t < 230: + left, right = L1, R1 + elif t < 270: + u = (t - 230) / 40.0 + left = (1 - u) * L1 + u * L2 + right = (1 - u) * R1 + u * R2 + else: + left, right = L2, R2 + + if t < 150: + a = self.base_servo(a, obs, np.array([0.16, 0.02, 0.0])) + elif t < 230: + a[0:5] = [0.0, 0.0, 0.74, 0.0, 0.0] + elif t < 310: + a = self.base_servo(a, obs, np.array([0.28, 0.02, 0.0])) + else: + a[0:5] = [0.0, 0.0, 0.74, 0.0, 0.0] + + if 230 <= t < 270: + a[19:21] = 0.8 * (t - 230) / 40.0 + elif 270 <= t < 310: + a[19:21] = 0.8 + elif t >= 310: + a[19:21] = 0.8 + 0.2 * min(1.0, (t - 310) / 40.0) + + elif t < 1190: + s = (t - 350) % 210 + if s < 50: + u = s / 50.0 + left = L2 + u * LD + right = R2 + u * RD + a[19:21] = 1.0 + a[0:5] = [0.0, 0.0, 0.74, 0.0, 0.0] + elif s < 80: + left, right = LF, RF + a[19:21] = 1.0 + a[0:5] = [0.0, 0.0, 0.74, 0.0, 0.0] + elif s < 180: + u = (s - 80) / 100.0 + left = (1 - u) * LF + u * L2 + right = (1 - u) * RF + u * R2 + a[19:21] = 0.8 + a = self.base_servo(a, obs, np.array([0.28, 0.02, 0.0])) + else: + left, right = L2, R2 + a[19:21] = 1.0 + a = self.base_servo(a, obs, np.array([0.28, 0.02, 0.0])) + + if s < 80: + a[3] = float(np.clip(2.0 * wrap(0.05 - obs["low_dim_obs"][24]), -0.4, 0.4)) + + else: + u = min(1.0, (t - 1190) / 50.0) + left = L2 + u * LD + right = R2 + u * RD + a[0:5] = [0.0, 0.0, 0.74, 0.0, 0.0] + a[19:21] = 1.0 if t < 1240 else 0.0 + if t < 1240: + a[3] = float(np.clip(2.0 * wrap(0.05 - obs["low_dim_obs"][24]), -0.4, 0.4)) + + a[5:12] = left + a[12:19] = right + return a diff --git a/policies/wall_cupboard_open/kimi31pro-s3/episodes.csv b/policies/wall_cupboard_open/kimi31pro-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..208825a2681ed9d76106255e35976ef036dbcaf9 --- /dev/null +++ b/policies/wall_cupboard_open/kimi31pro-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,0,1450,timeout,0 +620001,0,1450,timeout,0 +620002,0,1450,timeout,0 +620003,0,1450,timeout,0 +620004,0,1450,timeout,0 +620005,0,1450,timeout,0 +620006,0,1450,timeout,0 +620007,0,1450,timeout,0 +620008,0,1450,timeout,0 +620009,0,1450,timeout,0 +620010,0,1450,timeout,0 +620011,0,1450,timeout,0 +620012,0,1450,timeout,0 +620013,0,1450,timeout,0 +620014,0,1450,timeout,0 +620015,0,1450,timeout,0 +620016,0,1450,timeout,0 +620017,0,1450,timeout,0 +620018,0,1450,timeout,0 +620019,0,1450,timeout,0 +620020,0,1450,timeout,0 +620021,0,1450,timeout,0 +620022,0,1450,timeout,0 +620023,0,1450,timeout,0 +620024,0,1450,timeout,0 +620025,0,1450,timeout,0 +620026,0,1450,timeout,0 +620027,0,1450,timeout,0 +620028,0,1450,timeout,0 +620029,0,1450,timeout,0 +620030,0,1450,timeout,0 +620031,0,1450,timeout,0 +620032,0,1450,timeout,0 +620033,0,1450,timeout,0 +620034,0,1450,timeout,0 +620035,0,1450,timeout,0 +620036,0,1450,timeout,0 +620037,0,1450,timeout,0 +620038,0,1450,timeout,0 +620039,0,1450,timeout,0 +620040,0,1450,timeout,0 +620041,0,1450,timeout,0 +620042,0,1450,timeout,0 +620043,0,1450,timeout,0 +620044,0,1450,timeout,0 +620045,0,1450,timeout,0 +620046,0,1450,timeout,0 +620047,0,1450,timeout,0 +620048,0,1450,timeout,0 +620049,0,1450,timeout,0 +620050,0,1450,timeout,0 +620051,0,1450,timeout,0 +620052,0,1450,timeout,0 +620053,0,1450,timeout,0 +620054,0,1450,timeout,0 +620055,0,1450,timeout,0 +620056,0,1450,timeout,0 +620057,0,1450,timeout,0 +620058,0,1450,timeout,0 +620059,0,1450,timeout,0 +620060,0,1450,timeout,0 +620061,0,1450,timeout,0 +620062,0,1450,timeout,0 +620063,0,1450,timeout,0 +620064,0,1450,timeout,0 +620065,0,1450,timeout,0 +620066,0,1450,timeout,0 +620067,0,1450,timeout,0 +620068,0,1450,timeout,0 +620069,0,1450,timeout,0 +620070,0,1450,timeout,0 +620071,0,1450,timeout,0 +620072,0,1450,timeout,0 +620073,0,1450,timeout,0 +620074,0,1450,timeout,0 +620075,0,1450,timeout,0 +620076,0,1450,timeout,0 +620077,0,1450,timeout,0 +620078,0,1450,timeout,0 +620079,0,1450,timeout,0 +620080,0,1450,timeout,0 +620081,0,1450,timeout,0 +620082,0,1450,timeout,0 +620083,0,1450,timeout,0 +620084,0,1450,timeout,0 +620085,0,1450,timeout,0 +620086,0,1450,timeout,0 +620087,0,1450,timeout,0 +620088,0,1450,timeout,0 +620089,0,1450,timeout,0 +620090,0,1450,timeout,0 +620091,0,1450,timeout,0 +620092,0,1450,timeout,0 +620093,0,1450,timeout,0 +620094,0,1450,timeout,0 +620095,0,1450,timeout,0 +620096,0,1450,timeout,0 +620097,0,1450,timeout,0 +620098,0,1450,timeout,0 +620099,0,1450,timeout,0 diff --git a/policies/wall_cupboard_open/kimi31pro-s3/policy.py b/policies/wall_cupboard_open/kimi31pro-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..2d2ec0f72d792dc34936be0391ca1e1537f1b677 --- /dev/null +++ b/policies/wall_cupboard_open/kimi31pro-s3/policy.py @@ -0,0 +1,113 @@ +"""Deterministic staged controller for the two-door wall cabinet. + +The right hand engages first and remains closed. The left hand then approaches +on an outward trajectory to avoid the stationary right forearm. Only after +both grasp attempts are complete does the controller pull both doors outward. +""" + +import numpy as np + + +class Policy: + def reset(self, obs, tools): + self.hold = np.asarray(tools.hold_action(), dtype=np.float32) + state = np.asarray(obs["low_dim_obs"], dtype=np.float64) + self.home = state[21:25].copy() + self.start = self.hold[5:19].astype(np.float64) + self.t = 0 + + @staticmethod + def pose(roll=0.0, wp=0.6, wy=0.0): + return np.array([-1.7, roll, 0.0, 0.5, 0.0, wp, wy]) + + def base_hold(self, obs): + state = np.asarray(obs["low_dim_obs"], dtype=np.float64) + pos = state[21:25] + dx, dy = self.home[:2] - pos[:2] + yaw = pos[3] + vx = np.cos(yaw) * dx + np.sin(yaw) * dy + vy = -np.sin(yaw) * dx + np.cos(yaw) * dy + out = np.zeros(4) + if abs(vx) > 0.035: + out[0] = np.clip(2.0 * vx, -0.15, 0.15) + if abs(vy) > 0.035: + out[1] = np.clip(2.0 * vy, -0.15, 0.15) + if abs(self.home[3] - yaw) > 0.055: + out[3] = np.clip(self.home[3] - yaw, -0.15, 0.15) + return out + + def act(self, obs, tools): + self.t += 1 + t = self.t + a = self.hold.copy().astype(np.float64) + a[0:2] = 0.0 + a[3] = 0.0 + base = np.zeros(4) + left = np.zeros(7) + right = np.zeros(7) + left_grip = right_grip = 0.6 + + raised = self.pose() + raised_left = self.pose(0.3) + aligned_r = self.pose(0.01, wy=-0.4) + grasp_r = self.pose(-0.09, 0.85, -0.4) + aligned_l = self.pose(-0.01, wy=0.4) + grasp_l = self.pose(0.09, 0.85, 0.4) + aligned_r[0] = grasp_r[0] = -1.65 + aligned_l[0] = grasp_l[0] = -1.65 + + if t <= 420: + local = t + if local <= 180: + u = min(1.0, local / 140.0) + right = self.start[7:] * (1.0 - u) + raised * u + right_grip = 0.0 + base = self.base_hold(obs) + elif local <= 320: + u = min(1.0, (local - 180) / 100.0) + right = raised * (1.0 - u) + aligned_r * u + right_grip = 0.0 + else: + u = min(1.0, (local - 320) / 50.0) + right = aligned_r * (1.0 - u) + grasp_r * u + right_grip = 0.0 if local <= 340 else 0.6 + if local <= 370: + base[0] = 0.08 + else: + # Do not release or move the first handle while the second hand + # approaches. In particular, there is no base-return transition. + right = grasp_r + right_grip = 1.0 + local = t - 420 + if local <= 420: + if local <= 180: + u = min(1.0, local / 140.0) + left = self.start[:7] * (1.0 - u) + raised_left * u + left_grip = 0.0 + base = self.base_hold(obs) + elif local <= 320: + u = min(1.0, (local - 180) / 100.0) + left = raised_left * (1.0 - u) + aligned_l * u + left_grip = 0.0 + else: + u = min(1.0, (local - 320) / 50.0) + left = aligned_l * (1.0 - u) + grasp_l * u + left_grip = 0.0 if local <= 340 else (0.6 if local <= 420 else 1.0) + if local <= 370: + base[0] = 0.08 + else: + left = grasp_l + left_grip = 1.0 + if local > 480: + u = min(1.0, (local - 480) / 200.0) + left = left.copy() + right = right.copy() + left[1] += 0.4 * u + right[1] -= 0.4 * u + base[0] = -0.12 + + a[0], a[1], a[3] = base[0], base[1], base[3] + a[5:12] = left + a[12:19] = right + a[19], a[20] = left_grip, right_grip + return np.asarray(a, dtype=np.float32) diff --git a/policies/wall_cupboard_open/opus-s1/episodes.csv b/policies/wall_cupboard_open/opus-s1/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..518de7f0d9cc18ff0c162dddf669c560bc3cf829 --- /dev/null +++ b/policies/wall_cupboard_open/opus-s1/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1115,success,0 +620001,1,1115,success,0 +620002,1,1115,success,0 +620003,1,1115,success,0 +620004,1,1115,success,0 +620005,1,1115,success,0 +620006,1,1115,success,0 +620007,1,1115,success,0 +620008,1,1115,success,0 +620009,1,1115,success,0 +620010,1,1115,success,0 +620011,1,1115,success,0 +620012,1,1115,success,0 +620013,1,1115,success,0 +620014,1,1115,success,0 +620015,1,1115,success,0 +620016,1,1115,success,0 +620017,1,1115,success,0 +620018,1,1115,success,0 +620019,1,1115,success,0 +620020,1,1115,success,0 +620021,1,1115,success,0 +620022,1,1115,success,0 +620023,1,1115,success,0 +620024,1,1115,success,0 +620025,1,1115,success,0 +620026,1,1115,success,0 +620027,1,1115,success,0 +620028,1,1115,success,0 +620029,1,1115,success,0 +620030,1,1115,success,0 +620031,1,1115,success,0 +620032,1,1115,success,0 +620033,1,1115,success,0 +620034,1,1115,success,0 +620035,1,1115,success,0 +620036,1,1115,success,0 +620037,1,1115,success,0 +620038,1,1115,success,0 +620039,1,1115,success,0 +620040,1,1115,success,0 +620041,1,1115,success,0 +620042,1,1115,success,0 +620043,1,1115,success,0 +620044,1,1115,success,0 +620045,1,1115,success,0 +620046,1,1115,success,0 +620047,1,1115,success,0 +620048,1,1115,success,0 +620049,1,1115,success,0 +620050,1,1115,success,0 +620051,1,1115,success,0 +620052,1,1115,success,0 +620053,1,1115,success,0 +620054,1,1115,success,0 +620055,1,1115,success,0 +620056,1,1115,success,0 +620057,1,1115,success,0 +620058,1,1115,success,0 +620059,1,1115,success,0 +620060,1,1115,success,0 +620061,1,1115,success,0 +620062,1,1115,success,0 +620063,1,1115,success,0 +620064,1,1115,success,0 +620065,1,1115,success,0 +620066,1,1115,success,0 +620067,1,1115,success,0 +620068,1,1115,success,0 +620069,1,1115,success,0 +620070,1,1115,success,0 +620071,1,1115,success,0 +620072,1,1115,success,0 +620073,1,1115,success,0 +620074,1,1115,success,0 +620075,1,1115,success,0 +620076,1,1115,success,0 +620077,1,1115,success,0 +620078,1,1115,success,0 +620079,1,1115,success,0 +620080,1,1115,success,0 +620081,1,1115,success,0 +620082,1,1115,success,0 +620083,1,1115,success,0 +620084,1,1115,success,0 +620085,1,1115,success,0 +620086,1,1115,success,0 +620087,1,1115,success,0 +620088,1,1115,success,0 +620089,1,1115,success,0 +620090,1,1115,success,0 +620091,1,1115,success,0 +620092,1,1115,success,0 +620093,1,1115,success,0 +620094,1,1115,success,0 +620095,1,1115,success,0 +620096,1,1115,success,0 +620097,1,1115,success,0 +620098,1,1115,success,0 +620099,1,1115,success,0 diff --git a/policies/wall_cupboard_open/opus-s1/policy.py b/policies/wall_cupboard_open/opus-s1/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..ba01dcd8cb5059c08b19c6e2f34cb522132a825a --- /dev/null +++ b/policies/wall_cupboard_open/opus-s1/policy.py @@ -0,0 +1,516 @@ +"""Open both doors of the wall cabinet (Unitree G1, hand-written control). + +Strategy, one door at a time (left, then right): + 1. tuck the active arm (MID), step to a reaching stance in front of the door; + 2. move the gripper in front of the handle (IK on an approximate G1 arm model), + then visually servo on the handle bar seen by the wrist camera (centre it, + approach until it is as large as in the demonstration's grasp frames); + 3. close the gripper, pull the handle along the door's arc (~35 deg), release; + 4. drop below the door edge, slip behind the opened door, rise and sweep it + open around the hinge to ~110 deg, drop down and away so it stays open; + 5. lower that arm to rest and repeat with the other arm on the other door. +An integral term on the arm joint errors removes the gravity sag of the +position-controlled arms so the commanded IK poses are actually reached. +""" + +import cv2 +import numpy as np + + +# ----------------------------------------------------------------------------- kinematics +def _rx(a): + c, s = np.cos(a), np.sin(a) + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + + +def _ry(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + + +def _rz(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def _T(R=None, p=None): + M = np.eye(4) + if R is not None: + M[:3, :3] = R + if p is not None: + M[:3, 3] = p + return M + + +_AX = {'x': _rx, 'y': _ry, 'z': _rz} +TIP = 0.16 +LO = np.array([-3.0892, -1.5882, -2.618, -1.0472, -1.9722, -1.6144, -1.6144]) +HI = np.array([2.6704, 2.2515, 2.618, 2.0944, 1.9722, 1.6144, 1.6144]) + + +def _chain(side): + sg = 1.0 if side == 'l' else -1.0 + return [ + ((0.0039563, sg * 0.10022, 0.23778), sg * 0.27931, 'y'), + ((0, sg * 0.038, -0.013831), -sg * 0.27931, 'x'), + ((0, sg * 0.00624, -0.1032), 0.0, 'z'), + ((0.015783, 0, -0.080518), 0.0, 'y'), + ((0.100, sg * 0.00188791, -0.010), 0.0, 'x'), + ((0.038, 0, 0), 0.0, 'y'), + ((0.046, 0, 0), 0.0, 'z'), + ] + + +_CH = {'l': _chain('l'), 'r': _chain('r')} +_TORSO = _T(None, (-0.0039635, 0, 0.054)) + + +def fk(q, side='l', tip=TIP): + M = _TORSO.copy() + for (p, rr, ax), qi in zip(_CH[side], q): + M = M @ _T(_rx(rr), p) @ _T(_AX[ax](qi)) + return M @ _T(None, (tip, 0, 0)) + + +def limits(side): + """Joint ranges used by IK: the hardware limits narrowed to sane reaching postures.""" + lo = np.array([-3.0, -0.11, -1.2, -1.0, -1.2, -1.6, -1.2]) # shoulder roll stops near -0.12 (body) + hi = np.array([0.5, 1.4, 0.9, 2.0, 1.0, 1.6, 1.0]) + if side == 'r': + lo, hi = lo.copy(), hi.copy() + lo[[1, 2, 4, 6]], hi[[1, 2, 4, 6]] = -hi[[1, 2, 4, 6]], -lo[[1, 2, 4, 6]] + return lo, hi + + +def ik(target_p, target_d, q0, side, free=(0, 1, 2, 3, 4, 5, 6), w_dir=0.4, q_nom=None, w_nom=0.03, + iters=30, tip=TIP, w_roll=0.4): + lo, hi = limits(side) + q = np.array(q0, float).copy() + free = list(free) + d = np.asarray(target_d, float) + d = d / np.linalg.norm(d) + qn = q.copy() if q_nom is None else np.asarray(q_nom, float) + + def resid(qq): + M = fk(qq, side, tip) + return np.concatenate([np.asarray(target_p) - M[:3, 3], w_dir * (d - M[:3, 0]), + [w_roll * M[2, 1], w_roll * (1.0 - M[1, 1])], w_nom * (qn - qq)[free]]) + + for _ in range(iters): + r = resid(q) + J = np.zeros((len(r), len(free))) + for j, i in enumerate(free): + dq = q.copy() + dq[i] += 1e-5 + J[:, j] = -(resid(dq) - r) / 1e-5 + step = np.linalg.solve(J.T @ J + 1e-4 * np.eye(len(free)), J.T @ r) + q[free] += np.clip(step, -0.15, 0.15) + q = np.clip(q, lo, hi) + if np.linalg.norm(step) < 1e-6: + break + return q + + +def ik_best(p, d, side): + """Multi-start IK, used once per reach (slow but robust).""" + best = None + dn = np.asarray(d, float) / np.linalg.norm(d) + for sp in [-1.2, -1.6, -2.0, -2.4]: + for e in [-0.8, -0.3, 0.3, 0.9]: + for sr in [0.0, 0.3]: + n = np.array([sp, sr, 0, e, 0, 1.2, 0]) + if side == 'r': + n = mirror(n) + q = ik(p, d, n, side, iters=100, q_nom=n, w_nom=0.01) + M = fk(q, side) + err = (np.linalg.norm(M[:3, 3] - p) + 0.3 * np.linalg.norm(M[:3, 0] - dn) + + 0.3 * (1 - M[2, 2])) + if best is None or err < best[0]: + best = (err, q) + return best[1] + + +def mirror(q): + q = np.array(q, float).copy() + q[[1, 2, 4, 6]] *= -1 + return q + + +# ----------------------------------------------------------------------------- vision +def detect_bars(img): + im = img.astype(np.int16) + gray = im.mean(-1) + sat = im.max(-1) - im.min(-1) + mask = ((gray > 85) & (gray < 135) & (sat < 25)).astype(np.uint8) + n, lab, st, _ = cv2.connectedComponentsWithStats(mask, connectivity=4) + out = [] + for i in range(1, n): + x, y, w, h, a = st[i] + if h < 8 or a < 16: + continue + ys, xs = np.nonzero(lab == i) + rows = np.arange(y, y + h) + cnt = np.bincount(ys - y, minlength=h) + good = cnt > 0 + if good.sum() < 8: + continue + mw = float(np.median(cnt[good])) + if mw < 2 or h < 1.5 * mw or mw > 25: + continue + xm = np.bincount(ys - y, weights=xs, minlength=h)[good] / cnt[good] + r = rows[good] + slope, icpt = np.polyfit(r, xm, 1) # x = slope * row + icpt + if abs(slope) > 1.0: + continue + resid = np.abs(xm - (slope * r + icpt)) + if np.median(resid) > 2.0: + continue + bot = int(r.max()) + out.append(dict(u=float(xm.mean()), u_bot=float(slope * bot + icpt), top=int(r.min()), bot=bot, + w=mw, h=int(h), slope=float(slope))) + return out + + +# ----------------------------------------------------------------------------- policy +MID = np.array([-1.0, 0.3, 0.0, -1.0, 0.0, 0.0, 0.0]) +REST = np.array([0.0, 0.15, 0.0, 0.0, 0.0, 0.0, 0.0]) +NOM = np.array([-2.0, 0.2, 0.0, 0.3, 0.0, 1.0, 0.0]) +Y_WALK_L = -0.04 +Y_WALK_R = 0.05 +X_WALK_R = 0.14 +X_WALK = 0.13 # pelvis x (world) to walk to before reaching +PRE_P = np.array([0.43, 0.06, 0.47]) +PRE_D = np.array([1.0, 0.0, 0.2]) +U_STAR, BOT_STAR, W_STAR = 41.0, 40.0, 11.5 +BAR = 0.02 # assumed handle bar thickness (m), image scale +W_MIN = 3.5 +YANK = np.array([-0.10, 0.03, 0.0]) +YANK_T = 12 +R_DOOR = 0.28 +TH_MAX = 0.6 +TH_RATE = 0.015 +PULL_TILT = 0.5 +PUSH = True +PUSH_EXIT = True +PUSH_R = 0.20 +PUSH_PH0 = 0.25 +PUSH_PH1 = 1.9 +PUSH_RATE = 0.025 +PUSH_DROP = 0.12 +PUSH_RISE = 0.03 +SECOND = True +FIRST = 'l' +KEEP = False +K_COMP = 0.02 +COMP_MAX = 0.3 +K_SERVO = 0.05 +SERVO_BOX = np.array([0.20, 0.12, 0.10]) +W_TOL = 1.0 +GRIP_MISS = 0.96 +APPROACH_V = 0.002 +Z_MIN = 0.40 + + +class Policy: + scan = None # dev: list of (p, d) targets to visit instead of servoing + + def reset(self, obs, tools): + self.t = 0 + self.phase = 'raise' + self.pt = 0 # steps in phase + self.h = 0.78 + self.pitch = -0.15 + self.q = {'l': np.zeros(7), 'r': np.zeros(7)} + self.q_start = {'l': np.zeros(7), 'r': np.zeros(7)} + self.g = {'l': 0.0, 'r': 0.0} + self.p = {'l': PRE_P.copy(), 'r': PRE_P * [1, -1, 1]} + self.d = {'l': PRE_D.copy(), 'r': PRE_D * [1, -1, 1]} + self.track = {'l': None, 'r': None} + self.err = {'l': None, 'r': None} + self.good = {'l': 0, 'r': 0} + self.miss = {'l': 0, 'r': 0} + self.last_u = {'l': None, 'r': None} + self.base = np.zeros(3) # vx, vy, wz + self.x_goal = X_WALK + self.scan_i = 0 + self.comp = {'l': np.zeros(7), 'r': np.zeros(7)} + self.comp_on = {'l': True, 'r': True} + self.active = FIRST + self.keep = [] if KEEP else None + self.gt = 0 + self.retries = 0 + self.dbg = '' + + def _goto(self, phase): + self.phase = phase + self.pt = -1 # incremented to 0 at the end of act() + self.q_start = {s: self.q[s].copy() for s in 'lr'} + + def _interp(self, target, T): + a = min(1.0, (self.pt + 1) / T) + a = 0.5 - 0.5 * np.cos(np.pi * a) + for s in 'lr': + self.q[s] = self.q_start[s] + a * (target[s] - self.q_start[s]) + return self.pt + 1 >= T + + def _walk(self, lo): + """P-control of pelvis pose toward (x_goal, 0, yaw 0). Returns True when there.""" + x, y, yaw = lo[21], lo[22], lo[24] + y_goal = Y_WALK_R if self.active == 'r' else Y_WALK_L + x_goal = X_WALK_R if self.active == 'r' else X_WALK + ex, ey = x_goal - x, y_goal - y + c, s = np.cos(yaw), np.sin(yaw) + bx, by = c * ex + s * ey, -s * ex + c * ey + vx = float(np.clip(1.5 * bx, -0.2, 0.2)) + vy = float(np.clip(1.5 * by, -0.15, 0.15)) + sp = np.hypot(vx, vy) + vmin = 0.12 if vx < 0 else 0.07 # backward steps need a larger command + if sp < vmin: + if np.hypot(bx, by) < 0.015: + vx = vy = 0.0 + else: + vx, vy = vx / max(sp, 1e-6) * vmin, vy / max(sp, 1e-6) * vmin + wz = float(np.clip(-2.0 * yaw, -0.3, 0.3)) + self.base = np.array([vx, vy, wz]) + return np.hypot(bx, by) < 0.012 and abs(yaw) < 0.012 + + def _servo(self, s, img): + bars = detect_bars(img) + bars = [b for b in bars if b['w'] >= W_MIN and b['h'] >= 12] + self.err[s] = None + b = None + if bars and self.track[s] is not None: + tr = self.track[s] + c = min(bars, key=lambda b: abs(b['u_bot'] - tr['u_bot']) + 0.5 * abs(b['bot'] - tr['bot'])) + if abs(c['u_bot'] - tr['u_bot']) <= 8 and abs(c['bot'] - tr['bot']) <= 12: + b = c + elif bars: + c = min(bars, key=lambda b: abs(b['u_bot'] - U_STAR) + 40 * abs(b['slope'])) + if abs(c['u_bot'] - U_STAR) < 32: + b = c + if b is None: + self.miss[s] += 1 + if self.miss[s] > 25: + self.track[s] = None + # search: towards where the handle was last seen, else inward + lu = self.last_u[s] + sy = (1.0 if lu < U_STAR else -1.0) if lu is not None else (-1.0 if s == 'l' else 1.0) + self.p[s] = np.clip(self.p[s] + np.array([0.0, 0.001 * sy, 0.0]), + self.p0[s] - SERVO_BOX, self.p0[s] + SERVO_BOX) + return None + self.miss[s] = 0 + self.track[s] = b + self.last_u[s] = b['u_bot'] + scale = BAR / max(b['w'], 1.0) # metres per pixel at the handle + eu = b['u_bot'] - U_STAR + ev = b['bot'] - BOT_STAR + ew = W_STAR - b['w'] + self.err[s] = (eu, ev, ew) + R = fk(self.q[s], s)[:3, :3] + dy = float(np.clip(-K_SERVO * eu * scale, -0.002, 0.002)) + dz = float(np.clip(-K_SERVO * ev * scale, -0.002, 0.002)) + aligned = abs(eu) < 5 and abs(ev) < 6 + dx = APPROACH_V * float(np.clip(ew / 3.0, -1, 1)) if aligned else 0.0 + p = self.p[s] + R[:, 0] * dx + R[:, 1] * dy + R[:, 2] * dz + self.p[s] = np.clip(p, self.p0[s] - SERVO_BOX, self.p0[s] + SERVO_BOX) + return b + + def act(self, obs, tools): + lo = obs['low_dim_obs'] + self.t += 1 + raw = np.zeros(21) + self.base = np.zeros(3) + if self.phase == 'raise': + o = 'r' if self.active == 'l' else 'l' + tgt = {self.active: MID if self.active == 'l' else mirror(MID), o: REST if o == 'l' else mirror(REST)} + if self._interp(tgt, 35): + self._goto('walk') + elif self.phase == 'walk': + there = self._walk(lo) + if (there and self.pt > 20) or self.pt > 200: + self.base = np.zeros(3) + self._goto('pre') + elif self.phase == 'walk2': + there = self._walk(lo) + if (there and self.pt > 10) or self.pt > 120: + self.base = np.zeros(3) + self._goto('pre') + elif self.phase == 'pre': + if self.scan is not None: + self.p['l'], self.d['l'] = np.array(self.scan[0][0], float), np.array(self.scan[0][1], float) + self.p['r'], self.d['r'] = self.p['l'] * [1, -1, 1], self.d['l'] * [1, -1, 1] + if self.pt == 0: + self.qnom = {s: ik_best(self.p[s], self.d[s], s) for s in 'lr'} + if self.scan is None: # only the active arm reaches; the other stays tucked + for s in 'lr': + if s != self.active: + self.qnom[s] = self.q[s].copy() + if self._interp(self.qnom, 40): + self._goto('scan' if self.scan is not None else 'servo') + elif self.phase == 'scan': + if self.pt == 0: + self.scan_i += 1 + if self.scan_i >= len(self.scan): + self.scan_i = len(self.scan) - 1 + p, d = np.array(self.scan[self.scan_i][0], float), np.array(self.scan[self.scan_i][1], float) + self.p = {'l': p, 'r': p * [1, -1, 1]} + self.d = {'l': d, 'r': d * [1, -1, 1]} + self.scan_tgt = {s: ik(self.p[s], self.d[s], self.q[s], s, iters=150, + q_nom=self.qnom[s]) for s in 'lr'} + if self._interp(self.scan_tgt, 30) and self.pt > 45: + self._goto('scan') + elif self.phase == 'yank': + s = self.active + if self.pt == 0: + self.p_start = self.p[s].copy() + self.comp_on[s] = False + sg = 1.0 if s == 'l' else -1.0 + th = min(TH_MAX, (self.pt + 1) * TH_RATE) + hinge = self.p_start + np.array([0.0, sg * R_DOOR, 0.0]) + self.hinge = hinge + self.p[s] = hinge + np.array([-R_DOOR * np.sin(th), -sg * R_DOOR * np.cos(th), 0.0]) + self.d[s] = np.array([np.cos(th), -sg * np.sin(th), PRE_D[2] + PULL_TILT * th]) + self.q[s] = ik(self.p[s], self.d[s], self.q[s], s, iters=15, q_nom=self.qnom[s]) + gs = lo[50 if s == 'l' else 51] + self.dbg = f'th {th:.2f} grip {gs:.2f}' + if th >= TH_MAX and self.pt * TH_RATE > TH_MAX + 0.2: + self.g[s] = 0.0 + self._goto('release') + elif self.phase == 'release': + s = self.active + if self.pt >= 8 and PUSH: + self.path = self._push_path(s) + self.seg = 0 + self._goto('path') + elif self.pt >= 15: + tgt = {k: self.q[k] for k in 'lr'} + tgt[s] = MID if s == 'l' else mirror(MID) + if self.pt == 15: + self.q_start = {k: self.q[k].copy() for k in 'lr'} + self.pt -= 15 + fin = self._interp(tgt, 40) + self.pt += 15 + if fin: + self.comp[s][:] = 0.0 + self.comp_on[s] = True + if s == 'l' and SECOND: + self.active = 'r' + self.gt = 0 + self._goto('pre') + else: + self._goto('done') + elif self.phase == 'path': + s = self.active + if self.pt == 0: + self.seg_p0, self.seg_d0 = self.p[s].copy(), self.d[s].copy() + p1, d1, T = self.path[self.seg] + a = min(1.0, (self.pt + 1) / T) + self.p[s] = self.seg_p0 + a * (p1 - self.seg_p0) + self.d[s] = self.seg_d0 + a * (d1 - self.seg_d0) + self.q[s] = ik(self.p[s], self.d[s], self.q[s], s, iters=15, q_nom=self.qnom[s]) + self.dbg = f'seg {self.seg}/{len(self.path)}' + if self.pt + 1 >= T: + self.seg += 1 + if self.seg >= len(self.path): + if PUSH_EXIT: + self._goto('retract') + elif s == 'l' and SECOND: # keep the left arm as a door stop, start the right door + self.active = 'r' + self.gt = 0 + self._goto('walk2') + else: + self._goto('done') + else: + self.pt = -1 + elif self.phase == 'retract': + s = self.active + if self._interp({k: (self.q[k] if k != s else (MID if s == 'l' else mirror(MID))) for k in 'lr'}, 35): + self.comp[s][:] = 0.0 + self.comp_on[s] = True + if s == 'l' and SECOND: + self._goto('swap') + else: + self._goto('done') + elif self.phase == 'swap': # finished arm down to rest, other arm up to MID + s = self.active + o = 'r' if s == 'l' else 'l' + tgt = {s: REST if s == 'l' else mirror(REST), o: MID if o == 'l' else mirror(MID)} + if self._interp(tgt, 40): + self.active = o + self.gt = 0 + self._goto('walk2') + elif self.phase == 'servo': + if self.pt == 0: + self.p0 = {s: self.p[s].copy() for s in 'lr'} + info = [] + for s in self.active: + if self.g[s] > 0: # closing / closed on the handle + self.g[s] = min(1.0, self.g[s] + 0.1) + info.append(('grip', round(float(lo[50 if s == 'l' else 51]), 2))) + if self.g[s] >= 1.0: + self.gt += 1 + if self.gt >= 8: + if lo[50 if s == 'l' else 51] > GRIP_MISS: # closed on nothing: back off, retry + self.g[s] = 0.0 + self.gt = 0 + self.good[s] = 0 + self.track[s] = None + self.retries += 1 + R = fk(self.q[s], s)[:3, :3] + self.p[s] = self.p[s] - 0.04 * R[:, 0] + else: + self._goto('yank') + continue + img = tools.image('left_wrist' if s == 'l' else 'right_wrist') + b = self._servo(s, img) + if self.keep is not None: + self.keep.append(img) + e = self.err[s] + ok = e is not None and abs(e[0]) < 4 and abs(e[1]) < 5 and e[2] < W_TOL + self.good[s] = self.good[s] + 1 if ok else 0 + if self.good[s] >= 10: + self.g[s] = 0.05 + self.q[s] = ik(self.p[s], self.d[s], self.q[s], s, iters=10, + q_nom=self.qnom[s]) + info.append(None if b is None else (round(b['u_bot'], 1), b['bot'], round(b['w'], 1))) + self.dbg = f"{info} pL{np.round(self.p['l'], 3)} pR{np.round(self.p['r'], 3)}" + self.pt += 1 + return self._raw(lo) + + def _push_path(self, s): + """Waypoints: drop below the door edge, slip behind the opened door, rise, sweep it open.""" + sg = 1.0 if s == 'l' else -1.0 + h = self.hinge + dfw = np.array([1.0, 0.0, PRE_D[2]]) + + def arc(ph, z): + return h + np.array([-PUSH_R * np.sin(ph), -sg * PUSH_R * np.cos(ph), z - h[2]]) + + z_lo, z_hi = h[2] - PUSH_DROP, h[2] + PUSH_RISE + path = [(self.p[s] + np.array([-0.03, 0.0, -PUSH_DROP]), dfw, 15), + (arc(PUSH_PH0, z_lo), dfw, 25), + (arc(PUSH_PH0, z_hi), dfw, 15)] + ph = PUSH_PH0 + while ph < PUSH_PH1: + ph = min(PUSH_PH1, ph + 0.1) + path.append((arc(ph, z_hi), dfw, int(0.1 / PUSH_RATE))) + if PUSH_EXIT: + e1 = arc(PUSH_PH1, z_hi) + np.array([0.0, 0.0, -0.15]) + path.append((e1, dfw, 20)) + path.append((e1 + np.array([-0.12, 0.0, 0.0]), dfw, 20)) + return path + + def _raw(self, lo): + raw = np.zeros(21) + raw[0], raw[1], raw[3] = self.base + raw[2] = self.h + raw[4] = self.pitch + # integral joint compensation: removes the steady sag of the position-controlled arms + for s, i0, j0 in (('l', 5, 3), ('r', 12, 12)): + if self.comp_on[s] and s == self.active: + err = self.q[s] - lo[j0:j0 + 7] + self.comp[s] = np.clip(self.comp[s] + K_COMP * err, -COMP_MAX, COMP_MAX) + raw[i0:i0 + 7] = self.q[s] + self.comp[s] + raw[19] = self.g['l'] + raw[20] = self.g['r'] + return raw diff --git a/policies/wall_cupboard_open/opus-s2/ctrl.py b/policies/wall_cupboard_open/opus-s2/ctrl.py new file mode 100644 index 0000000000000000000000000000000000000000..b8974af0c64a1823c60fab7a22fb5237fa9cd132 --- /dev/null +++ b/policies/wall_cupboard_open/opus-s2/ctrl.py @@ -0,0 +1,62 @@ +"""World-frame arm/base control helpers for the G1 policy.""" +import numpy as np + +import fk + +MIR = np.array([1, -1, -1, 1, -1, 1, -1]) +REST = {1: np.array([-1.35, 0.15, 0.15, -0.45, 0.0, 1.2, 0.2])} +REST[-1] = REST[1] * MIR + + +def rot(yaw=0.0, pitch=0.0, roll=0.0): + """Hand orientation: x-axis = approach direction (yaw about z, pitch + = down), roll about x.""" + return fk._rz(yaw) @ fk._ry(pitch) @ fk._rx(roll) + + +def pel_pose(obs): + o = obs["low_dim_obs"] + return np.array([o[21], o[22], o[23], o[24]], dtype=float) + + +def world_to_pelvis(p_w, R_w, pel): + c, s = np.cos(pel[3]), np.sin(pel[3]) + Rzt = np.array([[c, s, 0], [-s, c, 0], [0, 0, 1]]) + d = np.asarray(p_w, float) - pel[:3] + return Rzt @ d, (Rzt @ R_w if R_w is not None else None) + + +def pelvis_to_world(p, pel): + c, s = np.cos(pel[3]), np.sin(pel[3]) + return np.array([pel[0] + c * p[0] - s * p[1], pel[1] + s * p[0] + c * p[1], pel[2] + p[2]]) + + +def hand_world(obs, side): + o = obs["low_dim_obs"] + q = o[3:10] if side > 0 else o[12:19] + R, p, _, _ = fk.fk_full(q, side, o[0:3]) + return pelvis_to_world(p, pel_pose(obs)) + + +class Arm: + def __init__(self, side, q0): + self.side = side + self.q = np.array(q0, dtype=float) + + def solve(self, obs, p_w, R_w, iters=30, wrot=0.3): + pel = pel_pose(obs) + waist = obs["low_dim_obs"][0:3] + p, R = world_to_pelvis(p_w, R_w, pel) + q = fk.ik(p, R, self.q, self.side, waist, iters=iters, wrot=wrot, q_rest=REST[self.side], wrest=0.01) + ep, er = fk.ik_err(q, p, R, self.side, waist) + if ep > 0.01 or er > 0.1: + q2 = fk.ik(p, R, REST[self.side], self.side, waist, iters=150, wrot=wrot, q_rest=REST[self.side], wrest=0.01) + ep2, er2 = fk.ik_err(q2, p, R, self.side, waist) + if ep2 + 0.1 * er2 < ep + 0.1 * er - 0.003: + q, ep, er = q2, ep2, er2 + self.q = q + return q, ep, er + + +def ease(s): + s = min(max(s, 0.0), 1.0) + return 0.5 - 0.5 * np.cos(np.pi * s) diff --git a/policies/wall_cupboard_open/opus-s2/episodes.csv b/policies/wall_cupboard_open/opus-s2/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..c01fa1b016503596a7e6e514d45348dd660b289f --- /dev/null +++ b/policies/wall_cupboard_open/opus-s2/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,997,success,0 +620001,1,997,success,0 +620002,1,997,success,0 +620003,1,997,success,0 +620004,1,997,success,0 +620005,1,997,success,0 +620006,1,997,success,0 +620007,1,997,success,0 +620008,1,997,success,0 +620009,1,997,success,0 +620010,1,997,success,0 +620011,1,997,success,0 +620012,1,997,success,0 +620013,1,997,success,0 +620014,1,997,success,0 +620015,1,997,success,0 +620016,1,997,success,0 +620017,1,997,success,0 +620018,1,997,success,0 +620019,1,997,success,0 +620020,1,997,success,0 +620021,1,997,success,0 +620022,1,997,success,0 +620023,1,997,success,0 +620024,1,997,success,0 +620025,1,997,success,0 +620026,1,997,success,0 +620027,1,997,success,0 +620028,1,997,success,0 +620029,1,997,success,0 +620030,1,997,success,0 +620031,1,997,success,0 +620032,1,997,success,0 +620033,1,997,success,0 +620034,1,997,success,0 +620035,1,997,success,0 +620036,1,997,success,0 +620037,1,997,success,0 +620038,1,997,success,0 +620039,1,997,success,0 +620040,1,997,success,0 +620041,1,997,success,0 +620042,1,997,success,0 +620043,1,997,success,0 +620044,1,997,success,0 +620045,1,997,success,0 +620046,1,997,success,0 +620047,1,997,success,0 +620048,1,997,success,0 +620049,1,997,success,0 +620050,1,997,success,0 +620051,1,997,success,0 +620052,1,997,success,0 +620053,1,997,success,0 +620054,1,997,success,0 +620055,1,997,success,0 +620056,1,997,success,0 +620057,1,997,success,0 +620058,1,997,success,0 +620059,1,997,success,0 +620060,1,997,success,0 +620061,1,997,success,0 +620062,1,997,success,0 +620063,1,997,success,0 +620064,1,997,success,0 +620065,1,997,success,0 +620066,1,997,success,0 +620067,1,997,success,0 +620068,1,997,success,0 +620069,1,997,success,0 +620070,1,997,success,0 +620071,1,997,success,0 +620072,1,997,success,0 +620073,1,997,success,0 +620074,1,997,success,0 +620075,1,997,success,0 +620076,1,997,success,0 +620077,1,997,success,0 +620078,1,997,success,0 +620079,1,997,success,0 +620080,1,997,success,0 +620081,1,997,success,0 +620082,1,997,success,0 +620083,1,997,success,0 +620084,1,997,success,0 +620085,1,997,success,0 +620086,1,997,success,0 +620087,1,997,success,0 +620088,1,997,success,0 +620089,1,997,success,0 +620090,1,997,success,0 +620091,1,997,success,0 +620092,1,997,success,0 +620093,1,997,success,0 +620094,1,997,success,0 +620095,1,997,success,0 +620096,1,997,success,0 +620097,1,997,success,0 +620098,1,997,success,0 +620099,1,997,success,0 diff --git a/policies/wall_cupboard_open/opus-s2/fk.py b/policies/wall_cupboard_open/opus-s2/fk.py new file mode 100644 index 0000000000000000000000000000000000000000..0226f7ca4a52687f92a602cc96a3eb48d72f5320 --- /dev/null +++ b/policies/wall_cupboard_open/opus-s2/fk.py @@ -0,0 +1,162 @@ +"""Approximate forward kinematics of the G1 arms (pelvis frame) and a small IK solver.""" +import numpy as np + + +def _rx(a): + c, s = np.cos(a), np.sin(a) + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + + +def _ry(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + + +def _rz(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def _rpy(r, p, y): + return _rz(y) @ _ry(p) @ _rx(r) + + +HAND = 0.16 # wrist_yaw frame -> point between the fingertips (approx.) + +# (fixed rotation, offset, joint axis) for the 7 arm joints, left side +_EX, _EY, _EZ = np.eye(3) + + +def _links(s): + return [ + (_rpy(s * 0.27931, 5.4949e-05, -s * 0.00019159), np.array([0.0039563, s * 0.10022, 0.23778]), _EY), + (_rpy(-s * 0.27925, 0, 0), np.array([0, s * 0.038, -0.013831]), _EX), + (np.eye(3), np.array([0, s * 0.00624, -0.1032]), _EZ), + (np.eye(3), np.array([0.015783, 0, -0.080518]), _EY), + (np.eye(3), np.array([0.100, s * 0.00188791, -0.010]), _EX), + (np.eye(3), np.array([0.038, 0, 0]), _EY), + (np.eye(3), np.array([0.046, 0, 0]), _EZ), + ] + + +_LINKS = {1: _links(1), -1: _links(-1)} +_ROT = {0: _rx, 1: _ry, 2: _rz} + + +def _axis_rot(axis, a): + if axis is _EX: + return _rx(a) + if axis is _EY: + return _ry(a) + return _rz(a) + + +def torso_frame(waist): + R = _rz(waist[0]) + p = np.zeros(3) + p = p + R @ np.array([-0.0039635, 0, 0.035]) + R = R @ _rx(waist[1]) + p = p + R @ np.array([0, 0, 0.019]) + R = R @ _ry(waist[2]) + return R, p + + +def fk_full(q, side, waist=(0.0, 0.0, 0.0), hand=HAND): + """Return (R, p) of the grasp point and the joint axes/positions (pelvis frame).""" + R, p = torso_frame(waist) + axes, pos = [], [] + for (Rf, off, ax), qi in zip(_LINKS[side], q): + p = p + R @ off + R = R @ Rf + axes.append(R @ ax) + pos.append(p.copy()) + R = R @ _axis_rot(ax, qi) + p = p + R @ np.array([hand, 0, 0]) + return R, p, axes, pos + + +def arm_chain(q, side, waist=(0.0, 0.0, 0.0), hand=HAND): + R, p, _, _ = fk_full(q, side, waist, hand) + T = np.eye(4) + T[:3, :3] = R + T[:3, 3] = p + return T + + +def _rotvec(Re): + ang = np.arccos(np.clip((np.trace(Re) - 1) / 2, -1, 1)) + if ang < 1e-9: + return np.zeros(3) + v = np.array([Re[2, 1] - Re[1, 2], Re[0, 2] - Re[2, 0], Re[1, 0] - Re[0, 1]]) + if ang > np.pi - 1e-4: + # near pi: use a stable fallback + w, V = np.linalg.eigh((Re + Re.T) / 2) + return V[:, -1] * ang + return ang / (2 * np.sin(ang)) * v + + +# shoulder roll lower bound raised to -0.1 (the upper arm hits the head when adducted further) +LO = np.array([-3.0892, -0.1, -2.618, -1.0472, -1.97222, -1.61443, -1.61443]) +HI = np.array([2.6704, 2.2515, 2.618, 2.0944, 1.97222, 1.61443, 1.61443]) + + +def limits(side): + if side > 0: + return LO, HI + lo, hi = LO.copy(), HI.copy() + for j in (1, 2, 4, 6): + lo[j], hi[j] = -HI[j], -LO[j] + return lo, hi + + +def ik(pos, R, q0, side, waist=(0, 0, 0), iters=60, wrot=0.3, q_rest=None, wrest=0.02, hand=HAND, tol=1e-4): + """Damped least squares IK for the grasp point position (and orientation R if given).""" + q = np.array(q0, dtype=float) + lo, hi = limits(side) + lo = lo + 0.02 + hi = hi - 0.02 + W = np.array([1, 1, 1, wrot, wrot, wrot]) + for _ in range(iters): + Rc, pc, axes, jp = fk_full(q, side, waist, hand) + e = np.zeros(6) + e[:3] = pos - pc + if R is not None: + e[3:] = _rotvec(R @ Rc.T) + e *= W + if np.linalg.norm(e) < tol: + break + J = np.zeros((6, 7)) + for j in range(7): + J[:3, j] = np.cross(axes[j], pc - jp[j]) + J[3:, j] = axes[j] + J *= W[:, None] + if R is None: + J[3:] = 0 + lam = 1e-3 + dqs = J.T @ np.linalg.solve(J @ J.T + lam * np.eye(6), e) + if q_rest is not None: + dqs += wrest * (np.asarray(q_rest) - q) * 0.5 + n = np.abs(dqs).max() + if n > 0.2: + dqs *= 0.2 / n + q = np.clip(q + dqs, lo, hi) + return q + + +def ik_err(q, pos, R, side, waist=(0, 0, 0), hand=HAND): + Rc, pc, _, _ = fk_full(q, side, waist, hand) + ep = np.linalg.norm(pos - pc) + er = np.linalg.norm(_rotvec(R @ Rc.T)) if R is not None else 0.0 + return ep, er + + +def ik_best(pos, R, q0, side, waist=(0, 0, 0), wrot=0.3, q_rest=None, wrest=0.02, hand=HAND, seeds=()): + """Run ik from q0 and extra seeds; return the solution with the smallest error and its errors.""" + best = None + for s in [q0] + list(seeds): + q = ik(pos, R, s, side, waist, iters=150, wrot=wrot, q_rest=q_rest, wrest=wrest, hand=hand) + ep, er = ik_err(q, pos, R, side, waist, hand) + c = ep + 0.1 * er + 0.002 * np.linalg.norm(q - np.asarray(q0)) + if best is None or c < best[0]: + best = (c, q, ep, er) + return best[1], best[2], best[3] diff --git a/policies/wall_cupboard_open/opus-s2/policy.py b/policies/wall_cupboard_open/opus-s2/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..2d5b55d9832a6c00a44336edd2b3c2dee63f7255 --- /dev/null +++ b/policies/wall_cupboard_open/opus-s2/policy.py @@ -0,0 +1,330 @@ +"""Open both doors of the wall cabinet (Unitree G1). + +Hand-written phase script, per door: grasp the handle, pull it along the hinge arc +to ~60 deg (hand yaw following the door), release, pass the hand below the door to +its inner side and push it open to its stop. The right door starts 300 steps after +the left one. Arm targets are given in the world frame and converted to joint +targets every step with an approximate G1 arm model (fk.py); a slow integral term +removes the arm sag in free space, and the base is held with the velocity commands. +The scene is the same for every seed (checked on 13 seeds), so the handle and hinge +positions are constants measured during development. +""" + +import os +import sys + +import numpy as np + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + +import ctrl # noqa: E402 +import vision # noqa: E402 + +PITCH = -0.1 # torso pitch command +GP = -0.6 # gripper pitch while grasping (points up) +PP = -0.8 # gripper pitch while pushing +PULL_DEG = 60 # door angle reached by pulling the handle +PULL_N = 200 # steps of the pull +UNDER_Z = 1.0 # hand height for passing below the opened door +PULL_KYAW = 1.0 # gripper yaw follows this fraction of the door angle +OBSERVER = ([0.36, -0.18, 1.0], (0.7, -1.15, 0)) # idle hand (left-door frame): watch the other door +USE_OBSERVER = False +USE_SERVO = False # the handle column read-out is too noisy to help; nominal positions are used +RIGHT_DELAY = 300 # steps after the start of the left door when the right door starts (None: sequential) +USE_WAIT = False # park the second hand at WAIT_POSE until the first push passes SYNC_PHI +ORDER = (-1, 1) +START_DELAY = 0 # idle steps before starting (robustness tests only) +RETRY_ORDER = (-1, 1) # doors pushed again if the task is not done after the main script +RETRY_PHI0 = 30 +PUSH_DEG = 100 # push point angle at the end of the push (stops early when blocked) +PUSH_N = 130 +PUSH_STOP = 0.035 # tracking error that means the door is at its stop +PUSH_R = 0.16 # push point distance from the hinge along the door +PUSH_D = 0.05 # push point offset from the door plane (behind it) +PUSH_YAW_OFF = 0.0 # hand yaw offset while pushing (0: hand points at the hinge) +WAIT_POSE = ([0.50, 0.10, 1.12], (0.0, -0.6, 0.0)) # second hand waits here (mirrored) until the first door is pushed +SYNC_PHI = 75 # the second hand starts when the first push passes this angle +HANDLE = np.array([0.631, 0.032, 1.225]) # left handle grasp point (world); right is mirrored +HINGE = np.array([0.632, 0.28]) # left door hinge (world x, y); right is mirrored +COL_TARGET = {1: 45.5, -1: 35.5} # handle column in the wrist image when centred +SERVO_GAIN = (0.0045, 0.003, 0.002) # m of lateral hand motion per pixel, per approach stage +BASE_TGT = np.array([0.168, -0.003, 0.0]) +# hand at about (0.45, +-0.22, 1.05) world, pointing forward and slightly up +PARK = np.array([-0.031, 0.138, 0.553, -0.981, -0.405, 0.657, -0.213]) + + +def _mir(p, side): + p = np.array(p, dtype=float) + if side < 0: + p[1] = -p[1] + return p + + +class Policy: + def reset(self, obs, tools): + o = obs["low_dim_obs"] + self.arm = {1: ctrl.Arm(1, PARK), -1: ctrl.Arm(-1, PARK * ctrl.MIR)} + self.q = {1: np.array(o[3:10], float), -1: np.array(o[12:19], float)} + self.grip = {1: 0.6, -1: 0.6} + self.corr = {1: np.zeros(3), -1: np.zeros(3)} + self.tgt = {1: None, -1: None} # (pos, (yaw, pitch, roll)) world targets + self.ki = {1: 0.0, -1: 0.0} + self.holding = {1: False, -1: False} + self.wrot = {1: 0.3, -1: 0.3} + self.bg = {} # background motion generators per hand + self.pushed = {} # side -> its door has been pushed past SYNC_PHI + self.t = 0 + self.plan = self._plan() + self.cur = None + self.debug = [] + + # ------------------------------------------------------------------ plan + def _plan(self): + """Generator of per-step commands; each yield is one control step.""" + for i in range(START_DELAY): + yield + yield from self._joint_move({1: PARK, -1: PARK * ctrl.MIR}, 60, grip={1: 0.0, -1: 0.0}) + if RIGHT_DELAY is not None: + self.bg[-1] = self._second(-1) + yield from self._door(1) + while self.bg: + yield + # normally the episode has ended with success by now; otherwise push both doors again + for side in RETRY_ORDER: + yield from self._repush(side) + else: + for side in ORDER: + yield from self._door(side) + while True: + yield + + def _second(self, side): + """Second door: wait, move to a waiting pose, wait for the first push, then open.""" + for i in range(RIGHT_DELAY): + yield + if USE_WAIT: + wp, wa = WAIT_POSE + self.ki[side] = 0.08 + yield from self._move(side, _mir(wp, side), (side * wa[0], wa[1], wa[2]), 60, grip=0.0) + while not self.pushed.get(-side, False): + yield + yield from self._door(side) + + def _joint_move(self, qt, n, grip=None): + q0 = {s: self.q[s].copy() for s in qt} + g0 = dict(self.grip) + for i in range(n): + s = ctrl.ease((i + 1) / n) + for side in qt: + self.q[side] = q0[side] + s * (np.asarray(qt[side]) - q0[side]) + self.tgt[side] = None + if grip is not None and side in grip: + self.grip[side] = g0[side] + s * (grip[side] - g0[side]) + yield + + def _move(self, side, pos, ang, n, grip=None, ki=None, hold=0): + """Straight-line world move of one hand (cosine eased).""" + if self.tgt[side] is None: + self.tgt[side] = (ctrl.hand_world(self.obs, side), tuple(ang)) + p0, a0 = self.tgt[side] + p0 = np.asarray(p0, float) + a0 = np.asarray(a0, float) + p1 = np.asarray(pos, float) + a1 = np.asarray(ang, float) + g0 = self.grip[side] + if ki is not None: + self.ki[side] = ki + self.holding[side] = False + for i in range(n): + s = ctrl.ease((i + 1) / n) + self.tgt[side] = (p0 + s * (p1 - p0), tuple(a0 + s * (a1 - a0))) + if grip is not None: + self.grip[side] = g0 + s * (grip - g0) + yield + self.holding[side] = True + for i in range(hold): + yield + + def _settle(self, side, tol=0.006, nmin=10, nmax=60): + """Hold the target until the measured hand position is within tol.""" + self.holding[side] = True + for i in range(nmax): + yield + err = np.linalg.norm(np.asarray(self.tgt[side][0]) - ctrl.hand_world(self.obs, side)) + if i >= nmin and err < tol: + break + self.debug.append((self.t, side, "settle", i, round(float(err), 4))) + + def _servo(self, side, cam, iters, gain): + """Shift the hand sideways until the handle sits at the target image column.""" + h_nom = _mir(HANDLE, side) + for it in range(iters if USE_SERVO else 0): + runs = vision.handle_runs(self.tools.image(cam)) + if not runs: + return + runs = [r for r in runs if 4 <= r[1] <= 16] + if not runs: + return + c, w, b = min(runs, key=lambda r: abs(r[0] - COL_TARGET[side])) + self.debug.append((self.t, side, "servo", c, w, b)) + if abs(c - COL_TARGET[side]) < 1.5: + return + p, a = self.tgt[side] + p = np.array(p) + # bounded lateral correction around the nominal handle position + dy = float(np.clip((COL_TARGET[side] - c) * gain, -0.01, 0.01)) + p[1] = np.clip(p[1] + dy, h_nom[1] - 0.02, h_nom[1] + 0.02) + yield from self._move(side, p, a, 10) + yield from self._settle(side, nmin=8, nmax=30) + + def _door(self, side): + cam = "left_wrist" if side > 0 else "right_wrist" + other = -side + # park the other hand low and to its side + h = _mir(HANDLE, side) + if USE_OBSERVER: + op, oa = OBSERVER + self.bg[other] = self._move(other, _mir(op, side), (side * oa[0], oa[1], oa[2]), 60, grip=0.0) + self.ki[side] = 0.08 + yield from self._move(side, h + [-0.07, 0.0, 0.0], (0, GP, 0), 70) + yield from self._settle(side, nmin=20, nmax=80) + yield from self._servo(side, cam, 1, SERVO_GAIN[0]) + for dx, gain in ((0.035, SERVO_GAIN[1]), (0.0, SERVO_GAIN[2])): + p, a = self.tgt[side] + p = np.array(p) + p[0] = h[0] - dx + yield from self._move(side, p, a, 25) + yield from self._settle(side, nmin=10, nmax=40) + yield from self._servo(side, cam, 1, gain) + # grasp + self.ki[side] = 0.0 + yield from self._move(side, self.tgt[side][0], self.tgt[side][1], 20, grip=1.0, hold=5) + gs = float(self.obs["low_dim_obs"][50 if side > 0 else 51]) + self.debug.append((self.t, side, "grasp", round(gs, 3), np.round(ctrl.hand_world(self.obs, side), 3))) + # pull the door ajar along the hinge arc, the hand yaw following the door + g = np.array(self.tgt[side][0]) + hinge = _mir(HINGE, side) + r = np.hypot(g[0] - hinge[0], g[1] - hinge[1]) + th0 = np.arctan2(hinge[0] - g[0], side * (hinge[1] - g[1])) + for i in range(PULL_N): + d = ctrl.ease((i + 1) / PULL_N) * np.radians(PULL_DEG) + th = th0 + d + pos = np.array([hinge[0] - r * np.sin(th), hinge[1] - side * r * np.cos(th), g[2]]) + self.tgt[side] = (pos, (-side * d * PULL_KYAW, GP, 0)) + if i % 10 == 0: + self.debug.append((self.t, "pull", np.round(ctrl.hand_world(self.obs, side), 3), np.round(pos, 3))) + yield + # release and back off along the approach axis + yield from self._move(side, self.tgt[side][0], self.tgt[side][1], 15, grip=0.0) + p, a = self.tgt[side] + back = np.array([np.cos(a[0]), np.sin(a[0]), 0.0]) + yield from self._move(side, np.asarray(p) - 0.06 * back, a, 25) + # pass below the door to its inner side, rise, then push it open from behind + p = np.array(self.tgt[side][0]) + p[2] = UNDER_Z + yield from self._move(side, p, self.tgt[side][1], 25, grip=1.0) + phi0 = PULL_DEG - 10 + q = self._push_pt(side, phi0) + yield from self._move(side, [q[0], q[1], UNDER_Z], self._push_ang(side, phi0), 35) + self.wrot[side] = 0.1 + yield from self._move(side, q, self._push_ang(side, phi0), 25) + n = PUSH_N + blocked = 0 + for i in range(n): + phi = phi0 + ctrl.ease((i + 1) / n) * (PUSH_DEG - phi0) + self.tgt[side] = (self._push_pt(side, phi), self._push_ang(side, phi)) + yield + err = np.linalg.norm(np.asarray(self.tgt[side][0]) - ctrl.hand_world(self.obs, side)) + blocked = blocked + 1 if err > PUSH_STOP else 0 + if phi >= SYNC_PHI: + self.pushed[side] = True + if i % 10 == 0: + self.debug.append((self.t, side, "push", round(float(phi), 1), round(float(err), 3))) + if blocked >= 5 and phi > 75: + self.debug.append((self.t, side, "push stop", round(float(phi), 1))) + break + # retreat: down below the door, then back towards the body + p = np.array(self.tgt[side][0]) + p[2] = UNDER_Z + yield from self._move(side, p, self.tgt[side][1], 25) + self.wrot[side] = 0.3 + yield from self._move(side, _mir([0.38, 0.18, 1.0], side), (0, -0.4, 0), 40) + + def _repush(self, side, phi0=RETRY_PHI0): + """Push a door open again from behind (for a door left partly open).""" + self.ki[side] = 0.0 + p = np.array(self.tgt[side][0]) + p[2] = UNDER_Z + yield from self._move(side, p, self.tgt[side][1], 20, grip=1.0) + q = self._push_pt(side, phi0) + yield from self._move(side, [q[0], q[1], UNDER_Z], self._push_ang(side, phi0), 30) + self.wrot[side] = 0.1 + yield from self._move(side, q, self._push_ang(side, phi0), 20) + blocked = 0 + n = 110 + for i in range(n): + phi = phi0 + ctrl.ease((i + 1) / n) * (PUSH_DEG - phi0) + self.tgt[side] = (self._push_pt(side, phi), self._push_ang(side, phi)) + yield + err = np.linalg.norm(np.asarray(self.tgt[side][0]) - ctrl.hand_world(self.obs, side)) + blocked = blocked + 1 if err > PUSH_STOP else 0 + if blocked >= 5 and phi > 75: + break + p = np.array(self.tgt[side][0]) + p[2] = UNDER_Z + yield from self._move(side, p, self.tgt[side][1], 20) + self.wrot[side] = 0.3 + yield from self._move(side, _mir([0.38, 0.18, 1.0], side), (0, -0.4, 0), 30) + + def _push_pt(self, side, phi): + t = np.radians(phi) + u = np.array([-np.sin(t), -np.cos(t)]) + nrm = np.array([np.cos(t), -np.sin(t)]) + xy = HINGE + PUSH_R * u + PUSH_D * nrm + return _mir([xy[0], xy[1], 1.22], side) + + def _push_ang(self, side, phi): + return (side * (np.pi / 2 - np.radians(phi) + PUSH_YAW_OFF), PP, 0) + + # ------------------------------------------------------------------ act + def _base(self, obs): + pel = ctrl.pel_pose(obs) + ex, ey = BASE_TGT[0] - pel[0], BASE_TGT[1] - pel[1] + c, s = np.cos(pel[3]), np.sin(pel[3]) + bx, by = c * ex + s * ey, -s * ex + c * ey + eyaw = (BASE_TGT[2] - pel[3] + np.pi) % (2 * np.pi) - np.pi + vx = vy = wz = 0.0 + if np.hypot(bx, by) > 0.04: + v = np.array([bx, by]) * 1.0 + nv = np.linalg.norm(v) + v = v / nv * np.clip(nv, 0.07, 0.15) + vx, vy = v + if abs(eyaw) > 0.08: + wz = float(np.clip(1.0 * eyaw, -0.3, 0.3)) + return vx, vy, wz + + def act(self, obs, tools): + self.obs, self.tools = obs, tools + self.t = int(obs["t"]) + next(self.plan) + for side in list(self.bg): + try: + next(self.bg[side]) + except StopIteration: + del self.bg[side] + for side in (1, -1): + if self.tgt[side] is not None: + p, ang = self.tgt[side] + p = np.asarray(p, float) + if self.ki[side] > 0 and self.holding[side]: + act = ctrl.hand_world(obs, side) + self.corr[side] = np.clip(self.corr[side] + self.ki[side] * (p - act), -0.1, 0.1) + q, ep, er = self.arm[side].solve(obs, p + self.corr[side], ctrl.rot(*ang), wrot=self.wrot[side]) + self.q[side] = q + vx, vy, wz = self._base(obs) + a = np.zeros(21, np.float32) + a[0], a[1], a[2], a[3], a[4] = vx, vy, 0.74, wz, PITCH + a[5:12] = self.q[1] + a[12:19] = self.q[-1] + a[19], a[20] = self.grip[1], self.grip[-1] + return a diff --git a/policies/wall_cupboard_open/opus-s2/vision.py b/policies/wall_cupboard_open/opus-s2/vision.py new file mode 100644 index 0000000000000000000000000000000000000000..a402105292b817b6ea139d6f08822ee263a2cc1b --- /dev/null +++ b/policies/wall_cupboard_open/opus-s2/vision.py @@ -0,0 +1,27 @@ +"""Small image helpers: find the vertical grey door handle in a wrist image.""" +import numpy as np + + +def handle_runs(img, r0=0, r1=60, lo=45, hi=160, frac=0.6, minw=4): + """Return list of (center_col, width, bottom_row) runs of grey vertical bars.""" + g = img.astype(np.float32).mean(2) + m = (g > lo) & (g < hi) + f = m[r0:r1].mean(0) + good = f > frac + runs = [] + c = 0 + W = img.shape[1] + while c < W: + if good[c]: + s = c + while c < W and good[c]: + c += 1 + if c - s >= minw: + cols = slice(s, c) + rowfrac = m[:, cols].mean(1) + rows = np.where(rowfrac > 0.5)[0] + bottom = int(rows.max()) if len(rows) else -1 + runs.append(((s + c - 1) / 2.0, c - s, bottom)) + else: + c += 1 + return runs diff --git a/policies/wall_cupboard_open/opus-s3/episodes.csv b/policies/wall_cupboard_open/opus-s3/episodes.csv new file mode 100644 index 0000000000000000000000000000000000000000..3953de7d55040f9ce60e1ae93f3f0cb2a885c5e8 --- /dev/null +++ b/policies/wall_cupboard_open/opus-s3/episodes.csv @@ -0,0 +1,101 @@ +seed,success,length,termination,fell +620000,1,1229,success,0 +620001,1,1229,success,0 +620002,1,1229,success,0 +620003,1,1229,success,0 +620004,1,1229,success,0 +620005,1,1229,success,0 +620006,1,1229,success,0 +620007,1,1229,success,0 +620008,1,1229,success,0 +620009,1,1229,success,0 +620010,1,1229,success,0 +620011,1,1229,success,0 +620012,1,1229,success,0 +620013,1,1229,success,0 +620014,1,1229,success,0 +620015,1,1229,success,0 +620016,1,1229,success,0 +620017,1,1229,success,0 +620018,1,1229,success,0 +620019,1,1229,success,0 +620020,1,1229,success,0 +620021,1,1229,success,0 +620022,1,1229,success,0 +620023,1,1229,success,0 +620024,1,1229,success,0 +620025,1,1229,success,0 +620026,1,1229,success,0 +620027,1,1229,success,0 +620028,1,1229,success,0 +620029,1,1229,success,0 +620030,1,1229,success,0 +620031,1,1229,success,0 +620032,1,1229,success,0 +620033,1,1229,success,0 +620034,1,1229,success,0 +620035,1,1229,success,0 +620036,1,1229,success,0 +620037,1,1229,success,0 +620038,1,1229,success,0 +620039,1,1229,success,0 +620040,1,1229,success,0 +620041,1,1229,success,0 +620042,1,1229,success,0 +620043,1,1229,success,0 +620044,1,1229,success,0 +620045,1,1229,success,0 +620046,1,1229,success,0 +620047,1,1229,success,0 +620048,1,1229,success,0 +620049,1,1229,success,0 +620050,1,1229,success,0 +620051,1,1229,success,0 +620052,1,1229,success,0 +620053,1,1229,success,0 +620054,1,1229,success,0 +620055,1,1229,success,0 +620056,1,1229,success,0 +620057,1,1229,success,0 +620058,1,1229,success,0 +620059,1,1229,success,0 +620060,1,1229,success,0 +620061,1,1229,success,0 +620062,1,1229,success,0 +620063,1,1229,success,0 +620064,1,1229,success,0 +620065,1,1229,success,0 +620066,1,1229,success,0 +620067,1,1229,success,0 +620068,1,1229,success,0 +620069,1,1229,success,0 +620070,1,1229,success,0 +620071,1,1229,success,0 +620072,1,1229,success,0 +620073,1,1229,success,0 +620074,1,1229,success,0 +620075,1,1229,success,0 +620076,1,1229,success,0 +620077,1,1229,success,0 +620078,1,1229,success,0 +620079,1,1229,success,0 +620080,1,1229,success,0 +620081,1,1229,success,0 +620082,1,1229,success,0 +620083,1,1229,success,0 +620084,1,1229,success,0 +620085,1,1229,success,0 +620086,1,1229,success,0 +620087,1,1229,success,0 +620088,1,1229,success,0 +620089,1,1229,success,0 +620090,1,1229,success,0 +620091,1,1229,success,0 +620092,1,1229,success,0 +620093,1,1229,success,0 +620094,1,1229,success,0 +620095,1,1229,success,0 +620096,1,1229,success,0 +620097,1,1229,success,0 +620098,1,1229,success,0 +620099,1,1229,success,0 diff --git a/policies/wall_cupboard_open/opus-s3/policy.py b/policies/wall_cupboard_open/opus-s3/policy.py new file mode 100644 index 0000000000000000000000000000000000000000..737b06620b875e6a879081aa0d4152ab5523e835 --- /dev/null +++ b/policies/wall_cupboard_open/opus-s3/policy.py @@ -0,0 +1,503 @@ +"""Open both doors of the wall cabinet (Unitree G1). + +Hand-written controller, one door at a time (the two handles are too close +together for both grippers at once): + 1. raise the arm to a pre-grasp pose below/in front of the handle, + 2. visually servo the gripper onto the handle with the wrist camera + (handle = dark-gray vertical bar on the white door; position-based servo + from the bar's image position and apparent width), + 3. close the gripper and pull the handle ~40 deg around the door hinge, + 4. release, move the hand behind the door's free edge to its inner side and + push the door around the hinge to ~130 deg (the doors swing freely and + must be opened past 90 deg), + 5. park the arm and do the same with the other arm / door. +Kinematics: analytic G1 arm forward kinematics (URDF offsets) + numerical IK. +The base holds its start pose (paused while servoing so the robot does not +step), and the torso pitch is regulated upright throughout. +""" + +import cv2 +import numpy as np +from scipy.optimize import minimize + +# ---------------------------------------------------------------------------- +# kinematics + + +def _rx(a): + c, s = np.cos(a), np.sin(a) + return np.array([[1, 0, 0], [0, c, -s], [0, s, c]]) + + +def _ry(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]]) + + +def _rz(a): + c, s = np.cos(a), np.sin(a) + return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]]) + + +def _T(R=None, p=None): + M = np.eye(4) + if R is not None: + M[:3, :3] = R + if p is not None: + M[:3, 3] = p + return M + + +_TORSO = _T(p=[-0.0039635, 0, 0.035]) @ _T(p=[0, 0, 0.019]) + + +def arm_fk(q, side='L', hand=0.10): + """4x4 pose of the gripper point in the pelvis frame (upright torso).""" + s = 1 if side == 'L' else -1 + sp, sr, sy, el, wr, wp, wy = q + M = _TORSO @ _T(_rx(s * 0.27931), [0.0039563, s * 0.10022, 0.23778]) @ _T(_ry(sp)) + M = M @ _T(_rx(-s * 0.27925), [0, s * 0.038, -0.013831]) @ _T(_rx(sr)) + M = M @ _T(p=[0, s * 0.00624, -0.1032]) @ _T(_rz(sy)) + M = M @ _T(p=[0.015783, 0, -0.080518]) @ _T(_ry(el)) + M = M @ _T(p=[0.100, s * 0.00188791, -0.010]) @ _T(_rx(wr)) + M = M @ _T(p=[0.038, 0, 0]) @ _T(_ry(wp)) + M = M @ _T(p=[0.046, 0, 0]) @ _T(_rz(wy)) + return M @ _T(p=[hand, 0, 0]) + + +MIR = np.array([1, -1, -1, 1, -1, 1, -1]) +PZ = 0.747 +_BLO = np.array([-3.0, -0.6, -1.2, -1.0, -1.2, -1.5, -1.2]) +_WLO = np.array([-3.0, -0.6, -2.0, -1.0, -1.9, -1.55, -1.55]) +_BHI = np.array([0.5, 1.8, 1.2, 2.0, 1.2, 1.5, 1.2]) +_WHI = np.array([0.5, 2.2, 2.0, 2.0, 1.9, 1.55, 1.55]) + + +def _bounds(side, wide=False): + lo, hi = (_WLO, _WHI) if wide else (_BLO, _BHI) + if side == 'L': + return lo, hi + a, b = lo * MIR, hi * MIR + return np.minimum(a, b), np.maximum(a, b) + + +def ik(pos, xdir, side, q0, zdir=None, yhoriz=0.0, wdir=1.0, reg=1e-4, qnom=None, tries=3, wide=False): + """Gripper point to pos (pelvis frame, z relative to pelvis), gripper x axis to xdir.""" + pos = np.asarray(pos, float) + d = np.asarray(xdir, float) + d = d / np.linalg.norm(d) + q0 = np.asarray(q0, float) + qnom = q0 if qnom is None else qnom + lo, hi = _bounds(side, wide) + + def cost(q): + M = arm_fk(q, side) + c = 100.0 * np.sum((M[:3, 3] - pos) ** 2) + wdir * np.sum((M[:3, 0] - d) ** 2) + if zdir is not None: + c += np.sum((M[:3, 2] - zdir) ** 2) + if yhoriz: + c += yhoriz * M[2, 1] ** 2 + return c + reg * 0.01 * np.sum((q - qnom) ** 2) + + best = None + rng = np.random.default_rng(0) + for k in range(tries): + qi = np.clip(q0 if k == 0 else q0 + rng.normal(0, 0.3, 7), lo, hi) + r = minimize(cost, qi, method='L-BFGS-B', bounds=list(zip(lo, hi))) + if best is None or r.fun < best.fun: + best = r + if best.fun < 1e-4: + break + return best.x, best.fun + + +def pose_ik(x, y, z, el, side, yaw=0.0, q0=None): + """Gripper at (x, y, z_world) pointing forward with elevation el, camera upright.""" + d = np.array([np.cos(el) * np.cos(yaw), np.cos(el) * np.sin(yaw), np.sin(el)]) + if q0 is None: + q0 = np.array([-1.0, 0.15, 0, 0, -0.4, 0, 0]) + if side == 'R': + q0 = q0 * MIR + return ik([x, y, z - PZ], d, side, q0, yhoriz=1.0, wdir=2.0, reg=0.01, tries=3)[0] + + +def cart_move(q, side, dp_world): + """Translate the gripper by dp (pelvis frame) keeping its orientation.""" + M = arm_fk(q, side) + R = M[:3, :3] + dp = np.asarray(dp_world, float) + for _ in range(4): + qn, f = ik(M[:3, 3] + dp, R[:, 0], side, q, zdir=R[:, 2], reg=1.0, qnom=q, tries=1) + if np.abs(qn - q).max() < 0.35: + return qn + dp = dp * 0.5 # avoid configuration jumps near the reach limit + return q + + +# ---------------------------------------------------------------------------- +# wrist camera model and handle detection + +F_PX = 101.4 # focal length (fovy 45 deg, 84 px) +CAM_TILT = 0.65 # optical axis pitched down from the gripper x axis +HANDLE_W = 0.012 # handle bar width (m) + + +def cam_axes(q, side): + M = arm_fk(q, side) + R = M[:3, :3] + ax = R @ np.array([np.cos(CAM_TILT), 0, -np.sin(CAM_TILT)]) + up = R @ np.array([np.sin(CAM_TILT), 0, np.cos(CAM_TILT)]) + return ax, R[:, 1], up + + +def detect_handles(im, min_h=5): + g = im.astype(np.float32).mean(axis=2) + H, W = g.shape + mask = ((g > 20) & (g < 145)).astype(np.uint8) + mask[30:52, :4] = 0 + mask[30:52, W - 4:] = 0 + bright = g > 195 + n, lab, stats, _ = cv2.connectedComponentsWithStats(mask, connectivity=4) + out = [] + for i in range(1, n): + x, y, w, h, area = stats[i] + if h < min_h or h < 1.3 * w: + continue + ys, xs = np.nonzero(lab == i) + ok = 0 + widths = [] + for r in range(y, y + h): + cols = xs[ys == r] + widths.append(len(cols)) + l, rr = cols.min(), cols.max() + if bright[r, max(0, l - 4):l].any() and bright[r, rr + 1:rr + 5].any(): + ok += 1 + if ok < 0.5 * h: + continue + out.append(dict(x=float(xs.mean()), w=float(np.median(widths)), top=int(y), bot=int(y + h - 1))) + return out + + +# ---------------------------------------------------------------------------- +# policy + +PRE0 = (0.30, 0.07, 1.18) # safe first waypoint (y mirrored for the right arm) +PRE = {'L': (0.386, 0.005, 1.14), 'R': (0.371, -0.012, 1.144)} # pre-grasp gripper (home pelvis frame, z world) +EL = 0.65 # gripper elevation during the grasp (camera horizontal) +TGT_U, TGT_V, TGT_W = 42.0, 45.0, 12.5 +SERVO_GAIN, SERVO_MAX, SERVO_MOVE, SERVO_SETTLE = 0.6, 0.025, 12, 6 +ARC_R, ARC_DX = 0.215, 0.074 # grasp point -> hinge (lateral, depth), world frame +ARC_END = 40.0 # degrees (door angle) +ARC_STEP, ARC_TICKS = 4.0, 6 +ARC_WIDE = True +SWEEP = True +REL_BACK = 0.09 +SW_RHO = 0.20 # push radius from the hinge +SW_OFF = 0.07 # gripper point offset from the door face (inner side) +SW_PEN = 0.03 # how far the command presses into the door +SW_EL = 1.0 # gripper elevation while pushing +SW_RISE = 0.06 # pushing height above the grasp height +SW_END = 130.0 +SW_BACK = 10.0 +SW_WIDTH = 0.24 # hinge -> free edge +SW_CLEAR = 0.09 # how far behind the free edge to pass +SW_INNER = 0.07 +SW_YAWK = 0.5 +SW_STEP, SW_TICKS = 5.0, 9 +BASE_K, BASE_KYAW = 3.0, 3.0 +PARK_L = np.array([0.3, 0.6, 0.0, 0.6, 0.0, 0.0, 0.0]) + + +class Policy: + def reset(self, obs, tools): + self.tools = tools + lo = np.asarray(obs['low_dim_obs'], float) + self.home = lo[21:25].copy() + self.a = np.asarray(tools.hold_action(), dtype=np.float64) + self.a[19] = self.a[20] = 0.0 + self.q = {'L': np.zeros(7), 'R': np.zeros(7)} + self.cmd = {'L': np.zeros(7), 'R': np.zeros(7)} + self.pitch = 0.0 + self.obs = obs + self.phase = 'start' + self.hinge = {} + self.door_angle = {} + self.base_on = True + self.gen = self._script() + + # -- low level --------------------------------------------------------- + def _base(self): + lo = np.asarray(self.obs['low_dim_obs'], float) + ex, ey = self.home[0] - lo[21], self.home[1] - lo[22] + yaw = lo[24] + c, s = np.cos(yaw), np.sin(yaw) + bx, by = c * ex + s * ey, -s * ex + c * ey + vx, vy = np.clip(BASE_K * bx, -0.3, 0.3), np.clip(BASE_K * by, -0.3, 0.3) + if np.hypot(vx, vy) < 0.06: + vx = vy = 0.0 + dyaw = yaw - self.home[3] + wz = np.clip(-BASE_KYAW * dyaw, -0.4, 0.4) if abs(dyaw) > 0.02 else 0.0 + if not self.base_on: + vx = vy = wz = 0.0 + self.a[0], self.a[1], self.a[3] = vx, vy, wz + self.pitch = float(np.clip(self.pitch - 0.02 * lo[2], -0.2, 0.8)) + self.a[4] = self.pitch + + def act(self, obs, tools): + self.obs = obs + if self.gen is not None: + try: + next(self.gen) + except StopIteration: + self.gen = None + self._base() + self.a[5:12] = self.cmd['L'] + self.a[12:19] = self.cmd['R'] + return self.a.copy() + + def _wait(self, n): + for _ in range(n): + yield + + def _par(self, *gens): + gens = list(gens) + while gens: + alive = [] + for g in gens: + try: + next(g) + alive.append(g) + except StopIteration: + pass + gens = alive + if gens: + yield + + def _move(self, side, q, n): + q0 = self.q[side].copy() + q = np.asarray(q, float) + for k in range(n): + s = 0.5 - 0.5 * np.cos(np.pi * (k + 1) / n) + self.cmd[side] = q0 + (q - q0) * s + yield + self.q[side] = q.copy() + self.cmd[side] = q.copy() + + def _grip(self, side, v, n): + self.a[19 if side == 'L' else 20] = v + yield from self._wait(n) + + def _lo(self): + return np.asarray(self.obs['low_dim_obs'], float) + + def _hand_world(self, side, q=None): + """Gripper point: world xy, z relative to the pelvis; and orientation.""" + lo = self._lo() + if q is None: + q = lo[3:10] if side == 'L' else lo[12:19] + M = arm_fk(q, side) + Rw = _rz(lo[24]) + return np.array([lo[21], lo[22], 0.0]) + Rw @ M[:3, 3], Rw @ M[:3, :3] + + def _goto_world(self, side, p, xdir, n, yh=1.0, tries=1): + lo = self._lo() + Rp = _rz(-lo[24]) + pp = Rp @ (np.asarray(p) - np.array([lo[21], lo[22], 0.0])) + q, _ = ik(pp, Rp @ np.asarray(xdir), side, self.q[side], yhoriz=yh, wdir=2.0, tries=tries, + reg=0.3, qnom=self.q[side]) + yield from self._move(side, q, n) + + def _line_world(self, side, p, xdir, n, step=0.02): + """Straight-line (Cartesian) move of the gripper point, orientation blended.""" + p0, R0 = self._hand_world(side, self.q[side]) + p = np.asarray(p, float) + k = max(1, int(np.ceil(np.linalg.norm(p - p0) / step))) + x0 = R0[:, 0] + for i in range(1, k + 1): + a = i / k + xd = (1 - a) * x0 + a * np.asarray(xdir) + yield from self._goto_world(side, p0 + a * (p - p0), xd / np.linalg.norm(xd), max(2, n // k)) + + # -- skills ------------------------------------------------------------ + def _servo(self, side): + s = 1 if side == 'L' else -1 + cam = 'left_wrist' if side == 'L' else 'right_wrist' + track = None + for it in range(30): + im = self.tools.image(cam) + cands = [c for c in detect_handles(im) if c['w'] >= 2] + if not cands: + # nothing visible: back off a little and look again + ax, left, up = cam_axes(self.q[side], side) + yield from self._move(side, cart_move(self.q[side], side, -0.02 * ax), 10) + track = None + continue + if track is None: + c = min(cands, key=lambda c: s * c['x']) + else: + c = min(cands, key=lambda c: abs(c['x'] - track['x']) + 0.5 * abs(c['w'] - track['w'])) + track = c + w = max(c['w'], 2.0) + Z = F_PX * HANDLE_W / w + vb = min(c['bot'], 83) + Pc = np.array([Z, (41.5 - c['x']) * Z / F_PX, (41.5 - vb) * Z / F_PX]) + Zt = F_PX * HANDLE_W / TGT_W + Pt = np.array([Zt, (41.5 - TGT_U) * Zt / F_PX, (41.5 - TGT_V) * Zt / F_PX]) + e = Pc - Pt + if c['bot'] >= 82: + e[2] = -0.01 + if abs(c['x'] - TGT_U) > 8 or abs(vb - TGT_V) > 12: + # centre the handle before getting close (open fingers could hit it) + e[0] = min(e[0], 0.0) if w < TGT_W - 3 else -0.015 + if abs(c['x'] - TGT_U) < 4.5 and abs(vb - TGT_V) < 6 and abs(w - TGT_W) < 2: + return True + ax, left, up = cam_axes(self.q[side], side) + dw = SERVO_GAIN * (e[0] * ax + e[1] * left + e[2] * up) + nrm = np.linalg.norm(dw) + if nrm > SERVO_MAX: + dw *= SERVO_MAX / nrm + elif 1e-6 < nrm < 0.005: + dw *= 0.005 / nrm + yield from self._move(side, cart_move(self.q[side], side, dw), SERVO_MOVE) + yield from self._wait(SERVO_SETTLE) + return False + + def _recenter(self, n): + self.base_on = True + for _ in range(n): + lo = self._lo() + if np.hypot(*(lo[21:23] - self.home[:2])) < 0.015 and abs(lo[24] - self.home[3]) < 0.02: + break + yield + self.base_on = False + yield from self._wait(10) + + def _approach(self, side): + self.phase = side + ':pre' + s = 1 if side == 'L' else -1 + lo = self._lo() + Rh = _rz(self.home[3])[:2, :2] + Rp = _rz(-lo[24])[:2, :2] + q = None + for (x, y, z), n in [((PRE0[0], s * PRE0[1], PRE0[2]), 45), (PRE[side], 30)]: + # express the (home-frame) point in the current pelvis frame + pp = Rp @ (self.home[:2] + Rh @ np.array([x, y]) - lo[21:23]) + q = pose_ik(pp[0], pp[1], z, EL, side, yaw=self.home[3] - lo[24], q0=q) + yield from self._move(side, q, n) + self.phase = side + ':recenter' + yield from self._recenter(60) + self.phase = side + ':servo' + self.base_on = False + yield from self._servo(side) + + def _grasp(self, side): + gi = 50 if side == 'L' else 51 + for attempt in range(3): + if attempt: + self.phase = side + ':servo%d' % attempt + yield from self._servo(side) + self.phase = side + ':close%d' % attempt + yield from self._grip(side, 1.0, 30) + if self._lo()[gi] < 0.97: + return True + # missed: open, back off, retry + yield from self._grip(side, 0.0, 15) + ax, left, up = cam_axes(self.q[side], side) + yield from self._move(side, cart_move(self.q[side], side, -0.05 * ax), 20) + return False + + def _arc(self, side): + """Pull the grasped handle around the door hinge (world frame).""" + self.phase = side + ':arc' + self.base_on = True + s = 1 if side == 'L' else -1 + p0, _ = self._hand_world(side) # actual gripper point + pc0, R0 = self._hand_world(side, self.q[side]) # commanded + off = pc0 - p0 # steady tracking offset + hinge = p0 + np.array([ARC_DX, s * ARC_R, 0.0]) + self.hinge[side] = hinge + qc = self.q[side].copy() + phi = 0.0 + while phi < ARC_END: + phi += ARC_STEP + Rz = _rz(-s * np.deg2rad(phi)) + tgt = hinge + Rz @ (p0 - hinge) + off + Rt = Rz @ R0 + lo = self._lo() + Rp = _rz(-lo[24]) + pp = Rp @ (tgt - np.array([lo[21], lo[22], 0.0])) + Rpt = Rp @ Rt + qc, f = ik(pp, Rpt[:, 0], side, qc, zdir=Rpt[:, 2], tries=1, wide=ARC_WIDE) + yield from self._move(side, qc, ARC_TICKS) + pa, _ = self._hand_world(side) + v0, v1 = p0[:2] - hinge[:2], pa[:2] - hinge[:2] + self.door_angle[side] = abs(np.rad2deg(np.arctan2(v0[0] * v1[1] - v0[1] * v1[0], v0 @ v1))) + + def _release(self, side): + self.phase = side + ':release' + yield from self._grip(side, 0.0, 15) + M = arm_fk(self.q[side], side) + yield from self._move(side, cart_move(self.q[side], side, -REL_BACK * M[:3, 0]), 20) + + def _sweep(self, side): + """Push the door further open from its inner side.""" + self.phase = side + ':sweep' + s = 1 if side == 'L' else -1 + H = self.hinge[side] + th = np.deg2rad(self.door_angle.get(side, ARC_END) - SW_BACK) + + def dvec(th): # hinge -> free edge + return np.array([-np.sin(th), -s * np.cos(th), 0.0]) + + def nin(th): # inner-face normal + return np.array([np.cos(th), -s * np.sin(th), 0.0]) + + def xdir(th): + yaw = self.home[3] + s * SW_YAWK * (th - np.pi / 2) + return np.array([np.cos(SW_EL) * np.cos(yaw), np.cos(SW_EL) * np.sin(yaw), np.sin(SW_EL)]) + + cur, Rc = self._hand_world(side, self.q[side]) + z_hi = H[2] + SW_RISE + th_rel = np.deg2rad(self.door_angle.get(side, ARC_END)) + edge = H + SW_WIDTH * dvec(th_rel) # free edge of the door + xb = edge[0] - SW_CLEAR + # 1) back away from the outer face, 2) behind the free edge, 3) to the inner side + for i, (px, py) in enumerate([(xb, cur[1] + s * 0.02), (xb, edge[1] - s * SW_INNER)]): + xd = Rc[:, 0] if i == 0 else xdir(th) # keep the release orientation until clear of the door + yield from self._line_world(side, np.array([px, py, z_hi]), xd, 30) + start = H + SW_RHO * dvec(th) + SW_OFF * nin(th) + start[2] = z_hi + yield from self._line_world(side, start, xdir(th), 30) + # 4) sweep around the hinge + end = np.deg2rad(SW_END) + while th < end: + th = min(end, th + np.deg2rad(SW_STEP)) + p = H + SW_RHO * dvec(th) + (SW_OFF - SW_PEN) * nin(th) + p[2] = z_hi + yield from self._goto_world(side, p, xdir(th), SW_TICKS, tries=3) + # 5) back off toward the inside and down + p = H + SW_RHO * dvec(th) + (SW_OFF + 0.06) * nin(th) + p[2] = z_hi + yield from self._goto_world(side, p, xdir(th), 15) + + def _park(self, side): + self.phase = side + ':park' + yield from self._move(side, PARK_L if side == 'L' else PARK_L * MIR, 40) + + def _finish(self, side): + if SWEEP: + yield from self._sweep(side) + yield from self._park(side) + + def _script(self): + yield from self._wait(3) + yield from self._approach('L') + yield from self._grasp('L') + yield from self._arc('L') + yield from self._release('L') + yield from self._finish('L') + yield from self._approach('R') + yield from self._grasp('R') + yield from self._arc('R') + yield from self._release('R') + yield from self._finish('R')