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

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

SCENE_ARTIFACT = '../../../artifacts/20260324/PickPlaceSinkToCounter/20260324_205331_pick-place-sink-to-counter_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'PickPlaceSinkToCounter',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/PickPlaceSinkToCounter/20260324_205331_pick-place-sink-to-counter_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/PickPlaceSinkToCounter/20260324_205331_pick-place-sink-to-counter_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/PickPlaceSinkToCounter/20260324_205331_pick-place-sink-to-counter_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 85,
    'stable_release_contact_loss_t': 202,
    'uses_moveC': False,
    'controller_mode': 'whole_body_ik',
}

OBJ_POSE_T0 = pose(x=2.680138, y=-0.259268, z=0.723685, qw=0.914614, qx=-0.129267, qy=-0.152518, qz=-0.351438)
GOAL_RECEPTACLE_POSE = pose(x=2.064533, y=-0.369370, z=0.929176, qw=0.999085, qx=-0.003435, qy=-0.005870, qz=0.042227)

APPROACH_004_JOINTS = [-0.029513, -1.059504, -0.031982, -2.266534, 0.040570, 1.453447, 0.708722]  # t=4
APPROACH_005_JOINTS = [-0.029181, -1.068154, -0.032494, -2.272507, 0.040031, 1.447436, 0.708734]  # t=5
APPROACH_008_JOINTS = [-0.026589, -1.091677, -0.018226, -2.334423, 0.045779, 1.453855, 0.714879]  # t=8
APPROACH_012_JOINTS = [-0.021838, -1.124535, 0.013507, -2.475021, 0.067430, 1.514558, 0.737278]  # t=12
APPROACH_013_JOINTS = [-0.020844, -1.127534, 0.019625, -2.510391, 0.070910, 1.534831, 0.741494]  # t=13
APPROACH_016_JOINTS = [-0.017322, -1.121738, 0.030445, -2.613154, 0.079365, 1.617327, 0.735438]  # t=16
APPROACH_020_JOINTS = [-0.009576, -1.096143, 0.042475, -2.736742, 0.092093, 1.749950, 0.694935]  # t=20
APPROACH_022_JOINTS = [-0.005808, -1.081505, 0.046201, -2.787583, 0.096314, 1.809960, 0.670684]  # t=22
APPROACH_024_JOINTS = [-0.003359, -1.070896, 0.040856, -2.835889, 0.094953, 1.865711, 0.631704]  # t=24
APPROACH_028_JOINTS = [0.001288, -1.047647, 0.028366, -2.931622, 0.095123, 1.980780, 0.553759]  # t=28
APPROACH_032_JOINTS = [0.005172, -1.004770, 0.018761, -3.015645, 0.097904, 2.123600, 0.496075]  # t=32
APPROACH_036_JOINTS = [0.010070, -0.904477, 0.014233, -3.058064, 0.108364, 2.286741, 0.471410]  # t=36
APPROACH_040_JOINTS = [0.016619, -0.743991, 0.012127, -3.047344, 0.120551, 2.437097, 0.459306]  # t=40
APPROACH_044_JOINTS = [0.027614, -0.566876, 0.016470, -2.988511, 0.138593, 2.548990, 0.452611]  # t=44
APPROACH_048_JOINTS = [0.033806, -0.402732, 0.020323, -2.900935, 0.148614, 2.600217, 0.450794]  # t=48
APPROACH_051_JOINTS = [0.034026, -0.291259, 0.021070, -2.828865, 0.150502, 2.613642, 0.451425]  # t=51
APPROACH_052_JOINTS = [0.033692, -0.254750, 0.021393, -2.806394, 0.151180, 2.617830, 0.450547]  # t=52
APPROACH_056_JOINTS = [0.031397, -0.123958, 0.022869, -2.734875, 0.158675, 2.655998, 0.440715]  # t=56
APPROACH_060_JOINTS = [0.027788, -0.004131, 0.026508, -2.682925, 0.172790, 2.717153, 0.424140]  # t=60
APPROACH_064_JOINTS = [0.022837, 0.101295, 0.035518, -2.636831, 0.200883, 2.774439, 0.398968]  # t=64
APPROACH_068_JOINTS = [0.014363, 0.195639, 0.048503, -2.590348, 0.247722, 2.820299, 0.357173]  # t=68
APPROACH_072_JOINTS = [0.000093, 0.293928, 0.066476, -2.523961, 0.310011, 2.855739, 0.299280]  # t=72
APPROACH_075_JOINTS = [-0.013353, 0.366378, 0.077573, -2.465907, 0.347782, 2.872310, 0.257366]  # t=75
DESCEND_076_JOINTS = [-0.017577, 0.389311, 0.080705, -2.445864, 0.356138, 2.876684, 0.246567]  # t=76
DESCEND_077_JOINTS = [-0.021794, 0.411623, 0.083768, -2.425248, 0.363428, 2.879722, 0.237020]  # t=77
DESCEND_078_JOINTS = [-0.025738, 0.433239, 0.085691, -2.404730, 0.367977, 2.882453, 0.229144]  # t=78
DESCEND_079_JOINTS = [-0.029124, 0.454231, 0.086571, -2.384463, 0.369333, 2.885007, 0.223545]  # t=79
DESCEND_080_JOINTS = [-0.031955, 0.474514, 0.087051, -2.364221, 0.368585, 2.886920, 0.220198]  # t=80
DESCEND_081_JOINTS = [-0.034522, 0.493267, 0.088005, -2.344040, 0.367478, 2.887104, 0.218394]  # t=81
DESCEND_082_JOINTS = [-0.036867, 0.511199, 0.088513, -2.324275, 0.365420, 2.886582, 0.217684]  # t=82
DESCEND_083_JOINTS = [-0.038832, 0.528719, 0.088513, -2.304478, 0.362015, 2.886008, 0.217931]  # t=83
DESCEND_084_JOINTS = [-0.040293, 0.544379, 0.089028, -2.284115, 0.357682, 2.884601, 0.219345]  # t=84
GRASP_HOLD_085_JOINTS = [-0.041077, 0.555168, 0.089655, -2.268349, 0.351984, 2.879264, 0.222297]  # t=85
LIFT_087_JOINTS = [-0.041827, 0.568223, 0.090190, -2.247183, 0.339817, 2.865647, 0.229649]  # t=87
LIFT_089_JOINTS = [-0.041609, 0.580002, 0.090811, -2.227966, 0.327877, 2.853350, 0.238436]  # t=89
LIFT_091_JOINTS = [-0.041336, 0.588665, 0.090262, -2.210466, 0.316663, 2.840916, 0.246946]  # t=91
LIFT_093_JOINTS = [-0.040464, 0.600235, 0.090626, -2.193439, 0.306992, 2.829503, 0.255235]  # t=93
LIFT_095_JOINTS = [-0.037795, 0.621550, 0.091575, -2.163926, 0.295719, 2.821410, 0.266398]  # t=95
LIFT_097_JOINTS = [-0.034977, 0.629717, 0.089312, -2.148282, 0.282941, 2.808552, 0.278295]  # t=97
LIFT_099_JOINTS = [-0.033492, 0.627594, 0.087798, -2.144619, 0.275072, 2.796952, 0.286801]  # t=99
LIFT_101_JOINTS = [-0.032473, 0.620354, 0.091333, -2.149225, 0.273886, 2.799183, 0.290319]  # t=101
LIFT_102_JOINTS = [-0.032357, 0.613801, 0.094204, -2.156481, 0.275542, 2.806322, 0.289978]  # t=102
LIFT_103_JOINTS = [-0.033102, 0.601734, 0.098319, -2.169232, 0.280451, 2.811264, 0.288146]  # t=103
LIFT_105_JOINTS = [-0.036911, 0.561908, 0.104906, -2.207903, 0.294748, 2.813847, 0.279210]  # t=105
LIFT_106_JOINTS = [-0.039476, 0.527906, 0.107347, -2.239630, 0.302983, 2.815838, 0.272099]  # t=106
LIFT_107_JOINTS = [-0.043235, 0.481664, 0.108852, -2.281787, 0.314211, 2.819458, 0.261636]  # t=107
LIFT_108_JOINTS = [-0.048092, 0.426714, 0.110576, -2.330821, 0.329692, 2.825193, 0.246342]  # t=108
TRANSPORT_111_JOINTS = [-0.064170, 0.242111, 0.120951, -2.493274, 0.401807, 2.852722, 0.176064]  # t=111
TRANSPORT_112_JOINTS = [-0.069046, 0.177659, 0.124389, -2.547118, 0.434214, 2.862667, 0.144917]  # t=112
TRANSPORT_114_JOINTS = [-0.074186, 0.042847, 0.132926, -2.652668, 0.510022, 2.876933, 0.075809]  # t=114
TRANSPORT_116_JOINTS = [-0.071231, -0.094706, 0.136920, -2.754286, 0.588170, 2.884797, 0.007743]  # t=116
TRANSPORT_117_JOINTS = [-0.066778, -0.159223, 0.136135, -2.801427, 0.619193, 2.884911, -0.019124]  # t=117
TRANSPORT_120_JOINTS = [-0.047279, -0.355335, 0.128549, -2.938085, 0.656247, 2.870027, -0.043045]  # t=120
TRANSPORT_123_JOINTS = [-0.030244, -0.569441, 0.120734, -3.059283, 0.614838, 2.828304, 0.010408]  # t=123
TRANSPORT_124_JOINTS = [-0.029323, -0.640671, 0.118769, -3.076207, 0.584272, 2.798281, 0.044753]  # t=124
TRANSPORT_126_JOINTS = [-0.042941, -0.757983, 0.114687, -3.068394, 0.487792, 2.691575, 0.137987]  # t=126
TRANSPORT_128_JOINTS = [-0.047343, -0.846764, 0.111847, -3.043340, 0.403658, 2.587524, 0.222907]  # t=128
TRANSPORT_129_JOINTS = [-0.046050, -0.881667, 0.107489, -3.026236, 0.370814, 2.537481, 0.254240]  # t=129
TRANSPORT_132_JOINTS = [-0.027877, -0.954709, 0.105472, -2.958312, 0.307156, 2.388461, 0.330747]  # t=132
TRANSPORT_135_JOINTS = [0.007988, -1.004638, 0.134612, -2.880975, 0.294873, 2.217669, 0.395057]  # t=135
TRANSPORT_136_JOINTS = [0.023516, -1.011842, 0.154992, -2.858225, 0.304224, 2.171020, 0.414046]  # t=136
TRANSPORT_138_JOINTS = [0.052973, -1.011933, 0.199285, -2.823837, 0.332925, 2.111424, 0.438300]  # t=138
TRANSPORT_140_JOINTS = [0.078836, -0.984035, 0.250048, -2.801184, 0.374894, 2.101401, 0.447483]  # t=140
TRANSPORT_141_JOINTS = [0.089885, -0.965728, 0.275512, -2.788971, 0.396395, 2.102293, 0.449096]  # t=141
TRANSPORT_144_JOINTS = [0.116346, -0.903009, 0.351380, -2.747985, 0.459164, 2.112631, 0.445598]  # t=144
TRANSPORT_147_JOINTS = [0.131708, -0.831593, 0.427633, -2.700380, 0.512625, 2.146193, 0.439000]  # t=147
TRANSPORT_148_JOINTS = [0.133707, -0.803233, 0.453205, -2.683010, 0.527499, 2.165286, 0.436891]  # t=148
TRANSPORT_150_JOINTS = [0.135094, -0.749200, 0.502410, -2.644342, 0.550813, 2.194872, 0.438152]  # t=150
TRANSPORT_152_JOINTS = [0.132239, -0.697413, 0.546156, -2.601580, 0.563563, 2.219104, 0.441715]  # t=152
TRANSPORT_153_JOINTS = [0.129534, -0.667737, 0.570064, -2.579593, 0.568805, 2.234512, 0.443688]  # t=153
TRANSPORT_156_JOINTS = [0.117039, -0.580551, 0.645145, -2.513471, 0.562470, 2.274513, 0.466143]  # t=156
TRANSPORT_159_JOINTS = [0.095833, -0.495333, 0.731866, -2.447204, 0.502838, 2.309019, 0.538028]  # t=159
TRANSPORT_160_JOINTS = [0.087531, -0.466923, 0.758970, -2.422809, 0.478644, 2.318280, 0.568459]  # t=160
TRANSPORT_162_JOINTS = [0.067747, -0.404689, 0.816136, -2.374583, 0.414244, 2.338482, 0.642234]  # t=162
TRANSPORT_164_JOINTS = [0.045859, -0.339332, 0.871574, -2.327954, 0.333760, 2.352184, 0.725978]  # t=164
TRANSPORT_165_JOINTS = [0.034203, -0.303035, 0.897567, -2.305186, 0.289396, 2.360994, 0.768011]  # t=165
TRANSPORT_168_JOINTS = [0.001431, -0.186084, 0.964919, -2.238143, 0.136603, 2.378265, 0.897439]  # t=168
TRANSPORT_171_JOINTS = [-0.011659, -0.074179, 1.009577, -2.172332, -0.022399, 2.365628, 1.024076]  # t=171
TRANSPORT_172_JOINTS = [-0.010154, -0.038426, 1.016617, -2.149750, -0.073705, 2.356247, 1.063886]  # t=172
TRANSPORT_174_JOINTS = [0.004162, 0.035834, 1.017804, -2.103406, -0.167979, 2.342468, 1.132315]  # t=174
TRANSPORT_176_JOINTS = [0.036493, 0.114774, 1.005192, -2.060134, -0.265484, 2.328938, 1.199040]  # t=176
TRANSPORT_177_JOINTS = [0.059596, 0.151481, 0.993532, -2.038826, -0.312301, 2.317053, 1.231648]  # t=177
TRANSPORT_180_JOINTS = [0.153080, 0.259255, 0.937087, -1.966497, -0.439670, 2.280546, 1.320034]  # t=180
TRANSPORT_182_JOINTS = [0.227746, 0.327963, 0.883711, -1.907523, -0.505057, 2.261363, 1.363759]  # t=182
PLACE_184_JOINTS = [0.306180, 0.394817, 0.823047, -1.841246, -0.556426, 2.242106, 1.393443]  # t=184
PLACE_186_JOINTS = [0.380019, 0.445895, 0.763178, -1.771905, -0.589005, 2.216167, 1.409963]  # t=186
PLACE_188_JOINTS = [0.445244, 0.489948, 0.703754, -1.703316, -0.607072, 2.192042, 1.411380]  # t=188
PLACE_190_JOINTS = [0.499043, 0.526721, 0.646196, -1.645235, -0.617170, 2.171063, 1.403238]  # t=190
PLACE_192_JOINTS = [0.543557, 0.554560, 0.597001, -1.601424, -0.629823, 2.158054, 1.397751]  # t=192
PLACE_193_JOINTS = [0.563103, 0.560228, 0.579078, -1.586584, -0.638498, 2.149807, 1.400134]  # t=193
PLACE_194_JOINTS = [0.580320, 0.560623, 0.564341, -1.576410, -0.648331, 2.140196, 1.405580]  # t=194
PLACE_196_JOINTS = [0.607993, 0.553403, 0.541356, -1.568503, -0.672984, 2.129970, 1.424293]  # t=196
PLACE_198_JOINTS = [0.628176, 0.532442, 0.529939, -1.584171, -0.704201, 2.129758, 1.459132]  # t=198
PLACE_200_JOINTS = [0.642156, 0.505968, 0.528806, -1.617321, -0.738029, 2.141387, 1.506650]  # t=200
PLACE_202_JOINTS = [0.649573, 0.462756, 0.536959, -1.666574, -0.774810, 2.148727, 1.564565]  # t=202
RELEASE_POSE_202_JOINTS = [0.649573, 0.462756, 0.536959, -1.666574, -0.774810, 2.148727, 1.564565]  # t=202
RETRACT_204_JOINTS = [0.650066, 0.404087, 0.554971, -1.732233, -0.807688, 2.156195, 1.627934]  # t=204
RETRACT_206_JOINTS = [0.643970, 0.334684, 0.581817, -1.805822, -0.832991, 2.163725, 1.690851]  # t=206
RETRACT_208_JOINTS = [0.629875, 0.282279, 0.604370, -1.863601, -0.848635, 2.188977, 1.736335]  # t=208
RETRACT_210_JOINTS = [0.609914, 0.234297, 0.624040, -1.901948, -0.863650, 2.204543, 1.762142]  # t=210
RETRACT_211_JOINTS = [0.599012, 0.207447, 0.637670, -1.917078, -0.864869, 2.207205, 1.769652]  # t=211
RETRACT_212_JOINTS = [0.588292, 0.177609, 0.655767, -1.930515, -0.862121, 2.205946, 1.775624]  # t=212
RETRACT_214_JOINTS = [0.566743, 0.111557, 0.702270, -1.956143, -0.839232, 2.193761, 1.785100]  # t=214
RETRACT_216_JOINTS = [0.543371, 0.045061, 0.754723, -1.974723, -0.794446, 2.178199, 1.784640]  # t=216
RETRACT_217_JOINTS = [0.530817, 0.011897, 0.781818, -1.980150, -0.766052, 2.167511, 1.779479]  # t=217
RETRACT_218_JOINTS = [0.517611, -0.024413, 0.809042, -1.984189, -0.733602, 2.152561, 1.772267]  # t=218
RETRACT_220_JOINTS = [0.488826, -0.105314, 0.861472, -1.989025, -0.657120, 2.120751, 1.750745]  # t=220
RETRACT_222_JOINTS = [0.456717, -0.191120, 0.909478, -1.993319, -0.571112, 2.085403, 1.723953]  # t=222
RETRACT_224_JOINTS = [0.422668, -0.289068, 0.949248, -2.004909, -0.475497, 2.039851, 1.700769]  # t=224
RETRACT_225_JOINTS = [0.405639, -0.341395, 0.965023, -2.013384, -0.425052, 2.018290, 1.685132]  # t=225
RETRACT_226_JOINTS = [0.389176, -0.396539, 0.976748, -2.023893, -0.373222, 1.995234, 1.667103]  # t=226
RETRACT_228_JOINTS = [0.360129, -0.513796, 0.986296, -2.047712, -0.265790, 1.953679, 1.626128]  # t=228
RETRACT_229_JOINTS = [0.348095, -0.573898, 0.984350, -2.062766, -0.212118, 1.936455, 1.601884]  # t=229
RETRACT_230_JOINTS = [0.338029, -0.633984, 0.978393, -2.080504, -0.159790, 1.921838, 1.574431]  # t=230
RETRACT_232_JOINTS = [0.324305, -0.752182, 0.952459, -2.122618, -0.060870, 1.905230, 1.508999]  # t=232
RETRACT_234_JOINTS = [0.320667, -0.867743, 0.911799, -2.176420, 0.032104, 1.900461, 1.436031]  # t=234
RETRACT_235_JOINTS = [0.322238, -0.924503, 0.889014, -2.208033, 0.074855, 1.899267, 1.399129]  # t=235
APPROACH_000_JOINTS = [-0.030597, -1.046055, -0.031126, -2.267429, 0.041242, 1.468732, 0.708397]  # 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_pregrasp():
    """Coarse approach into the pregrasp corridor."""
    moveJoint(APPROACH_000_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_004_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_005_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_008_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_012_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_013_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_016_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_020_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_022_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_024_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_028_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_032_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_036_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_040_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_044_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_048_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_051_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_052_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_056_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_060_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_064_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_068_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_072_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_075_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)

