Mujoco-py: Access camera data from mujoco model

Created on 2 May 2018  Â·  6Comments  Â·  Source: openai/mujoco-py

I have a model of AUBO i5 in mujoco and I am using mujoco py with gym AI to implement reinforcement learning algorithm. I have put camera on the robot and I want to get images from the camera and access those in mujoco py so that I can process them.

Any help would be highly appreciated

Thank you,
Adarsh Sehgal

Most helpful comment

@adarshsehgal
I figured it out.

model = load_model_from_path("test.xml")
sim = MjSim(model)

 ## a is a tuple if depth is True and a numpy array if depth is False ##
a = sim.render(width=200, height=200, camera_name='rgb', depth=True)
rgb_img = a[0]
depth_img = a[1]

It's in their api reference:
https://openai.github.io/mujoco-py/build/html/reference.html#mjsim-basic-simulation

All 6 comments

I would also like to know how to do this!

Thanks,
Guy Isely

Hi, @adarshsehgal @gisely
have you guys figured this out yet? I ran into the same problem.
Thanks in advance!

Unfortunately, I was not able to figure this out.

On Sun, Mar 31, 2019 at 7:53 PM kracon7 notifications@github.com wrote:

Hi, @adarshsehgal https://github.com/adarshsehgal @gisely
https://github.com/gisely
have you guys figured this out yet? I ran into the same problem.
Thanks in advance!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/openai/mujoco-py/issues/249#issuecomment-478417983,
or mute the thread
https://github.com/notifications/unsubscribe-auth/APQYQkMk0zCHZUiDLWymO7c9vros4XU2ks5vcXSUgaJpZM4TwCMJ
.

@adarshsehgal
I figured it out.

model = load_model_from_path("test.xml")
sim = MjSim(model)

 ## a is a tuple if depth is True and a numpy array if depth is False ##
a = sim.render(width=200, height=200, camera_name='rgb', depth=True)
rgb_img = a[0]
depth_img = a[1]

It's in their api reference:
https://openai.github.io/mujoco-py/build/html/reference.html#mjsim-basic-simulation

Great! Thank you so much!

On Mon, Apr 1, 2019 at 12:32 PM kracon7 notifications@github.com wrote:

@adarshsehgal https://github.com/adarshsehgal
I figured it out.

model = load_model_from_path("test.xml")
sim = MjSim(model)

## a is a tuple if depth is True and a numpy array if depth is False ##
a = sim.render(width=200, height=200, camera_name='rgb', depth=True)
rgb_img = a[0]
depth_img = a[1]

It's in their api reference:

https://openai.github.io/mujoco-py/build/html/reference.html#mjsim-basic-simulation

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/openai/mujoco-py/issues/249#issuecomment-478714301,
or mute the thread
https://github.com/notifications/unsubscribe-auth/APQYQr9ICbx7CytTNzTUC5F3UP9Ubzkbks5vcl6wgaJpZM4TwCMJ
.

'rgb' is not a valid camera but you can use ('frontview', 'birdview', 'agentview', 'sideview', 'robot0_robotview', 'robot0_eye_in_hand')

Was this page helpful?
0 / 5 - 0 ratings

Related issues

libo-wu picture libo-wu  Â·  3Comments

cbjtu picture cbjtu  Â·  5Comments

rajathkmp picture rajathkmp  Â·  4Comments

samuela picture samuela  Â·  3Comments

hartikainen picture hartikainen  Â·  4Comments