mani_skill.utils.gym_utils#

various gymnasium/gym utilities used in ManiSkill, mostly to handle observation/action spaces and noramlization

Attributes#

Functions#

clip_and_scale_action(action, low, high)

Clip action to [-1, 1] and scale according to a range [low, high].

convert_observation_to_space(observation[, prefix, ...])

Convert observation to OpenAI gym observation space (recursively).

extract_scalars_from_info(info[, blacklist, batch_size])

Recursively extract scalar metrics from an info dict returned by env.step.

find_max_episode_steps_value(env)

Finds the max episode steps parameter given by user or registered in the environment.

get_dtype_bounds(dtype)

Gets the min and max values of a given numpy type

inv_clip_and_scale_action(action, low, high)

Inverse of clip_and_scale_action.

inv_scale_action(action, low, high)

Inverse of clip_and_scale_action without clipping.

normalize_action_space(action_space)

Module Contents#

mani_skill.utils.gym_utils.clip_and_scale_action(action, low, high)[source]#

Clip action to [-1, 1] and scale according to a range [low, high].

mani_skill.utils.gym_utils.convert_observation_to_space(observation, prefix='', unbatched=False)[source]#

Convert observation to OpenAI gym observation space (recursively). Modified from gym.envs.mujoco_env

mani_skill.utils.gym_utils.extract_scalars_from_info(info, blacklist=(), batch_size=1)[source]#

Recursively extract scalar metrics from an info dict returned by env.step.

Parameters:
  • info (dict) – info dict

  • blacklist (tuple, optional) – keys to exclude.

Returns:

scalar metrics

Return type:

dict[str, float]

mani_skill.utils.gym_utils.find_max_episode_steps_value(env)[source]#

Finds the max episode steps parameter given by user or registered in the environment.

This is a useful utility as not all specs may include max episode steps and some wrappers may need access to this in order to implement e.g. TimeLimits correctly on the GPU sim.

mani_skill.utils.gym_utils.get_dtype_bounds(dtype)[source]#

Gets the min and max values of a given numpy type

Parameters:

dtype (numpy.dtype) –

mani_skill.utils.gym_utils.inv_clip_and_scale_action(action, low, high)[source]#

Inverse of clip_and_scale_action.

mani_skill.utils.gym_utils.inv_scale_action(action, low, high)[source]#

Inverse of clip_and_scale_action without clipping.

mani_skill.utils.gym_utils.normalize_action_space(action_space)[source]#
Parameters:

action_space (gymnasium.spaces.Box) –

mani_skill.utils.gym_utils.IS_GYMNASIUM_1 = False[source]#
mani_skill.utils.gym_utils.IS_GYMNASIUM_1 = True[source]#