# Open-loop trajectory-fit action2code policy generated from the RoboCasa GT EE trajectory
# Task: CloseFridge
# Episode: episode_000000

from primitives import moveJoint, moveLinear, moveC, moveA, moveWholeBodyPath, moveActionSequence, grasp, release, wait

SCENE_ARTIFACT = '../../../artifacts/20260324/CloseFridge/20260324_205254_close-fridge_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'CloseFridge',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/CloseFridge/20260324_205254_close-fridge_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/CloseFridge/20260324_205254_close-fridge_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/CloseFridge/20260324_205254_close-fridge_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 278,
    'stable_release_contact_loss_t': 278,
    'uses_moveC': False,
    'controller_mode': 'whole_body_ik',
}

OBJ_POSE_T0 = pose(x=1.528040, y=-4.936388, z=1.456120, qw=0.024288, qx=0.158458, qy=-0.001041, qz=0.987066)
GOAL_RECEPTACLE_POSE = pose(x=0.646441, y=-4.938412, z=0.920047, qw=-0.043192, qx=0.000001, qy=-0.000000, qz=0.999067)

APPROACH_002_JOINTS = [-0.042328, -1.021834, -0.040833, -2.274612, 0.009138, 1.506788, 0.717668]  # t=2
APPROACH_003_JOINTS = [-0.042673, -1.032982, -0.046122, -2.272497, 0.003997, 1.493566, 0.718745]  # t=3
APPROACH_005_JOINTS = [-0.044820, -1.081704, -0.071951, -2.270905, -0.005982, 1.474925, 0.716107]  # t=5
APPROACH_008_JOINTS = [-0.050564, -1.219801, -0.127796, -2.284821, 0.004221, 1.493843, 0.717001]  # t=8
APPROACH_010_JOINTS = [-0.055738, -1.324727, -0.174902, -2.290816, 0.032662, 1.509293, 0.723150]  # t=10
APPROACH_012_JOINTS = [-0.062628, -1.421107, -0.233347, -2.288507, 0.062926, 1.522371, 0.729690]  # t=12
APPROACH_014_JOINTS = [-0.071173, -1.501241, -0.295903, -2.281842, 0.090531, 1.541071, 0.740167]  # t=14
APPROACH_015_JOINTS = [-0.075826, -1.532914, -0.327510, -2.280669, 0.101761, 1.557265, 0.748176]  # t=15
APPROACH_016_JOINTS = [-0.080563, -1.560116, -0.358510, -2.281268, 0.112433, 1.578725, 0.756679]  # t=16
APPROACH_019_JOINTS = [-0.096236, -1.621103, -0.445781, -2.298233, 0.136367, 1.653922, 0.783499]  # t=19
APPROACH_020_JOINTS = [-0.102373, -1.638076, -0.471487, -2.304552, 0.143887, 1.678167, 0.791467]  # t=20
APPROACH_022_JOINTS = [-0.117074, -1.671781, -0.516129, -2.317905, 0.159359, 1.719350, 0.806778]  # t=22
APPROACH_025_JOINTS = [-0.139310, -1.694173, -0.562673, -2.340948, 0.155065, 1.762984, 0.826376]  # t=25
APPROACH_029_JOINTS = [-0.157840, -1.675904, -0.639847, -2.329943, 0.140172, 1.809171, 0.851726]  # t=29
APPROACH_030_JOINTS = [-0.158643, -1.661700, -0.667521, -2.324005, 0.149885, 1.819404, 0.873812]  # t=30
APPROACH_033_JOINTS = [-0.152978, -1.593652, -0.749690, -2.286835, 0.185615, 1.825580, 0.960441]  # t=33
APPROACH_035_JOINTS = [-0.139418, -1.525961, -0.799683, -2.251517, 0.215438, 1.826350, 1.021246]  # t=35
APPROACH_038_JOINTS = [-0.103661, -1.399826, -0.874867, -2.187526, 0.274969, 1.825795, 1.106711]  # t=38
APPROACH_040_JOINTS = [-0.069656, -1.306897, -0.933268, -2.144623, 0.321294, 1.823228, 1.156919]  # t=40
APPROACH_044_JOINTS = [0.025219, -1.132504, -1.086858, -2.078190, 0.446653, 1.830505, 1.227319]  # t=44
APPROACH_045_JOINTS = [0.056199, -1.092852, -1.128841, -2.064997, 0.478603, 1.837470, 1.242537]  # t=45
APPROACH_047_JOINTS = [0.126802, -1.022155, -1.209114, -2.040578, 0.525854, 1.859336, 1.250884]  # t=47
APPROACH_050_JOINTS = [0.236266, -0.948321, -1.302360, -2.007492, 0.567484, 1.891541, 1.257334]  # t=50
APPROACH_052_JOINTS = [0.316573, -0.916167, -1.360716, -1.990160, 0.582367, 1.936599, 1.257346]  # t=52
APPROACH_055_JOINTS = [0.451845, -0.900358, -1.443194, -1.961100, 0.596611, 2.026755, 1.237783]  # t=55
APPROACH_056_JOINTS = [0.495541, -0.905168, -1.466682, -1.943982, 0.594534, 2.045452, 1.232385]  # t=56
APPROACH_058_JOINTS = [0.565815, -0.929095, -1.505408, -1.900051, 0.572366, 2.050539, 1.237915]  # t=58
APPROACH_060_JOINTS = [0.617526, -0.967062, -1.530792, -1.854165, 0.537038, 2.027594, 1.268084]  # t=60
APPROACH_061_JOINTS = [0.640578, -0.988881, -1.538789, -1.833840, 0.516228, 2.014932, 1.288346]  # t=61
APPROACH_063_JOINTS = [0.689677, -1.034498, -1.547059, -1.801210, 0.470623, 2.001356, 1.325441]  # t=63
APPROACH_065_JOINTS = [0.737484, -1.079687, -1.546926, -1.776912, 0.417787, 1.980002, 1.357276]  # t=65
APPROACH_066_JOINTS = [0.760962, -1.100459, -1.544589, -1.765829, 0.389313, 1.966669, 1.372938]  # t=66
APPROACH_070_JOINTS = [0.847615, -1.171932, -1.523656, -1.723081, 0.292416, 1.891543, 1.429870]  # t=70
APPROACH_072_JOINTS = [0.883113, -1.201422, -1.511612, -1.704786, 0.258281, 1.835432, 1.447572]  # t=72
APPROACH_075_JOINTS = [0.916973, -1.241019, -1.490770, -1.691217, 0.231274, 1.727000, 1.446948]  # t=75
APPROACH_079_JOINTS = [0.932131, -1.278086, -1.463233, -1.716575, 0.223266, 1.616304, 1.396710]  # t=79
APPROACH_080_JOINTS = [0.931886, -1.283262, -1.460102, -1.724110, 0.218765, 1.605035, 1.376521]  # t=80
APPROACH_085_JOINTS = [0.895928, -1.283563, -1.420382, -1.813444, 0.194603, 1.582131, 1.237624]  # t=85
APPROACH_090_JOINTS = [0.818955, -1.247953, -1.368567, -1.975418, 0.196429, 1.665151, 1.086832]  # t=90
APPROACH_093_JOINTS = [0.765629, -1.213864, -1.331237, -2.085513, 0.232757, 1.737041, 1.012146]  # t=93
APPROACH_095_JOINTS = [0.732618, -1.185173, -1.298724, -2.157325, 0.278379, 1.813963, 0.970350]  # t=95
APPROACH_099_JOINTS = [0.677446, -1.100058, -1.208892, -2.305076, 0.392017, 2.061282, 0.929101]  # t=99
APPROACH_100_JOINTS = [0.668793, -1.070918, -1.180912, -2.335307, 0.426113, 2.138925, 0.925602]  # t=100
APPROACH_105_JOINTS = [0.665411, -0.892254, -1.042510, -2.414316, 0.640133, 2.526836, 0.922328]  # t=105
APPROACH_107_JOINTS = [0.681876, -0.803660, -0.996624, -2.406879, 0.739454, 2.649585, 0.930119]  # t=107
APPROACH_110_JOINTS = [0.711176, -0.656232, -0.968072, -2.340793, 0.879523, 2.757603, 0.935963]  # t=110
APPROACH_113_JOINTS = [0.703284, -0.555366, -0.954749, -2.287152, 1.012644, 2.816358, 0.907822]  # t=113
APPROACH_115_JOINTS = [0.700687, -0.469397, -0.940979, -2.245231, 1.114447, 2.866952, 0.893885]  # t=115
PRESS_116_JOINTS = [0.694104, -0.435536, -0.924641, -2.229928, 1.167583, 2.892368, 0.884251]  # t=116
PRESS_117_JOINTS = [0.681459, -0.410213, -0.902480, -2.222388, 1.219265, 2.921717, 0.870038]  # t=117
PRESS_118_JOINTS = [0.664761, -0.389262, -0.877217, -2.217055, 1.269581, 2.950351, 0.852790]  # t=118
PRESS_119_JOINTS = [0.643680, -0.375169, -0.848969, -2.215398, 1.317857, 2.976758, 0.832198]  # t=119
PRESS_121_JOINTS = [0.591718, -0.362621, -0.788569, -2.219576, 1.408135, 3.015235, 0.780159]  # t=121
PRESS_122_JOINTS = [0.562171, -0.361164, -0.759037, -2.223388, 1.449272, 3.025358, 0.751105]  # t=122
PRESS_123_JOINTS = [0.529951, -0.366053, -0.729624, -2.229487, 1.485781, 3.031465, 0.721328]  # t=123
PRESS_125_JOINTS = [0.457485, -0.409905, -0.662935, -2.263866, 1.544406, 3.048270, 0.662047]  # t=125
PRESS_127_JOINTS = [0.380033, -0.488179, -0.587567, -2.319563, 1.584927, 3.071733, 0.611230]  # t=127
PRESS_129_JOINTS = [0.305089, -0.570303, -0.514344, -2.379922, 1.607860, 3.091714, 0.582548]  # t=129
PRESS_131_JOINTS = [0.235452, -0.651075, -0.443511, -2.439367, 1.614288, 3.107931, 0.578473]  # t=131
PRESS_133_JOINTS = [0.173131, -0.723936, -0.377602, -2.491795, 1.605739, 3.120063, 0.594636]  # t=133
PRESS_135_JOINTS = [0.119790, -0.781540, -0.321338, -2.530529, 1.582608, 3.124296, 0.630383]  # t=135
PRESS_137_JOINTS = [0.074934, -0.829386, -0.273025, -2.559480, 1.544271, 3.127139, 0.679547]  # t=137
PRESS_139_JOINTS = [0.037894, -0.865769, -0.231765, -2.584314, 1.486755, 3.135765, 0.737255]  # t=139
PRESS_141_JOINTS = [0.007487, -0.887588, -0.197273, -2.605095, 1.408839, 3.150111, 0.810030]  # t=141
PRESS_143_JOINTS = [-0.019941, -0.901972, -0.165858, -2.628995, 1.312106, 3.167004, 0.901189]  # t=143
PRESS_145_JOINTS = [-0.050120, -0.910521, -0.135926, -2.657784, 1.197893, 3.178393, 1.009522]  # t=145
PRESS_147_JOINTS = [-0.090003, -0.918765, -0.106699, -2.688709, 1.070324, 3.179241, 1.125491]  # t=147
PRESS_149_JOINTS = [-0.143863, -0.920774, -0.077234, -2.712315, 0.931845, 3.163422, 1.238335]  # t=149
PRESS_151_JOINTS = [-0.211167, -0.918674, -0.039669, -2.722910, 0.784673, 3.121964, 1.345417]  # t=151
PRESS_153_JOINTS = [-0.290956, -0.919502, 0.007366, -2.733141, 0.627384, 3.042324, 1.455478]  # t=153
PRESS_154_JOINTS = [-0.332991, -0.915964, 0.034046, -2.727244, 0.543394, 2.990646, 1.518691]  # t=154
PRESS_155_JOINTS = [-0.372493, -0.909494, 0.057878, -2.706079, 0.461547, 2.935069, 1.590498]  # t=155
PRESS_156_JOINTS = [-0.408389, -0.903945, 0.077793, -2.678106, 0.378863, 2.868866, 1.661983]  # t=156
PRESS_157_JOINTS = [-0.437888, -0.902124, 0.095156, -2.641116, 0.295601, 2.793333, 1.724089]  # t=157
PRESS_159_JOINTS = [-0.467955, -0.893853, 0.116754, -2.541691, 0.150881, 2.620825, 1.800438]  # t=159
PRESS_160_JOINTS = [-0.469809, -0.891000, 0.117872, -2.486460, 0.093910, 2.530361, 1.815447]  # t=160
PRESS_161_JOINTS = [-0.465331, -0.889958, 0.113622, -2.430815, 0.045501, 2.440001, 1.818684]  # t=161
PRESS_163_JOINTS = [-0.443392, -0.885897, 0.096369, -2.321000, -0.033274, 2.267237, 1.800153]  # t=163
PRESS_165_JOINTS = [-0.411773, -0.882873, 0.073115, -2.218364, -0.093982, 2.107599, 1.769453]  # t=165
PRESS_166_JOINTS = [-0.394636, -0.886816, 0.060314, -2.175866, -0.118900, 2.038838, 1.760874]  # t=166
PRESS_167_JOINTS = [-0.377140, -0.895944, 0.048533, -2.144105, -0.141915, 1.979520, 1.756166]  # t=167
PRESS_169_JOINTS = [-0.341837, -0.929132, 0.024706, -2.109569, -0.176109, 1.897624, 1.757357]  # t=169
PRESS_171_JOINTS = [-0.307632, -0.976812, -0.001096, -2.103429, -0.195606, 1.840068, 1.757172]  # t=171
PRESS_173_JOINTS = [-0.275496, -1.034559, -0.027663, -2.109188, -0.203961, 1.801914, 1.744943]  # t=173
PRESS_175_JOINTS = [-0.246383, -1.104693, -0.049079, -2.124242, -0.200891, 1.778365, 1.729693]  # t=175
PRESS_177_JOINTS = [-0.222016, -1.185289, -0.060863, -2.146608, -0.192821, 1.763273, 1.722012]  # t=177
PRESS_179_JOINTS = [-0.203487, -1.275379, -0.057551, -2.174033, -0.181749, 1.754534, 1.732906]  # t=179
PRESS_181_JOINTS = [-0.190579, -1.374973, -0.031924, -2.205901, -0.165753, 1.752655, 1.770403]  # t=181
PRESS_183_JOINTS = [-0.181141, -1.478672, 0.003487, -2.241459, -0.147360, 1.766921, 1.822022]  # t=183
PRESS_185_JOINTS = [-0.173303, -1.584164, 0.043789, -2.282340, -0.129354, 1.796593, 1.877696]  # t=185
PRESS_186_JOINTS = [-0.169606, -1.638545, 0.065472, -2.304269, -0.120867, 1.815736, 1.906881]  # t=186
PRESS_187_JOINTS = [-0.165978, -1.693585, 0.088089, -2.326978, -0.113036, 1.836603, 1.937545]  # t=187
PRESS_188_JOINTS = [-0.162511, -1.748504, 0.111623, -2.349254, -0.106529, 1.858699, 1.970712]  # t=188
PRESS_189_JOINTS = [-0.159118, -1.768253, 0.136874, -2.350839, -0.103710, 1.878230, 2.007267]  # t=189
PRESS_191_JOINTS = [-0.152694, -1.763135, 0.193483, -2.286105, -0.111023, 1.852010, 2.088655]  # t=191
PRESS_193_JOINTS = [-0.148909, -1.762893, 0.253758, -2.221664, -0.125836, 1.801002, 2.166936]  # t=193
PRESS_195_JOINTS = [-0.146081, -1.762632, 0.313134, -2.170188, -0.136034, 1.743875, 2.226630]  # t=195
PRESS_197_JOINTS = [-0.141205, -1.755196, 0.351133, -2.136219, -0.141413, 1.703252, 2.250698]  # t=197
PRESS_198_JOINTS = [-0.138257, -1.747544, 0.357473, -2.126525, -0.146116, 1.692087, 2.255490]  # t=198
PRESS_199_JOINTS = [-0.135123, -1.740449, 0.360898, -2.118384, -0.150358, 1.684035, 2.259943]  # t=199
PRESS_200_JOINTS = [-0.131892, -1.734705, 0.365741, -2.111391, -0.154580, 1.678794, 2.260358]  # t=200
PRESS_201_JOINTS = [-0.128761, -1.730784, 0.375674, -2.105098, -0.156309, 1.674698, 2.259027]  # t=201
PRESS_203_JOINTS = [-0.123899, -1.730491, 0.416183, -2.093650, -0.146202, 1.663010, 2.272599]  # t=203
PRESS_205_JOINTS = [-0.120392, -1.735456, 0.470658, -2.085325, -0.130226, 1.649998, 2.300769]  # t=205
PRESS_207_JOINTS = [-0.116627, -1.741795, 0.529968, -2.080361, -0.113038, 1.637074, 2.330526]  # t=207
PRESS_209_JOINTS = [-0.112060, -1.749461, 0.591247, -2.075627, -0.097983, 1.629152, 2.362115]  # t=209
PRESS_211_JOINTS = [-0.108382, -1.750647, 0.650360, -2.069263, -0.084050, 1.627876, 2.392938]  # t=211
PRESS_213_JOINTS = [-0.108441, -1.741003, 0.705354, -2.065961, -0.070757, 1.637293, 2.432452]  # t=213
PRESS_215_JOINTS = [-0.113501, -1.720907, 0.761608, -2.066513, -0.055397, 1.659259, 2.484229]  # t=215
PRESS_217_JOINTS = [-0.123275, -1.693698, 0.819910, -2.066353, -0.042620, 1.689416, 2.542639]  # t=217
PRESS_219_JOINTS = [-0.138239, -1.660011, 0.877829, -2.063998, -0.034876, 1.726908, 2.603231]  # t=219
PRESS_221_JOINTS = [-0.158586, -1.621399, 0.932640, -2.059641, -0.033555, 1.767871, 2.663349]  # t=221
PRESS_223_JOINTS = [-0.183973, -1.580003, 0.983265, -2.054058, -0.037412, 1.811786, 2.720419]  # t=223
PRESS_225_JOINTS = [-0.215074, -1.537405, 1.032111, -2.043968, -0.044703, 1.857473, 2.775390]  # t=225
PRESS_227_JOINTS = [-0.250707, -1.496414, 1.076562, -2.027933, -0.056166, 1.898071, 2.826601]  # t=227
PRESS_229_JOINTS = [-0.287367, -1.459015, 1.107674, -2.011982, -0.072259, 1.928409, 2.865735]  # t=229
PRESS_231_JOINTS = [-0.323980, -1.426162, 1.134326, -2.001473, -0.086040, 1.957942, 2.896856]  # t=231
PRESS_233_JOINTS = [-0.361091, -1.395755, 1.150243, -1.995906, -0.091471, 1.988695, 2.897526]  # t=233
PRESS_235_JOINTS = [-0.398484, -1.362240, 1.158619, -1.992500, -0.086920, 2.021676, 2.893358]  # t=235
PRESS_237_JOINTS = [-0.437020, -1.325417, 1.165510, -1.987647, -0.077770, 2.055854, 2.883264]  # t=237
PRESS_239_JOINTS = [-0.477563, -1.287609, 1.174815, -1.981153, -0.068389, 2.090008, 2.869878]  # t=239
PRESS_241_JOINTS = [-0.517557, -1.255483, 1.186929, -1.972114, -0.065463, 2.120680, 2.861773]  # t=241
PRESS_243_JOINTS = [-0.551808, -1.235012, 1.198922, -1.960277, -0.069561, 2.141848, 2.864270]  # t=243
PRESS_245_JOINTS = [-0.581622, -1.221360, 1.212965, -1.950272, -0.072283, 2.158103, 2.870143]  # t=245
PRESS_247_JOINTS = [-0.606869, -1.212975, 1.226723, -1.942053, -0.071488, 2.170085, 2.878833]  # t=247
PRESS_249_JOINTS = [-0.625944, -1.208881, 1.233503, -1.936658, -0.067801, 2.175111, 2.886322]  # t=249
PRESS_250_JOINTS = [-0.630508, -1.209230, 1.232799, -1.935851, -0.065120, 2.172084, 2.886811]  # t=250
PRESS_251_JOINTS = [-0.632643, -1.210446, 1.231050, -1.935275, -0.060905, 2.166872, 2.887236]  # t=251
PRESS_253_JOINTS = [-0.634943, -1.213788, 1.224732, -1.939260, -0.053676, 2.154331, 2.888395]  # t=253
PRESS_255_JOINTS = [-0.631912, -1.219814, 1.213200, -1.951780, -0.049045, 2.134820, 2.892325]  # t=255
PRESS_257_JOINTS = [-0.621702, -1.226932, 1.193141, -1.974565, -0.045481, 2.115415, 2.896601]  # t=257
PRESS_259_JOINTS = [-0.614396, -1.228897, 1.169809, -2.007193, -0.042781, 2.111575, 2.897484]  # t=259
PRESS_261_JOINTS = [-0.628696, -1.212817, 1.151640, -2.037924, -0.042080, 2.132788, 2.897382]  # t=261
PRESS_263_JOINTS = [-0.659896, -1.178283, 1.135351, -2.068018, -0.047768, 2.169961, 2.897330]  # t=263
PRESS_265_JOINTS = [-0.697277, -1.135322, 1.118694, -2.090486, -0.059248, 2.212611, 2.897396]  # t=265
PRESS_267_JOINTS = [-0.729599, -1.097137, 1.108469, -2.090917, -0.072267, 2.235922, 2.897581]  # t=267
PRESS_269_JOINTS = [-0.763659, -1.058985, 1.102949, -2.081534, -0.084035, 2.244369, 2.897542]  # t=269
PRESS_271_JOINTS = [-0.801835, -1.014465, 1.096464, -2.077156, -0.097247, 2.260001, 2.897532]  # t=271
PRESS_273_JOINTS = [-0.844940, -0.960274, 1.094266, -2.075236, -0.111597, 2.296423, 2.897527]  # t=273
PRESS_275_JOINTS = [-0.886513, -0.904439, 1.099916, -2.067673, -0.126756, 2.344194, 2.897526]  # t=275
PRESS_277_JOINTS = [-0.931254, -0.842386, 1.104128, -2.057658, -0.146289, 2.394464, 2.897453]  # t=277
PRESS_278_JOINTS = [-0.952792, -0.808679, 1.103386, -2.052021, -0.154833, 2.417767, 2.897427]  # t=278
PRESS_279_JOINTS = [-0.955132, -0.795137, 1.103652, -2.054264, -0.155733, 2.438671, 2.897649]  # t=279
PRESS_281_JOINTS = [-0.940234, -0.791170, 1.088647, -2.090475, -0.147175, 2.512078, 2.897651]  # t=281
PRESS_282_JOINTS = [-0.926381, -0.795742, 1.076141, -2.117640, -0.141267, 2.556292, 2.897518]  # t=282
RETREAT_283_JOINTS = [-0.913573, -0.797426, 1.062207, -2.144425, -0.137766, 2.601124, 2.897448]  # t=283
RETREAT_284_JOINTS = [-0.902019, -0.796499, 1.045820, -2.171147, -0.135826, 2.646868, 2.897408]  # t=284
RETREAT_285_JOINTS = [-0.886858, -0.799508, 1.026709, -2.198920, -0.133998, 2.690563, 2.897400]  # t=285
RETREAT_286_JOINTS = [-0.866851, -0.807526, 1.006517, -2.228536, -0.130684, 2.734244, 2.897389]  # t=286
RETREAT_287_JOINTS = [-0.842103, -0.821126, 0.985798, -2.261283, -0.126134, 2.777526, 2.897345]  # t=287
RETREAT_288_JOINTS = [-0.813888, -0.838166, 0.964383, -2.297785, -0.119905, 2.821203, 2.896524]  # t=288
RETREAT_289_JOINTS = [-0.783775, -0.855712, 0.942466, -2.336578, -0.111305, 2.866886, 2.892455]  # t=289
RETREAT_290_JOINTS = [-0.752124, -0.873397, 0.920178, -2.376129, -0.099886, 2.913325, 2.883614]  # t=290
RETREAT_291_JOINTS = [-0.718562, -0.891794, 0.896874, -2.415663, -0.084877, 2.957106, 2.869201]  # t=291
RETREAT_292_JOINTS = [-0.683253, -0.909200, 0.872827, -2.453402, -0.065658, 2.996104, 2.848015]  # t=292
RETREAT_293_JOINTS = [-0.645829, -0.924863, 0.848507, -2.488558, -0.042244, 3.028688, 2.819241]  # t=293
APPROACH_000_JOINTS = [-0.042861, -1.016750, -0.040271, -2.275602, 0.009804, 1.516156, 0.717502]  # t=1

