diff --git a/gymnasium/envs/mujoco/mujoco_rendering.py b/gymnasium/envs/mujoco/mujoco_rendering.py index e1ffe3abb..26f2806f0 100644 --- a/gymnasium/envs/mujoco/mujoco_rendering.py +++ b/gymnasium/envs/mujoco/mujoco_rendering.py @@ -702,6 +702,10 @@ def render( Returns: If render_mode is "rgb_array" or "depth_array" it returns a numpy array in the specified format. "human" render mode does not return anything. """ + if render_mode != "human": + assert ( + self.width is not None and self.height is not None + ), f"The width: {self.width} and height: {self.height} cannot be `None` when the render_mode is not `human`." viewer = self._get_viewer(render_mode=render_mode)