VPG playing CarRacing-v0 from https://github.com/sgoodfriend/rl-algo-impls/tree/e8bc541d8b5e67bb4d3f2075282463fb61f5f2c6
6b1b740
import gym | |
import gym.spaces.dict | |
import numpy as np | |
from gym import ObservationWrapper | |
class GetRgbObservation(ObservationWrapper): | |
def __init__(self, env) -> None: | |
super().__init__(env) | |
assert isinstance(env.observation_space, gym.spaces.dict.Dict) | |
self.observation_space = env.observation_space["rgb"] # type: ignore | |
if getattr(env, "is_vector_env"): | |
self.single_observation_space = env.single_observation_space["rgb"] # type: ignore | |
def observation(self, observation: gym.spaces.dict.Dict) -> np.ndarray: | |
return observation["rgb"] # type: ignore | |