UniSim Unified API
UniSim is the sole interface layer between FastSim and the underlying simulation engines. It abstracts "start the simulator, advance physics, query running state" into a fixed set of interfaces, so SceneManager, ControllerManager, and other upper modules are completely unaware of which backend is running.
Core Interfaces
| Method | When Called | Description |
|---|---|---|
initialize_simulation() | During setup_all_before_loop() | Start the simulation App/SimulationContext |
setup_viewport_camera() | After init (optional) | Set default viewport for debugging |
reset() | After scene construction | Reset physics, run initialization steps |
step() | Each simulation frame | Advance physics by one timestep (dt) |
is_running() | Main loop condition | Query whether the backend is still running |
Position in the Simulation Loop
ControllerManager.run_all_commands() ← Execute command queue
SceneManager.pre_physics_update() ← Write target values to simulator
UniSim.step() ← Physics engine advances one frame
SceneManager.post_physics_update() ← Read latest state from simulator
[step callbacks] ← Extension hook points
Backend Selection
The backend is determined by simulation.stereotype. UniSimFactory.create(config) instantiates the corresponding backend:
simulation:
stereotype: isaaclab # or mujoco, pybullet
dt: 0.01667
IsaacLab Backend
GPU-accelerated physics and rendering via NVIDIA Isaac Lab. Supports cuda:0 device, PhysX GPU pipeline, and high-fidelity rendering.
Source: fastsim/simulators/isaaclab/
MuJoCo Backend
Lightweight CPU physics engine. Fast startup, suitable for debugging and rapid iteration. Supports MJCF and URDF asset formats.
simulation:
stereotype: mujoco
dt: 0.002
Source: fastsim/simulators/mujuco/
PyBullet Backend
Open-source CPU physics engine with built-in OpenGL rendering. Commonly used in reinforcement learning research.
simulation:
stereotype: pybullet
dt: 0.002
Source: fastsim/simulators/pybullet/
Custom Backend
To integrate a new simulator, inherit UniSim and implement the five interface methods, then register via stereotype:
from fastsim.unisim.unisim import UniSim
from fastsim.annotations.stereotype import stereotype
@stereotype("my_simulator")
class MySimulator(UniSim):
def initialize_simulation(self): ...
def step(self): ...
def reset(self): ...
def is_running(self) -> bool: ...