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.