Skip to content

Using mediapy with MuJoCo (Visual Studio Code / Windows 10) #2399

Closed Answered by Ad-MTL
Ad-MTL asked this question in Asking for Help
Discussion options

You must be logged in to vote

I think I figured it out. Mediapy doesn't work with Visual Studio Code. I switched to Jupyter Lab and my original code gave me a blank image (but no errors). Adding a camera and stepping the simulation gives me a render of a UR5.
Strangely, if you omit 'renderer=None; it will only render if you restart the kernel every time you run the code, otherwise the output is just black.

Here's the working code:

import mujoco
import mediapy as media

renderer = None

model = mujoco.MjModel.from_xml_path('universal_robots_ur5e/ur5e.xml')
data = mujoco.MjData(model)
renderer = mujoco.Renderer(model)

mujoco.mj_forward(model, data)

camera = mujoco.MjvCamera()
mujoco.mjv_defaultFreeCamera(model, camera…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Ad-MTL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants