Skip to content

Commit

Permalink
Fix Mujoco Rendering for rgb_array that is upside down (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts authored Nov 28, 2024
1 parent 8a46c3a commit ac1e744
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gymnasium/envs/mujoco/mujoco_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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":
Expand Down

0 comments on commit ac1e744

Please sign in to comment.