def execute_grasp_approach():
    """Final Cartesian descent into grasp alignment."""
    moveJoint(DESCEND_076_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_077_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_078_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_079_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_080_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_081_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_082_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_083_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_084_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

def close_gripper_on_object():
    """Close the gripper and let the grasp settle briefly."""
    grasp(hold_target=GRASP_HOLD_085_JOINTS, input_type='joint', close_steps=9, settle_steps=0, gripper=1.0, require_contact_count=4)
    wait(duration=0.05, hold_target=GRASP_HOLD_085_JOINTS, input_type='joint', gripper=1.0)

def lift_object():
    """Lift the grasped object clear of the counter."""
    moveJoint(LIFT_087_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(LIFT_089_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(LIFT_091_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(LIFT_093_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_095_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_097_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_099_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_101_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_102_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_103_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_105_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_106_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_107_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_108_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)

def transport_to_place():
    """Carry the object through the curved transport corridor."""
    moveJoint(TRANSPORT_111_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_112_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_114_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_116_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_117_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_120_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_123_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_124_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_126_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_128_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_129_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_132_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_135_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_136_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_138_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_140_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_141_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_144_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_147_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_148_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_150_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_152_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_153_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_156_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_159_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_160_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_162_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_164_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_165_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_168_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_171_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_172_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_174_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_176_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_177_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_180_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_182_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)

def prepare_release():
    """Set the object into the receptacle and stabilize before release."""
    moveJoint(PLACE_184_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_186_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_188_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_190_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_192_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_193_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_194_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_196_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_198_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_200_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_202_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    wait(duration=0.05, hold_target=RELEASE_POSE_202_JOINTS, input_type='joint', gripper=-1.0)

def release_object():
    """Open the gripper and hold briefly to avoid disturbing the placement."""
    release(hold_target=RELEASE_POSE_202_JOINTS, input_type='joint', open_steps=1, settle_steps=0, gripper=-1.0)
    wait(duration=0.05, hold_target=RELEASE_POSE_202_JOINTS, input_type='joint', gripper=-1.0)

def retreat_after_release():
    """Retreat away from the placed object without clipping it."""
    moveJoint(RETRACT_204_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_206_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_208_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_210_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_211_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_212_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_214_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_216_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_217_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_218_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_220_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_222_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_224_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_225_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_226_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_228_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_229_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_230_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_232_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_234_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_235_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

move_to_pregrasp()
execute_grasp_approach()
close_gripper_on_object()
lift_object()
transport_to_place()
prepare_release()
release_object()
retreat_after_release()

# 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

Pick the squash from the sink and place it on the plate located on the counter.


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

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

SCENE_ARTIFACT = '../../../artifacts/20260324/PickPlaceStoveToCounter/20260324_205332_pick-place-stove-to-counter_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'PickPlaceStoveToCounter',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/PickPlaceStoveToCounter/20260324_205332_pick-place-stove-to-counter_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/PickPlaceStoveToCounter/20260324_205332_pick-place-stove-to-counter_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/PickPlaceStoveToCounter/20260324_205332_pick-place-stove-to-counter_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 60,
    'stable_release_contact_loss_t': 156,
    'uses_moveC': False,
    'controller_mode': 'whole_body_ik',
}

OBJ_POSE_T0 = pose(x=5.541262, y=-3.689008, z=0.958358, qw=0.971169, qx=0.017796, qy=-0.048129, qz=-0.232802)
GOAL_RECEPTACLE_POSE = pose(x=5.547819, y=-3.691117, z=0.957187, qw=0.951841, qx=0.000017, qy=-0.000004, qz=-0.306593)

APPROACH_003_JOINTS = [-0.039325, -0.996488, -0.055615, -2.293746, 0.020077, 1.541686, 0.701309]  # t=3
APPROACH_005_JOINTS = [-0.036609, -0.968710, -0.054480, -2.314876, 0.019509, 1.596368, 0.702115]  # t=5
APPROACH_006_JOINTS = [-0.034946, -0.946717, -0.054181, -2.330940, 0.019899, 1.635472, 0.702392]  # t=6
APPROACH_009_JOINTS = [-0.028934, -0.866214, -0.051391, -2.381392, 0.024320, 1.764752, 0.700726]  # t=9
APPROACH_012_JOINTS = [-0.020155, -0.772203, -0.053081, -2.422884, 0.036730, 1.905601, 0.654519]  # t=12
APPROACH_015_JOINTS = [-0.008496, -0.664351, -0.064649, -2.441746, 0.063933, 2.039661, 0.551445]  # t=15
APPROACH_018_JOINTS = [0.005012, -0.545987, -0.078912, -2.419991, 0.105366, 2.141395, 0.422422]  # t=18
APPROACH_020_JOINTS = [0.013525, -0.459025, -0.087861, -2.391854, 0.133961, 2.197857, 0.335130]  # t=20
APPROACH_021_JOINTS = [0.017225, -0.412763, -0.091119, -2.375518, 0.145097, 2.222068, 0.293949]  # t=21
APPROACH_024_JOINTS = [0.023173, -0.271061, -0.100185, -2.301736, 0.160205, 2.251859, 0.199348]  # t=24
APPROACH_026_JOINTS = [0.021658, -0.181988, -0.102717, -2.234436, 0.140250, 2.235725, 0.193152]  # t=26
APPROACH_027_JOINTS = [0.020331, -0.139837, -0.100412, -2.197584, 0.121472, 2.223216, 0.207523]  # t=27
APPROACH_030_JOINTS = [0.015626, -0.016647, -0.084141, -2.076711, 0.047767, 2.178673, 0.321991]  # t=30
APPROACH_033_JOINTS = [0.012712, 0.077271, -0.058550, -1.957517, 0.000487, 2.100038, 0.438521]  # t=33
APPROACH_034_JOINTS = [0.011181, 0.098313, -0.051997, -1.923422, -0.005427, 2.063652, 0.452090]  # t=34
APPROACH_036_JOINTS = [0.007060, 0.147772, -0.043224, -1.867417, -0.009090, 2.017451, 0.461712]  # t=36
APPROACH_039_JOINTS = [0.000500, 0.231854, -0.035438, -1.808618, -0.010145, 1.998128, 0.464048]  # t=39
APPROACH_042_JOINTS = [-0.004216, 0.300338, -0.029287, -1.751358, -0.018925, 1.979617, 0.468726]  # t=42
DESCEND_043_JOINTS = [-0.005280, 0.320284, -0.027277, -1.733285, -0.023183, 1.976338, 0.471373]  # t=43
DESCEND_044_JOINTS = [-0.006283, 0.338325, -0.025174, -1.715343, -0.025327, 1.974001, 0.473396]  # t=44
DESCEND_045_JOINTS = [-0.007334, 0.354710, -0.023386, -1.697212, -0.026017, 1.971254, 0.474504]  # t=45
DESCEND_046_JOINTS = [-0.008365, 0.370341, -0.021929, -1.678284, -0.026296, 1.968598, 0.475034]  # t=46
DESCEND_047_JOINTS = [-0.009332, 0.385762, -0.020705, -1.658338, -0.026380, 1.965923, 0.475212]  # t=47
DESCEND_048_JOINTS = [-0.010214, 0.400669, -0.019654, -1.637863, -0.026384, 1.961869, 0.475224]  # t=48
DESCEND_049_JOINTS = [-0.011012, 0.416157, -0.018714, -1.617183, -0.026385, 1.958137, 0.475226]  # t=49
DESCEND_050_JOINTS = [-0.011733, 0.432585, -0.017865, -1.596609, -0.026384, 1.955089, 0.475228]  # t=50
DESCEND_051_JOINTS = [-0.012379, 0.449583, -0.017096, -1.576048, -0.026383, 1.952561, 0.475230]  # t=51
DESCEND_052_JOINTS = [-0.013008, 0.467172, -0.016549, -1.556111, -0.026385, 1.950350, 0.475229]  # t=52
DESCEND_053_JOINTS = [-0.013706, 0.484728, -0.016403, -1.537104, -0.026413, 1.948171, 0.475099]  # t=53
DESCEND_054_JOINTS = [-0.014532, 0.501461, -0.016585, -1.520016, -0.026418, 1.944814, 0.474618]  # t=54
DESCEND_055_JOINTS = [-0.015390, 0.517550, -0.016704, -1.505026, -0.026361, 1.941192, 0.473932]  # t=55
DESCEND_056_JOINTS = [-0.016198, 0.532966, -0.016705, -1.491373, -0.026307, 1.938310, 0.473329]  # t=56
DESCEND_057_JOINTS = [-0.016903, 0.547653, -0.016636, -1.478289, -0.026232, 1.937144, 0.472888]  # t=57
DESCEND_058_JOINTS = [-0.017516, 0.561659, -0.016537, -1.465627, -0.026195, 1.936960, 0.472614]  # t=58
DESCEND_059_JOINTS = [-0.018119, 0.574764, -0.016527, -1.452687, -0.026193, 1.936950, 0.472360]  # t=59
GRASP_HOLD_060_JOINTS = [-0.018807, 0.585331, -0.016543, -1.438804, -0.025920, 1.934020, 0.471141]  # t=60
LIFT_062_JOINTS = [-0.019989, 0.603658, -0.015987, -1.408166, -0.023976, 1.924503, 0.467663]  # t=62
LIFT_064_JOINTS = [-0.020776, 0.624943, -0.015067, -1.373354, -0.022062, 1.916269, 0.464980]  # t=64
LIFT_066_JOINTS = [-0.020776, 0.645929, -0.013198, -1.337667, -0.020811, 1.902300, 0.464502]  # t=66
LIFT_067_JOINTS = [-0.020690, 0.654019, -0.012560, -1.321977, -0.020752, 1.891361, 0.464796]  # t=67
LIFT_068_JOINTS = [-0.020643, 0.660607, -0.012205, -1.308088, -0.020866, 1.880261, 0.464802]  # t=68
LIFT_069_JOINTS = [-0.020696, 0.666499, -0.012178, -1.295779, -0.020922, 1.870361, 0.464747]  # t=69
LIFT_070_JOINTS = [-0.021382, 0.671971, -0.013558, -1.284812, -0.021324, 1.861803, 0.463955]  # t=70
LIFT_072_JOINTS = [-0.024715, 0.680279, -0.019165, -1.267889, -0.020762, 1.845534, 0.457597]  # t=72
LIFT_073_JOINTS = [-0.026866, 0.681923, -0.022234, -1.262527, -0.019791, 1.836650, 0.453085]  # t=73
LIFT_074_JOINTS = [-0.029438, 0.680785, -0.025522, -1.259993, -0.017881, 1.827647, 0.447810]  # t=74
LIFT_075_JOINTS = [-0.032792, 0.676460, -0.028644, -1.261067, -0.012115, 1.820427, 0.440784]  # t=75
LIFT_076_JOINTS = [-0.037436, 0.668193, -0.031522, -1.266261, 0.000496, 1.817536, 0.430703]  # t=76
LIFT_077_JOINTS = [-0.043387, 0.654962, -0.034628, -1.276425, 0.018924, 1.819474, 0.417119]  # t=77
LIFT_078_JOINTS = [-0.050514, 0.635971, -0.037960, -1.292175, 0.042870, 1.826349, 0.399837]  # t=78
LIFT_080_JOINTS = [-0.067383, 0.583515, -0.046416, -1.342276, 0.101023, 1.855179, 0.354526]  # t=80
LIFT_081_JOINTS = [-0.076375, 0.550503, -0.051246, -1.376041, 0.133222, 1.876779, 0.327197]  # t=81
PLACE_083_JOINTS = [-0.093051, 0.473402, -0.061230, -1.458074, 0.195609, 1.930814, 0.267598]  # t=83
PLACE_085_JOINTS = [-0.106701, 0.373977, -0.069872, -1.558124, 0.259715, 1.997973, 0.201175]  # t=85
PLACE_087_JOINTS = [-0.117247, 0.257712, -0.079431, -1.678251, 0.327693, 2.079770, 0.126040]  # t=87
PLACE_089_JOINTS = [-0.125603, 0.131800, -0.093500, -1.816952, 0.408061, 2.178630, 0.030072]  # t=89
PLACE_091_JOINTS = [-0.129965, 0.006330, -0.109707, -1.964489, 0.510902, 2.294933, -0.095249]  # t=91
PLACE_093_JOINTS = [-0.127630, -0.111970, -0.124949, -2.112060, 0.651574, 2.421219, -0.257656]  # t=93
PLACE_095_JOINTS = [-0.115629, -0.213847, -0.138937, -2.254588, 0.841463, 2.548139, -0.466563]  # t=95
PLACE_097_JOINTS = [-0.094293, -0.314385, -0.160040, -2.365590, 1.082954, 2.624714, -0.692067]  # t=97
PLACE_099_JOINTS = [-0.071453, -0.411482, -0.190000, -2.442866, 1.312787, 2.662243, -0.887495]  # t=99
PLACE_101_JOINTS = [-0.054139, -0.495900, -0.221896, -2.501980, 1.499262, 2.699343, -1.048715]  # t=101
PLACE_103_JOINTS = [-0.045449, -0.548027, -0.246269, -2.533663, 1.632591, 2.758148, -1.163418]  # t=103
PLACE_105_JOINTS = [-0.045527, -0.575095, -0.258709, -2.537715, 1.717478, 2.829685, -1.229057]  # t=105
PLACE_107_JOINTS = [-0.051398, -0.564805, -0.255243, -2.525548, 1.746642, 2.920998, -1.241093]  # t=107
PLACE_109_JOINTS = [-0.060259, -0.531672, -0.234974, -2.508253, 1.721819, 3.032381, -1.195584]  # t=109
PLACE_111_JOINTS = [-0.070218, -0.486230, -0.205954, -2.496903, 1.653927, 3.154082, -1.104164]  # t=111
PLACE_113_JOINTS = [-0.079663, -0.429460, -0.177935, -2.503282, 1.553428, 3.279179, -0.991764]  # t=113
PLACE_115_JOINTS = [-0.087678, -0.363168, -0.162855, -2.531534, 1.430375, 3.402400, -0.871346]  # t=115
PLACE_117_JOINTS = [-0.104874, -0.287450, -0.159356, -2.573776, 1.309772, 3.517896, -0.770002]  # t=117
PLACE_119_JOINTS = [-0.126200, -0.205639, -0.170193, -2.609808, 1.223193, 3.626914, -0.719587]  # t=119
PLACE_121_JOINTS = [-0.142103, -0.141730, -0.176793, -2.629730, 1.191880, 3.726981, -0.715978]  # t=121
PLACE_123_JOINTS = [-0.148162, -0.106737, -0.171076, -2.629023, 1.204957, 3.754084, -0.725465]  # t=123
PLACE_125_JOINTS = [-0.148978, -0.098573, -0.168258, -2.619396, 1.217578, 3.752669, -0.735343]  # t=125
PLACE_127_JOINTS = [-0.146514, -0.122801, -0.164864, -2.615178, 1.245098, 3.752485, -0.761110]  # t=127
PLACE_129_JOINTS = [-0.143596, -0.163869, -0.163947, -2.612516, 1.296101, 3.746448, -0.807377]  # t=129
PLACE_131_JOINTS = [-0.141935, -0.206157, -0.165097, -2.604331, 1.367000, 3.738146, -0.881635]  # t=131
PLACE_133_JOINTS = [-0.145570, -0.219865, -0.182418, -2.579367, 1.446613, 3.734870, -1.018127]  # t=133
PLACE_135_JOINTS = [-0.154837, -0.176587, -0.229913, -2.511524, 1.529121, 3.712341, -1.211928]  # t=135
PLACE_137_JOINTS = [-0.160036, -0.103182, -0.279446, -2.414976, 1.641198, 3.697411, -1.440371]  # t=137
PLACE_139_JOINTS = [-0.159239, -0.025206, -0.322287, -2.296939, 1.798901, 3.697796, -1.692591]  # t=139
PLACE_141_JOINTS = [-0.155590, 0.030485, -0.351850, -2.176989, 1.997558, 3.708012, -1.920577]  # t=141
PLACE_143_JOINTS = [-0.158423, 0.068783, -0.377079, -2.071820, 2.197776, 3.729735, -2.134101]  # t=143
PLACE_145_JOINTS = [-0.178225, 0.120991, -0.409347, -1.983268, 2.393776, 3.737822, -2.356705]  # t=145
PLACE_147_JOINTS = [-0.220968, 0.191552, -0.434624, -1.901628, 2.590365, 3.736062, -2.576412]  # t=147
PLACE_149_JOINTS = [-0.290640, 0.269360, -0.430735, -1.821185, 2.784957, 3.739489, -2.778658]  # t=149
PLACE_151_JOINTS = [-0.383316, 0.342687, -0.380509, -1.735785, 2.905423, 3.754468, -2.906722]  # t=151
PLACE_153_JOINTS = [-0.472023, 0.386261, -0.262691, -1.681580, 2.897217, 3.752856, -2.884802]  # t=153
PLACE_155_JOINTS = [-0.554267, 0.418485, -0.160037, -1.632064, 2.878801, 3.752857, -2.867395]  # t=155
PLACE_156_JOINTS = [-0.590889, 0.429461, -0.116841, -1.616217, 2.858747, 3.752855, -2.859501]  # t=156
RELEASE_POSE_156_JOINTS = [-0.590889, 0.429461, -0.116841, -1.616217, 2.858747, 3.752855, -2.859501]  # t=156
RETRACT_158_JOINTS = [-0.652659, 0.444012, -0.039554, -1.597369, 2.808693, 3.752857, -2.839735]  # t=158
RETRACT_159_JOINTS = [-0.679274, 0.442779, -0.006216, -1.595794, 2.785206, 3.752855, -2.827864]  # t=159
RETRACT_160_JOINTS = [-0.703346, 0.434850, 0.024072, -1.598473, 2.765154, 3.752831, -2.816976]  # t=160
RETRACT_161_JOINTS = [-0.725334, 0.421037, 0.050866, -1.605991, 2.750240, 3.752822, -2.808613]  # t=161
RETRACT_162_JOINTS = [-0.745614, 0.400104, 0.074217, -1.619050, 2.743381, 3.752847, -2.804426]  # t=162
RETRACT_164_JOINTS = [-0.782921, 0.341281, 0.109583, -1.659236, 2.763965, 3.752716, -2.813153]  # t=164
RETRACT_166_JOINTS = [-0.814082, 0.264057, 0.124459, -1.714883, 2.825219, 3.752755, -2.851924]  # t=166
RETRACT_168_JOINTS = [-0.831036, 0.159955, 0.117379, -1.795202, 2.903355, 3.752745, -2.901830]  # t=168
RETRACT_169_JOINTS = [-0.826731, 0.101983, 0.118538, -1.847946, 2.899262, 3.752622, -2.896411]  # t=169
RETRACT_170_JOINTS = [-0.813003, 0.041493, 0.115748, -1.904793, 2.897787, 3.752315, -2.888035]  # t=170
RETRACT_172_JOINTS = [-0.759101, -0.085144, 0.082901, -2.018928, 2.897474, 3.752630, -2.867254]  # t=172
RETRACT_173_JOINTS = [-0.719402, -0.152345, 0.052750, -2.074661, 2.897293, 3.752628, -2.855485]  # t=173
RETRACT_174_JOINTS = [-0.671608, -0.223867, 0.014628, -2.127035, 2.897257, 3.752603, -2.842655]  # t=174
RETRACT_176_JOINTS = [-0.555360, -0.379318, -0.082161, -2.227224, 2.885674, 3.752779, -2.810161]  # t=176
RETRACT_177_JOINTS = [-0.489263, -0.463071, -0.137020, -2.276038, 2.867305, 3.752848, -2.786468]  # t=177
RETRACT_178_JOINTS = [-0.420250, -0.551056, -0.193021, -2.322991, 2.836476, 3.752931, -2.754761]  # t=178
RETRACT_180_JOINTS = [-0.282874, -0.741572, -0.292791, -2.413299, 2.735082, 3.753045, -2.661379]  # t=180
RETRACT_182_JOINTS = [-0.164754, -0.953502, -0.348481, -2.509375, 2.596713, 3.753097, -2.528056]  # t=182
RETRACT_184_JOINTS = [-0.082224, -1.181035, -0.343077, -2.618003, 2.457960, 3.753141, -2.368257]  # t=184
RETRACT_185_JOINTS = [-0.054314, -1.294995, -0.319066, -2.676509, 2.397379, 3.753135, -2.287079]  # t=185
RETRACT_186_JOINTS = [-0.028859, -1.402016, -0.301695, -2.745636, 2.342110, 3.752947, -2.218915]  # t=186
RETRACT_187_JOINTS = [-0.004118, -1.492487, -0.302820, -2.814279, 2.276783, 3.752655, -2.160734]  # t=187
RETRACT_188_JOINTS = [0.019178, -1.565019, -0.310346, -2.874449, 2.207197, 3.752656, -2.106092]  # t=188
RETRACT_190_JOINTS = [0.055674, -1.677054, -0.323877, -2.972094, 2.088100, 3.752770, -2.013227]  # t=190
RETRACT_191_JOINTS = [0.067458, -1.720419, -0.329187, -3.011691, 2.041010, 3.752746, -1.975961]  # t=191
APPROACH_000_JOINTS = [-0.040794, -1.004375, -0.055530, -2.287120, 0.022329, 1.525143, 0.699618]  # 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_pregrasp():
    """Coarse approach into the pregrasp corridor."""
    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_009_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_012_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_015_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_018_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_020_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_021_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_024_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_026_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_027_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_030_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_033_JOINTS, input_type='joint', steps=3, 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_039_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_042_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)

def execute_grasp_approach():
    """Final Cartesian descent into grasp alignment."""
    moveJoint(DESCEND_043_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_044_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_045_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_046_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_047_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_048_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_049_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_050_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_051_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_052_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_053_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_054_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_055_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_056_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_057_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_058_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_059_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)

def close_gripper_on_object():
    """Close the gripper and let the grasp settle briefly."""
    grasp(hold_target=GRASP_HOLD_060_JOINTS, input_type='joint', close_steps=1, settle_steps=0, gripper=1.0, require_contact_count=4)
    wait(duration=0.05, hold_target=GRASP_HOLD_060_JOINTS, input_type='joint', gripper=1.0)

def lift_object():
    """Lift the grasped object clear of the counter."""
    moveJoint(LIFT_062_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_064_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_066_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_067_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_068_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_069_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_070_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_072_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_073_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_074_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_075_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_076_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_077_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_078_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_080_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_081_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)

def prepare_release():
    """Set the object into the receptacle and stabilize before release."""
    moveJoint(PLACE_083_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_085_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_087_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_089_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_091_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_093_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_095_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_097_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_099_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_101_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_103_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_105_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_107_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_109_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_111_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_113_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_115_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_117_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_119_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_121_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_123_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_125_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_127_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_129_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_131_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_133_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_135_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_137_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_139_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_141_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_143_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_145_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_147_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_149_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PLACE_151_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_153_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_155_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_156_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    wait(duration=0.05, hold_target=RELEASE_POSE_156_JOINTS, input_type='joint', gripper=-1.0)

def release_object():
    """Open the gripper and hold briefly to avoid disturbing the placement."""
    release(hold_target=RELEASE_POSE_156_JOINTS, input_type='joint', open_steps=1, settle_steps=0, gripper=-1.0)
    wait(duration=0.05, hold_target=RELEASE_POSE_156_JOINTS, input_type='joint', gripper=-1.0)

def retreat_after_release():
    """Retreat away from the placed object without clipping it."""
    moveJoint(RETRACT_158_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_159_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_160_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_161_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_162_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_164_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_166_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_168_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_169_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_170_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_172_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_173_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_174_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_176_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_177_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_178_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_180_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_182_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_184_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_185_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_186_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_187_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_188_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_190_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_191_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

move_to_pregrasp()
execute_grasp_approach()
close_gripper_on_object()
lift_object()
prepare_release()
release_object()
retreat_after_release()

# 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

Pick the mushroom from the pan and place it in the bowl.

all pan receptacle cookware pots_and_pans

obj

all mushroom vegetable food in_container

container

all bowl receptacle stackable group1 container_set2


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

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

SCENE_ARTIFACT = '../../../artifacts/20260324/PickPlaceToasterOvenToCounter/20260324_205333_pick-place-toaster-oven-to-counter_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'PickPlaceToasterOvenToCounter',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/PickPlaceToasterOvenToCounter/20260324_205333_pick-place-toaster-oven-to-counter_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/PickPlaceToasterOvenToCounter/20260324_205333_pick-place-toaster-oven-to-counter_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/PickPlaceToasterOvenToCounter/20260324_205333_pick-place-toaster-oven-to-counter_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 85,
    'stable_release_contact_loss_t': 145,
    'uses_moveC': False,
    'controller_mode': 'whole_body_ik',
}

OBJ_POSE_T0 = pose(x=0.773928, y=-0.457796, z=1.088841, qw=0.948372, qx=0.014379, qy=-0.010157, qz=-0.316671)
GOAL_RECEPTACLE_POSE = pose(x=0.475819, y=-0.501009, z=0.929317, qw=0.994362, qx=0.010217, qy=-0.001789, qz=-0.105533)

APPROACH_003_JOINTS = [-0.010503, -1.041093, -0.020181, -2.273883, 0.021904, 1.513505, 0.710962]  # t=3
APPROACH_004_JOINTS = [-0.010137, -1.043447, -0.013860, -2.276910, 0.028860, 1.510204, 0.715379]  # t=4
APPROACH_006_JOINTS = [-0.008626, -1.056585, 0.008929, -2.290603, 0.049938, 1.498748, 0.733705]  # t=6
APPROACH_009_JOINTS = [-0.007010, -1.103526, 0.067435, -2.330307, 0.086516, 1.495349, 0.812385]  # t=9
APPROACH_012_JOINTS = [-0.004270, -1.175918, 0.135936, -2.392853, 0.134265, 1.520511, 0.924553]  # t=12
APPROACH_015_JOINTS = [0.000729, -1.254029, 0.199199, -2.464426, 0.190124, 1.568390, 1.042564]  # t=15
APPROACH_018_JOINTS = [0.007077, -1.326421, 0.251572, -2.537104, 0.240204, 1.632478, 1.155351]  # t=18
APPROACH_019_JOINTS = [0.009463, -1.349120, 0.265050, -2.562150, 0.254640, 1.655004, 1.189902]  # t=19
APPROACH_021_JOINTS = [0.015241, -1.392833, 0.282991, -2.613277, 0.283318, 1.697186, 1.248726]  # t=21
APPROACH_024_JOINTS = [0.027177, -1.453747, 0.285487, -2.686498, 0.327991, 1.747401, 1.295759]  # t=24
APPROACH_027_JOINTS = [0.039937, -1.501514, 0.275676, -2.747934, 0.367558, 1.779059, 1.304037]  # t=27
APPROACH_030_JOINTS = [0.049395, -1.534385, 0.275744, -2.795714, 0.387413, 1.806025, 1.303840]  # t=30
APPROACH_033_JOINTS = [0.056620, -1.553464, 0.283689, -2.834073, 0.399113, 1.833300, 1.301471]  # t=33
APPROACH_036_JOINTS = [0.062733, -1.562201, 0.294368, -2.867793, 0.409967, 1.862620, 1.298434]  # t=36
APPROACH_039_JOINTS = [0.068084, -1.561125, 0.306697, -2.900725, 0.422395, 1.901334, 1.293679]  # t=39
APPROACH_042_JOINTS = [0.072611, -1.550779, 0.318334, -2.929637, 0.434721, 1.946931, 1.287417]  # t=42
APPROACH_045_JOINTS = [0.075827, -1.531418, 0.326572, -2.950106, 0.444151, 1.994470, 1.280552]  # t=45
APPROACH_046_JOINTS = [0.076522, -1.523396, 0.328170, -2.954443, 0.446159, 2.009571, 1.278500]  # t=46
APPROACH_048_JOINTS = [0.077126, -1.503758, 0.330259, -2.960408, 0.449239, 2.041194, 1.274182]  # t=48
APPROACH_051_JOINTS = [0.077049, -1.470179, 0.328828, -2.962239, 0.452623, 2.082123, 1.268654]  # t=51
DESCEND_053_JOINTS = [0.076741, -1.445264, 0.326070, -2.961863, 0.457565, 2.109740, 1.264967]  # t=53
DESCEND_055_JOINTS = [0.076961, -1.416746, 0.329259, -2.959234, 0.463644, 2.138379, 1.261730]  # t=55
DESCEND_057_JOINTS = [0.077616, -1.385904, 0.337208, -2.953564, 0.470953, 2.166142, 1.261047]  # t=57
DESCEND_059_JOINTS = [0.077969, -1.351034, 0.348388, -2.947139, 0.480072, 2.198353, 1.261070]  # t=59
DESCEND_060_JOINTS = [0.077927, -1.332191, 0.354262, -2.943992, 0.484769, 2.215507, 1.261065]  # t=60
DESCEND_061_JOINTS = [0.077887, -1.311764, 0.360707, -2.940729, 0.490197, 2.233046, 1.261065]  # t=61
DESCEND_063_JOINTS = [0.077474, -1.267552, 0.374294, -2.932998, 0.501574, 2.267630, 1.261087]  # t=63
DESCEND_065_JOINTS = [0.076875, -1.225555, 0.386284, -2.924177, 0.510479, 2.294998, 1.261772]  # t=65
DESCEND_067_JOINTS = [0.076132, -1.190305, 0.394615, -2.916718, 0.515552, 2.314853, 1.262682]  # t=67
DESCEND_069_JOINTS = [0.075446, -1.160421, 0.400279, -2.912855, 0.518784, 2.332071, 1.262648]  # t=69
DESCEND_070_JOINTS = [0.075241, -1.146459, 0.402765, -2.912138, 0.520548, 2.341072, 1.262235]  # t=70
DESCEND_071_JOINTS = [0.075125, -1.133724, 0.404695, -2.912358, 0.522067, 2.349601, 1.261432]  # t=71
DESCEND_073_JOINTS = [0.074976, -1.108503, 0.408424, -2.914968, 0.526073, 2.369905, 1.258364]  # t=73
DESCEND_075_JOINTS = [0.072294, -1.081809, 0.407923, -2.908597, 0.524655, 2.393411, 1.251956]  # t=75
DESCEND_077_JOINTS = [0.067264, -1.050840, 0.405371, -2.896315, 0.519074, 2.411132, 1.245594]  # t=77
DESCEND_079_JOINTS = [0.061363, -1.017226, 0.402925, -2.882269, 0.512700, 2.428760, 1.239298]  # t=79
DESCEND_080_JOINTS = [0.058439, -1.000291, 0.402106, -2.874999, 0.509338, 2.437537, 1.236088]  # t=80
DESCEND_081_JOINTS = [0.055560, -0.983170, 0.401689, -2.867482, 0.505707, 2.446048, 1.232793]  # t=81
DESCEND_083_JOINTS = [0.049713, -0.946641, 0.401647, -2.847822, 0.496759, 2.456070, 1.227100]  # t=83
DESCEND_085_JOINTS = [0.046237, -0.913556, 0.405477, -2.820856, 0.488041, 2.440365, 1.231548]  # t=85
GRASP_HOLD_085_JOINTS = [0.046237, -0.913556, 0.405477, -2.820856, 0.488041, 2.440365, 1.231548]  # t=85
LIFT_086_JOINTS = [0.046550, -0.903129, 0.410967, -2.809069, 0.485625, 2.426506, 1.240088]  # t=86
LIFT_087_JOINTS = [0.047779, -0.904303, 0.412782, -2.802092, 0.482003, 2.406456, 1.249517]  # t=87
LIFT_088_JOINTS = [0.050620, -0.915178, 0.411917, -2.799897, 0.479925, 2.381767, 1.256803]  # t=88
LIFT_089_JOINTS = [0.055673, -0.934044, 0.412679, -2.799466, 0.478912, 2.353494, 1.263396]  # t=89
LIFT_090_JOINTS = [0.061605, -0.960262, 0.412472, -2.802234, 0.477421, 2.322172, 1.270732]  # t=90
LIFT_091_JOINTS = [0.068306, -0.990859, 0.411836, -2.807580, 0.476850, 2.290228, 1.277189]  # t=91
LIFT_092_JOINTS = [0.075913, -1.023919, 0.411396, -2.814662, 0.478006, 2.258446, 1.281429]  # t=92
LIFT_093_JOINTS = [0.084405, -1.060771, 0.410216, -2.822263, 0.479868, 2.224139, 1.284133]  # t=93
LIFT_094_JOINTS = [0.093715, -1.103875, 0.406822, -2.827945, 0.480522, 2.184135, 1.286398]  # t=94
LIFT_095_JOINTS = [0.103300, -1.151688, 0.401275, -2.830710, 0.479573, 2.140951, 1.288172]  # t=95
TRANSPORT_097_JOINTS = [0.120763, -1.249363, 0.385250, -2.826757, 0.473988, 2.058864, 1.287501]  # t=97
TRANSPORT_099_JOINTS = [0.136285, -1.328958, 0.376082, -2.811304, 0.479181, 1.992092, 1.281084]  # t=99
TRANSPORT_100_JOINTS = [0.143772, -1.352149, 0.383300, -2.799464, 0.494994, 1.973814, 1.275679]  # t=100
TRANSPORT_101_JOINTS = [0.150431, -1.362633, 0.399378, -2.785588, 0.519142, 1.966847, 1.269801]  # t=101
TRANSPORT_103_JOINTS = [0.159677, -1.358078, 0.443658, -2.752698, 0.575200, 1.968598, 1.257137]  # t=103
TRANSPORT_105_JOINTS = [0.164507, -1.332872, 0.489907, -2.716878, 0.634425, 1.978672, 1.232926]  # t=105
TRANSPORT_107_JOINTS = [0.166545, -1.295809, 0.535821, -2.682751, 0.695360, 1.992481, 1.197595]  # t=107
TRANSPORT_109_JOINTS = [0.168180, -1.259353, 0.581950, -2.649600, 0.753734, 2.002712, 1.163615]  # t=109
TRANSPORT_110_JOINTS = [0.167326, -1.240380, 0.606821, -2.633874, 0.779079, 2.012182, 1.151936]  # t=110
TRANSPORT_111_JOINTS = [0.164837, -1.220639, 0.631754, -2.620374, 0.800239, 2.025006, 1.143766]  # t=111
TRANSPORT_113_JOINTS = [0.158007, -1.184516, 0.676524, -2.603028, 0.830877, 2.050505, 1.131916]  # t=113
TRANSPORT_115_JOINTS = [0.149468, -1.148785, 0.728986, -2.593563, 0.850633, 2.078829, 1.125161]  # t=115
TRANSPORT_117_JOINTS = [0.138525, -1.110075, 0.792286, -2.585110, 0.860628, 2.111360, 1.123147]  # t=117
TRANSPORT_118_JOINTS = [0.132331, -1.090420, 0.824514, -2.581049, 0.862080, 2.127398, 1.123317]  # t=118
TRANSPORT_119_JOINTS = [0.125877, -1.071444, 0.855754, -2.578058, 0.860628, 2.142175, 1.123763]  # t=119
TRANSPORT_121_JOINTS = [0.113200, -1.037669, 0.911831, -2.575242, 0.850064, 2.166550, 1.125743]  # t=121
TRANSPORT_123_JOINTS = [0.103251, -1.012826, 0.953454, -2.576810, 0.830873, 2.179651, 1.127531]  # t=123
TRANSPORT_125_JOINTS = [0.095827, -0.993695, 0.983521, -2.578787, 0.812815, 2.188947, 1.130219]  # t=125
TRANSPORT_127_JOINTS = [0.089252, -0.974292, 1.008570, -2.581992, 0.807475, 2.206694, 1.131757]  # t=127
TRANSPORT_129_JOINTS = [0.084049, -0.954354, 1.028641, -2.587780, 0.812733, 2.231517, 1.126300]  # t=129
TRANSPORT_130_JOINTS = [0.081433, -0.944090, 1.037514, -2.591721, 0.816692, 2.246050, 1.120616]  # t=130
TRANSPORT_131_JOINTS = [0.077631, -0.932490, 1.046172, -2.596239, 0.821051, 2.263881, 1.112871]  # t=131
TRANSPORT_133_JOINTS = [0.066497, -0.905086, 1.062044, -2.605204, 0.829599, 2.304575, 1.092210]  # t=133
TRANSPORT_135_JOINTS = [0.055391, -0.876614, 1.076046, -2.612240, 0.837211, 2.340118, 1.069324]  # t=135
TRANSPORT_137_JOINTS = [0.046907, -0.851700, 1.087765, -2.617869, 0.842242, 2.370682, 1.048685]  # t=137
TRANSPORT_138_JOINTS = [0.043264, -0.841279, 1.092568, -2.620351, 0.842399, 2.387387, 1.039079]  # t=138
PLACE_139_JOINTS = [0.039438, -0.831129, 1.097356, -2.622698, 0.841757, 2.405929, 1.028882]  # t=139
PLACE_140_JOINTS = [0.036371, -0.822370, 1.101109, -2.624784, 0.839996, 2.424382, 1.017881]  # t=140
PLACE_141_JOINTS = [0.034944, -0.816248, 1.103166, -2.626824, 0.836879, 2.441325, 1.007157]  # t=141
PLACE_142_JOINTS = [0.035743, -0.813875, 1.104160, -2.629550, 0.832062, 2.456562, 0.998922]  # t=142
PLACE_143_JOINTS = [0.038352, -0.815393, 1.105324, -2.633462, 0.825045, 2.472932, 0.994729]  # t=143
PLACE_144_JOINTS = [0.043059, -0.821122, 1.105465, -2.637970, 0.816008, 2.489377, 0.994200]  # t=144
PLACE_145_JOINTS = [0.053385, -0.836254, 1.099805, -2.642763, 0.803946, 2.498179, 0.998945]  # t=145
RELEASE_POSE_145_JOINTS = [0.053385, -0.836254, 1.099805, -2.642763, 0.803946, 2.498179, 0.998945]  # t=145
RETRACT_147_JOINTS = [0.089446, -0.890130, 1.074001, -2.650580, 0.775862, 2.493761, 1.022985]  # t=147
RETRACT_149_JOINTS = [0.133419, -0.957398, 1.034089, -2.653890, 0.746685, 2.472260, 1.052741]  # t=149
RETRACT_151_JOINTS = [0.178290, -1.028908, 0.990574, -2.654162, 0.716674, 2.440157, 1.083094]  # t=151
RETRACT_153_JOINTS = [0.222404, -1.102494, 0.945728, -2.653639, 0.689993, 2.404615, 1.109787]  # t=153
RETRACT_155_JOINTS = [0.259953, -1.172058, 0.899927, -2.655685, 0.666204, 2.375870, 1.126811]  # t=155
RETRACT_157_JOINTS = [0.292486, -1.232597, 0.847776, -2.655979, 0.659966, 2.348865, 1.128765]  # t=157
RETRACT_159_JOINTS = [0.318120, -1.285909, 0.794889, -2.654293, 0.662283, 2.323664, 1.125117]  # t=159
RETRACT_160_JOINTS = [0.328323, -1.311669, 0.769359, -2.651759, 0.662878, 2.310243, 1.123327]  # t=160
RETRACT_161_JOINTS = [0.337041, -1.337611, 0.744144, -2.648007, 0.662939, 2.295749, 1.122359]  # t=161
RETRACT_163_JOINTS = [0.349557, -1.388731, 0.695511, -2.636960, 0.662652, 2.266483, 1.122400]  # t=163
RETRACT_165_JOINTS = [0.355212, -1.435479, 0.650191, -2.620664, 0.664119, 2.239310, 1.124300]  # t=165
RETRACT_167_JOINTS = [0.354047, -1.474228, 0.609757, -2.597785, 0.668342, 2.213482, 1.128140]  # t=167
RETRACT_169_JOINTS = [0.346976, -1.506049, 0.575078, -2.565761, 0.671045, 2.184632, 1.137377]  # t=169
RETRACT_171_JOINTS = [0.335379, -1.531905, 0.544657, -2.524021, 0.671659, 2.151874, 1.151765]  # t=171
RETRACT_173_JOINTS = [0.319104, -1.548508, 0.517557, -2.474736, 0.671665, 2.121035, 1.167658]  # t=173
RETRACT_174_JOINTS = [0.309275, -1.552371, 0.505210, -2.447757, 0.671497, 2.107198, 1.174783]  # t=174
APPROACH_000_JOINTS = [-0.010712, -1.040482, -0.026759, -2.272686, 0.015270, 1.514669, 0.707433]  # 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_pregrasp():
    """Coarse approach into the pregrasp corridor."""
    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_006_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_009_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_012_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_015_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_018_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_019_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_021_JOINTS, input_type='joint', steps=2, 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_033_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_036_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_039_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_042_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_045_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_046_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_048_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_051_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)

def execute_grasp_approach():
    """Final Cartesian descent into grasp alignment."""
    moveJoint(DESCEND_053_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_055_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_057_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_059_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_060_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_061_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_063_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_065_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_067_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_069_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_070_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_071_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_073_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_075_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_077_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_079_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(DESCEND_080_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(DESCEND_081_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(DESCEND_083_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(DESCEND_085_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)

def close_gripper_on_object():
    """Close the gripper and let the grasp settle briefly."""
    grasp(hold_target=GRASP_HOLD_085_JOINTS, input_type='joint', close_steps=1, settle_steps=0, gripper=1.0, require_contact_count=4)
    wait(duration=0.05, hold_target=GRASP_HOLD_085_JOINTS, input_type='joint', gripper=1.0)

def lift_object():
    """Lift the grasped object clear of the counter."""
    moveJoint(LIFT_086_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_087_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_088_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_089_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_090_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_091_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_092_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_093_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_094_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(LIFT_095_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)

def transport_to_place():
    """Carry the object through the curved transport corridor."""
    moveJoint(TRANSPORT_097_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_099_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_100_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_101_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_103_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_105_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_107_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_109_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_110_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_111_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_113_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_115_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_117_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_118_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_119_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_121_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_123_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_125_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_127_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(TRANSPORT_129_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(TRANSPORT_130_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(TRANSPORT_131_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(TRANSPORT_133_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(TRANSPORT_135_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(TRANSPORT_137_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(TRANSPORT_138_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

def prepare_release():
    """Set the object into the receptacle and stabilize before release."""
    moveJoint(PLACE_139_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_140_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_141_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_142_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_143_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_144_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PLACE_145_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    wait(duration=0.05, hold_target=RELEASE_POSE_145_JOINTS, input_type='joint', gripper=-1.0)

def release_object():
    """Open the gripper and hold briefly to avoid disturbing the placement."""
    release(hold_target=RELEASE_POSE_145_JOINTS, input_type='joint', open_steps=1, settle_steps=0, gripper=-1.0)
    wait(duration=0.05, hold_target=RELEASE_POSE_145_JOINTS, input_type='joint', gripper=-1.0)

def retreat_after_release():
    """Retreat away from the placed object without clipping it."""
    moveJoint(RETRACT_147_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_149_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_151_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_153_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_155_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_157_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_159_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_160_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_161_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_163_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_165_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_167_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_169_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_171_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_173_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(RETRACT_174_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)

move_to_pregrasp()
execute_grasp_approach()
close_gripper_on_object()
lift_object()
transport_to_place()
prepare_release()
release_object()
retreat_after_release()

# 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

Pick the hotdog bun from the rack and place it on the plate on the counter.

all plate receptacle container container_set2