|
1 | | -# Cross Simulator |
2 | | -## Basic usage |
3 | | -By default, the simulator is set to `isaacsim`. You can change it to other simulators by setting the `sim` argument. Currently, we support: |
4 | | -- `isaacsim` |
5 | | -- `isaacgym` |
6 | | -- `pyrep` |
7 | | - |
8 | | -## IsaacGym example |
9 | | -For example, to replay the demo in IsaacGym, you can run: |
| 1 | +# Cross-Simulator Support |
| 2 | + |
| 3 | +MetaSim enables you to write code once and run it across multiple physics simulators without modifications. This is one of the core features that makes RoboVerse a unified platform for robot learning. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Supported Simulators |
| 8 | + |
| 9 | +| Simulator | Backend | GPU Parallel | Best Use Case | |
| 10 | +|-----------|---------|--------------|---------------| |
| 11 | +| `mujoco` | MuJoCo | Via MJX | Fast prototyping, CPU training | |
| 12 | +| `mjx` | MuJoCo MJX | Native | Massively parallel RL | |
| 13 | +| `isaacsim` | Isaac Sim | Native | High-fidelity sim2real | |
| 14 | +| `isaacgym` | Isaac Gym | Native | GPU-accelerated RL | |
| 15 | +| `sapien3` | SAPIEN 3 | Native | Manipulation research | |
| 16 | +| `sapien2` | SAPIEN 2 | - | Legacy support | |
| 17 | +| `genesis` | Genesis | Native | Large-scale training | |
| 18 | +| `pybullet` | PyBullet | - | Debugging, education | |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Basic Usage |
| 23 | + |
| 24 | +### Switching Simulators |
| 25 | + |
| 26 | +Change the simulator by setting the `simulator` parameter in your scenario: |
| 27 | + |
| 28 | +```python |
| 29 | +from metasim.scenario.scenario import ScenarioCfg |
| 30 | + |
| 31 | +# Run with MuJoCo |
| 32 | +scenario = ScenarioCfg( |
| 33 | + robots=["franka"], |
| 34 | + simulator="mujoco", # Change this to switch simulators |
| 35 | + num_envs=1, |
| 36 | +) |
| 37 | + |
| 38 | +# Or switch to Isaac Sim |
| 39 | +scenario = ScenarioCfg( |
| 40 | + robots=["franka"], |
| 41 | + simulator="isaacsim", |
| 42 | + num_envs=1, |
| 43 | +) |
| 44 | +``` |
| 45 | + |
| 46 | +### Command Line Examples |
| 47 | + |
| 48 | +Most scripts support the `--sim` argument to select the simulator: |
| 49 | + |
10 | 50 | ```bash |
| 51 | +# Run with MuJoCo |
| 52 | +python scripts/advanced/replay_demo.py --sim=mujoco --task=StackCube |
| 53 | + |
| 54 | +# Run with Isaac Gym |
11 | 55 | python scripts/advanced/replay_demo.py --sim=isaacgym --task=StackCube |
| 56 | + |
| 57 | +# Run with SAPIEN 3 |
| 58 | +python scripts/advanced/replay_demo.py --sim=sapien3 --task=PickCube |
12 | 59 | ``` |
13 | 60 |
|
14 | | -task could also be: |
15 | | -- `PickCube` |
16 | | -- `StackCube` |
17 | | -- `CloseBox` |
| 61 | +--- |
| 62 | + |
| 63 | +## Considerations |
| 64 | + |
| 65 | +### Feature Parity |
| 66 | + |
| 67 | +Not all features are available across all simulators. Check the [Support Matrix](support_matrix.rst) for detailed compatibility information. |
| 68 | + |
| 69 | +### Performance Differences |
| 70 | + |
| 71 | +| Simulator | Single Env Speed | Parallel Scaling | Rendering Quality | |
| 72 | +|-----------|------------------|------------------|-------------------| |
| 73 | +| MuJoCo | Fast | Good (via MJX) | Medium | |
| 74 | +| Isaac Sim | Medium | Excellent | Excellent (RTX) | |
| 75 | +| SAPIEN 3 | Fast | Good | Good | |
| 76 | +| Genesis | Fast | Excellent | Good | |
| 77 | + |
| 78 | +### Asset Compatibility |
| 79 | + |
| 80 | +Different simulators may require different asset formats: |
| 81 | + |
| 82 | +| Simulator | Preferred Format | |
| 83 | +|-----------|------------------| |
| 84 | +| MuJoCo | MJCF (.xml) | |
| 85 | +| Isaac Sim | USD (.usd, .usda) | |
| 86 | +| SAPIEN | URDF (.urdf) | |
| 87 | +| PyBullet | URDF (.urdf) | |
| 88 | + |
| 89 | +MetaSim handles format conversion automatically when possible. |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## Example: Multi-Simulator Evaluation |
| 94 | + |
| 95 | +Evaluate the same policy across different simulators to test sim2sim transfer: |
| 96 | + |
| 97 | +```python |
| 98 | +from metasim.scenario.scenario import ScenarioCfg |
| 99 | +from metasim.task.registry import get_task_class |
| 100 | + |
| 101 | +task_cls = get_task_class("StackCube") |
| 102 | + |
| 103 | +simulators = ["mujoco", "sapien3", "isaacsim"] |
| 104 | +results = {} |
| 105 | + |
| 106 | +for sim in simulators: |
| 107 | + scenario = task_cls.scenario.update( |
| 108 | + simulator=sim, |
| 109 | + num_envs=10, |
| 110 | + headless=True, |
| 111 | + ) |
| 112 | + env = task_cls(scenario=scenario) |
| 113 | + |
| 114 | + # Run evaluation |
| 115 | + success_rate = evaluate_policy(env, policy) |
| 116 | + results[sim] = success_rate |
| 117 | + |
| 118 | + env.close() |
| 119 | + |
| 120 | +print("Cross-simulator results:", results) |
| 121 | +``` |
0 commit comments