網(wǎng)站開(kāi)發(fā)實(shí)訓(xùn)意義南寧今日頭條最新消息
0.前置
- 機(jī)器人持續(xù)學(xué)習(xí)基準(zhǔn)LIBERO系列1——基本介紹與安裝測(cè)試
- 機(jī)器人持續(xù)學(xué)習(xí)基準(zhǔn)LIBERO系列2——路徑與基準(zhǔn)基本信息
- 機(jī)器人持續(xù)學(xué)習(xí)基準(zhǔn)LIBERO系列3——相機(jī)畫(huà)面可視化及單步移動(dòng)更新
- 機(jī)器人持續(xù)學(xué)習(xí)基準(zhǔn)LIBERO系列4——robosuite最基本demo
1.更改環(huán)境設(shè)置
- LIBERO-master/libero/libero/envs/env_wrapper.py,第37行camera_depths=False改為True
2.獲取歸一化后的深度圖
- robosuite里面直接獲取到的是三維的歸一化到[0,1]區(qū)間的深度圖
- 其中第三個(gè)維度為通道數(shù)1
agentview_depth = (obs["agentview_depth"])
robot0_eye_in_hand_depth = (obs["robot0_eye_in_hand_depth"])
3.調(diào)整顯示深度圖
- 要把第三個(gè)維度去掉,再把值擴(kuò)大到0-255,化為整數(shù)才能顯示(參考)
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))
4.同時(shí)可視化彩色圖和深度圖
- 前置代碼:機(jī)器人持續(xù)學(xué)習(xí)基準(zhǔn)LIBERO系列1——基本介紹與安裝測(cè)試, 機(jī)器人持續(xù)學(xué)習(xí)基準(zhǔn)LIBERO系列2——路徑與基準(zhǔn)基本信息
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)
#設(shè)置種子
env.seed(0)
#環(huán)境重置
env.reset()
#初始化
env.set_init_state(init_states[0])import numpy as np
#運(yùn)動(dòng)機(jī)械臂更新環(huán)境
obs, _, _, _ = env.step([0.] * 7)
#獲取手外相機(jī)視角圖片
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"])
#深度圖第三個(gè)維度是1,還是歸一化后的,所以要把第三個(gè)維度去掉,再把值擴(kuò)大到0-255,化為整數(shù)才能顯示
#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))
- 關(guān)閉環(huán)境
env.close()