Refactor Mujoco Rendering and bump to Mujoco 2.3.0#112
Conversation
|
Hey @tudorjnu. Will this PR fix your issue in openai/gym#2989? I've used it to render an rgb_array camera sensor at the same time I debug with |
pseudo-rnd-thoughts
left a comment
There was a problem hiding this comment.
As this PR solves the issue that you note
Im uncertain on removing viewer_setup as this prevents generic environment implementations however I think this is not a great issue.
Otherwise I can spot minimal issues
| self.viewer = None | ||
| self._viewers = {} | ||
|
|
||
| def viewer_setup(self): |
There was a problem hiding this comment.
Why does this function still exist if we are using the default_camera_config parameter
There was a problem hiding this comment.
This function only concerns the mujoco environments that depend on mujoco_py which are not maintained.
| def __del__(self): | ||
| self.free() | ||
|
|
||
| def render(self): |
There was a problem hiding this comment.
Could you add a comment explaining this function
3b40f57 to
02efb37
Compare
pseudo-rnd-thoughts
left a comment
There was a problem hiding this comment.
This is a complex PR that I can't follow all the way through but if you are happy with it, Im happy to merge
|
Hello @rodrigodelazcano! Thank you for the PR. Unfortunately, it seems like it did not fix the problem. Firstly, it seems that the renderer can render a single camera at a time given the current implementation. I manage to get away with it by redefining the def render(
self,
render_mode: str = None,
camera_id: int = None,
camera_name: str = None
):
if render_mode is None:
render_mode = self.render_mode
if camera_id is None:
camera_id = self.camera_id
if camera_name is None:
camera_name = self.camera_name
return self.mujoco_renderer.render(
render_mode, camera_id, camera_name
)Still, rendering the "rgb_array" and "human" at the same time is not possible at this moment. However, I think that allowing the user to change the rendering values as above offers more versatility. Whilst it does not work with the |
|
Hey @tudorjnu, thank you for replying back. What is your use case? The purpose of the However, if you want to add images to your observations from other cameras you can still do that. You can call Also, are you using the |
|
Hello @rodrigodelazcano! Thanks for the prompt answer. Indeed, it seems to work in the way you mentioned. Massive thanks for that! 😁 I thought I tried to render an image that way but it seems I did not! Cheers for your help! Also, what would be the easiest way to access individual camera information (e.g. extracting segmentation masks from the camera)? |
Description
This PR refactors the mujoco rendering:
MujocoRenderer. This class abstracts the viewer (offscreen or window) selection depending on the render_mode.gymrepository. Only oneglfwcontext can be made current in the main thread. The Offscreen and Window renders switch their context current status. Also note that this only works if the Offscreen renderer usesglfwas the opengl backend, if the environment variable isMUJOCO_GL=glfw, not foreglorosmesawhich are usually used for headless rendering (no "human" rendering permitted either way).New additions:
Please delete options that are not relevant.
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist:
pre-commitchecks withpre-commit run --all-files(seeCONTRIBUTING.mdinstructions to set it up)