import pytest from metaworld.benchmarks import ML1, MT10, ML10, ML45, MT50 from tests.helpers import step_env @pytest.mark.parametrize('name', ML1.available_tasks()) def test_all_ml1(name): train_env = ML1.get_train_tasks(name) tasks = train_env.sample_tasks(11) for t in tasks: train_env.set_task(t) step_env(train_env, max_path_length=3) train_env.close() del train_env test_env = ML1.get_test_tasks(name) tasks = test_env.sample_tasks(11) for t in tasks: test_env.set_task(t) step_env(test_env, max_path_length=3) test_env.close() del test_env def test_all_ml10(): ml10_train_env = ML10.get_train_tasks() train_tasks = ml10_train_env.sample_tasks(11) for t in train_tasks:
from metaworld.benchmarks import ML1 import time print(ML1.available_tasks()) # Check out the available tasks env = ML1.get_train_tasks( 'pick-place-v1') # Create an environment with task `pick_place` tasks = env.sample_tasks(1) # Sample a task (in this case, a goal variation) env.set_task(tasks[0]) # Set task obs = env.reset() # Reset environment for i in range(1000): print('iteration %d' % (i)) if i % 100 == 0: obs = env.reset() env.render() a = env.action_space.sample() # Sample an action obs, reward, done, info = env.step(a) print(obs) # Step the environoment with the sampled random action time.sleep(0.2)