pd_ee_delta_pose
,动作控制的是末端执行器的每一步运动hand_camera
、机械臂斜上方的相机base_camera),视野范围都很小,并且存在遮挡:python tools/replay_trajectory.py --traj-path demos/rigid_body_envs/PickCube-v0/PickCube-v0.h5 --vis
i7-7700HQ CPU
,大概五分钟,五分钟之内电脑卡的别的什么都干不了:python tools/replay_trajectory.py --traj-path demos/rigid_body_envs/PickCube-v0/PickCube-v0.h5 \
--save-traj --target-control-mode pd_ee_delta_pose --num-procs 10
matplotlib
散点图可视化import gym
import mani_skill2.envs
import numpy as np
import open3d as o3d
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
#obs_mode = pointcloud, rgbd, state_dict, state
env = gym.make("PickCube-v0", obs_mode="pointcloud", control_mode="pd_ee_delta_pose")
env.seed(0)
obs = env.reset()
done = False
fig = plt.figure()
i = 0
while not done:
action = np.array([0.1,0.1,0.1,0,0,0,1])
obs, reward, done, info = env.step(action)
point = np.array(obs['pointcloud']['xyzw'])
rgb = np.array(obs['pointcloud']['rgb'])
print(point.shape)#(32768,4)
print(rgb.shape)#(32768,3)
i += 1
if i == 10:
ax = fig.add_subplot(projection='3d')
#point_xyz = point[:,[0,1,2]]
ax.scatter(point[:,[0]], point[:,[1]], point[:,[2]], zdir="z",facecolors=rgb/255, marker="o", s=40)
#ax.scatter(xs, ys, zs=zs2, zdir="z", facecolors=rgb, marker="^", s=40)
ax.set(xlabel="X", ylabel="Y", zlabel="Z")
plt.show()
env.render() # a display is required to render
env.close()
python tools/convert_state.py --env-name PickCube-v0 --num-procs 1 \
--traj-name /home/jiangyvhang/ManiSkill2/demos/rigid_body_envs/PickCube-v0/PickCube-v0.none.pd_ee_delta_pose.h5 \
--json-name /home/jiangyvhang/ManiSkill2/demos/rigid_body_envs/PickCube-v0/PickCube-v0.none.pd_ee_delta_pose.json \
--output-name /home/jiangyvhang/ManiSkill2/demos/rigid_body_envs/PickCube-v0/PickCube-v0.trajectory.none.pd_ee_delta_pose_pcd.h5 \
--control-mode pd_ee_delta_pose \
--max-num-traj 6 \
--obs-mode pointcloud \
--n-points 1200 \
--obs-frame base \
--reward-mode dense \
--n-goal-points 50 \
--obs-frame base \
--render \
--env-name:环境名字 \
--num-procs :线程数,越多转换越快,但启动多线程会比较慢,1 \
--traj-name .h5示例文件路径 \
--json-name .json示例文件路径 \
--output-name 输出的转换后的.h5文件路径 \
--control-mode :控制模式,pd_ee_delta_pose \
--max-num-traj :转换的路径个数,小一点,更快完成转换,快速验证,6 \
--obs-mode :观测方式,pointcloud \
--n-points :点云点数,1200 \
--obs-frame :观测点云基准,base \
--reward-mode:选择稠密或稀疏奖赏 dense:稠密,sparse:稀疏 \
--n-goal-points :目标位置处点云数量,50 \
--render :演示,会降低转换速度,并且只能开启一个线程\
import h5py
import numpy as np
file = '/home/jiangyvhang/ManiSkill2/demos/rigid_body_envs/PickCube-v0/PickCube-v0.trajectory.none.pd_ee_delta_pose_pcd.h5'
h5file = h5py.File(file, "r")
print(np.array(h5file['traj_0']))
for key in h5file['traj_0'].keys():
#print(h5file['traj_0'][key])
'''
'''
#print( np.array( h5file['traj_0'][key] ) )
pass
'''
for key in h5file['traj_0']['dict_str_obs']:
print(h5file['traj_0']['dict_str_obs'][key])
print( np.array( h5file['traj_0']['dict_str_obs'][key] ) )
'''
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
point = np.array( h5file['traj_0']['dict_str_obs']['dict_str_xyz'] )
rgb = np.array( h5file['traj_0']['dict_str_obs']['dict_str_rgb'] )
i = 80#查看第i帧
ax.scatter(point[[i],:,[0]], point[[i],:,[1]], point[[i],:,[2]], zdir="z",facecolors=np.squeeze(rgb[[i],:],0), marker=".", s=40)
ax.set(xlabel="X", ylabel="Y", zlabel="Z")
plt.show()
效果:
i = 0
i = 10
i = 80
python tools/convert_state.py --env-name PickCube-v0 --num-procs 1 \
--traj-name /home/jiangyvhang/ManiSkill2/demos/rigid_body_envs/PickCube-v0/PickCube-v0.none.pd_ee_delta_pose.h5 \
--json-name /home/jiangyvhang/ManiSkill2/demos/rigid_body_envs/PickCube-v0/PickCube-v0.none.pd_ee_delta_pose.json \
--output-name /home/jiangyvhang/ManiSkill2/demos/rigid_body_envs/PickCube-v0/PickCube-v0.trajectory.none.pd_ee_delta_pose_pcd.h5 \
--control-mode pd_ee_delta_pose \
--max-num-traj 2 \
--obs-mode pointcloud \
--n-points 10000 \
--obs-frame world \
--reward-mode dense \
--n-goal-points 50 \
--render \
Obs mode: pointcloud; Control mode: pd_ee_delta_pose
Obs frame: world; n_points: 10000; n_goal_points: 50
Reset kwargs for the current trajectory: {'seed': 0}
Convert Trajectory: completed 1 / 2; this trajectory has length 88
Reset kwargs for the current trajectory: {'seed': 1}
Convert Trajectory: completed 2 / 2; this trajectory has length 101
Finish using /tmp/0.h5
maniskill2_learn - (record_utils.py:280) - INFO - 2022-12-02,16:31:19 - Total number of trajectories 2
Finish merging files to /home/jiangyvhang/ManiSkill2/demos/rigid_body_envs/PickCube-v0/PickCube-v0.trajectory.none.pd_ee_delta_pose_pcd.h5
i = 0
i = 10
i = 80