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

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

SCENE_ARTIFACT = '../../../artifacts/20260324/OpenDishwasher/20260324_205307_open-dishwasher_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'OpenDishwasher',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/OpenDishwasher/20260324_205307_open-dishwasher_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/OpenDishwasher/20260324_205307_open-dishwasher_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/OpenDishwasher/20260324_205307_open-dishwasher_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 121,
    'stable_release_contact_loss_t': 121,
    '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=4.221945, y=-3.110296, z=0.931740, qw=0.517221, qx=0.038190, qy=-0.048621, qz=-0.853616)

APPROACH_003_JOINTS = [-0.027034, -1.018439, -0.030158, -2.282368, 0.025567, 1.508517, 0.684073]  # t=3
APPROACH_004_JOINTS = [-0.028102, -1.026856, -0.041813, -2.282194, 0.024886, 1.502573, 0.686155]  # t=4
APPROACH_005_JOINTS = [-0.030146, -1.039005, -0.059558, -2.282905, 0.023252, 1.494231, 0.690990]  # t=5
APPROACH_006_JOINTS = [-0.033028, -1.055650, -0.083334, -2.284681, 0.021130, 1.484457, 0.696247]  # t=6
APPROACH_009_JOINTS = [-0.046539, -1.135648, -0.178865, -2.305670, 0.008251, 1.460641, 0.708309]  # t=9
APPROACH_010_JOINTS = [-0.052639, -1.168740, -0.213754, -2.318428, 0.000042, 1.458075, 0.712092]  # t=10
APPROACH_012_JOINTS = [-0.067456, -1.238991, -0.283479, -2.348773, -0.022339, 1.461163, 0.722426]  # t=12
APPROACH_014_JOINTS = [-0.086203, -1.312185, -0.352609, -2.384914, -0.050840, 1.476028, 0.737266]  # t=14
APPROACH_015_JOINTS = [-0.097556, -1.350075, -0.387199, -2.405951, -0.068204, 1.486345, 0.746944]  # t=15
APPROACH_017_JOINTS = [-0.124709, -1.427820, -0.459006, -2.451413, -0.108067, 1.509971, 0.769402]  # t=17
APPROACH_020_JOINTS = [-0.176103, -1.541526, -0.584380, -2.520028, -0.177167, 1.553121, 0.802133]  # t=20
APPROACH_025_JOINTS = [-0.287436, -1.687196, -0.862448, -2.618124, -0.308767, 1.661909, 0.838900]  # t=25
APPROACH_030_JOINTS = [-0.410960, -1.708228, -1.185988, -2.686740, -0.423549, 1.846807, 0.863688]  # t=30
APPROACH_033_JOINTS = [-0.465751, -1.642821, -1.362317, -2.712100, -0.458399, 2.000414, 0.857593]  # t=33
APPROACH_035_JOINTS = [-0.476645, -1.572836, -1.460229, -2.728403, -0.460071, 2.117059, 0.833730]  # t=35
APPROACH_039_JOINTS = [-0.398888, -1.405714, -1.597047, -2.732960, -0.395386, 2.333899, 0.761699]  # t=39
APPROACH_040_JOINTS = [-0.364659, -1.367215, -1.621183, -2.722693, -0.364288, 2.375208, 0.742183]  # t=40
APPROACH_042_JOINTS = [-0.287125, -1.302213, -1.659826, -2.692411, -0.288038, 2.438893, 0.703883]  # t=42
APPROACH_045_JOINTS = [-0.163343, -1.239101, -1.705586, -2.626531, -0.156190, 2.487898, 0.648480]  # t=45
APPROACH_050_JOINTS = [0.015920, -1.219368, -1.788464, -2.495051, 0.038995, 2.477833, 0.543682]  # t=50
APPROACH_055_JOINTS = [0.156714, -1.260053, -1.866913, -2.386007, 0.127696, 2.460593, 0.475503]  # t=55
APPROACH_060_JOINTS = [0.245195, -1.328818, -1.921421, -2.330518, 0.137901, 2.471849, 0.429797]  # t=60
APPROACH_065_JOINTS = [0.330138, -1.403482, -1.961351, -2.303327, 0.099147, 2.542675, 0.425844]  # t=65
APPROACH_070_JOINTS = [0.426092, -1.490983, -2.003427, -2.271173, 0.049192, 2.637048, 0.425306]  # t=70
APPROACH_075_JOINTS = [0.526212, -1.589293, -2.048051, -2.215600, -0.001708, 2.722130, 0.416464]  # t=75
APPROACH_080_JOINTS = [0.623456, -1.694490, -2.083426, -2.135628, -0.050631, 2.784968, 0.403317]  # t=80
APPROACH_081_JOINTS = [0.640802, -1.714544, -2.088034, -2.118763, -0.060046, 2.793951, 0.400851]  # t=81
PRESS_082_JOINTS = [0.642176, -1.719749, -2.087917, -2.118194, -0.067512, 2.798581, 0.398734]  # t=82
PRESS_083_JOINTS = [0.638772, -1.722085, -2.088644, -2.123061, -0.074156, 2.807851, 0.397419]  # t=83
PRESS_084_JOINTS = [0.634786, -1.726006, -2.089378, -2.129027, -0.081207, 2.821166, 0.396265]  # t=84
PRESS_085_JOINTS = [0.631407, -1.731059, -2.090025, -2.134887, -0.088783, 2.836560, 0.395287]  # t=85
PRESS_086_JOINTS = [0.628517, -1.736177, -2.090721, -2.140649, -0.096366, 2.852729, 0.394344]  # t=86
PRESS_087_JOINTS = [0.625963, -1.740997, -2.091494, -2.146348, -0.103457, 2.869125, 0.393183]  # t=87
PRESS_089_JOINTS = [0.621776, -1.749657, -2.093167, -2.157414, -0.115252, 2.901926, 0.389397]  # t=89
PRESS_091_JOINTS = [0.620495, -1.753891, -2.095264, -2.168354, -0.124198, 2.935675, 0.384992]  # t=91
PRESS_093_JOINTS = [0.624676, -1.749355, -2.097750, -2.179395, -0.128516, 2.970761, 0.390728]  # t=93
PRESS_094_JOINTS = [0.628234, -1.744615, -2.098688, -2.184624, -0.126710, 2.987302, 0.399627]  # t=94
PRESS_095_JOINTS = [0.632382, -1.738919, -2.099276, -2.189468, -0.121966, 3.002519, 0.412567]  # t=95
PRESS_097_JOINTS = [0.643904, -1.721570, -2.100213, -2.198417, -0.107587, 3.030445, 0.449514]  # t=97
PRESS_098_JOINTS = [0.651462, -1.710369, -2.100610, -2.202887, -0.098370, 3.045154, 0.472755]  # t=98
PRESS_099_JOINTS = [0.659467, -1.697094, -2.101074, -2.207718, -0.087699, 3.059954, 0.498832]  # t=99
PRESS_100_JOINTS = [0.667662, -1.681666, -2.101435, -2.211946, -0.074935, 3.071335, 0.528696]  # t=100
PRESS_101_JOINTS = [0.674791, -1.664940, -2.102650, -2.213965, -0.059632, 3.076426, 0.560978]  # t=101
PRESS_103_JOINTS = [0.683902, -1.640588, -2.111393, -2.203877, -0.023436, 3.073229, 0.617250]  # t=103
PRESS_105_JOINTS = [0.682862, -1.631084, -2.118957, -2.191884, 0.015500, 3.075705, 0.657037]  # t=105
PRESS_106_JOINTS = [0.677929, -1.631455, -2.121771, -2.187824, 0.034855, 3.080056, 0.669281]  # t=106
PRESS_107_JOINTS = [0.668180, -1.634806, -2.122730, -2.188125, 0.053547, 3.081785, 0.673546]  # t=107
PRESS_109_JOINTS = [0.630874, -1.647266, -2.121167, -2.190078, 0.088037, 3.052113, 0.654629]  # t=109
PRESS_110_JOINTS = [0.603372, -1.656184, -2.122729, -2.184637, 0.105929, 3.014238, 0.633764]  # t=110
PRESS_111_JOINTS = [0.571090, -1.666409, -2.125887, -2.171609, 0.125298, 2.955784, 0.606802]  # t=111
PRESS_113_JOINTS = [0.499738, -1.699823, -2.138313, -2.107814, 0.172227, 2.774576, 0.524983]  # t=113
PRESS_114_JOINTS = [0.463927, -1.724139, -2.151717, -2.058089, 0.200744, 2.651253, 0.463409]  # t=114
PRESS_115_JOINTS = [0.431460, -1.752148, -2.171395, -1.993349, 0.231047, 2.506225, 0.388373]  # t=115
PRESS_116_JOINTS = [0.408122, -1.766097, -2.198176, -1.915644, 0.268900, 2.347079, 0.306990]  # t=116
PRESS_117_JOINTS = [0.399923, -1.763706, -2.234607, -1.828944, 0.324459, 2.196367, 0.221510]  # t=117
PRESS_118_JOINTS = [0.400495, -1.763247, -2.276786, -1.742189, 0.386732, 2.069649, 0.132478]  # t=118
PRESS_119_JOINTS = [0.403025, -1.763235, -2.319838, -1.668565, 0.454238, 1.977344, 0.043587]  # t=119
PRESS_120_JOINTS = [0.401692, -1.763196, -2.359157, -1.613899, 0.522749, 1.922131, -0.042029]  # t=120
PRESS_121_JOINTS = [0.394902, -1.763192, -2.390232, -1.579863, 0.584312, 1.901654, -0.123160]  # t=121
PRESS_122_JOINTS = [0.381103, -1.763172, -2.414407, -1.564980, 0.642576, 1.902289, -0.201753]  # t=122
PRESS_123_JOINTS = [0.359276, -1.763146, -2.432257, -1.565221, 0.699233, 1.914557, -0.280079]  # t=123
PRESS_124_JOINTS = [0.331632, -1.763154, -2.445202, -1.576532, 0.754847, 1.936978, -0.359541]  # t=124
PRESS_125_JOINTS = [0.300735, -1.763137, -2.448942, -1.606458, 0.811754, 1.965129, -0.443862]  # t=125
RETREAT_132_JOINTS = [0.080320, -1.763213, -2.400594, -1.880467, 1.431053, 2.268292, -1.175191]  # t=132
RETREAT_137_JOINTS = [0.041866, -1.763096, -2.393352, -1.961349, 2.002592, 2.211798, -1.685826]  # t=137
APPROACH_000_JOINTS = [-0.026551, -1.011721, -0.020807, -2.283420, 0.026653, 1.515840, 0.683065]  # 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_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_010_JOINTS, input_type='joint', steps=1, 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_017_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_020_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_025_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_030_JOINTS, input_type='joint', steps=5, 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_039_JOINTS, input_type='joint', steps=4, 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_050_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_055_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_060_JOINTS, input_type='joint', steps=5, 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_075_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_080_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_081_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_082_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_083_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_084_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_085_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_086_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_087_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_089_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_091_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_093_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_094_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_095_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_097_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_098_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_099_JOINTS, input_type='joint', steps=1, 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)
    moveJoint(PRESS_103_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_105_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_106_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_107_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_109_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_110_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_111_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_113_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_114_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_115_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    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_120_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_121_JOINTS, input_type='joint', steps=1, 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_124_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_125_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_132_JOINTS, input_type='joint', steps=7, settle_steps=0, gripper=1.000)
    moveJoint(RETREAT_137_JOINTS, input_type='joint', steps=5, 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: OpenDrawer
# Episode: episode_000000

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

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

OBJ_POSE_T0 = pose(x=2.684349, y=-3.743318, z=0.788661, qw=0.753573, qx=0.000013, qy=0.000013, qz=-0.657365)
GOAL_RECEPTACLE_POSE = pose(x=2.796999, y=-3.860064, z=0.965589, qw=0.588126, qx=0.000095, qy=-0.000189, qz=-0.808770)

APPROACH_003_JOINTS = [-0.020991, -1.050439, -0.028689, -2.278176, 0.036951, 1.514700, 0.702371]  # t=3
APPROACH_004_JOINTS = [-0.019260, -1.054923, -0.015751, -2.278350, 0.044666, 1.507864, 0.706313]  # t=4
APPROACH_005_JOINTS = [-0.016266, -1.062769, 0.000866, -2.279059, 0.057566, 1.495748, 0.704534]  # t=5
APPROACH_006_JOINTS = [-0.012149, -1.074542, 0.020553, -2.280868, 0.074122, 1.479179, 0.696818]  # t=6
APPROACH_008_JOINTS = [-0.001613, -1.105907, 0.062438, -2.292860, 0.118698, 1.445404, 0.669954]  # t=8
APPROACH_010_JOINTS = [0.010615, -1.145550, 0.104028, -2.315771, 0.172548, 1.417257, 0.637071]  # t=10
APPROACH_012_JOINTS = [0.023700, -1.188244, 0.146910, -2.343306, 0.230173, 1.398406, 0.605408]  # t=12
APPROACH_015_JOINTS = [0.044306, -1.245113, 0.216769, -2.389026, 0.321740, 1.392238, 0.562440]  # t=15
APPROACH_017_JOINTS = [0.058595, -1.274592, 0.266850, -2.419082, 0.385765, 1.401465, 0.532996]  # t=17
APPROACH_020_JOINTS = [0.078475, -1.301875, 0.361919, -2.463544, 0.460104, 1.466711, 0.481588]  # t=20
APPROACH_025_JOINTS = [0.111916, -1.323993, 0.561716, -2.499432, 0.504156, 1.607285, 0.404687]  # t=25
APPROACH_029_JOINTS = [0.133993, -1.319277, 0.728981, -2.493145, 0.471906, 1.704741, 0.387354]  # t=29
APPROACH_030_JOINTS = [0.138895, -1.314944, 0.767617, -2.490224, 0.460113, 1.726014, 0.386018]  # t=30
APPROACH_032_JOINTS = [0.148372, -1.304051, 0.838105, -2.482858, 0.431340, 1.761348, 0.382997]  # t=32
APPROACH_035_JOINTS = [0.159495, -1.279518, 0.929997, -2.473307, 0.385598, 1.812364, 0.376327]  # t=35
APPROACH_036_JOINTS = [0.163059, -1.270422, 0.957263, -2.471873, 0.372105, 1.830016, 0.374623]  # t=36
APPROACH_039_JOINTS = [0.173809, -1.240680, 1.032911, -2.475163, 0.340916, 1.890285, 0.366660]  # t=39
APPROACH_040_JOINTS = [0.176444, -1.228491, 1.057780, -2.478928, 0.334570, 1.913956, 0.362414]  # t=40
APPROACH_042_JOINTS = [0.179949, -1.202688, 1.106973, -2.488791, 0.322130, 1.960430, 0.357615]  # t=42
APPROACH_045_JOINTS = [0.189413, -1.169800, 1.174911, -2.502547, 0.301195, 2.010657, 0.362159]  # t=45
APPROACH_047_JOINTS = [0.197989, -1.151357, 1.218591, -2.509966, 0.285755, 2.037186, 0.371958]  # t=47
APPROACH_050_JOINTS = [0.217702, -1.130548, 1.277660, -2.516128, 0.262079, 2.062105, 0.394938]  # t=50
APPROACH_051_JOINTS = [0.224634, -1.124620, 1.295860, -2.518686, 0.252917, 2.068228, 0.402726]  # t=51
APPROACH_055_JOINTS = [0.240481, -1.098678, 1.367760, -2.536105, 0.213241, 2.083064, 0.445526]  # t=55
APPROACH_059_JOINTS = [0.232927, -1.065915, 1.441751, -2.555808, 0.182262, 2.122264, 0.506049]  # t=59
APPROACH_060_JOINTS = [0.228976, -1.057557, 1.458832, -2.560855, 0.175352, 2.136135, 0.521365]  # t=60
APPROACH_065_JOINTS = [0.202459, -1.020695, 1.547376, -2.588047, 0.142025, 2.212483, 0.607118]  # t=65
APPROACH_067_JOINTS = [0.187883, -1.010767, 1.585860, -2.597771, 0.126070, 2.241975, 0.649661]  # t=67
APPROACH_070_JOINTS = [0.166694, -1.002930, 1.635433, -2.604256, 0.095549, 2.271222, 0.712407]  # t=70
APPROACH_072_JOINTS = [0.150822, -1.001844, 1.661201, -2.607025, 0.072961, 2.287778, 0.748402]  # t=72
APPROACH_075_JOINTS = [0.126147, -1.006268, 1.686043, -2.609439, 0.034348, 2.307007, 0.791908]  # t=75
APPROACH_080_JOINTS = [0.065186, -1.019596, 1.716895, -2.625304, -0.016879, 2.372479, 0.833746]  # t=80
APPROACH_083_JOINTS = [0.012860, -1.027276, 1.744455, -2.638629, -0.031876, 2.434149, 0.846798]  # t=83
APPROACH_085_JOINTS = [-0.022221, -1.031772, 1.769891, -2.643280, -0.035476, 2.471479, 0.856951]  # t=85
APPROACH_088_JOINTS = [-0.079873, -1.042305, 1.816805, -2.645708, -0.034081, 2.530067, 0.873064]  # t=88
APPROACH_090_JOINTS = [-0.120841, -1.053669, 1.852743, -2.642964, -0.030365, 2.570627, 0.883132]  # t=90
APPROACH_093_JOINTS = [-0.172828, -1.079437, 1.903323, -2.630543, -0.027086, 2.615292, 0.902864]  # t=93
APPROACH_095_JOINTS = [-0.196369, -1.103061, 1.928286, -2.618425, -0.029844, 2.630273, 0.919839]  # t=95
APPROACH_100_JOINTS = [-0.227671, -1.179901, 1.970338, -2.585391, -0.051769, 2.638561, 0.972384]  # t=100
APPROACH_105_JOINTS = [-0.240258, -1.264048, 1.992315, -2.562971, -0.084049, 2.636346, 1.031261]  # t=105
APPROACH_110_JOINTS = [-0.306076, -1.350802, 2.018108, -2.548500, -0.088801, 2.714788, 1.054774]  # t=110
APPROACH_115_JOINTS = [-0.387597, -1.434755, 2.057393, -2.522338, -0.085577, 2.816234, 1.079610]  # t=115
APPROACH_116_JOINTS = [-0.402381, -1.452140, 2.067417, -2.513046, -0.085288, 2.833801, 1.088016]  # t=116
APPROACH_117_JOINTS = [-0.408961, -1.464847, 2.071103, -2.509466, -0.085624, 2.846732, 1.099682]  # t=117
PRESS_119_JOINTS = [-0.403183, -1.481390, 2.072728, -2.514819, -0.090359, 2.870645, 1.130041]  # t=119
PRESS_121_JOINTS = [-0.396342, -1.502009, 2.074442, -2.521091, -0.097341, 2.899420, 1.164584]  # t=121
PRESS_123_JOINTS = [-0.388380, -1.524694, 2.076003, -2.528434, -0.105943, 2.932101, 1.202628]  # t=123
PRESS_124_JOINTS = [-0.383790, -1.535693, 2.076555, -2.531728, -0.111059, 2.945781, 1.220554]  # t=124
PRESS_125_JOINTS = [-0.379374, -1.546375, 2.077174, -2.533933, -0.116494, 2.955968, 1.236990]  # t=125
PRESS_126_JOINTS = [-0.374317, -1.556709, 2.077854, -2.535333, -0.122503, 2.962372, 1.252523]  # t=126
PRESS_127_JOINTS = [-0.368108, -1.566136, 2.078590, -2.536312, -0.128758, 2.964951, 1.267852]  # t=127
PRESS_129_JOINTS = [-0.356006, -1.579565, 2.079953, -2.537289, -0.140188, 2.963181, 1.292436]  # t=129
PRESS_130_JOINTS = [-0.352338, -1.582856, 2.080249, -2.537863, -0.144132, 2.962834, 1.300290]  # t=130
PRESS_131_JOINTS = [-0.348806, -1.582551, 2.080467, -2.539053, -0.146981, 2.962045, 1.305300]  # t=131
PRESS_133_JOINTS = [-0.337171, -1.576041, 2.080559, -2.542813, -0.152792, 2.953549, 1.312804]  # t=133
PRESS_135_JOINTS = [-0.318614, -1.571636, 2.076956, -2.547298, -0.163181, 2.934764, 1.321781]  # t=135
PRESS_137_JOINTS = [-0.293978, -1.568304, 2.076154, -2.550515, -0.177100, 2.908051, 1.336635]  # t=137
PRESS_139_JOINTS = [-0.258908, -1.557767, 2.078764, -2.554289, -0.193626, 2.869962, 1.356505]  # t=139
PRESS_141_JOINTS = [-0.214478, -1.529700, 2.084346, -2.559525, -0.207305, 2.821850, 1.374318]  # t=141
PRESS_143_JOINTS = [-0.162774, -1.485458, 2.089437, -2.564388, -0.217632, 2.763156, 1.387630]  # t=143
PRESS_145_JOINTS = [-0.115892, -1.436499, 2.091911, -2.566224, -0.217553, 2.708678, 1.405310]  # t=145
PRESS_146_JOINTS = [-0.096322, -1.411533, 2.091589, -2.567110, -0.213525, 2.687826, 1.413057]  # t=146
PRESS_147_JOINTS = [-0.078523, -1.389182, 2.091085, -2.567223, -0.210283, 2.668986, 1.420944]  # t=147
PRESS_149_JOINTS = [-0.044265, -1.351862, 2.090886, -2.564247, -0.207772, 2.630735, 1.440988]  # t=149
PRESS_151_JOINTS = [-0.011556, -1.320995, 2.091855, -2.557111, -0.207835, 2.589922, 1.460564]  # t=151
PRESS_153_JOINTS = [0.020456, -1.293255, 2.093515, -2.546286, -0.207456, 2.546476, 1.479819]  # t=153
PRESS_155_JOINTS = [0.051478, -1.269970, 2.096334, -2.531509, -0.206408, 2.501437, 1.502544]  # t=155
PRESS_157_JOINTS = [0.078689, -1.252090, 2.100288, -2.513137, -0.204009, 2.458867, 1.523168]  # t=157
PRESS_159_JOINTS = [0.101364, -1.239149, 2.104369, -2.491595, -0.199380, 2.419406, 1.538641]  # t=159
PRESS_160_JOINTS = [0.111695, -1.233902, 2.106571, -2.479626, -0.196109, 2.399910, 1.544880]  # t=160
PRESS_161_JOINTS = [0.121182, -1.229677, 2.108765, -2.466730, -0.192297, 2.381025, 1.549957]  # t=161
PRESS_162_JOINTS = [0.129944, -1.226429, 2.110910, -2.452947, -0.187941, 2.362342, 1.554120]  # t=162
PRESS_163_JOINTS = [0.137858, -1.224168, 2.113105, -2.438137, -0.183003, 2.344143, 1.556833]  # t=163
PRESS_165_JOINTS = [0.151347, -1.222750, 2.116861, -2.405130, -0.171594, 2.308354, 1.558974]  # t=165
PRESS_166_JOINTS = [0.157335, -1.223454, 2.118416, -2.386929, -0.165215, 2.290161, 1.559818]  # t=166
PRESS_167_JOINTS = [0.162733, -1.225172, 2.119707, -2.367450, -0.158499, 2.272035, 1.560234]  # t=167
PRESS_169_JOINTS = [0.171496, -1.231687, 2.121527, -2.325064, -0.143942, 2.235805, 1.559283]  # t=169
PRESS_171_JOINTS = [0.177841, -1.241902, 2.122243, -2.278410, -0.127880, 2.198925, 1.555099]  # t=171
PRESS_173_JOINTS = [0.183426, -1.255070, 2.120690, -2.227363, -0.111221, 2.159002, 1.550947]  # t=173
PRESS_174_JOINTS = [0.186197, -1.262686, 2.119338, -2.200561, -0.102647, 2.137839, 1.549743]  # t=174
PRESS_175_JOINTS = [0.189008, -1.270967, 2.118073, -2.173225, -0.093765, 2.116204, 1.549211]  # t=175
PRESS_177_JOINTS = [0.194559, -1.289568, 2.115227, -2.117094, -0.075414, 2.072302, 1.549202]  # t=177
PRESS_178_JOINTS = [0.197323, -1.299770, 2.113654, -2.088470, -0.065759, 2.049737, 1.549482]  # t=178
PRESS_179_JOINTS = [0.201053, -1.309779, 2.112558, -2.060841, -0.055360, 2.024677, 1.551610]  # t=179
PRESS_181_JOINTS = [0.209041, -1.331016, 2.108850, -2.004676, -0.034722, 1.975828, 1.558486]  # t=181
PRESS_183_JOINTS = [0.216336, -1.353594, 2.102711, -1.945709, -0.013724, 1.927468, 1.562865]  # t=183
PRESS_184_JOINTS = [0.219235, -1.365488, 2.098892, -1.914675, -0.002778, 1.903042, 1.562776]  # t=184
APPROACH_000_JOINTS = [-0.022245, -1.048325, -0.037527, -2.278245, 0.031587, 1.518674, 0.698715]  # 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_006_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_008_JOINTS, input_type='joint', steps=2, 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_015_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_017_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_020_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_025_JOINTS, input_type='joint', steps=5, 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_032_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_035_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_036_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_039_JOINTS, input_type='joint', steps=3, 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_050_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_051_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_055_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_059_JOINTS, input_type='joint', steps=4, 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_067_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_070_JOINTS, input_type='joint', steps=3, 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_080_JOINTS, input_type='joint', steps=5, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_083_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_085_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_088_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_090_JOINTS, input_type='joint', steps=2, 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_100_JOINTS, input_type='joint', steps=5, 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_117_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_119_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_121_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_123_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_124_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_125_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_126_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_127_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_129_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_130_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_131_JOINTS, input_type='joint', steps=1, 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_146_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_147_JOINTS, input_type='joint', steps=1, 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_155_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_157_JOINTS, input_type='joint', steps=2, 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_162_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_163_JOINTS, input_type='joint', steps=1, 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_174_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_175_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_177_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_178_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_179_JOINTS, input_type='joint', steps=1, 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_184_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)

move_to_control_panel()
press_control()

# 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 bowl stackable receptacle group1 container_set2


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

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

SCENE_ARTIFACT = '../../../artifacts/20260324/OpenElectricKettleLid/20260324_205309_open-electric-kettle-lid_episode_000000_action2code-open-loop-joint_initial-scene.json'
POLICY_METADATA = {
    'policy_kind': 'open_loop_joint',
    'policy_variant': 'open-loop-joint',
    'task_name': 'OpenElectricKettleLid',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/OpenElectricKettleLid/20260324_205309_open-electric-kettle-lid_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/OpenElectricKettleLid/20260324_205309_open-electric-kettle-lid_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/OpenElectricKettleLid/20260324_205309_open-electric-kettle-lid_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 43,
    'stable_release_contact_loss_t': 43,
    '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.009215, -1.030215, -0.043091, -2.319100, 0.043818, 1.506176, 0.716775]  # t=3
APPROACH_005_JOINTS = [-0.012989, -1.041505, -0.064312, -2.328418, 0.030849, 1.495532, 0.702325]  # t=5
APPROACH_006_JOINTS = [-0.015337, -1.047496, -0.079610, -2.336138, 0.023466, 1.494393, 0.692196]  # t=6
APPROACH_009_JOINTS = [-0.024865, -1.058378, -0.140312, -2.367910, -0.005744, 1.513274, 0.666150]  # t=9
APPROACH_012_JOINTS = [-0.036705, -1.061335, -0.197324, -2.405031, -0.047545, 1.545862, 0.665279]  # t=12
APPROACH_015_JOINTS = [-0.045698, -1.045011, -0.233612, -2.442337, -0.081699, 1.604961, 0.688535]  # t=15
APPROACH_018_JOINTS = [-0.050929, -1.007058, -0.257995, -2.462346, -0.106630, 1.666955, 0.721537]  # t=18
APPROACH_021_JOINTS = [-0.052294, -0.963784, -0.266651, -2.472448, -0.116133, 1.707531, 0.757157]  # t=21
APPROACH_024_JOINTS = [-0.053157, -0.922609, -0.272262, -2.476975, -0.118244, 1.740814, 0.794763]  # t=24
APPROACH_026_JOINTS = [-0.053662, -0.898318, -0.276042, -2.475292, -0.115397, 1.759205, 0.819470]  # t=26
APPROACH_027_JOINTS = [-0.053682, -0.886713, -0.276125, -2.473776, -0.113704, 1.768298, 0.832739]  # t=27
APPROACH_030_JOINTS = [-0.052967, -0.847995, -0.271732, -2.471969, -0.111128, 1.807682, 0.877709]  # t=30
APPROACH_033_JOINTS = [-0.051350, -0.804524, -0.268578, -2.473400, -0.103217, 1.854285, 0.921366]  # t=33
APPROACH_036_JOINTS = [-0.050113, -0.761459, -0.265382, -2.473193, -0.097625, 1.899454, 0.960388]  # t=36
APPROACH_039_JOINTS = [-0.049447, -0.721939, -0.262924, -2.473482, -0.090020, 1.939440, 0.996373]  # t=39
APPROACH_042_JOINTS = [-0.048088, -0.685933, -0.254896, -2.454099, -0.081721, 1.963587, 1.027828]  # t=42
APPROACH_043_JOINTS = [-0.047885, -0.674509, -0.252303, -2.446905, -0.080032, 1.966799, 1.037767]  # t=43
PRESS_044_JOINTS = [-0.047796, -0.663843, -0.249852, -2.439921, -0.078553, 1.969615, 1.047350]  # t=44
PRESS_045_JOINTS = [-0.047609, -0.652879, -0.247374, -2.433021, -0.076881, 1.973555, 1.056261]  # t=45
PRESS_046_JOINTS = [-0.047590, -0.643312, -0.245289, -2.426408, -0.075211, 1.975153, 1.064198]  # t=46
PRESS_047_JOINTS = [-0.047145, -0.633910, -0.241921, -2.417430, -0.071113, 1.976918, 1.074122]  # t=47
PRESS_048_JOINTS = [-0.046674, -0.623402, -0.238591, -2.407069, -0.066644, 1.978563, 1.085814]  # t=48
PRESS_049_JOINTS = [-0.046293, -0.611858, -0.235708, -2.396125, -0.062483, 1.979641, 1.098288]  # t=49
PRESS_050_JOINTS = [-0.046557, -0.602501, -0.233981, -2.384844, -0.059786, 1.977396, 1.111237]  # t=50
PRESS_051_JOINTS = [-0.047886, -0.597397, -0.235358, -2.373561, -0.057563, 1.975750, 1.122681]  # t=51
PRESS_052_JOINTS = [-0.050536, -0.600270, -0.241710, -2.366931, -0.052548, 1.977670, 1.129360]  # t=52
PRESS_053_JOINTS = [-0.054736, -0.610133, -0.252856, -2.366942, -0.047601, 1.985557, 1.133344]  # t=53
PRESS_054_JOINTS = [-0.060142, -0.625113, -0.266532, -2.370856, -0.044767, 1.997259, 1.137337]  # t=54
PRESS_055_JOINTS = [-0.066301, -0.644203, -0.280379, -2.378742, -0.044579, 2.009559, 1.142707]  # t=55
PRESS_056_JOINTS = [-0.072794, -0.665737, -0.293113, -2.388775, -0.046557, 2.022221, 1.150333]  # t=56
RETREAT_072_JOINTS = [-0.186694, -1.269949, -0.347012, -2.588847, -0.188778, 1.629431, 1.166823]  # t=72
APPROACH_000_JOINTS = [-0.007052, -1.025241, -0.033795, -2.316659, 0.049770, 1.514740, 0.721474]  # 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_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_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_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_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_043_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_044_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_045_JOINTS, input_type='joint', steps=1, 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_048_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_049_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_050_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_051_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_052_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_053_JOINTS, input_type='joint', steps=1, 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)

def retreat_after_press():
    """Retreat away after the button press interaction."""
    moveJoint(RETREAT_072_JOINTS, input_type='joint', steps=16, 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

Press the button to open the lid of the electric kettle.


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

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

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

OBJ_POSE_T0 = pose(x=4.764046, y=-1.144976, z=1.102371, qw=0.755094, qx=0.000000, qy=-0.000005, qz=-0.655617)
GOAL_RECEPTACLE_POSE = pose(x=3.503247, y=-0.205187, z=0.953599, qw=0.963172, qx=-0.058727, qy=0.183760, qz=0.187306)

APPROACH_002_JOINTS = [0.005117, -1.048411, -0.031799, -2.283043, 0.056816, 1.518239, 0.696421]  # t=2
APPROACH_003_JOINTS = [0.004316, -1.053047, -0.031036, -2.281854, 0.057864, 1.525980, 0.695077]  # t=3
APPROACH_004_JOINTS = [0.003648, -1.061696, -0.028077, -2.283284, 0.060494, 1.543634, 0.693619]  # t=4
APPROACH_006_JOINTS = [0.002013, -1.090113, -0.016758, -2.292418, 0.064877, 1.600273, 0.694303]  # t=6
APPROACH_009_JOINTS = [0.000109, -1.144228, 0.003460, -2.320496, 0.076979, 1.703318, 0.697866]  # t=9
APPROACH_012_JOINTS = [-0.000235, -1.195480, 0.030253, -2.358108, 0.093321, 1.811532, 0.705143]  # t=12
APPROACH_014_JOINTS = [-0.000037, -1.218610, 0.052131, -2.391020, 0.104895, 1.893706, 0.713205]  # t=14
APPROACH_015_JOINTS = [0.000215, -1.223383, 0.064199, -2.408626, 0.111206, 1.937749, 0.717847]  # t=15
APPROACH_016_JOINTS = [0.000556, -1.223314, 0.077026, -2.426048, 0.117787, 1.979323, 0.723361]  # t=16
APPROACH_018_JOINTS = [0.000972, -1.205390, 0.102620, -2.455116, 0.129824, 2.052812, 0.735574]  # t=18
APPROACH_019_JOINTS = [0.000739, -1.188475, 0.114447, -2.464355, 0.133330, 2.088687, 0.740815]  # t=19
APPROACH_021_JOINTS = [-0.000598, -1.142945, 0.135113, -2.472812, 0.135082, 2.151589, 0.748785]  # t=21
APPROACH_022_JOINTS = [-0.001925, -1.115652, 0.143369, -2.471633, 0.132888, 2.176190, 0.751534]  # t=22
APPROACH_024_JOINTS = [-0.007702, -1.045082, 0.153419, -2.459001, 0.119953, 2.221678, 0.755943]  # t=24
APPROACH_027_JOINTS = [-0.021208, -0.921584, 0.163558, -2.410256, 0.084057, 2.266379, 0.772262]  # t=27
APPROACH_029_JOINTS = [-0.031174, -0.847885, 0.172708, -2.367514, 0.050350, 2.281218, 0.793480]  # t=29
APPROACH_030_JOINTS = [-0.036380, -0.816672, 0.177263, -2.346290, 0.030071, 2.284114, 0.807048]  # t=30
APPROACH_033_JOINTS = [-0.050185, -0.738881, 0.193406, -2.288399, -0.029853, 2.287196, 0.858517]  # t=33
APPROACH_036_JOINTS = [-0.056532, -0.664687, 0.203104, -2.245115, -0.058306, 2.305611, 0.890235]  # t=36
APPROACH_039_JOINTS = [-0.060593, -0.595092, 0.206355, -2.213483, -0.081031, 2.337963, 0.910138]  # t=39
APPROACH_042_JOINTS = [-0.063794, -0.523052, 0.207037, -2.181913, -0.103769, 2.378147, 0.926002]  # t=42
APPROACH_045_JOINTS = [-0.065412, -0.457683, 0.205413, -2.146967, -0.124809, 2.408017, 0.937773]  # t=45
APPROACH_048_JOINTS = [-0.066211, -0.386039, 0.202916, -2.107572, -0.147158, 2.440692, 0.949529]  # t=48
APPROACH_050_JOINTS = [-0.065890, -0.344199, 0.201142, -2.082211, -0.163558, 2.455896, 0.961550]  # t=50
PRESS_135_JOINTS = [-0.186839, -1.764526, -0.394325, -2.906311, 0.001555, 2.250495, 0.586704]  # t=135
PRESS_136_JOINTS = [-0.199786, -1.763020, -0.422417, -2.875786, -0.005395, 2.192321, 0.559276]  # t=136
PRESS_137_JOINTS = [-0.212420, -1.762549, -0.453476, -2.845642, -0.016624, 2.138669, 0.534692]  # t=137
PRESS_138_JOINTS = [-0.224031, -1.762201, -0.486841, -2.816922, -0.030606, 2.092906, 0.511006]  # t=138
PRESS_139_JOINTS = [-0.234445, -1.762034, -0.520899, -2.790147, -0.045648, 2.055728, 0.487377]  # t=139
PRESS_141_JOINTS = [-0.251882, -1.760541, -0.587278, -2.739373, -0.075503, 1.999461, 0.442179]  # t=141
PRESS_142_JOINTS = [-0.258745, -1.757838, -0.618656, -2.713703, -0.089269, 1.977189, 0.420715]  # t=142
PRESS_143_JOINTS = [-0.264313, -1.753433, -0.648327, -2.687271, -0.101655, 1.957420, 0.399849]  # t=143
PRESS_145_JOINTS = [-0.271501, -1.738797, -0.702456, -2.631433, -0.122195, 1.923740, 0.359102]  # t=145
PRESS_146_JOINTS = [-0.273058, -1.728398, -0.727155, -2.601963, -0.130401, 1.909379, 0.338873]  # t=146
PRESS_147_JOINTS = [-0.273157, -1.715476, -0.753168, -2.570053, -0.138146, 1.895831, 0.318161]  # t=147
PRESS_148_JOINTS = [-0.270999, -1.699537, -0.780714, -2.536248, -0.142628, 1.881872, 0.296993]  # t=148
PRESS_149_JOINTS = [-0.267039, -1.681502, -0.805922, -2.502476, -0.144443, 1.868832, 0.275851]  # t=149
PRESS_151_JOINTS = [-0.255619, -1.641752, -0.852230, -2.434037, -0.144007, 1.845411, 0.235428]  # t=151
PRESS_153_JOINTS = [-0.241316, -1.601123, -0.894968, -2.363335, -0.140673, 1.821937, 0.194835]  # t=153
PRESS_155_JOINTS = [-0.222843, -1.559729, -0.937696, -2.291381, -0.133100, 1.801884, 0.155022]  # t=155
PRESS_157_JOINTS = [-0.198565, -1.517248, -0.981937, -2.221463, -0.120740, 1.789549, 0.116678]  # t=157
PRESS_159_JOINTS = [-0.167400, -1.474123, -1.029225, -2.153396, -0.101295, 1.783790, 0.083031]  # t=159
PRESS_160_JOINTS = [-0.149372, -1.452982, -1.054050, -2.119974, -0.089044, 1.782978, 0.068048]  # t=160
PRESS_161_JOINTS = [-0.129880, -1.432301, -1.079643, -2.088153, -0.076360, 1.784098, 0.054014]  # t=161
PRESS_163_JOINTS = [-0.087013, -1.393054, -1.131408, -2.025088, -0.050293, 1.792433, 0.030436]  # t=163
PRESS_165_JOINTS = [-0.040976, -1.358384, -1.183936, -1.966337, -0.026168, 1.810183, 0.016206]  # t=165
PRESS_166_JOINTS = [-0.017375, -1.343494, -1.209743, -1.938253, -0.014621, 1.822398, 0.013459]  # t=166
PRESS_167_JOINTS = [0.007336, -1.329490, -1.234842, -1.912343, -0.004121, 1.839594, 0.014299]  # t=167
PRESS_168_JOINTS = [0.033870, -1.315706, -1.258996, -1.890381, 0.004456, 1.863981, 0.018520]  # t=168
PRESS_169_JOINTS = [0.062330, -1.302791, -1.281830, -1.872612, 0.012642, 1.896168, 0.024664]  # t=169
PRESS_171_JOINTS = [0.122269, -1.282157, -1.324881, -1.846233, 0.028526, 1.975530, 0.039864]  # t=171
PRESS_172_JOINTS = [0.150735, -1.275424, -1.343950, -1.832000, 0.034976, 2.015312, 0.046979]  # t=172
PRESS_173_JOINTS = [0.174320, -1.273404, -1.359708, -1.804482, 0.042257, 2.041429, 0.052108]  # t=173
PRESS_174_JOINTS = [0.201724, -1.270661, -1.376033, -1.774025, 0.046564, 2.070401, 0.062018]  # t=174
PRESS_175_JOINTS = [0.232028, -1.267861, -1.392411, -1.741094, 0.047841, 2.100986, 0.074967]  # t=175
PRESS_176_JOINTS = [0.264549, -1.265317, -1.408526, -1.706253, 0.046020, 2.132916, 0.090181]  # t=176
PRESS_177_JOINTS = [0.298787, -1.263214, -1.424156, -1.670096, 0.040976, 2.166088, 0.107422]  # t=177
RETREAT_187_JOINTS = [0.602956, -1.348169, -1.544111, -1.351880, -0.122218, 2.532092, 0.257972]  # t=187
APPROACH_000_JOINTS = [0.005834, -1.047178, -0.032023, -2.283393, 0.056499, 1.517660, 0.696908]  # t=1
PRESS_065_JOINTS = [-0.039747, -0.328352, 0.198818, -2.029211, -0.287585, 2.327174, 1.095367]  # t=65
PRESS_075_JOINTS = [-0.091843, -0.359953, 0.146938, -2.290606, -0.570487, 3.007044, 1.482187]  # t=75
PRESS_076_JOINTS = [-0.104724, -0.350098, 0.145384, -2.298885, -0.599409, 3.070623, 1.513726]  # t=76
PRESS_080_JOINTS = [-0.195877, -0.286282, 0.163740, -2.322454, -0.680613, 3.395673, 1.576073]  # t=80
PRESS_083_JOINTS = [-0.251749, -0.195321, 0.188518, -2.356228, -0.576969, 3.744509, 1.423762]  # t=83
PRESS_085_JOINTS = [-0.246089, -0.191914, 0.203059, -2.379863, -0.465157, 3.750078, 1.305485]  # t=85
PRESS_097_JOINTS = [-0.217508, -0.547627, 0.362253, -2.520850, 0.414004, 3.195749, 0.716196]  # t=97
PRESS_107_JOINTS = [-0.221948, -0.842291, 0.309043, -2.643161, 0.321228, 2.880871, 0.911857]  # t=107
PRESS_120_JOINTS = [-0.057314, -1.202098, 0.050055, -2.849555, 0.247931, 2.744747, 0.809574]  # t=120
PRESS_133_JOINTS = [-0.157803, -1.736227, -0.325564, -2.938753, 0.032191, 2.333156, 0.630914]  # t=133

# 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_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_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_018_JOINTS, input_type='joint', steps=2, 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_022_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_024_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_027_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_029_JOINTS, input_type='joint', steps=2, 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_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_048_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=-1.000)
    moveJoint(APPROACH_050_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_065_JOINTS, input_type='joint', steps=15, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_075_JOINTS, input_type='joint', steps=10, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_076_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_080_JOINTS, input_type='joint', steps=4, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_083_JOINTS, input_type='joint', steps=3, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_085_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_097_JOINTS, input_type='joint', steps=12, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_107_JOINTS, input_type='joint', steps=10, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_120_JOINTS, input_type='joint', steps=13, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_133_JOINTS, input_type='joint', steps=13, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_135_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_136_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_137_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_138_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_139_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_141_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_142_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_143_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_145_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_146_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_147_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_148_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_149_JOINTS, input_type='joint', steps=1, 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_155_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_157_JOINTS, input_type='joint', steps=2, 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_168_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_169_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_171_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_172_JOINTS, input_type='joint', steps=1, 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_175_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_176_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=1.000)
    moveJoint(PRESS_177_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_187_JOINTS, input_type='joint', steps=10, 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: OpenFridgeDrawer
# Episode: episode_000000

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

SCENE_ARTIFACT = '../../../artifacts/20260324/OpenFridgeDrawer/20260324_205311_open-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': 'OpenFridgeDrawer',
    'episode_id': 'episode_000000',
    'scene_artifact_path': '../../../artifacts/20260324/OpenFridgeDrawer/20260324_205311_open-fridge-drawer_episode_000000_action2code-open-loop-joint_initial-scene.json',
    'fitting_summary_path': '../../../artifacts/20260324/OpenFridgeDrawer/20260324_205311_open-fridge-drawer_episode_000000_action2code-open-loop-joint_fitting-summary.json',
    'extracted_pose_metadata_path': '../../../artifacts/20260324/OpenFridgeDrawer/20260324_205311_open-fridge-drawer_episode_000000_action2code-open-loop-joint_extracted-pose-metadata.json',
    'stable_grasp_contact_t': 122,
    'stable_release_contact_loss_t': 122,
    '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.530211, y=-3.414327, z=0.789262, qw=0.872712, qx=0.040327, qy=0.038110, qz=0.485072)

APPROACH_BODY_003 = pose(x=0.435494, y=0.000769, z=1.291793, qx=0.661481, qy=0.737802, qz=0.100927, qw=0.088905)  # body-frame t=3
APPROACH_BODY_004 = pose(x=0.433114, y=0.000735, z=1.292475, qx=0.661535, qy=0.737810, qz=0.100710, qw=0.088688)  # body-frame t=4
APPROACH_BODY_006 = pose(x=0.427738, y=0.002167, z=1.295017, qx=0.660592, qy=0.737862, qz=0.103798, qw=0.091675)  # body-frame t=6
APPROACH_BODY_008 = pose(x=0.424638, y=0.008712, z=1.296523, qx=0.658675, qy=0.737884, qz=0.110261, qw=0.097561)  # body-frame t=8
APPROACH_BODY_012 = pose(x=0.421259, y=0.017279, z=1.294684, qx=0.658159, qy=0.735687, qz=0.117984, qw=0.108031)  # body-frame t=12
APPROACH_BODY_016 = pose(x=0.420202, y=0.019453, z=1.293032, qx=0.658092, qy=0.734565, qz=0.121275, qw=0.112343)  # body-frame t=16
APPROACH_BODY_019 = pose(x=0.420331, y=0.018854, z=1.293094, qx=0.657939, qy=0.734640, qz=0.122131, qw=0.111822)  # body-frame t=19
APPROACH_BODY_020 = pose(x=0.420572, y=0.018521, z=1.293219, qx=0.657830, qy=0.734817, qz=0.122194, qw=0.111228)  # body-frame t=20
APPROACH_BODY_022 = pose(x=0.420849, y=0.018241, z=1.293771, qx=0.657686, qy=0.735151, qz=0.121889, qw=0.110209)  # body-frame t=22
APPROACH_BODY_024 = pose(x=0.420642, y=0.018345, z=1.294417, qx=0.657606, qy=0.735339, qz=0.121488, qw=0.109874)  # body-frame t=24
APPROACH_BODY_027 = pose(x=0.421004, y=0.019631, z=1.294640, qx=0.657649, qy=0.735514, qz=0.119821, qw=0.110272)  # body-frame t=27
APPROACH_BODY_028 = pose(x=0.421575, y=0.020251, z=1.294497, qx=0.657848, qy=0.735509, qz=0.118847, qw=0.110173)  # body-frame t=28
APPROACH_BODY_029 = pose(x=0.422230, y=0.020399, z=1.294512, qx=0.658174, qy=0.735418, qz=0.118081, qw=0.109658)  # body-frame t=29
APPROACH_BODY_032 = pose(x=0.422308, y=0.019927, z=1.295709, qx=0.658554, qy=0.735379, qz=0.117488, qw=0.108267)  # body-frame t=32
APPROACH_BODY_034 = pose(x=0.422064, y=0.019646, z=1.295990, qx=0.658482, qy=0.735437, qz=0.117723, qw=0.108053)  # body-frame t=34
APPROACH_BODY_036 = pose(x=0.412448, y=0.019591, z=1.297565, qx=0.658421, qy=0.735800, qz=0.116694, qw=0.107064)  # body-frame t=36
APPROACH_BODY_040 = pose(x=0.395246, y=0.019542, z=1.297243, qx=0.658275, qy=0.736080, qz=0.115988, qw=0.106806)  # body-frame t=40
APPROACH_BODY_042 = pose(x=0.389176, y=0.019519, z=1.295795, qx=0.658332, qy=0.736286, qz=0.115101, qw=0.105991)  # body-frame t=42
APPROACH_BODY_044 = pose(x=0.386045, y=0.019301, z=1.289080, qx=0.658543, qy=0.737690, qz=0.106531, qw=0.103854)  # body-frame t=44
APPROACH_BODY_048 = pose(x=0.386750, y=0.019177, z=1.253895, qx=0.658754, qy=0.742929, qz=0.068508, qw=0.096986)  # body-frame t=48
APPROACH_BODY_050 = pose(x=0.389717, y=0.019260, z=1.233543, qx=0.659089, qy=0.743970, qz=0.056885, qw=0.094205)  # body-frame t=50
APPROACH_BODY_052 = pose(x=0.397528, y=0.019201, z=1.219170, qx=0.661808, qy=0.740998, qz=0.057316, qw=0.098219)  # body-frame t=52
APPROACH_BODY_053 = pose(x=0.403213, y=0.018936, z=1.213758, qx=0.664995, qy=0.737490, qz=0.059729, qw=0.101599)  # body-frame t=53
APPROACH_BODY_056 = pose(x=0.421994, y=0.018614, z=1.203652, qx=0.676242, qy=0.725169, qz=0.068813, qw=0.109960)  # body-frame t=56
APPROACH_BODY_060 = pose(x=0.447614, y=0.022447, z=1.198542, qx=0.704813, qy=0.694867, qz=0.078137, qw=0.119549)  # body-frame t=60
APPROACH_BODY_064 = pose(x=0.470102, y=0.025233, z=1.195545, qx=0.735508, qy=0.662211, qz=0.081152, qw=0.117977)  # body-frame t=64
APPROACH_BODY_068 = pose(x=0.492881, y=0.025663, z=1.185809, qx=0.762563, qy=0.632374, qz=0.088617, qw=0.103674)  # body-frame t=68
APPROACH_BODY_070 = pose(x=0.503227, y=0.026300, z=1.178174, qx=0.772776, qy=0.620807, qz=0.093834, qw=0.092793)  # body-frame t=70
APPROACH_BODY_072 = pose(x=0.513863, y=0.026275, z=1.166559, qx=0.777937, qy=0.615268, qz=0.098920, qw=0.080464)  # body-frame t=72
APPROACH_BODY_076 = pose(x=0.537036, y=0.025549, z=1.142498, qx=0.779305, qy=0.613499, qz=0.106616, qw=0.070260)  # body-frame t=76
APPROACH_BODY_077 = pose(x=0.542579, y=0.025517, z=1.138776, qx=0.778847, qy=0.613800, qz=0.107874, qw=0.070789)  # body-frame t=77
APPROACH_BODY_080 = pose(x=0.558376, y=0.027734, z=1.131618, qx=0.774657, qy=0.618377, qz=0.111161, qw=0.071830)  # body-frame t=80
APPROACH_BODY_084 = pose(x=0.578243, y=0.030292, z=1.117827, qx=0.767029, qy=0.627798, qz=0.112034, qw=0.070594)  # body-frame t=84
APPROACH_BODY_088 = pose(x=0.599731, y=0.034020, z=1.100466, qx=0.757718, qy=0.638867, qz=0.113230, qw=0.069933)  # body-frame t=88
APPROACH_BODY_092 = pose(x=0.618471, y=0.038492, z=1.081946, qx=0.747167, qy=0.651414, qz=0.111356, qw=0.070720)  # body-frame t=92
APPROACH_BODY_095 = pose(x=0.628619, y=0.040793, z=1.070848, qx=0.740204, qy=0.659579, qz=0.108406, qw=0.072814)  # body-frame t=95
PRESS_097_JOINTS = [-0.019202, -0.502677, 0.105146, -2.554038, 0.080712, 2.314932, 0.918163]  # t=97
PRESS_099_JOINTS = [-0.019097, -0.483092, 0.106285, -2.538626, 0.069936, 2.314673, 0.909209]  # t=99
PRESS_101_JOINTS = [-0.018987, -0.464592, 0.107306, -2.523354, 0.059352, 2.311738, 0.901408]  # t=101
PRESS_102_JOINTS = [-0.019193, -0.460353, 0.107374, -2.517215, 0.052502, 2.299973, 0.900549]  # t=102
PRESS_103_JOINTS = [-0.019555, -0.467292, 0.106283, -2.517103, 0.044477, 2.276466, 0.900934]  # t=103
PRESS_104_JOINTS = [-0.019942, -0.485574, 0.103419, -2.526492, 0.037379, 2.248413, 0.900930]  # t=104
PRESS_105_JOINTS = [-0.020301, -0.510733, 0.098984, -2.543245, 0.031715, 2.224624, 0.899171]  # t=105
PRESS_107_JOINTS = [-0.020711, -0.571231, 0.087797, -2.585287, 0.025575, 2.191345, 0.893116]  # t=107
PRESS_108_JOINTS = [-0.020658, -0.604505, 0.082614, -2.607991, 0.024032, 2.176168, 0.890276]  # t=108
PRESS_109_JOINTS = [-0.020397, -0.639199, 0.078179, -2.630765, 0.023130, 2.159601, 0.887818]  # t=109
PRESS_111_JOINTS = [-0.020086, -0.712394, 0.069201, -2.676203, 0.020849, 2.122962, 0.882712]  # t=111
PRESS_113_JOINTS = [-0.020542, -0.789290, 0.058366, -2.719696, 0.017074, 2.079386, 0.876326]  # t=113
PRESS_115_JOINTS = [-0.022064, -0.868601, 0.044589, -2.760006, 0.010700, 2.028141, 0.868155]  # t=115
PRESS_117_JOINTS = [-0.024245, -0.949336, 0.030646, -2.795965, 0.001581, 1.968663, 0.860464]  # t=117
PRESS_118_JOINTS = [-0.025523, -0.989319, 0.024242, -2.811521, -0.004062, 1.934567, 0.857355]  # t=118
PRESS_119_JOINTS = [-0.027045, -1.028794, 0.017728, -2.825466, -0.010605, 1.897970, 0.854282]  # t=119
PRESS_121_JOINTS = [-0.030924, -1.106635, 0.003721, -2.849507, -0.026482, 1.819438, 0.847342]  # t=121
PRESS_122_JOINTS = [-0.033153, -1.145285, -0.003707, -2.860149, -0.035106, 1.778786, 0.843318]  # t=122
PRESS_123_JOINTS = [-0.035523, -1.184017, -0.011280, -2.869991, -0.043922, 1.737156, 0.839014]  # t=123
PRESS_125_JOINTS = [-0.040565, -1.261693, -0.025784, -2.887071, -0.062708, 1.649747, 0.829914]  # t=125
PRESS_126_JOINTS = [-0.043383, -1.300654, -0.033354, -2.894470, -0.072897, 1.604564, 0.824815]  # t=126
RETREAT_127_JOINTS = [-0.046665, -1.339968, -0.042511, -2.901098, -0.083705, 1.558421, 0.818728]  # t=127
RETREAT_128_JOINTS = [-0.051428, -1.381126, -0.055684, -2.906035, -0.100892, 1.513140, 0.810658]  # t=128
RETREAT_129_JOINTS = [-0.057708, -1.424657, -0.074248, -2.910464, -0.120686, 1.467759, 0.801185]  # t=129
RETREAT_130_JOINTS = [-0.064970, -1.471471, -0.097006, -2.909354, -0.136492, 1.423448, 0.792163]  # t=130
RETREAT_131_JOINTS = [-0.072818, -1.522429, -0.121646, -2.897462, -0.146488, 1.378177, 0.783233]  # t=131
RETREAT_132_JOINTS = [-0.080495, -1.577090, -0.144868, -2.874967, -0.149147, 1.332846, 0.772624]  # t=132
RETREAT_133_JOINTS = [-0.087825, -1.634679, -0.164493, -2.847666, -0.144784, 1.290609, 0.762160]  # t=133
RETREAT_134_JOINTS = [-0.095231, -1.693644, -0.181215, -2.819714, -0.136941, 1.252055, 0.753900]  # t=134
RETREAT_135_JOINTS = [-0.102840, -1.752090, -0.196339, -2.791474, -0.127666, 1.217592, 0.747942]  # t=135
RETREAT_136_JOINTS = [-0.110382, -1.767861, -0.210527, -2.746950, -0.115119, 1.192999, 0.742421]  # t=136
RETREAT_137_JOINTS = [-0.117144, -1.763819, -0.223445, -2.691545, -0.099000, 1.172278, 0.735855]  # t=137
RETREAT_138_JOINTS = [-0.122251, -1.763050, -0.235740, -2.636941, -0.081839, 1.153443, 0.730432]  # t=138
RETREAT_139_JOINTS = [-0.126621, -1.762946, -0.247213, -2.583150, -0.064426, 1.136233, 0.726071]  # t=139
RETREAT_140_JOINTS = [-0.130742, -1.762922, -0.257561, -2.529985, -0.046669, 1.121295, 0.722075]  # t=140
RETREAT_141_JOINTS = [-0.134358, -1.762899, -0.266013, -2.478571, -0.029388, 1.110247, 0.717589]  # t=141
APPROACH_000_JOINTS = [0.014242, -1.064884, -0.017011, -2.295262, 0.015505, 1.500089, 0.683763]  # 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)
    moveWholeBodyPath(body_waypoints=[APPROACH_BODY_003, APPROACH_BODY_004, APPROACH_BODY_006, APPROACH_BODY_008, APPROACH_BODY_012, APPROACH_BODY_016, APPROACH_BODY_019, APPROACH_BODY_020, APPROACH_BODY_022, APPROACH_BODY_024, APPROACH_BODY_027, APPROACH_BODY_028, APPROACH_BODY_029, APPROACH_BODY_032, APPROACH_BODY_034, APPROACH_BODY_036, APPROACH_BODY_040, APPROACH_BODY_042, APPROACH_BODY_044, APPROACH_BODY_048, APPROACH_BODY_050, APPROACH_BODY_052, APPROACH_BODY_053, APPROACH_BODY_056, APPROACH_BODY_060, APPROACH_BODY_064, APPROACH_BODY_068, APPROACH_BODY_070, APPROACH_BODY_072, APPROACH_BODY_076, APPROACH_BODY_077, APPROACH_BODY_080, APPROACH_BODY_084, APPROACH_BODY_088, APPROACH_BODY_092, APPROACH_BODY_095], base_waypoints=[[1.305894315459964, -3.41751844734993, -3.141583313653309], [1.3058892349023723, -3.417518391672073, -3.1415821776278414], [1.3058877411916412, -3.417511477701843, -3.14161688317063], [1.3059858053964146, -3.4197614832596153, -3.141831419782901], [1.3065076008818406, -3.4344586795442336, -3.141708920848457], [1.3073716293173383, -3.4365366550479806, -3.1416157076078077], [1.3086685926558832, -3.4423258111458406, -3.1418641846721953], [1.310474519086369, -3.4480840694800654, -3.141944991828143], [1.3154708509901787, -3.4635598400885, -3.1420947668733796], [1.3165845757653762, -3.4824968409958617, -3.1421554540208403], [1.318387325464251, -3.502466454993087, -3.1418025093187225], [1.3234972995381917, -3.5033161155841115, -3.141629226306299], [1.3329715728529632, -3.5033654017312403, -3.141611362877804], [1.3693485985900369, -3.5033683063796857, -3.141615333275954], [1.3946993123921612, -3.503368518901008, -3.141618481905466], [1.3987235615461922, -3.5033682511206448, -3.1416166081339276], [1.3987285405557917, -3.50336813104028, -3.1416147898365696], [1.3987303954491126, -3.503368201290365, -3.141614455775553], [1.3987348352484987, -3.503364048202015, -3.141621948300098], [1.3987298548507896, -3.503369955365281, -3.1416112568755987], [1.3987328291572239, -3.5033687088033623, -3.141609761882865], [1.3987322605666779, -3.503369247772713, -3.141602739337679], [1.3987341893952308, -3.503368192325514, -3.141601738877783], [1.3987308359538444, -3.5033696131817993, -3.141601065449927], [1.3987323896583739, -3.5033683645100417, -3.1415853159164566], [1.3987317531188466, -3.50337033413491, -3.1415870166645847], [1.3987295553445769, -3.503369344296223, -3.141598782158179], [1.3987312861007797, -3.503369682186534, -3.141606688559779], [1.3987311063462688, -3.503368491502826, -3.141621645465464], [1.3987294623998812, -3.503366640660845, -3.1416231603234555], [1.3987298570217974, -3.5033671010901077, -3.1416218774077347], [1.39873098548019, -3.503367642220696, -3.141620358446104], [1.3987318114821348, -3.5033676550219592, -3.1416211383825203], [1.3987296461604546, -3.5033682827324113, -3.141616767275882], [1.3987287373153083, -3.503368149484661, -3.141615846030314], [1.398745307760657, -3.5033639765063427, -3.141644517433573]], base_modes=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], torso_targets=[1.0256045312383546e-06, 2.1659474711772995e-06, 4.25699310379428e-06, 6.990739534319728e-06, 5.887778759576735e-06, 6.736570139868757e-07, -5.900357185140138e-07, -5.899883566246399e-07, -2.105888278482203e-07, 6.415527507116962e-07, 6.708329486920943e-07, -2.3105089527217187e-07, -4.474961240835154e-07, 1.914423754023121e-06, 3.3247726979077058e-06, 1.0215524428743071e-05, 1.054113419626144e-05, 9.303049259743442e-06, 1.4866520880355275e-05, 2.8998100011060674e-05, 2.9355908250022466e-05, 1.8751092932541844e-05, 1.3768335024587583e-05, -2.7761729561457746e-07, -1.8234585256196086e-06, -4.405668633498357e-07, 4.424903733593478e-06, 7.430628507147799e-06, 1.142929000968889e-05, 7.36585490750663e-06, 4.922968233451449e-06, 1.8348422486580632e-06, 2.1957493364304294e-06, 3.4714791278092497e-06, 4.146683506036982e-06, 4.908900519724797e-05], segment_steps=[3, 1, 2, 2, 4, 4, 3, 1, 2, 2, 3, 1, 1, 3, 2, 2, 4, 2, 2, 4, 2, 2, 1, 3, 4, 4, 4, 2, 2, 4, 1, 3, 4, 4, 4, 4], settle_steps=0, gripper=-1.000, gripper_cmds=[], body_motion_priority=0.702636, base_xy_priority=0.702636, base_yaw_priority=0.001641, base_position_gain=4.905272, base_yaw_gain=3.223879, base_position_ff_gain=16.863267, base_yaw_ff_gain=4.245352, base_ee_anchor_mix=0.543287)

def press_control():
    """Execute the short interaction path that actuates the control."""
    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_101_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_102_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_103_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_104_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_105_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_107_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_108_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_109_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_111_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_113_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_115_JOINTS, input_type='joint', steps=2, settle_steps=0, gripper=-1.000)
    moveJoint(PRESS_117_JOINTS, input_type='joint', steps=2, 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_126_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_127_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_128_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_129_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_130_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_131_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_132_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_133_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_134_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_135_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_136_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_137_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_138_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_139_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_140_JOINTS, input_type='joint', steps=1, settle_steps=0, gripper=-1.000)
    moveJoint(RETREAT_141_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