common

real_robot.utils.common.clip_and_scale_action(action, new_range, old_range=(-1, 1))[source]

Clip action to old_range and scale according to a new_range. :param action: float or np.ndarray :param new_range: (low, high) or np.ndarray ([:, 0] is low, [:, 1] is high) :param old_range: (low, high) or np.ndarray ([:, 0] is low, [:, 1] is high)

real_robot.utils.common.convert_observation_to_space(observation, prefix='')[source]

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

real_robot.utils.common.flatten_dict_keys(d: dict, prefix='')[source]

Flatten a dict by expanding its keys recursively.

real_robot.utils.common.flatten_dict_space_keys(space: Dict, prefix='') Dict[source]

Flatten a dict of spaces by expanding its keys recursively.

real_robot.utils.common.flatten_state_dict(state_dict: dict) ndarray[source]

Flatten a dictionary containing states recursively.

Parameters:

state_dict – a dictionary containing scalars or 1-dim vectors.

Raises:

AssertionError – If a value of @state_dict is an ndarray with ndim > 2.

Returns:

flattened states.

Return type:

np.ndarray

Notes

The input is recommended to be ordered (e.g. OrderedDict). However, since python 3.7, dictionary order is guaranteed to be insertion order.

real_robot.utils.common.get_dtype_bounds(dtype: dtype)[source]
real_robot.utils.common.merge_dicts(ds: Sequence[dict], asarray=False)[source]

Merge multiple dicts with the same keys to a single one.

real_robot.utils.common.vectorize_pose(pose: Pose) ndarray[source]