You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
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.
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.
The text was updated successfully, but these errors were encountered: