-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.py
29 lines (28 loc) · 812 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import time
import os
import gym
import numpy as np
import gym_xarm
from matplotlib import pyplot as plt
# FetchPickAndPlace-v0 XarmPDStackTower-v0 XarmPDPushWithDoor-v0 XarmPDOpenBoxAndPlace-v0 XarmPDHandover-v0
config = {
'GUI': True,
'num_obj': 2,
'same_side_rate': 0.5,
'goal_shape': 'any',
'use_stand': False,
}
env = gym.make('XarmHandover-v0', config = config)
agent = lambda ob: env.action_space.sample()
ob = env.reset()
for i in range(env._max_episode_steps*100):
assert env.observation_space.contains(ob)
a = agent(ob)
assert env.action_space.contains(a)
(ob, _reward, done, _info) = env.step(a)
# plt.imshow(env.render(mode = "rgb_array"))
# plt.show()
time.sleep(0.02)
if i % env._max_episode_steps == 0:
ob = env.reset()
env.close()