harl.envs package

Submodules

harl.envs.env_wrappers module

Modified from OpenAI Baselines code to work with multi-agent envs

class harl.envs.env_wrappers.CloudpickleWrapper(x)[source]

Bases: object

Uses cloudpickle to serialize contents (otherwise multiprocessing tries to use pickle)

class harl.envs.env_wrappers.ShareDummyVecEnv(env_fns)[source]

Bases: ShareVecEnv

close()[source]
render(mode='human')[source]
reset()[source]

Reset all the environments and return an array of observations, or a dict of observation arrays.

If step_async is still doing work, that work will be cancelled and step_wait() should not be called until step_async() is invoked again.

step_async(actions)[source]

Tell all the environments to start taking a step with the given actions. Call step_wait() to get the results of the step.

You should not call this if a step_async run is already pending.

step_wait()[source]

Wait for the step taken with step_async().

Returns (obs, rews, dones, infos):
  • obs: an array of observations, or a dict of

    arrays of observations.

  • rews: an array of rewards

  • dones: an array of “episode done” booleans

  • infos: a sequence of info objects

class harl.envs.env_wrappers.ShareSubprocVecEnv(env_fns, spaces=None)[source]

Bases: ShareVecEnv

close()[source]
reset()[source]

Reset all the environments and return an array of observations, or a dict of observation arrays.

If step_async is still doing work, that work will be cancelled and step_wait() should not be called until step_async() is invoked again.

reset_task()[source]
step_async(actions)[source]

Tell all the environments to start taking a step with the given actions. Call step_wait() to get the results of the step.

You should not call this if a step_async run is already pending.

step_wait()[source]

Wait for the step taken with step_async().

Returns (obs, rews, dones, infos):
  • obs: an array of observations, or a dict of

    arrays of observations.

  • rews: an array of rewards

  • dones: an array of “episode done” booleans

  • infos: a sequence of info objects

class harl.envs.env_wrappers.ShareVecEnv(num_envs, observation_space, share_observation_space, action_space)[source]

Bases: ABC

An abstract asynchronous, vectorized environment. Used to batch data from multiple copies of an environment, so that each observation becomes an batch of observations, and expected action is a batch of actions to be applied per-environment.

close()[source]
close_extras()[source]

Clean up the extra resources, beyond what’s in this base class. Only runs when not self.closed.

closed = False
get_images()[source]

Return RGB images from each environment

get_viewer()[source]
metadata = {'render.modes': ['human', 'rgb_array']}
render(mode='human')[source]
abstract reset()[source]

Reset all the environments and return an array of observations, or a dict of observation arrays.

If step_async is still doing work, that work will be cancelled and step_wait() should not be called until step_async() is invoked again.

step(actions)[source]

Step the environments synchronously.

This is available for backwards compatibility.

abstract step_async(actions)[source]

Tell all the environments to start taking a step with the given actions. Call step_wait() to get the results of the step.

You should not call this if a step_async run is already pending.

abstract step_wait()[source]

Wait for the step taken with step_async().

Returns (obs, rews, dones, infos):
  • obs: an array of observations, or a dict of

    arrays of observations.

  • rews: an array of rewards

  • dones: an array of “episode done” booleans

  • infos: a sequence of info objects

property unwrapped
viewer = None
harl.envs.env_wrappers.shareworker(remote, parent_remote, env_fn_wrapper)[source]
harl.envs.env_wrappers.tile_images(img_nhwc)[source]
Tile N images into one big PxQ image

(P,Q) are chosen to be as close as possible, and if N is square, then P=Q.

input: img_nhwc, list or array of images, ndim=4 once turned into array

n = batch index, h = height, w = width, c = channel

Returns:

bigim_HWc, ndarray with ndim=3

Module contents