mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

not able to get depth image in ubuntu

Open AvalonGuo opened this issue 2 years ago • 1 comments

How to ask for help

Hi,

I'm a student and I'm trying to use MuJoCo for training robot to grasp.

I'm looking for some help with depth image. I noticed#743 and I tried to reproduce the depth rendering part of https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/tutorial.ipynb in my specific env. But i failed. And i also tried the testDepthRender function in https://github.com/google-deepmind/dm_control/blob/774f46182140106e22725914aad3c6299ed91edd/dm_control/mujoco/engine_test.py#L66 in my specific env. The same problem appeared.

However,there wasn't any problem in windows-version's mujoco and in colab-version's mujoco.

Here is a model which explains my process:

import mujoco import cv2 import numpy as np xml = """ """ model = mujoco.MjModel.from_xml_string(xml) renderer = mujoco.Renderer(model) data = mujoco.MjData(model) mujoco.mj_forward(model, data) renderer.update_scene(data) cv2.imshow("test",renderer.render()) cv2.waitKey(0) renderer.enable_depth_rendering()

reset the scene

renderer.update_scene(data)

depth is a float array, in meters.

depth = renderer.render() print("min:",depth.min(),"max:",depth.max()) cv2.imshow("depth",depth) cv2.waitKey(0) renderer.disable_depth_rendering()

Here is a screenshot , illustrating my question: 1710861441010

Here is my environment config: ubuntu20.04 using vmware mujoco==3.1.1 dm-control==1.0.6 opencv-python

AvalonGuo avatar Mar 19 '24 15:03 AvalonGuo

I'm sry for the first version of my submit.I made some mistakes because I am unfamiliar with Markdown. Here is my code: import mujoco import cv2 import numpy as np 1710862516698 model = mujoco.MjModel.from_xml_string(xml) renderer = mujoco.Renderer(model) data = mujoco.MjData(model) mujoco.mj_forward(model, data) renderer.update_scene(data) cv2.imshow("test",renderer.render()) cv2.waitKey(0) renderer.enable_depth_rendering() renderer.update_scene(data) depth = renderer.render() print("min:",depth.min(),"max:",depth.max())

AvalonGuo avatar Mar 19 '24 15:03 AvalonGuo