cambrian.renderer¶
This module defines the Cambrian renderer.
Submodules¶
Classes¶
The renderer for rendering scenes. This is essentially a wrapper around the |
|
The config for the renderer. Used for type hinting. |
|
The save modes for saving rendered images. |
Functions¶
|
Converts depth values from OpenGL to metric depth values using PyTorch. |
|
Resize the image while maintaining the aspect ratio and |
Package Contents¶
- convert_depth_distances(model, depth)[source]¶
Converts depth values from OpenGL to metric depth values using PyTorch.
- Parameters:
model (mj.MjModel) – The model.
depth (torch.Tensor) – The depth values to convert.
- Returns:
torch.Tensor – The converted depth values.
Note
This function is based on [this code](https://github.com/google-deepmind/mujoco/blob/main/ python/mujoco/renderer.py). It is adapted to use PyTorch instead of NumPy.
- resize_with_aspect_fill(images, height, width)[source]¶
Resize the image while maintaining the aspect ratio and filling the rest with black.
- class MjCambrianRenderer(config)[source]¶
The renderer for rendering scenes. This is essentially a wrapper around the mujoco viewer/renderer.
- Parameters:
config (MjCambrianRendererConfig) – The config to use for the renderer.
- Variables:
metadata (Dict[str, List[str]]) – The metadata for the renderer. The render modes are stored here.
- class MjCambrianRendererConfig[source]¶
Bases:
hydra_config.HydraContainerConfig
The config for the renderer. Used for type hinting.
A renderer corresponds to a single camera. The renderer can then view the scene in different ways, like offscreen (rgb_array) or onscreen (human).
- Variables:
render_modes (List[str]) – The render modes to use for the renderer. See MjCambrianRenderer.metadata[“render.modes”] for options.
width (Optional[int]) – The width of the rendered image. For onscreen renderers, if this is set, the window cannot be resized. Must be set for offscreen renderers.
height (Optional[int]) – The height of the rendered image. For onscreen renderers, if this is set, the window cannot be resized. Must be set for offscreen renderers.
fullscreen (Optional[bool]) – Whether to render in fullscreen or not. If True, the width and height are ignored and the window is rendered in fullscreen. This is only valid for onscreen renderers.
scene (Type[mj.MjvScene]) – The scene to render.
scene_options (mj.MjvOption) – The options to use for rendering.
camera (mj.MjvCamera) – The camera to use for rendering.
use_shared_context (bool) – Whether to use a shared context or not. If True, the renderer will share a context with other renderers. This is useful for rendering multiple renderers at the same time. If False, the renderer will create its own context. This is computationally expensive if there are many renderers.
save_mode (Optional[MjCambrianRendererSaveMode]) – The save modes to use for saving the rendered images. See MjCambrianRenderer.SaveMode for options. Must be set if save is called without save modes passed directly.