Renderer

Rendering API for MuJoCo simulations.

class myosuite.viz.renderer.RenderMode(value)

Bases: Enum

Rendering modes for offscreen rendering.

RGB = 0
DEPTH = 1
SEGMENTATION = 2
class myosuite.viz.renderer.Renderer(mj_model, mj_data)

Bases: ABC

Base interface for rendering simulations.

abstract render_to_window()

Renders the simulation to a window.

abstract refresh_window()

Refreshes the rendered window if one is present.

abstract render_offscreen(width, height, depth=False, segmentation=False, camera_id=-1, device_id=-1)

Renders the camera view as a numpy array of pixels.

Parameters:
  • width (int) – The viewport width (pixels).

  • height (int) – The viewport height (pixels).

  • mode – The rendering mode.

  • camera_id (int | str) – The ID of the camera to render from. By default uses the free camera.

  • depth (bool)

  • segmentation (bool)

Return type:

ndarray

Returns:

A numpy array of the pixels.

set_free_camera_settings(distance=None, azimuth=None, elevation=None, lookat=None, center=True)

Sets the free camera parameters.

Parameters:
  • distance (Optional[float]) – The distance of the camera from the target.

  • azimuth (Optional[float]) – Horizontal angle of the camera, in degrees.

  • elevation (Optional[float]) – Vertical angle of the camera, in degrees.

  • lookat (Optional[Sequence[float]]) – The (x, y, z) position in world coordinates to target.

  • center (bool) – If True and lookat is not given, targets the camera at the median position of the simulation geometry.

set_viewer_settings(render_tendon=None, render_actuator=None)

Sets the viewer parameters.

Parameters:
  • render_tendon (Optional[float]) – Turn tendon rendering on/off

  • render_actuator (Optional[float]) – Turn tendon rendering on/off

close()

Cleans up any resources being used by the renderer.

Return type:

None

class myosuite.viz.mj_renderer.MJRenderer(mj_model, mj_data)

Bases: Renderer

Renders Mujoco Physics objects.

key_callback(keycode)
setup_renderer(model, height, width)

Select the offscreen renderer for width x height, creating it once.

A mujoco.Renderer has a fixed image size, so one is kept per size (e.g. video frames and visual observations at different resolutions).

render_to_window()

Renders the Physics object to a window.

The window continuously renders the Physics in a separate thread.

This function is a no-op if the window was already created.

refresh_window()

Refreshes the rendered window if one is present.

render_offscreen(width=640, height=480, rgb=True, depth=False, segmentation=False, camera_id=-1, device_id=-1)

Renders the camera view as a numpy array of pixels.

Parameters:
  • width (int) – The viewport width (pixels).

  • height (int) – The viewport height (pixels).

  • mode – The rendering mode.

  • camera_id (int | str) – The ID of the camera to render from. By default uses the free camera.

  • rgb (bool)

  • depth (bool)

  • segmentation (bool)

Return type:

ndarray

Returns:

A numpy array of the pixels.

close()

Cleans up any resources being used by the renderer.

Return type:

None