基于 robosuite
库,进行双臂机器人学习训练
下面展示下分别控制两个机械手随机运动的画面:
双臂显示场景如下:双臂调用代码如下:
import numpy as np
import robosuite as suite
import robomimic
import robomimic.utils.file_utils as FileUtils
import robomimic.utils.torch_utils as TorchUtils
import robomimic.utils.tensor_utils as TensorUtils
import robomimic.utils.obs_utils as ObsUtils
from robomimic.envs.env_base import EnvBase
from robomimic.algo import RolloutPolicy
env = suite.make(
env_name = 'TwoArmLift',
robots=["Sawyer", "Kinova3"], # Kinova3, Auboi5, Sawyer
has_renderer = True,
has_offscreen_renderer = False,
use_camera_obs = False,
env_configuration = "single-arm-parallel",
)
env.reset()
low, high = env.action_spec
if __name__ == "__main__":
for i in range(100):
action_0 = np.random.randn(env.robots[0].dof) # dim = 8
action_1 = np.random.randn(env.robots[1].dof)
action = [x for x in action_0] + [x for x in action_1] # dim = 16
obs, reward, done, info = env.step(action)
# import ipdb; ipdb.set_trace()
env.render()
值得注意的是,与单机械手控制相比,只需要将 action
改成 16维的就可以。ps
:对于单机器人控制,action
是7维的,但是在这里,两个机器人的动作是 16维的。
手动示教生成的数据: