datasets_default_path = get_libero_path("datasets")print(datasets_default_path)
demo_files =[os.path.join(datasets_default_path, benchmark_instance.get_task_demonstration(i)) \
for i inrange(num_tasks)]print(demo_files)
demo_files是由hdf5文件路径组成的列表
4.重放轨迹有关包
import h5py
from libero.libero.utils.dataset_utils import get_dataset_info
from IPython.display import HTML
import imageio
5.轨迹hdf5文件结构
demo_0:n步
actions:(n,7)
dones:(n,)
obs
agentview_rgb:(n,128,128,3)
ee_ori:(n,3)
ee_pos:(n,3)
ee_states:(n,6)
eye_in_hand_rgb:(n,128,128,3)
gripper_states:(n,2)
joint_states:(n,7)
rewards:(n,)
robot_states:(329,47)
demo_1 …
6.使用手外相机生成重放视频
example_demo_file = demo_files[9]# Print the dataset info. We have a standalone script for doing the same thing available at `scripts/get_dataset_info.py`
get_dataset_info(example_demo_file)with h5py.File(example_demo_file,"r")as f:
images = f["data/demo_0/obs/agentview_rgb"][()]
video_writer = imageio.get_writer("output.mp4", fps=60)for image in images:
video_writer.append_data(image[::-1])
video_writer.close()
HTML("""
<video width="640" height="480" controls>
<source src="output.mp4" type="video/mp4">
</video>
<script>
var video = document.getElementsByTagName('video')[0];
video.playbackRate = 2.0; // Increase the playback speed to 2x
</script>
""")