agentview_depth = (obs["agentview_depth"])
robot0_eye_in_hand_depth = (obs["robot0_eye_in_hand_depth"])
agentview_depth = (agentview_depth.squeeze() * 255) .astype(np.uint8)
robot0_eye_in_hand_depth = (robot0_eye_in_hand_depth.squeeze() * 255) .astype(np.uint8)
display(Image.fromarray(agentview_depth))
display(Image.fromarray(robot0_eye_in_hand_depth))
env_args = {
"bddl_file_name": os.path.join(os.path.join(get_libero_path("bddl_files"), task.problem_folder, task.bddl_file)),
"camera_heights": 128,
"camera_widths": 128
}
env = OffScreenRenderEnv(**env_args)
#设置种子
env.seed(0)
#环境重置
env.reset()
#初始化
env.set_init_state(init_states[0])
import numpy as np
#运动机械臂更新环境
obs, _, _, _ = env.step([0.] * 7)
#获取手外相机视角图片
agentview_image = (obs["agentview_image"])
robot0_eye_in_hand_image = (obs["robot0_eye_in_hand_image"])
agentview_depth = (obs["agentview_depth"])
robot0_eye_in_hand_depth = (obs["robot0_eye_in_hand_depth"])
#深度图第三个维度是1,还是归一化后的,所以要把第三个维度去掉,再把值扩大到0-255,化为整数才能显示
#https://www.coder.work/article/7752795
agentview_depth = (agentview_depth.squeeze() * 255) .astype(np.uint8)
robot0_eye_in_hand_depth = (robot0_eye_in_hand_depth.squeeze() * 255) .astype(np.uint8)
display(Image.fromarray(agentview_image))
display(Image.fromarray(agentview_depth))
display(Image.fromarray(robot0_eye_in_hand_image))
display(Image.fromarray(robot0_eye_in_hand_depth))
env.close()