|
import tensorflow as tf |
|
|
|
from data.utils import clean_task_instruction, euler_to_rotation_matrix, rotation_matrix_to_ortho6d |
|
|
|
|
|
def process_step(step: dict) -> dict: |
|
""" |
|
Unify the action format and clean the task instruction. |
|
|
|
DO NOT use python list, use tf.TensorArray instead. |
|
""" |
|
|
|
action_dict = step['action'] |
|
|
|
step['action'] = {} |
|
action = step['action'] |
|
action['arm_concat'] = action_dict['ee_6d_pos'] |
|
|
|
|
|
action['format'] = tf.constant( |
|
"left_eef_pos_x,left_eef_pos_y,left_eef_pos_z,left_eef_angle_0,left_eef_angle_1,left_eef_angle_2,left_eef_angle_3,left_eef_angle_4,left_eef_angle_5,left_gripper_open,right_eef_pos_x,right_eef_pos_y,right_eef_pos_z,right_eef_angle_0,right_eef_angle_1,right_eef_angle_2,right_eef_angle_3,right_eef_angle_4,right_eef_angle_5,right_gripper_open" |
|
) |
|
|
|
|
|
|
|
state_dict = step['observation']['state'] |
|
state = {} |
|
state['arm_concat'] = state_dict |
|
|
|
|
|
state['format'] = tf.constant( |
|
"left_eef_pos_x,left_eef_pos_y,left_eef_pos_z,left_eef_angle_0,left_eef_angle_1,left_eef_angle_2,left_eef_angle_3,left_eef_angle_4,left_eef_angle_5,left_gripper_open,right_eef_pos_x,right_eef_pos_y,right_eef_pos_z,right_eef_angle_0,right_eef_angle_1,right_eef_angle_2,right_eef_angle_3,right_eef_angle_4,right_eef_angle_5,right_gripper_open" |
|
) |
|
|
|
|
|
replacements = { |
|
'_': ' ', |
|
'1f': ' ', |
|
'4f': ' ', |
|
'-': ' ', |
|
'50': ' ', |
|
'55': ' ', |
|
'56': ' ', |
|
|
|
} |
|
instr = step['language_instruction'] |
|
|
|
step['observation'] = state |
|
step['observation']['natural_language_instruction'] = instr |
|
|
|
return step |
|
|
|
|
|
if __name__ == "__main__": |
|
pass |
|
|