Skip to content

Commit

Permalink
Specify the camera of depth_array (openai#1960)
Browse files Browse the repository at this point in the history
* specify the camera of depth_array

* exclude human
  • Loading branch information
ryota-mo authored Jun 19, 2020
1 parent 5be0f52 commit e02ed92
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gym/envs/mujoco/mujoco_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def render(self,
height=DEFAULT_SIZE,
camera_id=None,
camera_name=None):
if mode == 'rgb_array':
if mode == 'rgb_array' or mode == 'depth_array':
if camera_id is not None and camera_name is not None:
raise ValueError("Both `camera_id` and `camera_name` cannot be"
" specified at the same time.")
Expand All @@ -143,6 +143,8 @@ def render(self,
camera_id = self.model.camera_name2id(camera_name)

self._get_viewer(mode).render(width, height, camera_id=camera_id)

if mode == 'rgb_array':
# window size used for old mujoco-py:
data = self._get_viewer(mode).read_pixels(width, height, depth=False)
# original image is upside-down, so flip it
Expand Down

0 comments on commit e02ed92

Please sign in to comment.