garage.envs.metaworld_set_task_env
¶
Environment that wraps a MetaWorld benchmark in the set_task interface.
-
class
MetaWorldSetTaskEnv
(benchmark=None, kind=None, wrapper=None, add_env_onehot=False)¶ Bases:
garage._environment.Environment
Environment form of a MetaWorld benchmark.
This class is generally less efficient than using a TaskSampler, if that can be used instead, since each instance of this class internally caches a copy of each environment in the benchmark.
In order to sample tasks from this environment, a benchmark must be passed at construction time.
- Parameters
benchmark (metaworld.Benchmark or None) – The benchmark to wrap.
wrapper (Callable[garage.Env, garage.Env] or None) – Wrapper to apply to env instances.
add_env_onehot (bool) – If true, a one-hot representing the current environment name will be added to the environments. Should only be used with multi-task benchmarks.
- Raises
ValueError – If kind is not ‘train’, ‘test’, or None. Also raisd if add_env_onehot is used on a metaworld meta learning (not multi-task) benchmark.
-
property
num_tasks
(self)¶ int: Returns number of tasks.
Part of the set_task environment protocol.
-
sample_tasks
(self, n_tasks)¶ Samples n_tasks tasks.
Part of the set_task environment protocol. To call this method, a benchmark must have been passed in at environment construction.
-
set_task
(self, task)¶ Set the task.
Part of the set_task environment protocol.
-
property
action_space
(self)¶ akro.Space: The action space specification.
-
property
observation_space
(self)¶ akro.Space: The observation space specification.
-
property
spec
(self)¶ EnvSpec: The envionrment specification.
-
property
render_modes
(self)¶ list: A list of string representing the supported render modes.
-
step
(self, action)¶ Step the wrapped env.
- Parameters
action (np.ndarray) – An action provided by the agent.
- Returns
The environment step resulting from the action.
- Return type
-
reset
(self)¶ Reset the wrapped env.
- Returns
- The first observation conforming to
observation_space.
- dict: The episode-level information.
Note that this is not part of env_info provided in step(). It contains information of he entire episode, which could be needed to determine the first action (e.g. in the case of goal-conditioned or MTRL.)
- Return type
numpy.ndarray
-
render
(self, mode)¶ Render the wrapped environment.
-
visualize
(self)¶ Creates a visualization of the wrapped environment.
-
close
(self)¶ Close the wrapped env.