facebookresearch / mbrl-lib

Library for Model Based RL
MIT License
952 stars 154 forks source link

[Bug] `cartpole_continuous` errors when using `render_mode='human'` #185

Open StephenWelch opened 1 year ago

StephenWelch commented 1 year ago

Steps to reproduce

  1. Run the PETS Example with render_mode='human'

Observed Results

The environment errors on the first call to reset() with the following stacktrace:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[2], line 3
      1 seed = 0
      2 env = cartpole_env.CartPoleEnv(render_mode="human")
----> 3 env.reset(seed)
      4 rng = np.random.default_rng(seed=0)
      5 generator = torch.Generator(device=device)

File ~/code/research/mbrl-lib/mbrl/env/cartpole_continuous.py:124, in CartPoleEnv.reset(self, seed)
    122 self.steps_beyond_terminated = None
    123 if self.render_mode == "human":
--> 124     self.render()
    125 return np.array(self.state), {}

File ~/code/research/mbrl-lib/mbrl/env/cartpole_continuous.py:216, in CartPoleEnv.render(self)
    214 if self.render_mode == "human":
    215     pygame.event.pump()
--> 216     self.clock.tick(self.metadata["render_fps"])
    217     pygame.display.flip()
    219 elif self.render_mode == "rgb_array":

KeyError: 'render_fps'

The pygame window opens but displays nothing.

Expected Results

The environment should display in a window.

Relevant Code

In the PETS Example notebook:

env = cartpole_env.CartPoleEnv(render_mode="human")