Renderer
Sport offscreen frames
MJRenderer.render_offscreen(scene="sport") adds a readable navy floor, a
bright neutral key, orange/cyan side lights and shadows to RGB frames. The
preset only edits the rendered scene; it leaves the shared model, simulation
state, depth and segmentation outputs unchanged. The light colours are scene
accents, independent of agent roles and activation values. For 1v1 chase-tag,
sparse court lines and broken orange/cyan identity arcs follow the two agents.
These are decorative graphics, not tag radii or trajectories. Camera settings
remain explicit:
from myosuite.viz.mj_renderer import MJRenderer
renderer = MJRenderer(env.unwrapped.model, env.unwrapped.data)
try:
renderer.set_free_camera_settings(
distance=0.9, azimuth=103.7, elevation=-2.1, lookat=[0.15, 0, 0.92]
)
frame = renderer.render_offscreen(width=640, height=360, scene="sport")
finally:
renderer.close()
The generic MJRenderer default remains scene="default". The 1v1 chase-tag
task selects sport styling automatically for env.render() in rgb_array
mode. To use its original appearance, override the task setting at construction:
from myosuite import make_env
env = make_env(
"myoChallengeChaseTagFBVs-v0", render_mode="rgb_array", render_scene="default"
)
Other tasks and interactive viewers keep their existing defaults. Choose frame dimensions within the model’s offscreen framebuffer.
Default (left) and sport (right), with the same staged Breakaway pose and camera. Rendered with MuJoCo 3.17.0; this is a kinematic composition, not a learned or contact-validated chase rollout.
Rendering API for MuJoCo simulations.
- class myosuite.viz.renderer.RenderMode(value)
Bases:
EnumRendering modes for offscreen rendering.
- RGB = 0
- DEPTH = 1
- SEGMENTATION = 2
- class myosuite.viz.renderer.Renderer(mj_model, mj_data)
Bases:
ABCBase 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:
- 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.
- class myosuite.viz.mj_renderer.MJRenderer(mj_model, mj_data)
Bases:
RendererRenders Mujoco Physics objects.
- key_callback(keycode)
- setup_renderer(model, height, width)
Select the offscreen renderer for
widthxheight, creating it once.A
mujoco.Rendererhas 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, *, scene='default')
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.scene (
str) –"default"or"sport"RGB styling. Depth and segmentation retain the model’s geometry and camera in either case.rgb (bool)
depth (bool)
segmentation (bool)
- Return type:
ndarray- Returns:
A numpy array of the pixels.
- invalidate_offscreen()
Release cached offscreen contexts so runtime asset edits are reloaded.
- Return type: