GLFW MUJOCO_GL
option for Darwin (M-series) instead of CGL
#2498
-
IntroHello! We are using MoJoCo to simulate Stretch from Hello Robot, to allow researchers and professors at universities to use Stretch in a simulated environment. My setup
My questionOn MacOS, I would like to create multiple renderers alongside the main However, I notice that CGL has a mutex lock on GL Context when the main viewer is in view. This prevent me from being able to call I'd like to use GLFW instead of CGL for rendering to support rendering multiple Renderers. On my local machine, I commented out the darwin check in However, gl_context.py ignores the My question is, why is this done? GLFW seems to work just fine on my local macOS. Thank you! Minimal model and/or code that explain my questionModel: Any, doesn't matter, but this is the one we're using: https://github.com/hello-robot/stretch_mujoco/blob/main/stretch_mujoco/models/scene.xml Thank you. Code: import mujoco
import mujoco._functions
import mujoco._callbacks
import mujoco._render
import mujoco.viewer
from mujoco._structs import MjData, MjModel
scene_xml_path = "./models/scene.xml"
mjmodel = MjModel.from_xml_path(scene_xml_path)
mjdata = MjData(mjmodel)
rgb_renderer = mujoco.Renderer(mjmodel, height=480, width=640)
def ctrl_callback( model: MjModel, data: MjData):
# This is simplified -> we'd have this on a thread. If there is a better option, please let us know!
rgb_renderer.update_scene(data, "d405_rgb")
rgb_frame = rgb_renderer.render() # This fails on CGL with darwin, works fine on linux
mujoco._callbacks.set_mjcb_control(ctrl_callback)
mujoco.viewer.launch(mjmodel) Confirmations
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
@saran-t, any thoughts? |
Beta Was this translation helpful? Give feedback.
Hey @saran-t, just updating you.
For the off-screen rendering of 5 cameras on CPU, we found the best simulation stability and performance with running:
viewer.sync()
andRenderer.render()
(inside a viewer.lock() context) on the main loop capped at 30Hz (sleeping this thread makes the lock available for longer on the physics thread)mj_step()
(with the viewer.lock() context) on the spawned physics thread.To note: a combination of not using the appropriate locks during rendering the off-screen renderers and stepping the simulation yielded weird instabilities in simulation.
It would be great to not have to use the lock to render the cameras (because acquiring the viewer lock blocks th…