API#
Python API#
Rendering event types. |
|
Core class that provides APIs for controlling rendering. |
|
Core class that provides APIs for managing viewports. |
- class RenderingEvent(
- value,
- names=<not given>,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Rendering event types.
- NEW_FRAME = 'isaacsim.rendering.new_frame'#
Event triggered when a new frame is rendered.
- class RenderingManager#
Bases:
objectCore class that provides APIs for controlling rendering.
- classmethod deregister_all_callbacks() None#
Deregister all callbacks registered via
register_callback().Example:
>>> from isaacsim.core.rendering_manager import RenderingManager >>> >>> RenderingManager.deregister_all_callbacks()
- classmethod deregister_callback(uid: int) None#
Deregister a callback registered via
register_callback().- Parameters:
uid – The unique identifier of the callback to deregister. If the unique identifier does not exist or has already been deregistered, a warning is logged and the method does nothing.
Example:
>>> from isaacsim.core.rendering_manager import RenderingManager >>> >>> # deregister the callback with the unique identifier 0 >>> RenderingManager.deregister_callback(0)
- classmethod get_dt() float#
Get the rendering dt.
- Returns:
Rendering dt.
Example:
>>> from isaacsim.core.rendering_manager import RenderingManager >>> >>> RenderingManager.get_dt() 0.0166666...
- classmethod register_callback(
- event: RenderingEvent,
- *,
- callback: callable,
- order: int = 0,
Register/subscribe a callback to be triggered when a specific rendering event occurs.
- Parameters:
event – The rendering event to subscribe to.
callback – The callback function.
order – The subscription order. Callbacks registered within the same order will be triggered in the order they were registered.
- Returns:
The unique identifier of the callback subscription.
Example:
>>> from isaacsim.core.rendering_manager import RenderingEvent, RenderingManager >>> >>> def callback(event, *args, **kwargs): ... print(event) ... >>> # subscribe to the NEW_FRAME event >>> callback_id = RenderingManager.register_callback(RenderingEvent.NEW_FRAME, callback=callback) >>> callback_id 0 >>> # perform a rendering step in order to trigger the callback and print the event >>> RenderingManager.render() <carb.eventdispatcher._eventdispatcher.Event object at 0x...> >>> >>> # deregister all callbacks >>> RenderingManager.deregister_all_callbacks()
- classmethod render() None#
Render the stage.
This method performs an app update without stepping the simulation or physics.
Example:
>>> from isaacsim.core.rendering_manager import RenderingManager >>> >>> RenderingManager.render()
- class ViewportManager#
Bases:
objectCore class that provides APIs for managing viewports.
- classmethod create_viewport_window(
- *,
- camera: str | Usd.Prim | UsdGeom.Camera = '/OmniverseKit_Persp',
- title: str | None = None,
- resolution: tuple[int, int] = (1280, 720),
Create a viewport window.
- Parameters:
camera – The camera to use for the viewport. If not provided, the default (perspective) camera is used.
title – The viewport window title (name). If not provided, a default title is generated.
resolution – The viewport window resolution: (width, height).
- Returns:
The viewport window (as a proxy).
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> import isaacsim.core.experimental.utils.stage as stage_utils >>> >>> # create a viewport window with the default camera and resolution >>> window = ViewportManager.create_viewport_window() >>> window.title 'Viewport 1' >>> window.viewport_api.camera_path Sdf.Path('/OmniverseKit_Persp') >>> >>> # create a viewport window with a custom camera and resolution >>> camera = stage_utils.define_prim("/Camera", "Camera") >>> window = ViewportManager.create_viewport_window( ... camera=camera, ... resolution=(640, 480), ... title="Custom Viewport", ... ) >>> window.title 'Custom Viewport' >>> window.viewport_api.camera_path Sdf.Path('/Camera') >>> window.viewport_api.resolution (640, 480)
- classmethod destroy_viewport_windows(
- *,
- include: list[str] = ['.*'],
- exclude: list[str] = [],
Destroy viewport windows.
- Parameters:
include – Viewport window titles (names) to destroy. If not provided, all viewport windows will be destroyed. Regular expressions are supported.
exclude – Viewport window titles (names) to exclude from destruction. Excluded names take precedence over included names. Regular expressions are supported.
- Returns:
List of destroyed viewport window titles (names).
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> # given the following viewport windows: "Viewport", "Viewport 1", and "Custom Viewport", >>> # destroy all viewport windows except the default one: "Viewport" >>> ViewportManager.destroy_viewport_windows(exclude=["Viewport"]) ['Viewport 1', 'Custom Viewport']
- classmethod get_camera(
- render_product_or_viewport: str | Usd.Prim | UsdRender.Product | 'ViewportAPI' | None = None,
Get a render product or viewport’s camera.
- Parameters:
render_product_or_viewport – The render product or viewport to get the camera from. If not provided, the active viewport is used.
- Returns:
USD Camera prim.
- Raises:
ValueError – Invalid render product or viewport.
ValueError – No camera prim target found for a given render product.
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> # get the camera of the active viewport >>> ViewportManager.get_camera() UsdGeom.Camera(Usd.Prim(</OmniverseKit_Persp>))
- classmethod get_render_product(
- render_product_or_viewport: str | Usd.Prim | UsdRender.Product | 'ViewportAPI' | None = None,
Get an USD RenderProduct prim that describes an artifact produced by a render.
Supported sources are:
Source
Return value
Unspecified (default)
The active viewport’s render product
ViewportAPIinstanceThe given viewport’s render product
UsdRender.Productprim instanceThe given prim instance
USD RenderProduct prim path
The
UsdRender.Productprim at the given pathViewport window title (name)
The given viewport window’s render product
- Parameters:
render_product_or_viewport – The render product or viewport to get the USD RenderProduct prim from. If not provided, the active viewport is used.
- Returns:
USD RenderProduct prim, or None if no render product is found.
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> # get render product from the active viewport >>> ViewportManager.get_render_product() UsdRender.Product(Usd.Prim(</Render/OmniverseKit/HydraTextures/omni_kit_widget_viewport_ViewportTexture_0>)) >>> >>> # get render product from a viewport API >>> viewport_api = ViewportManager.get_viewport_api() >>> ViewportManager.get_render_product(viewport_api) UsdRender.Product(Usd.Prim(</Render/OmniverseKit/HydraTextures/omni_kit_widget_viewport_ViewportTexture_0>)) >>> >>> # get render product from a USD RenderProduct prim path >>> path = "/Render/OmniverseKit/HydraTextures/omni_kit_widget_viewport_ViewportTexture_0" >>> ViewportManager.get_render_product(path) UsdRender.Product(Usd.Prim(</Render/OmniverseKit/HydraTextures/omni_kit_widget_viewport_ViewportTexture_0>)) >>> >>> # get render product from a viewport window >>> ViewportManager.get_render_product("Viewport") UsdRender.Product(Usd.Prim(</Render/OmniverseKit/HydraTextures/omni_kit_widget_viewport_ViewportTexture_0>))
- classmethod get_resolution(
- render_product_or_viewport: str | Usd.Prim | UsdRender.Product | 'ViewportAPI' | None = None,
Get a render product or viewport’s resolution: width x height.
- Parameters:
render_product_or_viewport – The render product or viewport to get the resolution from. If not provided, the active viewport is used. See
get_viewport_api()orget_render_product()for supported sources.- Returns:
Resolution as a tuple of width and height.
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> ViewportManager.get_resolution() (1280, 720)
- classmethod get_viewport_api(
- render_product_or_viewport: str | Usd.Prim | UsdRender.Product | 'ViewportAPI' | None = None,
Get a viewport API (also identified as viewport) instance.
Supported sources are:
Source
Return value
Unspecified (default)
The active viewport window’s viewport API instance
ViewportAPIinstanceThe given viewport API instance
Viewport window title (name)
The given viewport window’s viewport API instance
- Parameters:
render_product_or_viewport – The render product or viewport to get the viewport API from. If not provided, the active viewport window is used.
- Returns:
Viewport API instance (as a proxy), or None if no viewport API is found.
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> # get viewport API from the active viewport window >>> ViewportManager.get_viewport_api() <weakproxy at 0x... to ViewportAPI at 0x...> >>> >>> # get viewport API from a viewport window >>> ViewportManager.get_viewport_api("Viewport") <weakproxy at 0x... to ViewportAPI at 0x...>
- classmethod get_viewport_windows(
- *,
- include: list[str] = ['.*'],
- exclude: list[str] = [],
Get viewport windows.
- Parameters:
include – Viewport window titles (names) to get. If not provided, all viewport windows will be included. Regular expressions are supported.
exclude – Viewport window titles (names) to exclude from getting. Excluded names take precedence over included names. Regular expressions are supported.
- Returns:
List of viewport windows (as proxies).
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> # get all viewport windows >>> windows = ViewportManager.get_viewport_windows() >>> windows [<weakproxy at 0x... to ViewportWindow at 0x...>] >>> windows[0].title 'Viewport' >>> windows[0].viewport_api.camera_path Sdf.Path('/OmniverseKit_Persp') >>> windows[0].viewport_api.resolution (1280, 720)
- classmethod set_camera(
- camera: str | Usd.Prim | UsdGeom.Camera,
- *,
- render_product_or_viewport: str | Usd.Prim | UsdRender.Product | 'ViewportAPI' | None = None,
Set a render product or viewport’s camera.
Available Omniverse Kit cameras:# Camera view
USD path (on session layer)
Perspective view
/OmniverseKit_PerspTop view
/OmniverseKit_TopFront view
/OmniverseKit_FrontRight view
/OmniverseKit_Right- Parameters:
camera – The camera to set.
render_product_or_viewport – The render product or viewport to set the camera for. If not provided, the active viewport is used. See
get_viewport_api()orget_render_product()for supported sources.
- Raises:
ValueError – Invalid camera.
ValueError – Invalid render product or viewport.
Example:
>>> import isaacsim.core.experimental.utils.stage as stage_utils >>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> # set the active viewport's camera to the top view >>> ViewportManager.set_camera("/OmniverseKit_Top") >>> >>> # set the active viewport's camera to a custom camera >>> camera = stage_utils.define_prim("/Camera", "Camera") >>> ViewportManager.set_camera(camera)
- classmethod set_camera_view(
- camera: str | Usd.Prim | UsdGeom.Camera,
- *,
- eye: list | np.ndarray | wp.array | None = None,
- target: list | np.ndarray | wp.array | None = None,
- relative_tracking: bool = False,
Set the camera view.
This method sets the camera view by adjusting its position and orientation, while taking into account the camera’s center of interest (COI) attribute:
omni:kit:centerOfInterest, if it exists.Depending on the forwarded arguments and the existence of the COI attribute, the camera view is adjusted as follows:
COIeyetargetBehavior
no
no
no
The camera’s view will not change. A warning will be logged.
no
no
yes
The camera remains in place but rotates to face the target.
no
yes
no
The camera teleports to the eye while keeping its orientation.
no
yes
yes
The camera teleports to the eye and rotates to face the target.
yes
no
no
The camera remains in place but rotates to face the COI.
yes
no
yes
The
relative_trackingflag determines the behavior:If
relative_trackingisFalse(default), the camera remains in place but rotates to face the target. The COI is updated to the target value.If
relative_trackingisTrue, the camera teleports to face the target, while keeping the same orientation and distance relative to the COI. The COI is updated to the target value.
yes
yes
no
The camera teleports to the eye and rotates to face the COI.
yes
yes
yes
The camera teleports to the eye and rotates to face the target. The COI is updated to the target value.
- Parameters:
camera – The camera path or instance.
eye – The eye position (position of the camera in the world frame).
target – The target position (position of the target to look at in the world frame).
relative_tracking – Whether to track the target relative to the current camera position.
- Raises:
ValueError – The camera is not a valid USD Camera prim.
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> # set the active viewport's camera view to look at a target at (1.0, 2.0, 3.0) >>> camera = ViewportManager.get_camera() >>> ViewportManager.set_camera_view(camera, target=[1.0, 2.0, 3.0])
- classmethod set_resolution(
- resolution: tuple[int, int] | str,
- *,
- render_product_or_viewport: str | Usd.Prim | UsdRender.Product | 'ViewportAPI' | None = None,
Set a render product or viewport’s resolution: width x height.
- Parameters:
resolution – The resolution as a tuple of width and height.
render_product_or_viewport – The render product or viewport to set the resolution for. If not provided, the active viewport is used. See
get_viewport_api()orget_render_product()for supported sources.
- Raises:
ValueError – Invalid render product or viewport.
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> # set the active viewport's resolution to (640, 480) >>> ViewportManager.set_resolution((640, 480)) >>> >>> # check the resolution >>> ViewportManager.get_resolution() (640, 480) >>> ViewportManager.get_viewport_api().resolution (640, 480)
- classmethod wait_for_viewport(
- *,
- viewport: str | 'ViewportAPI' | None = None,
- max_frames: int = 60,
- sleep_time: float = 0.02,
Wait for the viewport to be ready.
Calling this method ensures that a new frame is rendered by the viewport during an app update (or rendering step).
- Parameters:
viewport – The viewport to wait for. If not provided, the active viewport is used. See
get_viewport_api()for supported viewport sources.max_frames – The maximum number of frames to wait for.
sleep_time – Time, in seconds, to sleep between frames. Setting a positive value reduces the number of frames required for the viewport to be ready.
- Returns:
A tuple containing a boolean indicating whether the viewport is ready and the number of frames waited for.
Example:
>>> from isaacsim.core.rendering_manager import ViewportManager >>> >>> ViewportManager.wait_for_viewport() (True, 0)
- async classmethod wait_for_viewport_async(
- *,
- viewport: str | 'ViewportAPI' | None = None,
- max_frames: int = 60,
- sleep_time: float = 0.02,
Wait for the viewport to be ready.
This method is the asynchronous version of
wait_for_viewport().- Parameters:
viewport – The viewport to wait for. If not provided, the active viewport is used. See
get_viewport_api()for supported viewport sources.max_frames – The maximum number of frames to wait for.
sleep_time – Time, in seconds, to sleep between frames. Setting a positive value reduces the number of frames required for the viewport to be ready.
- Returns:
A tuple containing a boolean indicating whether the viewport is ready and the number of frames waited for.