# PHYSICS [omni.physics.isaacsimready]

The `omni.physics.isaacsimready` extension enables seamless multiphysics workflows for IsaacSim-ready assets. It provides automatic schema capability checking and variant switching to ensure assets work correctly across different physics simulators.

## Overview

This extension provides two main capabilities:

1. **Schema Capability Checking**: Validates whether USD physics schemas on your stage are supported by the active simulator(s)
2. **Automatic Variant Switching**: Switches USD variants on prims when changing between different physics simulators (e.g., PhysX, Newton, MuJoCo)

## Features

### Schema Capability Report

The extension scans your USD stage and checks if all physics-related prim types and API schemas are supported by the currently active physics simulator. It reports:

- All prim types found on the stage
- All applied API schemas
- Whether each schema is supported by the active simulator
- List of unsupported schemas (if any)

Supported schema types include:
- USD Physics schemas (`PhysicsScene`, `PhysicsRigidBodyAPI`, etc.)
- PhysX-specific schemas (`PhysxSceneAPI`, `PhysxRigidBodyAPI`, etc.)
- MuJoCo schemas
- Newton schemas

### Variant Manager & Automatic Variant Switching

The Variant Manager tracks prims with simulation variants and automatically switches them when you change physics simulators. This is essential for IsaacSim-ready assets that define different physics representations for different simulators.

**Example workflow:**
1. Asset has a "Physics" variant set with options: `physx`, `mujoco`, `newton`
2. When you activate the PhysX simulator, the extension automatically switches to the `physx` variant
3. When you switch to Newton simulator, it switches to the `mujoco` variant
4. Notifications keep you informed of which prims were updated

## Usage

### Viewing the Schema Capability Report

**Via Viewport Menu:**
1. Open the Physics viewport menu
2. Enable "Schema Capability Report"
3. A window will appear showing capability analysis for the current stage

**Via Python API:**
```python
from omni.physics.isaacsimready.scripts.capability_checker import check_stage_capabilities, print_capability_report

# Check capabilities and print report
reports = check_stage_capabilities()
print_capability_report(reports)
```

### Using Variant Switching

Variant switching is enabled by default and works automatically. When you activate a different simulator, the extension:
1. Detects the simulator change
2. Looks up the corresponding variant name
3. Switches all tracked prims to that variant
4. Shows a notification with switched prim names

**Registering Custom Simulator-Variant Mappings:**
```python
from omni.physics.isaacsimready.scripts.extension import get_variant_switcher

switcher = get_variant_switcher()
switcher.register_simulator_variant("MySimulator", "my_variant_name")
```

## Settings

Configure the extension via Settings or Python API:

- **`/exts/omni.physics.isaacsimready/capability_check_enabled`** (default: `true`)
  Enable/disable capability checking functionality

- **`/exts/omni.physics.isaacsimready/capability_check_window_enabled`** (default: `false`)
  Show/hide the capability check window UI

- **`/exts/omni.physics.isaacsimready/variant_manager_enabled`** (default: `true`)
  Enable/disable automatic variant switching

## Developer API

### CapabilityManager

Manages registration and tracking of physics schema names.

```python
from omni.physics.isaacsimready.scripts.extension import get_capability_manager

manager = get_capability_manager()
manager.register_schema_type_names(["MyCustomSchema"])
manager.register_api_schema_names(["MyCustomAPI"])
```

### VariantSwitcher

Handles simulator-to-variant mappings and automatic switching.

```python
from omni.physics.isaacsimready.scripts.extension import get_variant_switcher

switcher = get_variant_switcher()

# Register simulator mapping
switcher.register_simulator_variant("PhysX", "physx")

# Get active simulation
sim_id, sim_name = switcher.get_active_simulation()

# Manually trigger variant switch
stage = omni.usd.get_context().get_stage()
count = switcher.switch_variants_for_active_simulation(stage)
```

### VariantManager

Tracks prims with variant sets for efficient variant switching.

```python
from omni.physics.isaacsimready.scripts.extension import get_variant_manager

manager = get_variant_manager()

# Register a simulation variant set name to track
manager.register_simulation_variant("Physics")

# Get all prims with a specific variant set
prim_paths = manager.get_prims_with_variant("Physics")
```

### Capability Checking Functions

```python
from omni.physics.isaacsimready.scripts.capability_checker import (
    gather_stage_schemas,
    check_stage_capabilities,
    get_active_simulations
)

# Gather all physics schemas from the stage
prim_types, applied_apis = gather_stage_schemas(stage)

# Check capabilities for all active simulators
reports = check_stage_capabilities(stage)

for report in reports:
    print(f"Simulator: {report.simulation_name}")
    print(f"All supported: {report.all_schemas_supported}")
    if not report.all_schemas_supported:
        print(f"Unsupported: {report.unsupported_schemas}")
```

## Requirements

- `omni.usd`
- `omni.physics` (version 110.0.0)
- Optional: `omni.ui`, `omni.usdphysics.ui`, `omni.kit.notification_manager`

## Author

Ales Borovicka <aborovicka@nvidia.com>

