-
Notifications
You must be signed in to change notification settings - Fork 1
/
render_test.py
25 lines (24 loc) · 944 Bytes
/
render_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
import metaworld
import random
import matplotlib.pyplot as plt
# print(metaworld.ML1.ENV_NAMES) # Check out the available environments
env_name='push-back-v2'
ml1 = metaworld.MT1(env_name) # Construct the benchmark, sampling tasks
env = ml1.train_classes[env_name]() # Create an environment with task `pick_place`
task = random.choice(ml1.train_tasks)
env.set_task(task) # Set task
env._freeze_rand_vec = False
for i in range(10):
obs = env.reset() # Reset environment
print(obs[-3:],env._freeze_rand_vec,env._last_rand_vec)
#image = env.sim.render(1024,1024)[::-1,:,:]
image=env.render( offscreen=True, camera_name="behindGripper", resolution=(640, 480))
plt.figure()
plt.imshow(image)
plt.show()
for i in range(100):
a = env.action_space.sample() # Sample an action
obs, reward, done, info = env.step(a)
image=env.render( offscreen=True, camera_name="behindGripper", resolution=(640, 480))
plt.figure()
plt.imshow(image)