-
-
Notifications
You must be signed in to change notification settings - Fork 808
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
Add mujoco rgbd rendering #1229
Add mujoco rgbd rendering #1229
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me other than the comment.
@Kallinteris-Andreas could you review as well
@pseudo-rnd-thoughts |
I can't from my phone but will be home in an hour or so and can do then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
need to update the index page (https://gymnasium.farama.org/environments/mujoco/ ) to document the available
render_mode
s -
add a test in
test_mujoco_rendering.py
namedtest_rgbd_array
, where we assert the output oftest_rgbd_array
is a proper combination ofrgb_array
anddepth_array
-
I am not convinced that the correct output format is a tuple of
(rgb_image, depth_image)
while it is the most human-readable format, it is not ideal for CNNs and would require an additionalrenderWrapper
(for the cases where it used asaddRenderObservation
wrapper)
edit: RGB-D CNNs do not appear to be "mature", see "RGB-D Object Recognition Using Deep Convolutional Neural Networks" as an example the data is preprocessed anyway, so long as the decision is done intentionally, I am fine with the current choice. @DavidPL1 you may be more familiar with depth CNNs what is your oppinon
Thanks
@@ -281,6 +281,10 @@ def render( | |||
seg_ids[geom.segid + 1, 1] = geom.objid | |||
rgb_img = seg_ids[seg_img] | |||
|
|||
if render_mode == "rgbd_array": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section (L259-L289) was not written to support 3 render types, it should be re-written to be clearer, into 2 stages, first stage collects the images, and the second stage returns the correct images.
if render_mode in ["depth_array", "rgbd_array"]:
depth_img = depth_arr.reshape(self.viewport.height, self.viewport.width)
if render_mode in ["rgb_array", "rgbd_array"]:
rgb_img = ...
if render_mode == "rgb_array":
return ...
elif render_mode == "depth_array":
return ...
elif render_mode == "rgbd_array":
return ...
Will do after we settle on the type
I'm am also not too familiar with RGB-D CNNs myself. After a quick read on the topic, researchers seem to perform all kinds of processing steps for alternative representations (voxels, pointclouds, ...). Usually RGB-D cameras provide access to two separate streams and datasets also provide the modalities separated. I opted for a tuple because I thought it achieves the same thing as the rendering twice alternative (which I have already seen), returning the same types as the individual images. Also I'm using an existing Wrapper combining the two images into a point cloud. |
The A tuple of rgb and depth should be fine, as it is easily convertible to all other formats Naming should perhaps be |
judging by the function calls of e.g. rgbd::warpFrame taking both as separate inputs, OpenCV seems to also store image and depth separately. Then I'll stick with the tuple implementation. |
|
@pseudo-rnd-thoughts All I want from you is to tell us if you are okay with the name of the new |
See a72f44d or do you want to add something more to the test? |
|
||
def test_rgbd_tuple(): | ||
"""Assert that rgbd_tuple is the proper combination of rgb and depth images as tuple""" | ||
env = gymnasium.make("Ant-v5", camera_id=0, render_mode="rgbd_tuple").unwrapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
render once with rgb_array
and depth_array
and assert that the resulting images are the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rgbd_tuple
sounds good to me.
Description
Adds a new
render_mode
to MuJoCo environments for when rgb and depth images are required as observations, e.g. to create point clouds.Fixes #1226
Type of change
Please delete options that are not relevant.
Checklist:
pre-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)Open Questions