diff --git a/omnigibson/__init__.py b/omnigibson/__init__.py index 9a5557ae1..135162918 100644 --- a/omnigibson/__init__.py +++ b/omnigibson/__init__.py @@ -1,5 +1,6 @@ import logging import os +import socket import shutil import tempfile import atexit @@ -75,7 +76,7 @@ def create_app(): # If multi_gpu is used, og.sim.render() will cause a segfault when called during on_contact callbacks, # e.g. when an attachment joint is being created due to contacts (create_joint calls og.sim.render() internally). gpu_id = None if gm.GPU_ID is None else int(gm.GPU_ID) - config_kwargs = {"headless": gm.HEADLESS, "multi_gpu": False} + config_kwargs = {"headless": gm.HEADLESS or bool(gm.REMOTE_STREAMING), "multi_gpu": False} if gpu_id is not None: config_kwargs["active_gpu"] = gpu_id config_kwargs["physics_gpu"] = gpu_id @@ -96,6 +97,29 @@ def create_app(): if os.name == "nt": enable_extension("omni.kit.window.viewport") + # Default Livestream settings + if gm.REMOTE_STREAMING: + app.set_setting("/app/window/drawMouse", True) + app.set_setting("/app/livestream/proto", "ws") + app.set_setting("/app/livestream/websocket/framerate_limit", 120) + app.set_setting("/ngx/enabled", False) + + hostname = socket.gethostname() + + # Note: Only one livestream extension can be enabled at a time + if gm.REMOTE_STREAMING == "native": + # Enable Native Livestream extension + # Default App: Streaming Client from the Omniverse Launcher + enable_extension("omni.kit.livestream.native") + print(f"Now streaming on {hostname} via Omniverse Streaming Client") + elif gm.REMOTE_STREAMING == "webrtc": + # Enable WebRTC Livestream extension + # Default URL: http://localhost:8211/streaming/webrtc-client/ + enable_extension("omni.services.streamclient.webrtc") + print(f"Now streaming on: http://{hostname}:8211/streaming/webrtc-client?server={hostname}") + else: + raise ValueError(f"Invalid REMOTE_STREAMING option {gm.REMOTE_STREAMING}. Must be one of None, native, webrtc.") + # If we're headless, suppress all warnings about GLFW if gm.HEADLESS: import omni.log diff --git a/omnigibson/macros.py b/omnigibson/macros.py index 045563ecc..5b2b32ff4 100644 --- a/omnigibson/macros.py +++ b/omnigibson/macros.py @@ -26,6 +26,9 @@ # Whether to generate a headless or non-headless application upon OmniGibson startup gm.HEADLESS = (os.getenv("OMNIGIBSON_HEADLESS", 'False').lower() in ('true', '1', 't')) +# Whether to enable remote streaming. None disables it, other valid options are "native", "webrtc". +gm.REMOTE_STREAMING = os.getenv("OMNIGIBSON_REMOTE_STREAMING", None) + # Whether only the viewport should be shown in the GUI or not (if not, other peripherals are additionally shown) # CANNOT be set at runtime gm.GUI_VIEWPORT_ONLY = False