Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mujoco Rendering for rgb_array that is upside down #1264

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading