pixel_observation#
Classes#
- class prt_rl.env.adapters.pixel_observation.PixelObservationAdapter(env: EnvironmentInterface, pixel_type: Literal['uint8', 'float32'] = 'uint8')[source]#
Adapater takes the ‘rgb_array’ pixels from the info dictionary and makes that the observation. The original observation is added back into the info dictionary under the ‘state’ key.
Assumes pixel observation are [H, W, C] numpy arrays of type uint8 and converts to [C, H, W] torch tensors normalized to [0, 1]. Note: This adapter assumes the base environment has render_mode set to “rgb_array”.
- Parameters:
env (EnvironmentInterface) – The environment to adapt
- get_num_envs() int#
Returns the number of environments in the interface.
- Returns:
Number of environments
- Return type:
- get_parameters()#
Returns the EnvParams object which contains information about the sizes of observations and actions needed for setting up RL agents.
- Returns:
environment parameters object
- Return type:
- reset(*args, **kwargs)#
Resets the environment to the initial state and returns the initial observation.
- Parameters:
seed (int | None) – Sets the random seed.
- Returns:
Tuple of tensors containing the initial observation and info dictionary
- Return type:
Tuple
- step(action)#
Steps the simulation using the action tensor and returns the new trajectory.
- Parameters:
action (torch.Tensor) – Tensor with “action” key that is a tensor with shape (# env, # actions)
- Returns:
Tuple of tensors containing the next state, reward, done, and info dictionary
- Return type:
Tuple