def _thunk(): env = gym.make(env_id) env = RandomizedEnvWrapper(env, seed + rank) env.seed(seed + rank) obs_shape = env.observation_space.shape # TODO: is this something we can remove return env
#!/usr/bin/env python import time import numpy as np import gym from tqdm import tqdm import common.envs from common.envs.wrappers import RandomizedEnvWrapper env = gym.make('Pusher3DOFRandomized-v0') env = RandomizedEnvWrapper(env=env, seed=0) # env.randomize() actions = [ np.array([0.0, 0.0, 1.0]), np.array([0.0, 0.0, -1.0]), np.array([0.0, 1.0, 0.0]), np.array([0.0, -1.0, 0.0]), np.array([1.0, 0.0, 0.0]), np.array([-1.0, 0.0, 0.0]) ] actions.reverse() action_change_freq = 50 for env_idx in tqdm(range(10)): env.reset() env.render() for action in actions:
# /usr/bin/env python import time import gym import common.envs from common.envs.wrappers import RandomizedEnvWrapper env = gym.make('HumanoidRandomizedEnv-v0') env = RandomizedEnvWrapper(env=env, seed=0) reward = 0. env.randomize(randomized_values=[ "random", "random", "random", "random", "random", "random" ]) env.reset() env.render() d = False while True: s_, r, d, info = env.step(env.action_space.sample()) time.sleep(0.1) if d: env.randomize(randomized_values=[ "random", "random", "random", "random", "random", "random" ]) env.reset() env.render()
from common.envs.wrappers import RandomizedEnvWrapper # MODE = "MANUAL" # slow but let's you see what's happening MODE = "SPEED" # as fast as possible def no_op(x): pass if MODE == "MANUAL": env = gym.make("ErgoReacherRandomized-Graphical-v0") # looks nice timer = time.sleep else: env = gym.make("ErgoReacherRandomized-Headless-v0") # runs fast timer = no_op env = RandomizedEnvWrapper(env=env, seed=0) for _ in tqdm(range(100)): env.reset() env.randomize(randomized_values=["random"] * 8) # 8 values to randomize over while True: action = env.action_space.sample() obs, rew, done, misc = env.step(action) timer(0.05) if done: break
# manual """ This script allows you to manually control the simulator or Duckiebot using the keyboard arrows. """ import sys from pynput import keyboard from pynput.keyboard import Key import numpy as np import gym import common.envs from common.envs.wrappers import RandomizedEnvWrapper env = gym.make("ErgoReacher4DOFRandomizedHardVisual-v0") env = RandomizedEnvWrapper(env=env, seed=0) env.reset() env.render() ACTION_KEYS = [ Key.up, Key.down, Key.page_up, Key.page_down, Key.right, Key.left, Key.home, Key.end, Key.alt ] def on_press(key): if key == Key.tab: env.reset() if key in ACTION_KEYS: action = np.zeros(4) if key != Key.alt:
import time from timeit import default_timer as timer import numpy as np import tqdm import gym import common.envs from common.envs.wrappers import RandomizedEnvWrapper np.random.seed(1234) env = gym.make('PusherRandomized-v0') env = RandomizedEnvWrapper(env=env, seed=0) obs = env.reset() start = timer() for i in tqdm.tqdm(range(int(1e6))): env.randomize(randomized_values=["random", "random", "random"]) print(timer() - start)
# manual """ This script allows you to manually control the simulator or Duckiebot using the keyboard arrows. """ import sys from pynput import keyboard from pynput.keyboard import Key import numpy as np import gym import common.envs from common.envs.wrappers import RandomizedEnvWrapper env = gym.make('Pusher3DOFUberHard-v0') env = RandomizedEnvWrapper(env=env, seed=0) reward = 0. print('hi') env.randomize(randomized_values=["random", "random"]) env.reset() env.render() ACTIONS = [ np.array([0.0, 0.0, 1.0]), np.array([0.0, 0.0, -1.0]), np.array([0.0, 1.0, 0.0]), np.array([0.0, -1.0, 0.0]), np.array([1.0, 0.0, 0.0]), np.array([-1.0, 0.0, 0.0])
import time from timeit import default_timer as timer import numpy as np import tqdm import gym import common.envs from common.envs.wrappers import RandomizedEnvWrapper np.random.seed(1234) env = gym.make('Pusher3DOFRandomized-v0') env = RandomizedEnvWrapper(env=env, seed=0) # obs = env.reset() start = timer() for i in tqdm.tqdm(range(100)): env.randomize(randomized_values=["random", "random", "random"]) env.reset() for _ in range(200): obs, reward, done, _ = env.step(env.action_space.sample()) env.render() print(obs) env.close() print(timer() - start)
#!/usr/bin/env python import time import numpy as np import gym from tqdm import tqdm import common.envs from common.envs.wrappers import RandomizedEnvWrapper env = gym.make('Pusher3DOFRandomized-v0') env = RandomizedEnvWrapper(env=env, seed=0) # env.randomize() actions = [ np.array([0.0, 0.0, 1.0]), np.array([0.0, 0.0, -1.0]), np.array([0.0, 1.0, 0.0]), np.array([0.0, -1.0, 0.0]), np.array([1.0, 0.0, 0.0]), np.array([-1.0, 0.0, 0.0]) ] actions.reverse() discretization = 50 randomized_values = ["default", "default"] values = np.linspace(0, 1, discretization) for dim in range(2): for i in tqdm(range(discretization)): rands = randomized_values