environment_wrappers

mock_env

class MockEnv(state_space=None, obs_space=None, act_space=None, init_space=None, task=None)[source]

Bases: SimEnv

A mock version of SimEnv, used in env wrapper tests. State, observation, action, and init spaces as well as the task are passed to the constructor. The step() method saves the last action into the last_act attribute. The action value is converted to a list to ease assertions. step() and reset() return next_obs as observation. If it is None, a random vector is returned.

Constructor

Parameters:
  • dt – integration step size in seconds, default value is used for for one-step environments

  • max_steps – max number of simulation time steps

property act_space

Get the space of the actions.

property domain_param: dict

Get the environment’s domain parameters. If there are none, this method should return an emtpy dict. The domain parameters are synonymous to the parameters used by the simulator to run the physics simulation (e.g., masses, extents, or friction coefficients). This must include all parameters that can be randomized, but there might also be additional parameters that depend on the domain parameters.

get_nominal_domain_param()[source]

Get the nominal a.k.a. default domain parameters.

Note

This function is used to check which domain parameters exist.

property init_space

Get the initial state space.

property obs_space

Get the space of the observations (agent’s perception of the environment).

render(mode=RenderMode(text=False, video=False, render=False), render_step=1)[source]

Visualize one time step of the simulation. The base version prints to console when the state exceeds its boundaries.

Parameters:
  • mode – render mode: console, video, or both

  • render_step – interval for rendering

reset(init_state=None, domain_param=None)[source]

Reset the environment to its initial state and optionally set different domain parameters.

Parameters:
  • init_state – set explicit initial state if not None. Must match init_space if any.

  • domain_param – set explicit domain parameters if not None

Return obs:

initial observation of the state.

property state_space

Get the space of the states (used for describing the environment).

step(act: ndarray) tuple[source]

Perform one time step of the simulation or on the real-world device. When a terminal condition is met, the reset function is called.

Note

This function is responsible for limiting the actions, i.e. has to call limit_act().

Parameters:

act – action to be taken in the step

Return obs:

current observation of the environment

Return reward:

reward depending on the selected reward function

Return done:

indicates whether the episode has ended

Return env_info:

contains diagnostic information about the environment

property task

Get the task describing what the agent should do in the environment.

test_action_delay

test_act_delay()[source]
test_domain_param()[source]
test_no_delay()[source]
test_reset()[source]

test_action_discrete

test_action_space_eles(num_bins: int)[source]
test_five_bins()[source]
test_one_bin()[source]
test_two_bins()[source]

test_action_downsampling

test_act_downsampling()[source]
test_combination_delay_downsampling()[source]

After delay number of actions, the actions are downsampled by the factor

test_combination_downsampling_delay()[source]
test_domain_param()[source]
test_no_downsampling()[source]
test_reset()[source]

test_action_noise

test_act_noise_simple(env: SimEnv)[source]
test_order_act_noise_act_norm(env: SimEnv)[source]

test_action_normalization

test_denormalization()[source]
test_space()[source]

test_combination

test_combination(env: SimEnv)[source]
test_combination_wrappers_domain_params(env: SimEnv)[source]
test_wrap_like_other_env(env: SimEnv)[source]

test_domain_param_transformation

test_domain_param_transforms(env: SimEnv, trafo_class: Type)[source]

test_domain_randomization

test_dr_wrapper_buffer_bob(env: SimEnv, selection: str)[source]
test_dr_wrapper_live_bob(env)[source]

test_observation_normalization

mock_obs_space()[source]
test_denormalization(mock_obs_space)[source]
test_space(mock_obs_space)[source]

test_observation_partial

test_mask_from_indices()[source]
test_mask_from_labels()[source]
test_mask_invert()[source]
test_spaces()[source]
test_values()[source]

test_observation_velfilt

test_velocity_filter(plot: bool)[source]

Module contents