# Phase-level helper functions keep the open-loop policy readable while preserving
# the exact primitive execution order used at runtime.

def move_to_control_panel():
    """Approach the appliance control region."""
    moveJoint(APPROACH_000_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_002_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_003_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_005_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_008_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_010_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_012_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_014_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_015_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_016_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_019_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_020_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_022_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_025_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_029_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_030_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_033_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_035_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_038_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_040_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_044_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_045_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_047_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_050_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_052_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_055_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_056_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_058_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_060_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_061_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_063_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_065_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_066_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_070_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_072_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_075_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_079_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_080_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_085_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_090_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_093_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_095_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_099_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_100_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_105_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_107_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_110_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_113_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(APPROACH_115_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)

def press_control():
    """Execute the short interaction path that actuates the control."""
    moveJoint(PRESS_116_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_117_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_118_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_119_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_121_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_122_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_123_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_125_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_127_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_129_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_131_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_133_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_135_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_137_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_139_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_141_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_143_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_145_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_147_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_149_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_151_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_153_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_154_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_155_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_156_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_157_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_159_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_160_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_161_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_163_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_165_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_166_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_167_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_169_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_171_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_173_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_175_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_177_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_179_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_181_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_183_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_185_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_186_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_187_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_188_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_189_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_191_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_193_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_195_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_197_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_198_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_199_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_200_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_201_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_203_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_205_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_207_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_209_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_211_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_213_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_215_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_217_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_219_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_221_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_223_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_225_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_227_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_229_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_231_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_233_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_235_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_237_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_239_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_241_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_243_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_245_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_247_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_249_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_250_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_251_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_253_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_255_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_257_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_259_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_261_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_263_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_265_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_267_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_269_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_271_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_273_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_275_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_277_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_278_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_279_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_281_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_282_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)

def retreat_after_press():
    """Retreat away after the button press interaction."""
    moveJoint(RETREAT_283_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_284_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_285_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_286_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_287_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_288_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_289_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_290_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_291_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_292_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_293_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)

move_to_control_panel()
press_control()
retreat_after_press()

# Fitting strategy:
# - adaptive per-phase waypoint selection on EE position + quaternion error
# - tight tolerances near descend / lift / place, looser tolerances in transport
# - optional moveC / moveA / segmented moveLinear chains / moveActionSequence when a segment is better represented by a smooth or constrained path
# - GT used only during generation; runtime execution uses this saved policy plus scene artifact


# Open-loop trajectory-fit action2code policy generated from the RoboCasa GT EE trajectory
# Task: CloseFridgeDrawer
# Episode: episode_000000

from primitives import moveJoint, moveLinear, moveC, moveA, moveWholeBodyPath, moveActionSequence, grasp, release, wait

SCENE_ARTIFACT = '../../../artifacts/20260324/CloseFridgeDrawer/20260324_205255_close-fridge-drawer_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'CloseFridgeDrawer',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/CloseFridgeDrawer/20260324_205255_close-fridge-drawer_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/CloseFridgeDrawer/20260324_205255_close-fridge-drawer_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/CloseFridgeDrawer/20260324_205255_close-fridge-drawer_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 101,
    'stable_release_contact_loss_t': 101,
    'uses_moveC': False,
    'controller_mode': 'whole_body_ik',
}

