mirror of
https://github.com/gryf/coach.git
synced 2025-12-18 11:40:18 +01:00
roboschool: updating envs to v1, fixing rendering (#112)
This commit is contained in:
@@ -83,7 +83,7 @@ class GymVectorEnvironment(GymEnvironmentParameters):
|
|||||||
gym_roboschool_envs = ['inverted_pendulum', 'inverted_pendulum_swingup', 'inverted_double_pendulum', 'reacher',
|
gym_roboschool_envs = ['inverted_pendulum', 'inverted_pendulum_swingup', 'inverted_double_pendulum', 'reacher',
|
||||||
'hopper', 'walker2d', 'half_cheetah', 'ant', 'humanoid', 'humanoid_flagrun',
|
'hopper', 'walker2d', 'half_cheetah', 'ant', 'humanoid', 'humanoid_flagrun',
|
||||||
'humanoid_flagrun_harder', 'pong']
|
'humanoid_flagrun_harder', 'pong']
|
||||||
roboschool_v0 = {e: "{}".format(lower_under_to_upper(e) + '-v0') for e in gym_roboschool_envs}
|
roboschool_v1 = {e: "Roboschool{}".format(lower_under_to_upper(e) + '-v1') for e in gym_roboschool_envs}
|
||||||
|
|
||||||
# Mujoco
|
# Mujoco
|
||||||
gym_mujoco_envs = ['inverted_pendulum', 'inverted_double_pendulum', 'reacher', 'hopper', 'walker2d', 'half_cheetah',
|
gym_mujoco_envs = ['inverted_pendulum', 'inverted_double_pendulum', 'reacher', 'hopper', 'walker2d', 'half_cheetah',
|
||||||
@@ -280,6 +280,7 @@ class GymEnvironment(Environment):
|
|||||||
# frame skip and max between consecutive frames
|
# frame skip and max between consecutive frames
|
||||||
self.is_robotics_env = 'robotics' in str(self.env.unwrapped.__class__)
|
self.is_robotics_env = 'robotics' in str(self.env.unwrapped.__class__)
|
||||||
self.is_mujoco_env = 'mujoco' in str(self.env.unwrapped.__class__)
|
self.is_mujoco_env = 'mujoco' in str(self.env.unwrapped.__class__)
|
||||||
|
self.is_roboschool_env = 'roboschool' in str(self.env.unwrapped.__class__)
|
||||||
self.is_atari_env = 'Atari' in str(self.env.unwrapped.__class__)
|
self.is_atari_env = 'Atari' in str(self.env.unwrapped.__class__)
|
||||||
self.timelimit_env_wrapper = self.env
|
self.timelimit_env_wrapper = self.env
|
||||||
if self.is_atari_env:
|
if self.is_atari_env:
|
||||||
@@ -443,8 +444,7 @@ class GymEnvironment(Environment):
|
|||||||
:param camera_idx: The index of the camera to use. Should be defined in the model
|
:param camera_idx: The index of the camera to use. Should be defined in the model
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
if self.env.unwrapped.viewer is not None and self.env.unwrapped.viewer.cam.fixedcamid != camera_idx and\
|
if self.env.unwrapped.viewer is not None and self.env.unwrapped.viewer.cam.fixedcamid != camera_idx:
|
||||||
self.env.unwrapped.viewer._ncam > camera_idx:
|
|
||||||
from mujoco_py.generated import const
|
from mujoco_py.generated import const
|
||||||
self.env.unwrapped.viewer.cam.type = const.CAMERA_FIXED
|
self.env.unwrapped.viewer.cam.type = const.CAMERA_FIXED
|
||||||
self.env.unwrapped.viewer.cam.fixedcamid = camera_idx
|
self.env.unwrapped.viewer.cam.fixedcamid = camera_idx
|
||||||
@@ -458,7 +458,7 @@ class GymEnvironment(Environment):
|
|||||||
def _render(self):
|
def _render(self):
|
||||||
self.env.render(mode='human')
|
self.env.render(mode='human')
|
||||||
# required for setting up a fixed camera for mujoco
|
# required for setting up a fixed camera for mujoco
|
||||||
if self.is_mujoco_env:
|
if self.is_mujoco_env and not self.is_roboschool_env:
|
||||||
self._set_mujoco_camera(0)
|
self._set_mujoco_camera(0)
|
||||||
|
|
||||||
def get_rendered_image(self):
|
def get_rendered_image(self):
|
||||||
@@ -468,7 +468,7 @@ class GymEnvironment(Environment):
|
|||||||
else:
|
else:
|
||||||
image = self.env.render(mode='rgb_array')
|
image = self.env.render(mode='rgb_array')
|
||||||
# required for setting up a fixed camera for mujoco
|
# required for setting up a fixed camera for mujoco
|
||||||
if self.is_mujoco_env:
|
if self.is_mujoco_env and not self.is_roboschool_env:
|
||||||
self._set_mujoco_camera(0)
|
self._set_mujoco_camera(0)
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user