-
-
Notifications
You must be signed in to change notification settings - Fork 839
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
Refactor Mujoco Rendering and bump to Mujoco 2.3.0 #112
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 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this function still exist if we are using the default_camera_config
parameter
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment explaining this function
3b40f57
to
02efb37
Compare
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 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.gym
repository. Only oneglfw
context 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 usesglfw
as the opengl backend, if the environment variable isMUJOCO_GL=glfw
, not foregl
orosmesa
which 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-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)