OBJ_POSE_T0 = pose(x=float('nan'), y=float('nan'), z=float('nan'), qw=float('nan'), qx=float('nan'), qy=float('nan'), qz=float('nan'))
GOAL_RECEPTACLE_POSE = pose(x=0.258172, y=-0.857218, z=0.790729, qw=0.537984, qx=-0.545464, qy=-0.433279, qz=0.474671)

APPROACH_001_JOINTS = [-0.043800, -1.050213, -0.033740, -2.284728, 0.043175, 1.520718, 0.714233]  # t=1
APPROACH_002_JOINTS = [-0.043039, -1.053878, -0.034313, -2.283995, 0.042504, 1.514266, 0.714621]  # t=2
APPROACH_003_JOINTS = [-0.042103, -1.056857, -0.034845, -2.284036, 0.041872, 1.511274, 0.715114]  # t=3
APPROACH_004_JOINTS = [-0.041035, -1.058328, -0.035271, -2.284803, 0.041318, 1.511333, 0.715676]  # t=4
APPROACH_005_JOINTS = [-0.039938, -1.060210, -0.035769, -2.286491, 0.040628, 1.509798, 0.716239]  # t=5
PRESS_009_JOINTS = [-0.044900, -1.136100, -0.076978, -2.291873, 0.002180, 1.447319, 0.736807]  # t=9
PRESS_011_JOINTS = [-0.053590, -1.208141, -0.119897, -2.306176, -0.029846, 1.420746, 0.766046]  # t=11
PRESS_013_JOINTS = [-0.065416, -1.275999, -0.158385, -2.324840, -0.075576, 1.397333, 0.814015]  # t=13
PRESS_015_JOINTS = [-0.078971, -1.328130, -0.195923, -2.338539, -0.127776, 1.378962, 0.874443]  # t=15
PRESS_016_JOINTS = [-0.085823, -1.348433, -0.214300, -2.341923, -0.154577, 1.366451, 0.904105]  # t=16
PRESS_017_JOINTS = [-0.092592, -1.364258, -0.230959, -2.342646, -0.182297, 1.350693, 0.933292]  # t=17
PRESS_019_JOINTS = [-0.105985, -1.384734, -0.263918, -2.335545, -0.238060, 1.306556, 0.989883]  # t=19
PRESS_021_JOINTS = [-0.118230, -1.388688, -0.302028, -2.317271, -0.293890, 1.255477, 1.042269]  # t=21
PRESS_023_JOINTS = [-0.128059, -1.375490, -0.332937, -2.298347, -0.346725, 1.211072, 1.096693]  # t=23
PRESS_025_JOINTS = [-0.135684, -1.348489, -0.360567, -2.280143, -0.399089, 1.173781, 1.153462]  # t=25
PRESS_026_JOINTS = [-0.139074, -1.332630, -0.379501, -2.264927, -0.426209, 1.153172, 1.176651]  # t=26
PRESS_027_JOINTS = [-0.142797, -1.318430, -0.403839, -2.242038, -0.450238, 1.126365, 1.193643]  # t=27
PRESS_028_JOINTS = [-0.146900, -1.306540, -0.428954, -2.214731, -0.469653, 1.094378, 1.206848]  # t=28
PRESS_029_JOINTS = [-0.151250, -1.296556, -0.447840, -2.188163, -0.486260, 1.058555, 1.218450]  # t=29
PRESS_030_JOINTS = [-0.155834, -1.288511, -0.459221, -2.164718, -0.501819, 1.021673, 1.229900]  # t=30
PRESS_031_JOINTS = [-0.160638, -1.282496, -0.466131, -2.147060, -0.517658, 0.985128, 1.241778]  # t=31
PRESS_032_JOINTS = [-0.165375, -1.278492, -0.472062, -2.137662, -0.536652, 0.952456, 1.253152]  # t=32
PRESS_033_JOINTS = [-0.170212, -1.277003, -0.479645, -2.134526, -0.560839, 0.924074, 1.263745]  # t=33
PRESS_034_JOINTS = [-0.174826, -1.277005, -0.490402, -2.134248, -0.590342, 0.900455, 1.272287]  # t=34
PRESS_035_JOINTS = [-0.178938, -1.277234, -0.504636, -2.135031, -0.623100, 0.880328, 1.278049]  # t=35
PRESS_037_JOINTS = [-0.186819, -1.280422, -0.535811, -2.142609, -0.688991, 0.846007, 1.284641]  # t=37
PRESS_038_JOINTS = [-0.191419, -1.285136, -0.549757, -2.153657, -0.718742, 0.831146, 1.288603]  # t=38
PRESS_039_JOINTS = [-0.196569, -1.292292, -0.562736, -2.174525, -0.744634, 0.820054, 1.296045]  # t=39
PRESS_041_JOINTS = [-0.209256, -1.315144, -0.593107, -2.234386, -0.779816, 0.821381, 1.330110]  # t=41
PRESS_043_JOINTS = [-0.227113, -1.350738, -0.630036, -2.294605, -0.802471, 0.838210, 1.371409]  # t=43
PRESS_045_JOINTS = [-0.248885, -1.393111, -0.669043, -2.355018, -0.829085, 0.857908, 1.404206]  # t=45
PRESS_046_JOINTS = [-0.260729, -1.414953, -0.688101, -2.386438, -0.845132, 0.870592, 1.419079]  # t=46
PRESS_047_JOINTS = [-0.273084, -1.436655, -0.706413, -2.418938, -0.862062, 0.885649, 1.434386]  # t=47
PRESS_049_JOINTS = [-0.296916, -1.474638, -0.742821, -2.477722, -0.896995, 0.920657, 1.455765]  # t=49
PRESS_051_JOINTS = [-0.316725, -1.500145, -0.786809, -2.524544, -0.942121, 0.961286, 1.455336]  # t=51
PRESS_053_JOINTS = [-0.333910, -1.514688, -0.832338, -2.569517, -0.980635, 1.008214, 1.455159]  # t=53
PRESS_054_JOINTS = [-0.341078, -1.517158, -0.853850, -2.590582, -0.996128, 1.035481, 1.458109]  # t=54
PRESS_055_JOINTS = [-0.347050, -1.516363, -0.873806, -2.611495, -1.007932, 1.065033, 1.463441]  # t=55
PRESS_056_JOINTS = [-0.351530, -1.512174, -0.891573, -2.632692, -1.015612, 1.097506, 1.472127]  # t=56
PRESS_057_JOINTS = [-0.354723, -1.504686, -0.908278, -2.654101, -1.020824, 1.131374, 1.483875]  # t=57
PRESS_059_JOINTS = [-0.358334, -1.481292, -0.941052, -2.694847, -1.030130, 1.201319, 1.511949]  # t=59
PRESS_061_JOINTS = [-0.357178, -1.447743, -0.972180, -2.728965, -1.038846, 1.279007, 1.540698]  # t=61
PRESS_063_JOINTS = [-0.351871, -1.410288, -0.990094, -2.747384, -1.030120, 1.362788, 1.555720]  # t=63
PRESS_065_JOINTS = [-0.339541, -1.362874, -1.012832, -2.770291, -1.020732, 1.458121, 1.583274]  # t=65
PRESS_067_JOINTS = [-0.321314, -1.307403, -1.036563, -2.792147, -1.013495, 1.558517, 1.615807]  # t=67
PRESS_069_JOINTS = [-0.296685, -1.245074, -1.058239, -2.809611, -1.004291, 1.662569, 1.649983]  # t=69
PRESS_071_JOINTS = [-0.264245, -1.174780, -1.078950, -2.819150, -0.992127, 1.767329, 1.682077]  # t=71
PRESS_073_JOINTS = [-0.224953, -1.099425, -1.097809, -2.821946, -0.972259, 1.872459, 1.710556]  # t=73
PRESS_075_JOINTS = [-0.178658, -1.019121, -1.115833, -2.818497, -0.944229, 1.977630, 1.735019]  # t=75
PRESS_077_JOINTS = [-0.125783, -0.933023, -1.134586, -2.811438, -0.911588, 2.082841, 1.755677]  # t=77
PRESS_079_JOINTS = [-0.067196, -0.842844, -1.153343, -2.802695, -0.871327, 2.191076, 1.772772]  # t=79
PRESS_081_JOINTS = [-0.004729, -0.750311, -1.171006, -2.791023, -0.818686, 2.298729, 1.781368]  # t=81
PRESS_083_JOINTS = [0.062004, -0.652645, -1.189239, -2.778486, -0.753495, 2.407727, 1.780415]  # t=83
PRESS_085_JOINTS = [0.134112, -0.547206, -1.209281, -2.767160, -0.671569, 2.521505, 1.766979]  # t=85
PRESS_087_JOINTS = [0.204430, -0.446438, -1.223170, -2.757597, -0.562279, 2.626554, 1.729107]  # t=87
PRESS_089_JOINTS = [0.272252, -0.350449, -1.228210, -2.750494, -0.421828, 2.725137, 1.665572]  # t=89
PRESS_090_JOINTS = [0.307753, -0.298878, -1.227931, -2.748311, -0.338358, 2.774687, 1.626379]  # t=90
PRESS_091_JOINTS = [0.347004, -0.242561, -1.224026, -2.748817, -0.241813, 2.825445, 1.581839]  # t=91
PRESS_093_JOINTS = [0.427345, -0.134935, -1.199801, -2.747877, -0.002997, 2.913562, 1.468728]  # t=93
PRESS_095_JOINTS = [0.494000, -0.027589, -1.143049, -2.725994, 0.291137, 2.960702, 1.321159]  # t=95
PRESS_097_JOINTS = [0.504996, 0.076757, -1.041838, -2.677569, 0.604898, 2.967609, 1.151719]  # t=97
PRESS_099_JOINTS = [0.447019, 0.156362, -0.907861, -2.623960, 0.873353, 2.973729, 0.988924]  # t=99
PRESS_100_JOINTS = [0.401523, 0.188276, -0.835117, -2.598136, 0.988071, 2.981295, 0.912235]  # t=100
PRESS_101_JOINTS = [0.349974, 0.217427, -0.762546, -2.572069, 1.092279, 2.989837, 0.837919]  # t=101
RETREAT_102_JOINTS = [0.295542, 0.244014, -0.692385, -2.545244, 1.187814, 2.997731, 0.765477]  # t=102
RETREAT_103_JOINTS = [0.241458, 0.265705, -0.625831, -2.520949, 1.275703, 3.007089, 0.694693]  # t=103
RETREAT_104_JOINTS = [0.190005, 0.281005, -0.563732, -2.501906, 1.356390, 3.017652, 0.625292]  # t=104
RETREAT_105_JOINTS = [0.145150, 0.274956, -0.504017, -2.506567, 1.416568, 3.033689, 0.564414]  # t=105
RETREAT_106_JOINTS = [0.104385, 0.269239, -0.451578, -2.510621, 1.460664, 3.046604, 0.515842]  # t=106
RETREAT_107_JOINTS = [0.068026, 0.265521, -0.406742, -2.512688, 1.491896, 3.054836, 0.479020]  # t=107
RETREAT_108_JOINTS = [0.036203, 0.263138, -0.369279, -2.513558, 1.512559, 3.058902, 0.452496]  # t=108
RETREAT_109_JOINTS = [0.008651, 0.261940, -0.338857, -2.513650, 1.524056, 3.059524, 0.434919]  # t=109
RETREAT_110_JOINTS = [-0.014910, 0.261330, -0.314575, -2.513316, 1.528501, 3.057823, 0.424262]  # t=110
RETREAT_111_JOINTS = [-0.034709, 0.260368, -0.295042, -2.513123, 1.527377, 3.053994, 0.418023]  # t=111
RETREAT_112_JOINTS = [-0.051272, 0.258346, -0.279859, -2.513417, 1.522702, 3.048664, 0.414701]  # t=112
RETREAT_113_JOINTS = [-0.065186, 0.256355, -0.268364, -2.513404, 1.515501, 3.041021, 0.413565]  # t=113
RETREAT_114_JOINTS = [-0.076798, 0.254645, -0.259753, -2.513181, 1.505716, 3.032467, 0.414689]  # t=114
RETREAT_115_JOINTS = [-0.086544, 0.252378, -0.253815, -2.513063, 1.493695, 3.023282, 0.417843]  # t=115
RETREAT_116_JOINTS = [-0.094772, 0.248732, -0.250256, -2.512920, 1.479775, 3.013549, 0.422746]  # t=116
PRESS_007_JOINTS = [-0.039813, -1.081520, -0.044821, -2.288959, 0.029381, 1.482837, 0.720444]  # t=7

