From ac1e7444cb9e5ddbfb4fc56e76710ecfd3a1c786 Mon Sep 17 00:00:00 2001 From: Mark Towers Date: Thu, 28 Nov 2024 17:07:38 +0000 Subject: [PATCH] Fix Mujoco Rendering for `rgb_array` that is upside down (#1264) --- gymnasium/envs/mujoco/mujoco_rendering.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gymnasium/envs/mujoco/mujoco_rendering.py b/gymnasium/envs/mujoco/mujoco_rendering.py index 44fd34872..d6b888103 100644 --- a/gymnasium/envs/mujoco/mujoco_rendering.py +++ b/gymnasium/envs/mujoco/mujoco_rendering.py @@ -258,11 +258,13 @@ def render( # Process rendered images according to render_mode if render_mode in ["depth_array", "rgbd_tuple"]: - depth_img = depth_arr.reshape(self.viewport.height, self.viewport.width) + depth_img = depth_arr.reshape((self.viewport.height, self.viewport.width)) # original image is upside-down, so flip it depth_img = depth_img[::-1, :] if render_mode in ["rgb_array", "rgbd_tuple"]: - rgb_img = rgb_arr.reshape(self.viewport.height, self.viewport.width, 3) + rgb_img = rgb_arr.reshape((self.viewport.height, self.viewport.width, 3)) + # original image is upside-down, so flip it + rgb_img = rgb_img[::-1, :] if segmentation: seg_img = ( @@ -281,8 +283,6 @@ def render( seg_ids[geom.segid + 1, 0] = geom.objtype seg_ids[geom.segid + 1, 1] = geom.objid rgb_img = seg_ids[seg_img] - # original image is upside-down, so flip it - rgb_img = rgb_img[::-1, :, :] # Return processed images based on render_mode if render_mode == "rgb_array":