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

How about glfw.window_hint(glfw.VISIBLE, 1) explicitly in the constructor? #47

Open
Qualot opened this issue May 29, 2024 · 0 comments
Open

Comments

@Qualot
Copy link

Qualot commented May 29, 2024

Thank you for the helpful software!

Our team uses mujoco.renderer and this MujocoViewer at the same time.
mujoco.renderer is for segmentation/depth rendering.

After the initialization of a renderer,
The viewer window does not appear.

I think that the constructor of renderer executes the following code
https://github.com/google-deepmind/mujoco/blob/2.3.7/python/mujoco/renderer.py#L80
https://github.com/google-deepmind/mujoco/blob/2.3.7/python/mujoco/glfw/__init__.py#L25

This is the MWE.

import mujoco
import mujoco_viewer
import glfw


model = mujoco.MjModel.from_xml_path('humanoid.xml')
data = mujoco.MjData(model)

renderer = mujoco.Renderer(model)

#Commenting out this line hides the viewer window
glfw.window_hint(glfw.VISIBLE, 1)

# create the viewer object
viewer = mujoco_viewer.MujocoViewer(model, data)

# simulate and render
for _ in range(10000):
    if viewer.is_alive:
        mujoco.mj_step(model, data)
        viewer.render()
    else:
        break

# close
viewer.close()

I think adding the line of glfw.window_hint(glfw.VISIBLE, 1) like
https://github.com/rohanpsingh/mujoco-python-viewer/blob/main/mujoco_viewer/mujoco_viewer.py#L46-L47
would solve this problem of unexpected hidden window.

It should be noted that using renderer and viewer.render() in the loop would require the context switching as the following issue.
#35

On the other hand, I guess that the frame buffer part does not need modifications because
https://github.com/rohanpsingh/mujoco-python-viewer/blob/main/mujoco_viewer/mujoco_viewer.py#L49-L50
automatically sets the active buffer to the default window.

What do you think of these?
If these sound reasonable, I would send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant