diff --git a/gym/envs/mujoco/ant.py b/gym/envs/mujoco/ant.py index 02c521d0844..866225b1b97 100644 --- a/gym/envs/mujoco/ant.py +++ b/gym/envs/mujoco/ant.py @@ -129,4 +129,7 @@ def reset_model(self): def viewer_setup(self): for key, value in DEFAULT_CAMERA_CONFIG.items(): - setattr(self.viewer.cam, key, value) + if isinstance(value, np.ndarray): + getattr(self.viewer.cam, key)[:] = value + else: + setattr(self.viewer.cam, key, value) diff --git a/gym/envs/mujoco/half_cheetah.py b/gym/envs/mujoco/half_cheetah.py index 22882ada925..0be8115976b 100644 --- a/gym/envs/mujoco/half_cheetah.py +++ b/gym/envs/mujoco/half_cheetah.py @@ -81,4 +81,7 @@ def reset_model(self): def viewer_setup(self): for key, value in DEFAULT_CAMERA_CONFIG.items(): - setattr(self.viewer.cam, key, value) + if isinstance(value, np.ndarray): + getattr(self.viewer.cam, key)[:] = value + else: + setattr(self.viewer.cam, key, value) diff --git a/gym/envs/mujoco/hopper.py b/gym/envs/mujoco/hopper.py index 4c0bd2433f1..9c6836b24ec 100644 --- a/gym/envs/mujoco/hopper.py +++ b/gym/envs/mujoco/hopper.py @@ -130,4 +130,7 @@ def reset_model(self): def viewer_setup(self): for key, value in DEFAULT_CAMERA_CONFIG.items(): - setattr(self.viewer.cam, key, value) + if isinstance(value, np.ndarray): + getattr(self.viewer.cam, key)[:] = value + else: + setattr(self.viewer.cam, key, value) diff --git a/gym/envs/mujoco/humanoid.py b/gym/envs/mujoco/humanoid.py index 033ab56eb6c..7a53b9ebda1 100644 --- a/gym/envs/mujoco/humanoid.py +++ b/gym/envs/mujoco/humanoid.py @@ -146,4 +146,7 @@ def reset_model(self): def viewer_setup(self): for key, value in DEFAULT_CAMERA_CONFIG.items(): - setattr(self.viewer.cam, key, value) + if isinstance(value, np.ndarray): + getattr(self.viewer.cam, key)[:] = value + else: + setattr(self.viewer.cam, key, value) diff --git a/gym/envs/mujoco/swimmer.py b/gym/envs/mujoco/swimmer.py index f20aeb70a12..4c7f37d003b 100644 --- a/gym/envs/mujoco/swimmer.py +++ b/gym/envs/mujoco/swimmer.py @@ -3,6 +3,9 @@ from gym import utils +DEFAULT_CAMERA_CONFIG = {} + + class SwimmerEnv(mujoco_env.MujocoEnv, utils.EzPickle): def __init__(self, forward_reward_weight=1.0, @@ -75,3 +78,10 @@ def reset_model(self): observation = self._get_obs() return observation + + def viewer_setup(self): + for key, value in DEFAULT_CAMERA_CONFIG.items(): + if isinstance(value, np.ndarray): + getattr(self.viewer.cam, key)[:] = value + else: + setattr(self.viewer.cam, key, value) diff --git a/gym/envs/mujoco/walker2d.py b/gym/envs/mujoco/walker2d.py index a7f949c7609..37ebcd7bf77 100644 --- a/gym/envs/mujoco/walker2d.py +++ b/gym/envs/mujoco/walker2d.py @@ -122,4 +122,7 @@ def reset_model(self): def viewer_setup(self): for key, value in DEFAULT_CAMERA_CONFIG.items(): - setattr(self.viewer.cam, key, value) + if isinstance(value, np.ndarray): + getattr(self.viewer.cam, key)[:] = value + else: + setattr(self.viewer.cam, key, value)