From a32343807f19acfef0e50f52784d661e696593a7 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sat, 10 Feb 2024 14:11:54 +0100 Subject: [PATCH] Only do auto-rendering for render_mode = human (https://gymnasium.farama.org/api/env/#gymnasium.Env.render) --- fancy_gym/envs/mujoco/ant_jump/ant_jump.py | 2 +- fancy_gym/envs/mujoco/beerpong/beerpong.py | 2 +- fancy_gym/envs/mujoco/box_pushing/box_pushing_env.py | 2 +- fancy_gym/envs/mujoco/half_cheetah_jump/half_cheetah_jump.py | 2 +- fancy_gym/envs/mujoco/hopper_jump/hopper_jump.py | 2 +- fancy_gym/envs/mujoco/hopper_jump/hopper_jump_on_box.py | 2 +- fancy_gym/envs/mujoco/hopper_throw/hopper_throw.py | 2 +- fancy_gym/envs/mujoco/hopper_throw/hopper_throw_in_basket.py | 2 +- fancy_gym/envs/mujoco/reacher/reacher.py | 2 +- fancy_gym/envs/mujoco/table_tennis/table_tennis_env.py | 2 +- fancy_gym/envs/mujoco/walker_2d_jump/walker_2d_jump.py | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fancy_gym/envs/mujoco/ant_jump/ant_jump.py b/fancy_gym/envs/mujoco/ant_jump/ant_jump.py index bcf78bf..f89e0dd 100644 --- a/fancy_gym/envs/mujoco/ant_jump/ant_jump.py +++ b/fancy_gym/envs/mujoco/ant_jump/ant_jump.py @@ -154,7 +154,7 @@ class AntJumpEnv(AntEnvCustomXML): } truncated = False - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return obs, reward, terminated, truncated, info diff --git a/fancy_gym/envs/mujoco/beerpong/beerpong.py b/fancy_gym/envs/mujoco/beerpong/beerpong.py index e8bab4c..e3af3fc 100644 --- a/fancy_gym/envs/mujoco/beerpong/beerpong.py +++ b/fancy_gym/envs/mujoco/beerpong/beerpong.py @@ -170,7 +170,7 @@ class BeerPongEnv(MujocoEnv, utils.EzPickle): truncated = False - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return ob, reward, terminated, truncated, infos diff --git a/fancy_gym/envs/mujoco/box_pushing/box_pushing_env.py b/fancy_gym/envs/mujoco/box_pushing/box_pushing_env.py index 225bccf..1c292dc 100644 --- a/fancy_gym/envs/mujoco/box_pushing/box_pushing_env.py +++ b/fancy_gym/envs/mujoco/box_pushing/box_pushing_env.py @@ -110,7 +110,7 @@ class BoxPushingEnvBase(MujocoEnv, utils.EzPickle): terminated = episode_end and infos['is_success'] truncated = episode_end and not infos['is_success'] - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return obs, reward, terminated, truncated, infos diff --git a/fancy_gym/envs/mujoco/half_cheetah_jump/half_cheetah_jump.py b/fancy_gym/envs/mujoco/half_cheetah_jump/half_cheetah_jump.py index 20c2a2c..24d855d 100644 --- a/fancy_gym/envs/mujoco/half_cheetah_jump/half_cheetah_jump.py +++ b/fancy_gym/envs/mujoco/half_cheetah_jump/half_cheetah_jump.py @@ -124,7 +124,7 @@ class HalfCheetahJumpEnv(HalfCheetahEnvCustomXML): 'max_height': self.max_height } - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return observation, reward, terminated, truncated, info diff --git a/fancy_gym/envs/mujoco/hopper_jump/hopper_jump.py b/fancy_gym/envs/mujoco/hopper_jump/hopper_jump.py index 7dee724..e866d7a 100644 --- a/fancy_gym/envs/mujoco/hopper_jump/hopper_jump.py +++ b/fancy_gym/envs/mujoco/hopper_jump/hopper_jump.py @@ -208,7 +208,7 @@ class HopperJumpEnv(HopperEnvCustomXML): contact_dist=self.contact_dist or 0 ) - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return observation, reward, terminated, truncated, info diff --git a/fancy_gym/envs/mujoco/hopper_jump/hopper_jump_on_box.py b/fancy_gym/envs/mujoco/hopper_jump/hopper_jump_on_box.py index c1a5123..b56840b 100644 --- a/fancy_gym/envs/mujoco/hopper_jump/hopper_jump_on_box.py +++ b/fancy_gym/envs/mujoco/hopper_jump/hopper_jump_on_box.py @@ -140,7 +140,7 @@ class HopperJumpOnBoxEnv(HopperEnvCustomXML): truncated = self.current_step >= self.max_episode_steps and not terminated - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return observation, reward, terminated, truncated, info diff --git a/fancy_gym/envs/mujoco/hopper_throw/hopper_throw.py b/fancy_gym/envs/mujoco/hopper_throw/hopper_throw.py index ac31b09..bf9169e 100644 --- a/fancy_gym/envs/mujoco/hopper_throw/hopper_throw.py +++ b/fancy_gym/envs/mujoco/hopper_throw/hopper_throw.py @@ -96,7 +96,7 @@ class HopperThrowEnv(HopperEnvCustomXML): } truncated = False - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return observation, reward, terminated, truncated, info diff --git a/fancy_gym/envs/mujoco/hopper_throw/hopper_throw_in_basket.py b/fancy_gym/envs/mujoco/hopper_throw/hopper_throw_in_basket.py index aefb5ff..56bbbec 100644 --- a/fancy_gym/envs/mujoco/hopper_throw/hopper_throw_in_basket.py +++ b/fancy_gym/envs/mujoco/hopper_throw/hopper_throw_in_basket.py @@ -119,7 +119,7 @@ class HopperThrowInBasketEnv(HopperEnvCustomXML): } truncated = False - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return observation, reward, terminated, truncated, info diff --git a/fancy_gym/envs/mujoco/reacher/reacher.py b/fancy_gym/envs/mujoco/reacher/reacher.py index 99dc44f..f3901a6 100644 --- a/fancy_gym/envs/mujoco/reacher/reacher.py +++ b/fancy_gym/envs/mujoco/reacher/reacher.py @@ -79,7 +79,7 @@ class ReacherEnv(MujocoEnv, utils.EzPickle): goal=self.goal if hasattr(self, "goal") else None ) - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return ob, reward, terminated, truncated, info diff --git a/fancy_gym/envs/mujoco/table_tennis/table_tennis_env.py b/fancy_gym/envs/mujoco/table_tennis/table_tennis_env.py index c48c7b6..5c976e3 100644 --- a/fancy_gym/envs/mujoco/table_tennis/table_tennis_env.py +++ b/fancy_gym/envs/mujoco/table_tennis/table_tennis_env.py @@ -160,7 +160,7 @@ class TableTennisEnv(MujocoEnv, utils.EzPickle): terminated, truncated = self._terminated, False - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return self._get_obs(), reward, terminated, truncated, info diff --git a/fancy_gym/envs/mujoco/walker_2d_jump/walker_2d_jump.py b/fancy_gym/envs/mujoco/walker_2d_jump/walker_2d_jump.py index a95779f..54ab00e 100644 --- a/fancy_gym/envs/mujoco/walker_2d_jump/walker_2d_jump.py +++ b/fancy_gym/envs/mujoco/walker_2d_jump/walker_2d_jump.py @@ -147,7 +147,7 @@ class Walker2dJumpEnv(Walker2dEnvCustomXML): } truncated = False - if self.render_active: + if self.render_active and self.render_mode=='human': self.render() return observation, reward, terminated, truncated, info