Skip to content

Commit

Permalink
Fix viewer setup lookat configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
hartikainen committed Feb 9, 2019
1 parent b2a439f commit 62b4bcf
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
5 changes: 4 additions & 1 deletion gym/envs/mujoco/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 4 additions & 1 deletion gym/envs/mujoco/half_cheetah.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 4 additions & 1 deletion gym/envs/mujoco/hopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 4 additions & 1 deletion gym/envs/mujoco/humanoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 10 additions & 0 deletions gym/envs/mujoco/swimmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
5 changes: 4 additions & 1 deletion gym/envs/mujoco/walker2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 62b4bcf

Please sign in to comment.