### Run Example (Windows) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_status_queries.html Executes the compiled status-queries example on Windows. ```bash .\build\Release\status-queries ``` -------------------------------- ### Run Example (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_status_queries.html Executes the compiled status-queries example on Linux. ```bash ./build/status-queries ``` -------------------------------- ### Run OVRTX Example (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_minimal.html Executes the compiled OVRTX minimal example on Linux. ```bash ./build/minimal ``` -------------------------------- ### Run OVRTX Example (Windows) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_minimal.html Executes the compiled OVRTX minimal example on Windows. ```bash .\build\Release\minimal ``` -------------------------------- ### Build OVRTX Example (Windows) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_minimal.html Configures and builds the OVRTX minimal example using CMake on Windows. ```bash cmake -B build cmake --build build --config Release ``` -------------------------------- ### Build and Run Minimal Example on Windows Source: https://nvidia-omniverse.github.io/ovrtx/c_api/getting_started.html Builds the minimal C example using CMake and then executes the compiled program. The output image is saved as 'out.png'. ```bash cmake --build build --config Release .\build\Release\minimal.exe ``` -------------------------------- ### Install CMake on Linux Source: https://nvidia-omniverse.github.io/ovrtx/c_api/getting_started.html Installs build-essential and CMake on Ubuntu systems. These are prerequisites for building C/C++ examples. ```bash sudo apt-get install build-essential cmake ``` -------------------------------- ### Build OVRTX Example (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_minimal.html Configures and builds the OVRTX minimal example using CMake in Release mode. ```bash cmake -B build -DCMAKE_BUILD_TYPE=Release cmake --build build ``` -------------------------------- ### Build and Run Minimal Example on Linux Source: https://nvidia-omniverse.github.io/ovrtx/c_api/getting_started.html Builds the minimal C example using CMake and then executes the compiled program. The output image is saved as 'out.png'. ```bash cmake --build build --config Release ./build/minimal ``` -------------------------------- ### Install and Test C Log Callback Source: https://nvidia-omniverse.github.io/ovrtx/core/async_status_errors.html Demonstrates installing a global log callback to capture all messages, resetting the stage, opening a USD file, flushing logs, and then installing a filtered callback to verify that messages are not captured when the filter is applied. Ensure the callback is disabled before the renderer is torn down. ```c++ // First pass: receive all messages (NULL channel filter). g_message_count.store(0); ovrtx_result_t r = ovrtx_set_log_callback(OVRTX_LOG_INFO, nullptr, // NULL = all channels &count_messages, &g_message_count); ASSERT_API_SUCCESS(r.status); // Reset first so the renderer is in a clean state. ovrtx_enqueue_result_t eq = ovrtx_reset_stage(renderer_); ASSERT_API_SUCCESS(eq.status); ovrtx_op_wait_result_t wait_result; ASSERT_API_SUCCESS(ovrtx_wait_op(renderer_, eq.op_index, ovrtx_timeout_infinite, &wait_result).status); do_open_usd(); // Ensure pending log messages have been delivered through the callback. ovrtx_timeout_t flush_timeout{5'000'000'000ull}; ovrtx_flush_log(flush_timeout); int observed_any_channel = g_message_count.load(); // Second pass: install a high default threshold and an explicit low // threshold for a channel prefix that cannot match any real channel. g_message_count.store(0); std::string bogus = "this.channel.does.not.exist.42=info"; ovx_string_t filter{bogus.c_str(), bogus.size()}; r = ovrtx_set_log_callback(OVRTX_LOG_FATAL, &filter, &count_messages, &g_message_count); ASSERT_API_SUCCESS(r.status); // Re-run the same work and flush — the callback should not fire. eq = ovrtx_reset_stage(renderer_); ASSERT_API_SUCCESS(eq.status); ASSERT_API_SUCCESS(ovrtx_wait_op(renderer_, eq.op_index, ovrtx_timeout_infinite, &wait_result).status); do_open_usd(); ovrtx_flush_log(flush_timeout); int observed_bogus_filter = g_message_count.load(); // Disable the callback before the renderer is torn down. ovrtx_set_log_callback(OVRTX_LOG_INFO, nullptr, nullptr, nullptr); ``` -------------------------------- ### Run Radar Sensor Example (Windows) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_radar.html Executes the compiled C++ radar sensor example on Windows. ```bash .\build\Release\radar-composite-tensor.exe ``` -------------------------------- ### Run Lidar Sensor Example Source: https://nvidia-omniverse.github.io/ovrtx/examples/python_sensor_lidar.html Navigate to the example directory and run the main script using uv. This command initiates the lidar sensor pipeline. ```bash cd examples/python/sensors/lidar uv run main.py ``` -------------------------------- ### Minimal OVRTX Python Example Source: https://nvidia-omniverse.github.io/ovrtx/python_api/getting_started.html This script demonstrates the core OVRTX Python API for rendering. It initializes the renderer, loads a USD scene from a URL, steps the simulation to capture a frame, and displays or saves the rendered image. Ensure Python 3.10-3.13 is installed. ```python import argparse import sys from pathlib import Path import numpy as np import ovrtx from PIL import Image USD_URL = "https://omniverse-content-production.s3.us-west-2.amazonaws.com/Samples/Robot-OVRTX/robot-ovrtx.usda" def main(): parser = argparse.ArgumentParser(description="Minimal ovrtx Python example") parser.add_argument("--png", action="store_true", help="Save render to _output/render.png instead of displaying") args = parser.parse_args() # Create the Renderer and load a USD layer into it print("Creating renderer. The first run of the application will take some time as shaders are compiled and cached...", file=sys.stderr) renderer = ovrtx.Renderer() print("Renderer created.", file=sys.stderr) print(f"Opening {USD_URL}...", file=sys.stderr) renderer.open_usd(USD_URL) print("USD loaded.", file=sys.stderr) # Step the renderer to simulate the Camera at 60Hz print("Stepping renderer...", file=sys.stderr) products = renderer.step( render_products = {"/Render/Camera"}, delta_time = 1.0 / 60 ) print("Stepped renderer.", file=sys.stderr) # Get the Camera output for the step as a numpy array and display it print("Fetching results...", file=sys.stderr) for _product_name, product in products.items(): for frame in product.frames: var = frame.render_vars["LdrColor"].map(device=ovrtx.Device.CPU) pixels = np.from_dlpack(var) img = Image.fromarray(pixels) if args.png: output_dir = Path("_output") output_dir.mkdir(exist_ok=True) img.save(output_dir / "render.png") print(f"Saved to {output_dir / 'render.png'}", file=sys.stderr) else: img.show() print("Fetched results.", file=sys.stderr) if __name__ == "__main__": main() ``` -------------------------------- ### Run Lidar Sensor Example (Windows) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_lidar.html Executes the compiled lidar sensor C++ example on Windows. ```bash .\build\Release\lidar-composite-tensor.exe ``` -------------------------------- ### Run Tiled Rendering Example Source: https://nvidia-omniverse.github.io/ovrtx/examples/python_tiled_rendering.html Navigate to the example directory and run the main Python script using uv. The first run may take longer due to shader compilation and caching. ```bash cd examples/python/tiled-rendering uv run main.py ``` -------------------------------- ### Run Python Status Queries Example Source: https://nvidia-omniverse.github.io/ovrtx/examples/python_status_queries.html Execute the main Python script for the status queries example. ```bash uv run main.py ``` -------------------------------- ### Run Radar Sensor Example (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_radar.html Executes the compiled C++ radar sensor example on Linux. ```bash ./build/radar-composite-tensor ``` -------------------------------- ### Clone Repository and Run Minimal Example Source: https://nvidia-omniverse.github.io/ovrtx/python_api/getting_started.html Clone the OVRTX repository and execute the minimal Python example using the uv project manager. This command sequence sets up the environment and runs the initial rendering script. ```bash git clone https://github.com/NVIDIA-Omniverse/ovrtx.git cd ovrtx/examples/python/minimal uv run main.py ``` -------------------------------- ### Install Build Tools (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_minimal.html Installs essential build tools and CMake on Linux systems. ```bash sudo apt install build-essential cmake ``` -------------------------------- ### Clone ovrtx Repository and Configure Minimal Example Source: https://nvidia-omniverse.github.io/ovrtx/c_api/getting_started.html Clones the ovrtx repository from GitHub and navigates to the minimal C example directory. It then configures the build using CMake. ```bash git clone https://github.com/NVIDIA-Omniverse/ovrtx.git cd ovrtx/examples/c/minimal cmake -B build ``` -------------------------------- ### Run Minimal Python Example Source: https://nvidia-omniverse.github.io/ovrtx/examples/python_minimal.html Use this command to run the minimal Python example. The first execution may take longer due to shader compilation and caching. ```bash uv run main.py ``` -------------------------------- ### Run Radar Sensor Example Source: https://nvidia-omniverse.github.io/ovrtx/examples/python_sensor_radar.html Navigate to the example directory and run the main Python script using uv. This command initiates the radar sensor simulation and visualization. ```bash cd examples/python/sensors/radar uv run main.py ``` -------------------------------- ### Run Semantic Segmentation Example Source: https://nvidia-omniverse.github.io/ovrtx/examples/python_semantic_segmentation.html Navigate to the example directory and run the main Python script using uv. This command initiates the semantic segmentation rendering process. ```bash cd examples/python/semantic-segmentation uv run main.py ``` -------------------------------- ### Run Lidar Sensor Example (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_lidar.html Executes the compiled lidar sensor C++ example on Linux. An optional scene path can be provided. ```bash ./build/lidar-composite-tensor ``` ```bash ./build/lidar-composite-tensor path/to/lidar_example.usda ``` -------------------------------- ### Build Lidar Sensor Example (Windows) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_lidar.html Builds the lidar sensor C++ example using CMake on Windows with Visual Studio. It configures a Release build. ```bash cd examples/c/sensors/lidar cmake -S . -B build cmake --build build --config Release ``` -------------------------------- ### Build Radar Sensor Example (Windows) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_radar.html Builds the C++ radar sensor example using CMake on Windows with Visual Studio. Sets the build configuration to Release. ```bash cd examples/c/sensors/radar cmake -S . -B build cmake --build build --config Release ``` -------------------------------- ### Run Radar Sensor Example with Custom Scene (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_radar.html Executes the compiled C++ radar sensor example on Linux, specifying an explicit scene path. ```bash ./build/radar-composite-tensor path/to/radar_example.usda ``` -------------------------------- ### Build Lidar Sensor Example (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_lidar.html Builds the lidar sensor C++ example using CMake on Linux. It configures a Release build type. ```bash cd examples/c/sensors/lidar cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build ``` -------------------------------- ### Build Radar Sensor Example (Linux) Source: https://nvidia-omniverse.github.io/ovrtx/examples/c_sensor_radar.html Builds the C++ radar sensor example using CMake on Linux. Sets the build type to Release. ```bash cd examples/c/sensors/radar cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build ``` -------------------------------- ### Fetchable Operation Example Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Demonstrates the lifecycle of a fetchable operation, from asynchronous initiation to waiting and fetching the result. ```python op = renderer.step_async(...) pending = op.wait() # PendingFetch[RenderProductSetOutputs] result = pending.fetch() # RenderProductSetOutputs ``` -------------------------------- ### Minimal C Lifecycle Example Source: https://nvidia-omniverse.github.io/ovrtx/core/application_flow.html This C example illustrates the same minimal application flow as the Python version, but with explicit API calls for waits, fetches, mapping, unmapping, result destruction, and renderer destruction. It includes error checking for API operations. ```C #include #include #include #include #include #include #include #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" template static bool check_and_print_error(ResultT const& result, std::string_view operation) { if (result.status == OVRTX_API_ERROR) { ovx_string_t error = ovrtx_get_last_error(); if (error.ptr && error.length > 0) { std::cerr << "ovrtx " << operation << " failed: " << std::string_view(error.ptr, error.length) << std::endl; } else { std::cerr << "ovrtx " << operation << " failed" << std::endl; } return true; } return false; } // Find the handle of the given output in the given set of outputs static ovrtx_render_var_output_handle_t find_output(ovrtx_render_product_set_outputs_t const& outputs, char const* output_to_find); int main() { ovrtx_renderer_t* renderer = nullptr; ovrtx_result_t result; // Create the renderer, optionally providing configuration settings. // In this case we need no configuration. ovrtx_config_t config {}; std::cerr << "Creating renderer. The first run of the application will take some time as shaders are compiled and cached..." << std::endl; result = ovrtx_create_renderer(&config, &renderer); if (check_and_print_error(result, "create_renderer")) { return 1; } std::cerr << "Renderer created." << std::endl; ``` -------------------------------- ### Run Python Status Queries Example and Save Output Source: https://nvidia-omniverse.github.io/ovrtx/examples/python_status_queries.html Execute the main Python script and save the rendered output as a PNG image instead of displaying it. ```bash uv run main.py --png ``` -------------------------------- ### Void Operation Example Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Shows how to handle void operations, where waiting returns True on success and indicates completion. ```python op = renderer.reset_stage_async() assert op.wait() is True ``` -------------------------------- ### RenderProduct Configuration with Camera and RenderVar in USDA Source: https://nvidia-omniverse.github.io/ovrtx/sensors/configuration.html This USDA snippet defines a RenderProduct named 'DocsCamera' associated with a 'DocsCamera' camera and a 'LdrColor' RenderVar. It's an example of a specific RenderProduct setup. ```USDA (subLayers = [ @../../data/ovrtx-test-base.usda@ ]) def Camera "DocsCamera" ( prepend apiSchemas = ["OmniSensorGenericCameraCoreAPI"] ) { } def "Render" { def RenderProduct "DocsCamera" { rel camera = rel orderedVars = [] def RenderVar "LdrColor" { string sourceName = "LdrColor" } } } ``` -------------------------------- ### Define Independent RenderProducts in USDA Source: https://nvidia-omniverse.github.io/ovrtx/sensors/configuration.html Use this snippet to define separate RenderProducts for each sensor when independent output variables, resolution, or other settings are required. This example shows the setup for 'FrontCamera' and 'RearCamera'. ```USDA def "Render" { def RenderProduct "FrontCamera" { rel camera = rel orderedVars = [<../Vars/LdrColor>] } def RenderProduct "RearCamera" { rel camera = rel orderedVars = [<../Vars/LdrColor>] } def "Vars" { def RenderVar "LdrColor" { string sourceName = "LdrColor" } } } ``` -------------------------------- ### Setting Up and Testing Log Callbacks Source: https://nvidia-omniverse.github.io/ovrtx/c_api/practical_patterns.html This example demonstrates setting up a global log callback to capture messages. It shows how to initially receive all messages and then how to filter them using channel prefixes and log levels. Ensure to flush logs and disable the callback when finished. ```cpp // First pass: receive all messages (NULL channel filter). g_message_count.store(0); ovrtx_result_t r = ovrtx_set_log_callback(OVRTX_LOG_INFO, nullptr, // NULL = all channels &count_messages, &g_message_count); ASSERT_API_SUCCESS(r.status); // Reset first so the renderer is in a clean state. ovrtx_enqueue_result_t eq = ovrtx_reset_stage(renderer_); ASSERT_API_SUCCESS(eq.status); ovrtx_op_wait_result_t wait_result; ASSERT_API_SUCCESS(ovrtx_wait_op(renderer_, eq.op_index, ovrtx_timeout_infinite, &wait_result).status); do_open_usd(); // Ensure pending log messages have been delivered through the callback. ovrtx_timeout_t flush_timeout{5'000'000'000ull}; ovrtx_flush_log(flush_timeout); int observed_any_channel = g_message_count.load(); // Second pass: install a high default threshold and an explicit low // threshold for a channel prefix that cannot match any real channel. g_message_count.store(0); std::string bogus = "this.channel.does.not.exist.42=info"; ovx_string_t filter{bogus.c_str(), bogus.size()}; r = ovrtx_set_log_callback(OVRTX_LOG_FATAL, &filter, &count_messages, &g_message_count); ASSERT_API_SUCCESS(r.status); // Re-run the same work and flush — the callback should not fire. eq = ovrtx_reset_stage(renderer_); ASSERT_API_SUCCESS(eq.status); ASSERT_API_SUCCESS(ovrtx_wait_op(renderer_, eq.op_index, ovrtx_timeout_infinite, &wait_result).status); do_open_usd(); ovrtx_flush_log(flush_timeout); int observed_bogus_filter = g_message_count.load(); // Disable the callback before the renderer is torn down. ovrtx_set_log_callback(OVRTX_LOG_INFO, nullptr, nullptr, nullptr); ``` -------------------------------- ### AttributeMapping Usage Example Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Example demonstrating how to map an attribute for direct buffer access using NumPy. ```python import numpy as np mapping = renderer.map_attribute( ["/World/Cube"], "xformOp:transform", dtype=np.float64, shape=(4, 4)) ``` -------------------------------- ### Configure Global Selection Styling (Python) Source: https://nvidia-omniverse.github.io/ovrtx/scene/picking.html Sets up the renderer with global selection outline properties like width and fill mode. Ensure the log file path is correctly configured. ```Python log_file_path = str(output_dir / "picking_selection_styled.ovrtx.log") config = ovrtx.RendererConfig( selection_outline_enabled=True, selection_outline_width=8, selection_fill_mode=ovrtx.SelectionFillMode.GROUP_FILL_COLOR, log_file_path=log_file_path, ) renderer = ovrtx.Renderer(config=config) ``` -------------------------------- ### RenderProductSetOutputs Indexing and Membership Example Source: https://nvidia-omniverse.github.io/ovrtx/python_api/index.html Illustrates how to access a specific render product by its path using dictionary-like indexing and how to check for the existence of a product using the 'in' operator. ```python # Dict-like indexing product = products["/Render/Product0"] # Membership test if "/Render/Product0" in products: ... ``` -------------------------------- ### RenderVarOutput Mapping Example Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Map a RenderVarOutput to a MappedRenderVar to access its tensors and parameters via DLPack. This example shows how to use the `map` method within a context manager. ```python # Example usage: # with render_var.map(device=Device.CUDA) as rv: # arr = wp.from_dlpack(rv) # single-tensor render variable # wp.launch(my_kernel, inputs=[arr]) ``` -------------------------------- ### Create and Configure Renderer Source: https://nvidia-omniverse.github.io/ovrtx/c_api/practical_patterns.html Builds a renderer configuration from entries and passes it to ovrtx_create_renderer. Ensure the created renderer is not null and destroy it when done. ```cpp uint32_t major = 0; uint32_t minor = 0; uint32_t patch = 0; ovrtx_get_version(&major, &minor, &patch); ovrtx_config_entry_t entries[] = { ovrtx_config_entry_log_level(ovx_str("info")), ovrtx_config_entry_sync_mode(true), }; ovrtx_config_t config{entries, 2}; ovrtx_renderer_t* configured_renderer = nullptr; ovrtx_result_t create_result = ovrtx_create_renderer(&config, &configured_renderer); ASSERT_API_SUCCESS(create_result.status); ASSERT_NE(configured_renderer, nullptr); ovrtx_destroy_renderer(configured_renderer); ``` -------------------------------- ### Programmatically Configure RenderProduct for Camera Output Source: https://nvidia-omniverse.github.io/ovrtx/sensors/cameras.html Sets up a RenderProduct and associated RenderVars using the USD Python API. This is an alternative to defining it directly in USD. ```Python render_scope = stage.DefinePrim("/Render") camera_product = UsdRender.Product.Define(stage, "/Render/Camera") camera_product.GetResolutionAttr().Set(Gf.Vec2i(1920, 1080)) camera_product.GetCameraRel().SetTargets(["/World/Camera"]) lldr_var = UsdRender.Var.Define(stage, "/Render/Camera/LdrColor") lldr_var.GetSourceNameAttr().Set("LdrColor") hdr_var = UsdRender.Var.Define(stage, "/Render/Camera/HdrColor") hdr_var.GetSourceNameAttr().Set("HdrColor") camera_product.GetOrderedVarsRel().SetTargets([ "/Render/Camera/LdrColor", "/Render/Camera/HdrColor", ]) ``` -------------------------------- ### Get Device Type Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Returns the device type (Device.CPU or Device.CUDA) to which the attribute is mapped. ```python return self._device ``` -------------------------------- ### Minimal OVRTX Rendering Example Source: https://nvidia-omniverse.github.io/ovrtx/c_api/getting_started.html This C++ code demonstrates the fundamental steps to initialize the OVRTX renderer, load a USD scene, render a single frame, and handle API errors. It's suitable for understanding the basic workflow. ```cpp #include #include #include #include #include #include #include #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" template static bool check_and_print_error(ResultT const& result, std::string_view operation) { if (result.status == OVRTX_API_ERROR) { ovx_string_t error = ovrtx_get_last_error(); if (error.ptr && error.length > 0) { std::cerr << "ovrtx " << operation << " failed: " << std::string_view(error.ptr, error.length) << std::endl; } else { std::cerr << "ovrtx " << operation << " failed" << std::endl; } return true; } return false; } // Find the handle of the given output in the given set of outputs static ovrtx_render_var_output_handle_t find_output(ovrtx_render_product_set_outputs_t const& outputs, char const* output_to_find); int main() { ovrtx_renderer_t* renderer = nullptr; ovrtx_result_t result; // Create the renderer, optionally providing configuration settings. // In this case we need no configuration. ovrtx_config_t config {}; std::cerr << "Creating renderer. The first run of the application will take some time as shaders are compiled and cached..." << std::endl; result = ovrtx_create_renderer(&config, &renderer); if (check_and_print_error(result, "create_renderer")) { return 1; } std::cerr << "Renderer created." << std::endl; // Load a USD layer into the renderer. // // As well as just passing a URI to an existing layer, we could pass a USDA // string in order to compose a Stage at runtime. This can be very useful // for dynamically creating the RenderProducts etc. that define the render // output rather than editing the original layer to add them. // // A real application might want to load the USD layer and traverse it to // find either existing RenderProducts, and/or Cameras and allow the user to // select which one to render, and which RenderVars to output. char const* usd_url = "https://omniverse-content-production.s3.us-west-2.amazonaws.com/Samples/Robot-OVRTX/robot-ovrtx.usda"; std::cerr << "Adding " << usd_url << " at root..." << std::endl; ovrtx_enqueue_result_t enqueue_result = ovrtx_open_usd_from_file(renderer, {usd_url, strlen(usd_url)}); // This operation is asynchronous as loading the USD may take a long time. // We'll just poll every 100ms till it's done. ovrtx_op_wait_result_t wait_result; result = ovrtx_wait_op( renderer, enqueue_result.op_index, ovrtx_timeout_t{0}, &wait_result); if (check_and_print_error(result, "wait_op")) { ovrtx_destroy_renderer(renderer); return 1; } while (ovrtx_wait_op(renderer, enqueue_result.op_index, ovrtx_timeout_t{0}, &wait_result).status == OVRTX_API_TIMEOUT) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } std::cerr << "USD loaded." << std::endl; // We render a frame by stepping the renderer. // // Any sensors whose exposures end during this step will generate a frame // that will be available in the step result. Since the camera in the loaded // USD layer is instantaneous (does not specify motion blur or rolling // shutter), it will generate a frame every time the render is stepped. // // To step the renderer we need to tell ovrtx which RenderProducts we're // interested in, which in this case is the RenderProduct we defined in the // loading layer. ovrtx_render_product_set_t render_products = {}; ovx_string_t render_product_str = {"/Render/Camera", strlen("/Render/Camera")}; render_products.render_products = &render_product_str; render_products.num_render_products = 1; std::cerr << "Stepping renderer..." << std::endl; ovrtx_step_result_handle_t step_result_handle = 0; enqueue_result = ovrtx_step(renderer, render_products, 1.0 / 60.0, &step_result_handle); if (check_and_print_error(enqueue_result, "step")) { ovrtx_destroy_renderer(renderer); return 1; } // Wait for the render to complete. Here we'll just block until it's done. result = ovrtx_wait_op(renderer, enqueue_result.op_index, ovrtx_timeout_infinite, &wait_result); if (check_and_print_error(result, "wait_op")) { ovrtx_destroy_results(renderer, step_result_handle); ovrtx_destroy_renderer(renderer); return 1; } std::cerr << "Stepped renderer." << std::endl; ``` -------------------------------- ### Polling with Timeout Example Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Demonstrates polling an operation's status with a timeout to check for readiness. ```python pending = op.wait(timeout_ns=0) if pending is None: print("Not ready yet") ``` -------------------------------- ### Minimal Lifecycle: Load USD, Step, Fetch Results Source: https://nvidia-omniverse.github.io/ovrtx/core/application_flow.html This snippet demonstrates the basic lifecycle of the Omniverse RTX renderer. It loads a USD layer, steps the renderer to produce a frame, and then fetches the rendered output. Ensure the renderer is initialized and error checking functions are available. ```cpp // Load a USD layer into the renderer. // // As well as just passing a URI to an existing layer, we could pass a USDA // string in order to compose a Stage at runtime. This can be very useful // for dynamically creating the RenderProducts etc. that define the render // output rather than editing the original layer to add them. // // A real application might want to load the USD layer and traverse it to // find either existing RenderProducts, and/or Cameras and allow the user to // select which one to render, and which RenderVars to output. char const* usd_url = "https://omniverse-content-production.s3.us-west-2.amazonaws.com/Samples/Robot-OVRTX/robot-ovrtx.usda"; std::cerr << "Adding " << usd_url << " at root..." << std::endl; ovrtx_enqueue_result_t enqueue_result = ovrtx_open_usd_from_file(renderer, {usd_url, strlen(usd_url)}); // This operation is asynchronous as loading the USD may take a long time. // We'll just poll every 100ms till it's done. ovrtx_op_wait_result_t wait_result; result = ovrtx_wait_op( renderer, enqueue_result.op_index, ovrtx_timeout_t{0}, &wait_result); if (check_and_print_error(result, "wait_op")) { ovrtx_destroy_renderer(renderer); return 1; } while (ovrtx_wait_op(renderer, enqueue_result.op_index, ovrtx_timeout_t{0}, &wait_result).status == OVRTX_API_TIMEOUT) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } std::cerr << "USD loaded." << std::endl; // We render a frame by stepping the renderer. // // Any sensors whose exposures end during this step will generate a frame // that will be available in the step result. Since the camera in the loaded // USD layer is instantaneous (does not specify motion blur or rolling // shutter), it will generate a frame every time the render is stepped. // // To step the renderer we need to tell ovrtx which RenderProducts we're // interested in, which in this case is the RenderProduct we defined in the // loading layer. ovrtx_render_product_set_t render_products = {}; ovx_string_t render_product_str = {"/Render/Camera", strlen("/Render/Camera")}; render_products.render_products = &render_product_str; render_products.num_render_products = 1; std::cerr << "Stepping renderer..." << std::endl; ovrtx_step_result_handle_t step_result_handle = 0; enqueue_result = ovrtx_step(renderer, render_products, 1.0 / 60.0, &step_result_handle); if (check_and_print_error(enqueue_result, "step")) { ovrtx_destroy_renderer(renderer); return 1; } // Wait for the render to complete. Here we'll just block until it's done. result = ovrtx_wait_op(renderer, enqueue_result.op_index, ovrtx_timeout_infinite, &wait_result); if (check_and_print_error(result, "wait_op")) { ovrtx_destroy_results(renderer, step_result_handle); ovrtx_destroy_renderer(renderer); return 1; } std::cerr << "Stepped renderer." << std::endl; std::cerr << "Fetching results..." << std::endl; ovrtx_render_product_set_outputs_t outputs = {}; result = ovrtx_fetch_results( renderer, step_result_handle, ovrtx_timeout_infinite, &outputs); if (check_and_print_error(result, "fetch_results")) { ovrtx_destroy_results(renderer, step_result_handle); ovrtx_destroy_renderer(renderer); return 1; } // Find LdrColor in outputs ovrtx_render_var_output_handle_t ldrcolor_output_handle = find_output(outputs, "LdrColor"); if (ldrcolor_output_handle == -1) { std::cerr << "LdrColor output not found" ovrtx_destroy_results(renderer, step_result_handle); ovrtx_destroy_renderer(renderer); return 1; } std::cerr << "Fetched results." << std::endl; // Map rendered output so that it can be accessed on the CPU ovrtx_map_output_description_t map_desc = {}; map_desc.device_type = OVRTX_MAP_DEVICE_TYPE_CPU; ovrtx_render_var_output_t rendered_output = {}; result = ovrtx_map_render_var_output(renderer, ldrcolor_output_handle, &map_desc, ovrtx_timeout_infinite, &rendered_output); if (check_and_print_error(result, "map_render_var_output")) { ovrtx_destroy_results(renderer, step_result_handle); ovrtx_destroy_renderer(renderer); return 1; } ``` -------------------------------- ### Get Binding Descriptor Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Retrieves the binding descriptor, which can be used for write_attribute calls if it was provided during mapping. ```python return self._binding_desc ``` -------------------------------- ### Get Map Handle Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Returns the map handle, which is a uint64 value used for the unmap operation. ```python return int(self._mapping.map_handle) ``` -------------------------------- ### RenderProductSetOutputs Iteration Example Source: https://nvidia-omniverse.github.io/ovrtx/python_api/index.html Demonstrates how to iterate through render products and their associated data within a RenderProductSetOutputs object. This includes accessing frames, render variables, and their mapped data. ```python # Dict-like iteration products = renderer.step(...) for product_name, product in products.items(): for frame in product.frames: for var_name, render_var in frame.render_vars.items(): mapping = render_var.map() # Process mapping.tensor... ``` -------------------------------- ### Get Operation ID Source: https://nvidia-omniverse.github.io/ovrtx/python_api/index.html Retrieves the unique identifier for an asynchronous operation. This ID can be useful for tracking or debugging. ```python _property _op_id _: int_# The operation ID. ``` -------------------------------- ### Initialize Renderer with Custom Configuration Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/renderer.html Instantiate the Renderer class with a custom configuration, specifying options like synchronization mode and log file path. Resources are automatically managed. ```python from ovrtx import Renderer, RendererConfig # Or customize config = RendererConfig(sync_mode=True, log_file_path="/path/to/app.log") renderer = Renderer(config=config) # Resources automatically cleaned up when renderer goes out of scope ``` -------------------------------- ### Initialize Renderer with Default Configuration Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/renderer.html Instantiate the Renderer class using default settings. Resources are automatically managed. ```python from ovrtx import Renderer, RendererConfig # Use defaults renderer = Renderer() ``` -------------------------------- ### Write Scalar Attribute Asynchronously Source: https://nvidia-omniverse.github.io/ovrtx/python_api/index.html This snippet demonstrates how to write a scalar attribute asynchronously. Refer to `write_attribute()` for full documentation and examples. ```python # This is a placeholder for the actual asynchronous write operation. # The actual implementation would involve calling write_attribute_async with parameters. # Example structure: # operation = renderer.write_attribute_async(prim_paths, attribute_name, tensor) # operation.wait() # To wait for completion pass ``` -------------------------------- ### Compose RenderProducts with Python Source: https://nvidia-omniverse.github.io/ovrtx/sensors/configuration.html Use `open_usd_from_string` to load a USD scene with inline RenderProducts and RenderVars composed via subLayers. This is useful when the original USD file lacks these prims. ```python renderer.open_usd_from_string(f''' #usda 1.0 ( subLayers = [ @{scene_path}@ ] ) def "Render" {{ def RenderProduct "Camera" {{ int2 resolution = (1920, 1080) rel camera = rel orderedVars = [, ] def RenderVar "LdrColor" {{ string sourceName = "LdrColor" }} def RenderVar "HdrColor" {{ string sourceName = "HdrColor" }} }} ''') products = renderer.step( render_products={"/Render/Camera"}, delta_time=1.0 / 60, ) ``` -------------------------------- ### Getting Data from ManagedDLTensor Source: https://nvidia-omniverse.github.io/ovrtx/python_api/index.html Demonstrates methods to retrieve data from a ManagedDLTensor. `to_bytes()` creates a copy, while `numpy()` provides a zero-copy view. ```python managed_tensor = ovrtx.ManagedDLTensor(...) # Get data as bytes (creates a copy) byte_data = managed_tensor.to_bytes() # Get a NumPy array view (zero-copy) numpy_array = managed_tensor.numpy() ``` -------------------------------- ### Python: Open USD Async and Wait Source: https://nvidia-omniverse.github.io/ovrtx/core/async_status_errors.html Asynchronously opens a USD file and waits for the operation to complete. Asserts that a prim is available after loading. ```python op = renderer.open_usd_async(TEST_BASE_PATH) # TODO: Restore the assertion once the packaged open_usd_async wrapper returns _VOID_RESULT. op.wait() assert "/World/Plane" in renderer.query_prims(attribute_filter_mode=ovrtx.AttributeFilterMode.NONE) ``` -------------------------------- ### FrameOutput Data Structure Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Defines a data structure for a single frame, containing its start and end times, and a dictionary of render variables. ```python @dataclass class FrameOutput(Generic[T]): """Single frame with multiple render variables.""" start_time: float """Sensor simulation time at frame start, in seconds. Accumulated from ``delta_time`` values passed to :meth:`Renderer.step`. Epoch is 0.0 at renderer creation and after :meth:`reset_stage`; set to *time* after :meth:`reset(time=...) `. """ end_time: float """Sensor simulation time at frame end, in seconds (``start_time + delta_time``).""" render_vars: dict[str, RenderVarOutput[T]] ``` -------------------------------- ### Simple Operation Example Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Illustrates a simple asynchronous operation that returns a handle directly upon waiting, without a separate fetch phase. ```python op = renderer.add_usd_reference_async(path, "/World/Props") handle = op.wait() # USD handle (no fetch phase) ``` -------------------------------- ### Renderer.open_usd_async Source: https://nvidia-omniverse.github.io/ovrtx/python_api/index.html Opens a USD file as the root layer asynchronously. Resets the current stage and loads the given file as the root sublayer, returning immediately with an Operation for manual control. ```APIDOC ## Renderer.open_usd_async ### Description Open a USD file as the root layer (asynchronous). Resets the current stage and loads the given file as the root sublayer. Returns immediately with an Operation for manual control. ### Parameters #### Path Parameters - **usd_file_path** (_str_) - Path to the USD file to open. ### Returns - **Operation** - Operation that can be polled or waited on with custom timeout. `wait()` returns `True` on success and `None` on timeout. ### Raises - **RuntimeError** - If renderer is invalid or enqueue fails. ### Example ```python op = renderer.open_usd_async("/path/to/scene.usda") op.wait(timeout_ns=1_000_000_000) ``` ``` -------------------------------- ### RenderProductSetOutputs keys Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/types.html Returns a view object displaying a list of all render product paths. ```python def keys(self): """Get all render product paths.""" return self._outputs.keys() ``` -------------------------------- ### Configure RenderProduct Device Pinning Source: https://nvidia-omniverse.github.io/ovrtx/sensors/configuration.html Example of defining a RenderProduct with specific CUDA-visible device IDs. Use this to restrict a RenderProduct to a deterministic GPU. ```usd def RenderProduct "Camera" { rel camera = uint[] deviceIds = [0] int2 resolution = (640, 320) rel orderedVars = def RenderVar "LdrColor" { string sourceName = "LdrColor" } } ``` -------------------------------- ### Get Renderer Configuration Source: https://nvidia-omniverse.github.io/ovrtx/_modules/ovrtx/_src/renderer.html Retrieves the configuration object used to create the renderer. Provides access to the settings and parameters used during renderer initialization. ```python @property def config(self) -> RendererConfig: """Get the configuration used to create this renderer.""" return self._config ``` -------------------------------- ### Configure OmniRadar Prim (Python) Source: https://nvidia-omniverse.github.io/ovrtx/sensors/radar.html Sets up the OmniRadar sensor prim with its API schema and frame rate. Use this for generic WPM DMAT radar models. ```python def OmniRadar "Radar" ( prepend apiSchemas = ["OmniSensorGenericRadarWpmDmatAPI"] ) { token omni:sensor:WpmDmat:elementsCoordsType = "CARTESIAN" double2 omni:sensor:frameRate = (10, 1) double3 xformOp:translate = (0, 0, 1) float3 xformOp:rotateXYZ = (90, 0, -90) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"] } ```