Open ZiwenZhuang opened 5 years ago
Partially solved,
By removing the code env.env.sim.render_contexts[0]._set_mujoco_buffers()
, it seems work.
But due to the OpenGL issue (from issue 408 and issue 432, even you provide it an on-screen viewer before any offscreen viewer, the rendering could still generate all-black image on both numpy arrays (offscreen render) and mujoco-py window in some frames.
Solved: referring to https://github.com/openai/mujoco-py/issues/408 and https://github.com/openai/mujoco-py/issues/383
Just wanted to add a note to this in case it helps anyone coming across the issue.
I was having a similar problem in a setting where I had 2 sims with offscreen render contexts:
sim1 = mujoco_py.MjSim(panda_model, nsubsteps=3)
viewer1 = mujoco_py.MjViewer(sim1)
sim2 = mujoco_py.MjSim(sawyer_model, nsubsteps=3)
viewer2 = mujoco_py.MjViewer(sim2)
render_context1 = mujoco_py.MjRenderContextOffscreen(sim1)
sim1.add_render_context(render_context1)
render_context2 = mujoco_py.MjRenderContextOffscreen(sim2)
sim2.add_render_context(render_context2)
I would step and render from these sims sequentially (sim1, then sim2, then sim1 again and so on). However, a call to the sim1 render (with data = sim1.render(720, 720, camera_name='sideview', depth=False)[::-1, :, :]
) would result in a broken image - either of the sim2 model from a weird angle, or sometimes I believe of the sim1 model but again from a weird angle. Calling sim1.render_contexts[n]._set_mujoco_buffers()
with n=1 or n=2 (unsure of what these two different render contexts are - they both seem to refer to the offscreen context) fixed things.
Describe the bug Certain behavior calling
env.sim
's state function will cause the later rendering image array with only the same value. The behavior is described in the script.To Reproduce
Expected behavior The last image plotted should be a meaningful image.
Error Messages No error message occurred
Desktop (please complete the following information):
Environment
echo $LD_LIBRARY_PATH
/opt/ros/melodic/lib:/home/leo/.mujoco/mjpro150/bin/:/home/leo/.mujoco/mujoco200/bin/:/home/leo/.mujoco/mujoco200_linux/bin/:/usr/local/cuda/lib64/:/usr/local/cuda-10.0/lib64/Additional context None