# Phase-level helper functions keep the open-loop policy readable while preserving
# the exact primitive execution order used at runtime.

def move_to_control_panel():
    """Approach the appliance control region."""
    moveJoint(APPROACH_001_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_002_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_003_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_004_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_005_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

def press_control():
    """Execute the short interaction path that actuates the control."""
    moveJoint(PRESS_007_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_009_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_011_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_013_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_015_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_016_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_017_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_019_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_021_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_023_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_025_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_026_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_027_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_028_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_029_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_030_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_031_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_032_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_033_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_034_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_035_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_037_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_038_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_039_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_041_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_043_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_045_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_046_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_047_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_049_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_051_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_053_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_054_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_055_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_056_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_057_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_059_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_061_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_063_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_065_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_067_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_069_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_071_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_073_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_075_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_077_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_079_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_081_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_083_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_085_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_087_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_089_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_090_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_091_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_093_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_095_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_097_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_099_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_100_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_101_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

def retreat_after_press():
    """Retreat away after the button press interaction."""
    moveJoint(RETREAT_102_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_103_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_104_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_105_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_106_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_107_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_108_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_109_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_110_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_111_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_112_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_113_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_114_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_115_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_116_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

move_to_control_panel()
press_control()
retreat_after_press()

# Fitting strategy:
# - adaptive per-phase waypoint selection on EE position + quaternion error
# - tight tolerances near descend / lift / place, looser tolerances in transport
# - optional moveC / moveA / segmented moveLinear chains / moveActionSequence when a segment is better represented by a smooth or constrained path
# - GT used only during generation; runtime execution uses this saved policy plus scene artifact

all mushroom vegetable food in_container

all corn vegetable food in_container oven_ready


# Open-loop trajectory-fit action2code policy generated from the RoboCasa GT EE trajectory
# Task: CloseMicrowave
# Episode: episode_000000

from primitives import moveJoint, moveLinear, moveC, moveA, moveWholeBodyPath, moveActionSequence, grasp, release, wait

SCENE_ARTIFACT = '../../../artifacts/20260324/CloseMicrowave/20260324_205256_close-microwave_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'CloseMicrowave',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/CloseMicrowave/20260324_205256_close-microwave_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/CloseMicrowave/20260324_205256_close-microwave_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/CloseMicrowave/20260324_205256_close-microwave_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 203,
    'stable_release_contact_loss_t': 203,
    'uses_moveC': False,
    'controller_mode': 'whole_body_ik',
}

OBJ_POSE_T0 = pose(x=2.144317, y=-0.247162, z=1.472589, qw=0.999989, qx=-0.000087, qy=-0.000003, qz=0.004630)
GOAL_RECEPTACLE_POSE = pose(x=2.769839, y=-0.094801, z=0.949546, qw=0.831743, qx=-0.158557, qy=0.387725, qz=0.364326)

APPROACH_003_JOINTS = [-0.016320, -1.029413, -0.037870, -2.276578, 0.039729, 1.506229, 0.701238]  # t=3
APPROACH_004_JOINTS = [-0.016686, -1.046482, -0.038522, -2.274233, 0.039459, 1.489140, 0.700916]  # t=4
APPROACH_005_JOINTS = [-0.017301, -1.074789, -0.041981, -2.271501, 0.042013, 1.476343, 0.700068]  # t=5
APPROACH_010_JOINTS = [-0.026124, -1.295396, -0.091215, -2.270712, 0.067765, 1.490939, 0.708327]  # t=10
APPROACH_011_JOINTS = [-0.028118, -1.337982, -0.104179, -2.266512, 0.074536, 1.495934, 0.709353]  # t=11
APPROACH_015_JOINTS = [-0.034403, -1.470210, -0.158111, -2.214945, 0.097442, 1.518194, 0.695268]  # t=15
APPROACH_016_JOINTS = [-0.035636, -1.494564, -0.167090, -2.195439, 0.103205, 1.526328, 0.688430]  # t=16
APPROACH_020_JOINTS = [-0.042190, -1.575039, -0.180334, -2.113920, 0.124987, 1.573699, 0.667487]  # t=20
APPROACH_021_JOINTS = [-0.045995, -1.592043, -0.176264, -2.094311, 0.119643, 1.590356, 0.669288]  # t=21
APPROACH_025_JOINTS = [-0.061876, -1.645508, -0.141475, -2.016551, 0.072850, 1.668543, 0.665772]  # t=25
APPROACH_030_JOINTS = [-0.072265, -1.708811, -0.122058, -1.945748, 0.034086, 1.764829, 0.683985]  # t=30
APPROACH_031_JOINTS = [-0.073453, -1.722330, -0.117440, -1.934553, 0.028145, 1.783281, 0.683689]  # t=31
APPROACH_033_JOINTS = [-0.076979, -1.754500, -0.095835, -1.917073, 0.016071, 1.812111, 0.673471]  # t=33
APPROACH_035_JOINTS = [-0.082360, -1.763460, -0.068345, -1.879376, -0.000485, 1.827854, 0.663069]  # t=35
APPROACH_040_JOINTS = [-0.105509, -1.762863, 0.023815, -1.724493, -0.087175, 1.805238, 0.667294]  # t=40
APPROACH_041_JOINTS = [-0.113123, -1.762833, 0.047721, -1.694184, -0.117144, 1.796813, 0.679597]  # t=41
APPROACH_044_JOINTS = [-0.136943, -1.760919, 0.122866, -1.605891, -0.215647, 1.770437, 0.714429]  # t=44
APPROACH_045_JOINTS = [-0.145414, -1.758941, 0.148549, -1.578180, -0.251301, 1.755849, 0.723166]  # t=45
APPROACH_047_JOINTS = [-0.164561, -1.756880, 0.203231, -1.534330, -0.326529, 1.709467, 0.742243]  # t=47
APPROACH_050_JOINTS = [-0.194793, -1.763398, 0.295514, -1.499692, -0.432524, 1.627636, 0.777945]  # t=50
APPROACH_053_JOINTS = [-0.226896, -1.762852, 0.395063, -1.467346, -0.549401, 1.546463, 0.826382]  # t=53
APPROACH_055_JOINTS = [-0.250685, -1.762853, 0.466303, -1.456160, -0.631240, 1.489290, 0.857974]  # t=55
APPROACH_056_JOINTS = [-0.263246, -1.762856, 0.504333, -1.455540, -0.671141, 1.457125, 0.872617]  # t=56
APPROACH_059_JOINTS = [-0.300901, -1.762839, 0.624901, -1.472388, -0.772921, 1.350712, 0.915507]  # t=59
APPROACH_060_JOINTS = [-0.311811, -1.762846, 0.664452, -1.485592, -0.798196, 1.313255, 0.930716]  # t=60
APPROACH_065_JOINTS = [-0.349272, -1.762382, 0.852729, -1.567333, -0.867896, 1.171532, 1.027041]  # t=65
APPROACH_070_JOINTS = [-0.373554, -1.749910, 1.012948, -1.637404, -0.862794, 1.115207, 1.151257]  # t=70
APPROACH_073_JOINTS = [-0.401433, -1.725550, 1.100357, -1.662083, -0.878593, 1.118306, 1.210031]  # t=73
APPROACH_075_JOINTS = [-0.423085, -1.703224, 1.143178, -1.670883, -0.897623, 1.130970, 1.241145]  # t=75
APPROACH_077_JOINTS = [-0.443993, -1.679937, 1.178196, -1.680420, -0.919745, 1.157422, 1.256056]  # t=77
APPROACH_079_JOINTS = [-0.463938, -1.657835, 1.207625, -1.696549, -0.937512, 1.189428, 1.263153]  # t=79
APPROACH_080_JOINTS = [-0.473239, -1.647839, 1.217944, -1.707947, -0.942424, 1.200445, 1.273230]  # t=80
APPROACH_082_JOINTS = [-0.492637, -1.629045, 1.232511, -1.729803, -0.945169, 1.213605, 1.306628]  # t=82
APPROACH_085_JOINTS = [-0.520797, -1.606567, 1.246671, -1.760579, -0.953720, 1.209723, 1.345911]  # t=85
APPROACH_090_JOINTS = [-0.538669, -1.582839, 1.244598, -1.820951, -0.964473, 1.146735, 1.382262]  # t=90
APPROACH_091_JOINTS = [-0.539396, -1.577517, 1.239521, -1.833101, -0.965749, 1.132044, 1.395269]  # t=91
APPROACH_094_JOINTS = [-0.539677, -1.557355, 1.213597, -1.861023, -0.969458, 1.085566, 1.451231]  # t=94
APPROACH_095_JOINTS = [-0.540095, -1.547446, 1.200975, -1.861523, -0.970124, 1.073964, 1.470796]  # t=95
APPROACH_097_JOINTS = [-0.543530, -1.523036, 1.178873, -1.850647, -0.968923, 1.056313, 1.495969]  # t=97
APPROACH_099_JOINTS = [-0.550323, -1.498658, 1.171342, -1.845061, -0.968818, 1.045284, 1.523882]  # t=99
APPROACH_100_JOINTS = [-0.555510, -1.485530, 1.173216, -1.846987, -0.969213, 1.048145, 1.538778]  # t=100
APPROACH_105_JOINTS = [-0.572535, -1.422046, 1.172453, -1.856391, -0.954357, 1.086586, 1.625407]  # t=105
APPROACH_110_JOINTS = [-0.557480, -1.369024, 1.156354, -1.926704, -0.918923, 1.185806, 1.740662]  # t=110
APPROACH_115_JOINTS = [-0.529250, -1.319655, 1.136630, -2.000284, -0.953304, 1.319825, 1.778307]  # t=115
APPROACH_116_JOINTS = [-0.522733, -1.311427, 1.130949, -2.010744, -0.964286, 1.338947, 1.780566]  # t=116
APPROACH_120_JOINTS = [-0.493087, -1.281596, 1.097608, -2.048853, -1.006318, 1.398928, 1.792619]  # t=120
APPROACH_125_JOINTS = [-0.450639, -1.237363, 1.033074, -2.081467, -1.059799, 1.476870, 1.743638]  # t=125
APPROACH_127_JOINTS = [-0.432894, -1.218213, 1.001190, -2.088417, -1.079189, 1.505100, 1.711854]  # t=127
APPROACH_129_JOINTS = [-0.414967, -1.200957, 0.968172, -2.097499, -1.083431, 1.516955, 1.703083]  # t=129
APPROACH_130_JOINTS = [-0.405790, -1.192343, 0.951130, -2.101779, -1.076084, 1.517933, 1.709093]  # t=130
APPROACH_132_JOINTS = [-0.386560, -1.175973, 0.919956, -2.107963, -1.054865, 1.519341, 1.726187]  # t=132
PRESS_134_JOINTS = [-0.365235, -1.163215, 0.891503, -2.108150, -1.028076, 1.518008, 1.739377]  # t=134
PRESS_136_JOINTS = [-0.341564, -1.153352, 0.858931, -2.112125, -1.001084, 1.524586, 1.752607]  # t=136
PRESS_138_JOINTS = [-0.317239, -1.144798, 0.823188, -2.120675, -0.977071, 1.541849, 1.765133]  # t=138
PRESS_140_JOINTS = [-0.293210, -1.137344, 0.784254, -2.132405, -0.957617, 1.568430, 1.776527]  # t=140
PRESS_142_JOINTS = [-0.269014, -1.132267, 0.742754, -2.146358, -0.938763, 1.600698, 1.786237]  # t=142
PRESS_144_JOINTS = [-0.243777, -1.132012, 0.696862, -2.163624, -0.917124, 1.639504, 1.804804]  # t=144
PRESS_146_JOINTS = [-0.216770, -1.134203, 0.642614, -2.187471, -0.893141, 1.697860, 1.818862]  # t=146
PRESS_148_JOINTS = [-0.190308, -1.139176, 0.584319, -2.215647, -0.873026, 1.771054, 1.834710]  # t=148
PRESS_150_JOINTS = [-0.166568, -1.141667, 0.526619, -2.246575, -0.857538, 1.855678, 1.837521]  # t=150
PRESS_152_JOINTS = [-0.145257, -1.144676, 0.466745, -2.277174, -0.844028, 1.943187, 1.826717]  # t=152
PRESS_154_JOINTS = [-0.127466, -1.147496, 0.406350, -2.308162, -0.836472, 2.033843, 1.807030]  # t=154
PRESS_155_JOINTS = [-0.120217, -1.148325, 0.377400, -2.323067, -0.835081, 2.079161, 1.795635]  # t=155
PRESS_156_JOINTS = [-0.114303, -1.148079, 0.349919, -2.337089, -0.835534, 2.124221, 1.783744]  # t=156
PRESS_158_JOINTS = [-0.106237, -1.143499, 0.299122, -2.361488, -0.839222, 2.213049, 1.759718]  # t=158
PRESS_160_JOINTS = [-0.102186, -1.133304, 0.252077, -2.380917, -0.843839, 2.300594, 1.734350]  # t=160
PRESS_162_JOINTS = [-0.101197, -1.116137, 0.205810, -2.395360, -0.846753, 2.389112, 1.706628]  # t=162
PRESS_164_JOINTS = [-0.101249, -1.095871, 0.159814, -2.406451, -0.842107, 2.475300, 1.677127]  # t=164
PRESS_166_JOINTS = [-0.100856, -1.072724, 0.113607, -2.415441, -0.825928, 2.560838, 1.641647]  # t=166
PRESS_168_JOINTS = [-0.099400, -1.046771, 0.068863, -2.423166, -0.798308, 2.646651, 1.596681]  # t=168
PRESS_169_JOINTS = [-0.098365, -1.032153, 0.048026, -2.425066, -0.780422, 2.688135, 1.570666]  # t=169
PRESS_170_JOINTS = [-0.096713, -1.016225, 0.029154, -2.425414, -0.758514, 2.725790, 1.540987]  # t=170
PRESS_172_JOINTS = [-0.089996, -0.982684, -0.002624, -2.421084, -0.698352, 2.784618, 1.469406]  # t=172
PRESS_173_JOINTS = [-0.084671, -0.965762, -0.015757, -2.416674, -0.660695, 2.806123, 1.427929]  # t=173
PRESS_174_JOINTS = [-0.078036, -0.949205, -0.027514, -2.410843, -0.618819, 2.822656, 1.383194]  # t=174
PRESS_176_JOINTS = [-0.060754, -0.918963, -0.048076, -2.396037, -0.524783, 2.841103, 1.285175]  # t=176
PRESS_177_JOINTS = [-0.050305, -0.904992, -0.056915, -2.386888, -0.474248, 2.843676, 1.233039]  # t=177
PRESS_178_JOINTS = [-0.040243, -0.892035, -0.066154, -2.375241, -0.424255, 2.843139, 1.182311]  # t=178
PRESS_180_JOINTS = [-0.023411, -0.869918, -0.084300, -2.348607, -0.330875, 2.837667, 1.093299]  # t=180
PRESS_181_JOINTS = [-0.016569, -0.860814, -0.092002, -2.335899, -0.288531, 2.834263, 1.055192]  # t=181
PRESS_182_JOINTS = [-0.010565, -0.853225, -0.098124, -2.325555, -0.249480, 2.830508, 1.020452]  # t=182
PRESS_183_JOINTS = [-0.005581, -0.846167, -0.103999, -2.315489, -0.213484, 2.827307, 0.989355]  # t=183
PRESS_184_JOINTS = [-0.001076, -0.839862, -0.108696, -2.307106, -0.180126, 2.823996, 0.960632]  # t=184
PRESS_186_JOINTS = [0.006211, -0.828460, -0.117039, -2.292268, -0.120511, 2.818992, 0.910963]  # t=186
PRESS_188_JOINTS = [0.012085, -0.820425, -0.124531, -2.280314, -0.067885, 2.813872, 0.869777]  # t=188
PRESS_190_JOINTS = [0.017657, -0.815478, -0.131963, -2.271328, -0.019486, 2.807955, 0.834340]  # t=190
PRESS_192_JOINTS = [0.023253, -0.812609, -0.139584, -2.265343, 0.025944, 2.802097, 0.803866]  # t=192
PRESS_194_JOINTS = [0.028952, -0.809767, -0.147725, -2.260677, 0.068055, 2.797609, 0.775533]  # t=194
PRESS_196_JOINTS = [0.034392, -0.807121, -0.155567, -2.256986, 0.105714, 2.794231, 0.748280]  # t=196
PRESS_198_JOINTS = [0.038387, -0.804669, -0.162272, -2.254123, 0.136768, 2.792013, 0.724453]  # t=198
PRESS_200_JOINTS = [0.039902, -0.802033, -0.166919, -2.251964, 0.158830, 2.791471, 0.705571]  # t=200
PRESS_201_JOINTS = [0.039843, -0.800013, -0.168025, -2.250607, 0.166304, 2.791860, 0.697673]  # t=201
PRESS_202_JOINTS = [0.039658, -0.796562, -0.168381, -2.248433, 0.172366, 2.792916, 0.690908]  # t=202
PRESS_203_JOINTS = [0.039533, -0.791387, -0.168309, -2.245312, 0.177642, 2.794720, 0.685325]  # t=203
PRESS_204_JOINTS = [0.039503, -0.785968, -0.168124, -2.241607, 0.182159, 2.795764, 0.679539]  # t=204
PRESS_206_JOINTS = [0.039420, -0.784316, -0.168577, -2.236916, 0.189015, 2.788904, 0.662769]  # t=206
PRESS_208_JOINTS = [0.038329, -0.782961, -0.169255, -2.229459, 0.192229, 2.773500, 0.649954]  # t=208
PRESS_210_JOINTS = [0.035195, -0.781591, -0.168672, -2.220786, 0.190942, 2.753656, 0.645729]  # t=210
PRESS_212_JOINTS = [0.031485, -0.779452, -0.167454, -2.212158, 0.188977, 2.734479, 0.646431]  # t=212
PRESS_214_JOINTS = [0.027811, -0.777464, -0.166141, -2.204001, 0.186987, 2.716251, 0.647711]  # t=214
RETREAT_218_JOINTS = [0.022925, -0.775628, -0.163816, -2.193891, 0.187539, 2.698922, 0.648047]  # t=218
APPROACH_000_JOINTS = [-0.016103, -1.020079, -0.037544, -2.278405, 0.039894, 1.519546, 0.701247]  # t=1

# Phase-level helper functions keep the open-loop policy readable while preserving
# the exact primitive execution order used at runtime.

def move_to_control_panel():
    """Approach the appliance control region."""
    moveJoint(APPROACH_000_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_003_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_004_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_005_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_010_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_011_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_015_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_016_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_020_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_021_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_025_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_030_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_031_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_033_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_035_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_040_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_041_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_044_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_045_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_047_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_050_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_053_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_055_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_056_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_059_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_060_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_065_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_070_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_073_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_075_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_077_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_079_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_080_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_082_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_085_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_090_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_091_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_094_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_095_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_097_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_099_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_100_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_105_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_110_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_115_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_116_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_120_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_125_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_127_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_129_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_130_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_132_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)

def press_control():
    """Execute the short interaction path that actuates the control."""
    moveJoint(PRESS_134_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_136_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_138_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_140_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_142_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_144_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_146_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_148_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_150_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_152_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_154_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_155_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_156_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_158_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_160_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_162_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_164_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_166_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_168_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_169_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_170_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_172_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_173_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_174_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_176_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_177_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_178_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_180_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_181_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_182_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_183_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_184_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_186_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_188_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_190_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_192_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_194_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_196_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_198_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_200_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_201_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_202_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_203_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_204_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_206_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_208_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_210_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_212_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_214_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)

def retreat_after_press():
    """Retreat away after the button press interaction."""
    moveJoint(RETREAT_218_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)

move_to_control_panel()
press_control()
retreat_after_press()

# Fitting strategy:
# - adaptive per-phase waypoint selection on EE position + quaternion error
# - tight tolerances near descend / lift / place, looser tolerances in transport
# - optional moveC / moveA / segmented moveLinear chains / moveActionSequence when a segment is better represented by a smooth or constrained path
# - GT used only during generation; runtime execution uses this saved policy plus scene artifact


# Open-loop trajectory-fit action2code policy generated from the RoboCasa GT EE trajectory
# Task: CloseStandMixerHead
# Episode: episode_000000

from primitives import moveJoint, moveLinear, moveC, moveA, moveWholeBodyPath, moveActionSequence, grasp, release, wait

SCENE_ARTIFACT = '../../../artifacts/20260324/CloseStandMixerHead/20260324_205258_close-stand-mixer-head_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'CloseStandMixerHead',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/CloseStandMixerHead/20260324_205258_close-stand-mixer-head_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/CloseStandMixerHead/20260324_205258_close-stand-mixer-head_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/CloseStandMixerHead/20260324_205258_close-stand-mixer-head_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 62,
    'stable_release_contact_loss_t': 62,
    'uses_moveC': False,
    'controller_mode': 'whole_body_ik',
}

OBJ_POSE_T0 = pose(x=float('nan'), y=float('nan'), z=float('nan'), qw=float('nan'), qx=float('nan'), qy=float('nan'), qz=float('nan'))
GOAL_RECEPTACLE_POSE = pose(x=float('nan'), y=float('nan'), z=float('nan'), qw=float('nan'), qx=float('nan'), qy=float('nan'), qz=float('nan'))

APPROACH_003_JOINTS = [-0.005969, -1.013322, -0.049984, -2.295131, 0.029970, 1.507608, 0.690263]  # t=3
APPROACH_005_JOINTS = [-0.011617, -1.029336, -0.079765, -2.295239, 0.005196, 1.509710, 0.667928]  # t=5
APPROACH_006_JOINTS = [-0.015490, -1.046452, -0.102268, -2.296349, -0.011352, 1.506803, 0.649459]  # t=6
APPROACH_007_JOINTS = [-0.019821, -1.069481, -0.127418, -2.299073, -0.028688, 1.503338, 0.627907]  # t=7
APPROACH_009_JOINTS = [-0.029268, -1.122727, -0.181676, -2.311254, -0.062571, 1.500224, 0.582029]  # t=9
APPROACH_012_JOINTS = [-0.043476, -1.197562, -0.269403, -2.333373, -0.109245, 1.510606, 0.507300]  # t=12
APPROACH_014_JOINTS = [-0.049911, -1.224789, -0.337705, -2.344963, -0.123056, 1.524709, 0.456636]  # t=14
APPROACH_015_JOINTS = [-0.051788, -1.227085, -0.373661, -2.346609, -0.126479, 1.534496, 0.436596]  # t=15
APPROACH_017_JOINTS = [-0.052482, -1.216373, -0.437590, -2.336644, -0.140109, 1.554541, 0.387162]  # t=17
APPROACH_018_JOINTS = [-0.051217, -1.205202, -0.464848, -2.325371, -0.149703, 1.563044, 0.355517]  # t=18
APPROACH_021_JOINTS = [-0.041456, -1.157404, -0.543820, -2.273404, -0.169558, 1.573303, 0.240823]  # t=21
APPROACH_024_JOINTS = [-0.021065, -1.094009, -0.632199, -2.215739, -0.173196, 1.593974, 0.094783]  # t=24
APPROACH_027_JOINTS = [0.010187, -1.041294, -0.736652, -2.155124, -0.123997, 1.640020, -0.098274]  # t=27
APPROACH_030_JOINTS = [0.057239, -0.989588, -0.851734, -2.091674, -0.038427, 1.683549, -0.319135]  # t=30
APPROACH_032_JOINTS = [0.098625, -0.956165, -0.926291, -2.047295, 0.029329, 1.697803, -0.473576]  # t=32
APPROACH_033_JOINTS = [0.123274, -0.937699, -0.960015, -2.027831, 0.062616, 1.709142, -0.546938]  # t=33
APPROACH_034_JOINTS = [0.151341, -0.916683, -0.989495, -2.013058, 0.096678, 1.728378, -0.612490]  # t=34
APPROACH_036_JOINTS = [0.211879, -0.873501, -1.038337, -1.989986, 0.156032, 1.769889, -0.727087]  # t=36
APPROACH_037_JOINTS = [0.238838, -0.858289, -1.058593, -1.971162, 0.175756, 1.770767, -0.782356]  # t=37
APPROACH_039_JOINTS = [0.291407, -0.831085, -1.099262, -1.906223, 0.199566, 1.675624, -0.900932]  # t=39
APPROACH_040_JOINTS = [0.326019, -0.809259, -1.124830, -1.860327, 0.209884, 1.632796, -0.963635]  # t=40
APPROACH_042_JOINTS = [0.405682, -0.765699, -1.175724, -1.776919, 0.226320, 1.605402, -1.086878]  # t=42
APPROACH_045_JOINTS = [0.519880, -0.734512, -1.234695, -1.683898, 0.224162, 1.622105, -1.257965]  # t=45
APPROACH_047_JOINTS = [0.576874, -0.743655, -1.244138, -1.652504, 0.211900, 1.644898, -1.360293]  # t=47
APPROACH_048_JOINTS = [0.595740, -0.757337, -1.238071, -1.650905, 0.204272, 1.656402, -1.407902]  # t=48
APPROACH_051_JOINTS = [0.622576, -0.814187, -1.193081, -1.693307, 0.170804, 1.706492, -1.542999]  # t=51
APPROACH_054_JOINTS = [0.608166, -0.882508, -1.127740, -1.779431, 0.130900, 1.743338, -1.663534]  # t=54
APPROACH_056_JOINTS = [0.590286, -0.920769, -1.078459, -1.833390, 0.113826, 1.795523, -1.722258]  # t=56
PRESS_060_JOINTS = [0.540054, -0.991269, -0.963761, -1.965275, 0.113578, 1.893023, -1.817052]  # t=60
PRESS_066_JOINTS = [0.482985, -1.029879, -0.828612, -2.083692, 0.157361, 1.827377, -1.998268]  # t=66
RETREAT_067_JOINTS = [0.474670, -1.029576, -0.806769, -2.097561, 0.163464, 1.806344, -2.029321]  # t=67
RETREAT_068_JOINTS = [0.466906, -1.027296, -0.782030, -2.107097, 0.169098, 1.783188, -2.058731]  # t=68
RETREAT_069_JOINTS = [0.461107, -1.020386, -0.751460, -2.107968, 0.175102, 1.761575, -2.085049]  # t=69
RETREAT_070_JOINTS = [0.457644, -1.007343, -0.715869, -2.099754, 0.179879, 1.739562, -2.108310]  # t=70
RETREAT_071_JOINTS = [0.455779, -0.989219, -0.678385, -2.083693, 0.183426, 1.714553, -2.129142]  # t=71
RETREAT_072_JOINTS = [0.454653, -0.967553, -0.640615, -2.060718, 0.185705, 1.686598, -2.148965]  # t=72
RETREAT_073_JOINTS = [0.453053, -0.944715, -0.603225, -2.031071, 0.185407, 1.655268, -2.169077]  # t=73
RETREAT_074_JOINTS = [0.450025, -0.922664, -0.565738, -1.996166, 0.182166, 1.619854, -2.187687]  # t=74
RETREAT_075_JOINTS = [0.445228, -0.901859, -0.526705, -1.957870, 0.175858, 1.582100, -2.201707]  # t=75
RETREAT_076_JOINTS = [0.438192, -0.883216, -0.486418, -1.919845, 0.165362, 1.541823, -2.208955]  # t=76
RETREAT_077_JOINTS = [0.428465, -0.869237, -0.444874, -1.886331, 0.149340, 1.498045, -2.211280]  # t=77
RETREAT_078_JOINTS = [0.415898, -0.861362, -0.401540, -1.860843, 0.127058, 1.454616, -2.208936]  # t=78
RETREAT_079_JOINTS = [0.401456, -0.859174, -0.355268, -1.843332, 0.102035, 1.416428, -2.204362]  # t=79
RETREAT_080_JOINTS = [0.385822, -0.862656, -0.306810, -1.834316, 0.075652, 1.383057, -2.200131]  # t=80
RETREAT_081_JOINTS = [0.369395, -0.872490, -0.258758, -1.833626, 0.050077, 1.356568, -2.196956]  # t=81
RETREAT_082_JOINTS = [0.352600, -0.888678, -0.213777, -1.840881, 0.026777, 1.336350, -2.194858]  # t=82
RETREAT_083_JOINTS = [0.335970, -0.910414, -0.172798, -1.855367, 0.006554, 1.323768, -2.194200]  # t=83
RETREAT_084_JOINTS = [0.320059, -0.935607, -0.137351, -1.875280, -0.007282, 1.321898, -2.192736]  # t=84
APPROACH_000_JOINTS = [-0.004038, -1.011219, -0.044819, -2.295809, 0.035305, 1.505550, 0.693525]  # t=1

# Phase-level helper functions keep the open-loop policy readable while preserving
# the exact primitive execution order used at runtime.

def move_to_control_panel():
    """Approach the appliance control region."""
    moveJoint(APPROACH_000_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_003_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_005_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_006_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_007_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_009_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_012_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_014_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_015_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_017_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_018_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_021_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_024_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_027_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_030_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_032_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_033_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_034_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_036_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_037_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_039_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_040_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_042_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_045_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_047_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_048_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_051_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_054_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_056_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)

def press_control():
    """Execute the short interaction path that actuates the control."""
    moveJoint(PRESS_060_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_066_JOINTS, input_type='joint', steps=6, settle_steps=0, gripper=-1.000)

def retreat_after_press():
    """Retreat away after the button press interaction."""
    moveJoint(RETREAT_067_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_068_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_069_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_070_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_071_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_072_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_073_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_074_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_075_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_076_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_077_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_078_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_079_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_080_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_081_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_082_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_083_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_084_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

move_to_control_panel()
press_control()
retreat_after_press()

# Fitting strategy:
# - adaptive per-phase waypoint selection on EE position + quaternion error
# - tight tolerances near descend / lift / place, looser tolerances in transport
# - optional moveC / moveA / segmented moveLinear chains / moveActionSequence when a segment is better represented by a smooth or constrained path
# - GT used only during generation; runtime execution uses this saved policy plus scene artifact