Simulation Manager#
The SimulationManager is the central class in EmbodiChain’s simulation framework for managing the simulation lifecycle. It handles:
Asset Management: Loading and managing robots, rigid objects, soft objects, articulations, and lights.
Simulation Loop: Controlling the physics stepping and rendering updates.
Rendering: Managing the simulation window, camera rendering, material settings and ray-tracing configuration.
Interaction: Providing gizmo controls for interactive manipulation of objects.
Configuration#
The simulation is configured using the SimulationManagerCfg class.
from embodichain.lab.sim import SimulationManagerCfg
sim_config = SimulationManagerCfg(
width=1920, # Window width
height=1080, # Window height
num_envs=10, # Number of parallel environments
physics_dt=0.01, # Physics time step
sim_device="cpu", # Simulation device ("cpu" or "cuda:0", etc.)
arena_space=5.0 # Spacing between environments
)
Configuration Parameters#
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
The width of the simulation window. |
|
|
|
The height of the simulation window. |
|
|
|
Whether to run the simulation in headless mode (no Window). |
|
|
|
Whether to enable ray tracing rendering. |
|
|
|
Whether to enable denoising for ray tracing rendering. |
|
|
|
Samples per pixel for ray tracing rendering. Only valid when ray tracing is enabled and denoiser is False. |
|
|
|
The gpu index that the simulation engine will be used. Affects gpu physics device. |
|
|
|
The threading mode for the simulation engine. |
|
|
|
The number of CPU threads to use for the simulation engine. |
|
|
|
The number of parallel environments (arenas) to simulate. |
|
|
|
The distance between each arena when building multiple arenas. |
|
|
|
The time step for the physics simulation. |
|
|
|
The device for the physics simulation. |
|
|
|
The physics configuration parameters. |
|
|
|
The GPU memory configuration parameters. |
Physics Configuration#
The PhysicsCfg class controls the global physics simulation parameters.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Gravity vector for the simulation environment. |
|
|
|
The speed threshold below which collisions will not produce bounce effects. |
|
|
|
Enable continuous collision detection (CCD) for fast-moving objects. |
|
|
|
The length tolerance for the simulation. Larger values increase speed. |
|
|
|
The speed tolerance for the simulation. Larger values increase speed. |
For more parameters and details, refer to the PhysicsCfg documentation.
Initialization#
Initialize the manager with the configuration object:
from embodichain.lab.sim import SimulationManager, SimulationManagerCfg
# User can customize the config as needed.
sim_config = SimulationManagerCfg()
sim = SimulationManager(sim_config)
Assets Management#
The manager provides methods to add, retrieve and remove various simulation assets including:
Rigid Objects
Soft Objects
Articulations
Robots
Lights
Materials
For more details on simulation assets, please refer to their respective documentation pages.
Simulation Loop#
Manual Update mode#
In this mode, the physics simulation should be explicitly stepped by calling update() method, which provides precise control over the simulation timing.
The use case for manual update mode includes:
Data generation with openai gym environments, in which the observation and action must be synchronized with the physics simulation.
Applications that require precise dynamic control over the simulation timing.
while True:
# Step physics simulation.
sim.update(step=1)
# Perform other tasks such as get data from the scene or apply sensor update.
The default mode is manual update mode. To switch to automatic update mode, call
set_manual_update(False).
Automatic Update mode#
In this mode, the physics simulation stepping is automatically handling by the physics thread running in dexsim engine, which makes it easier to use for visualization and interactive applications.
When in automatic update mode, user are recommanded to use CPU
sim_devicefor simulation.
Mainly used methods#
SimulationManager.update(physics_dt=None, step=1): Steps the physics simulation with optional custom time step and number of steps. Ifphysics_dtis None, uses the configured physics time step.SimulationManager.enable_physics(enable: bool): Enable or disable physics simulation.SimulationManager.set_manual_update(enable: bool): Set manual update mode for physics.
Multiple instances#
SimulationManager supports multiple instances to run separate simulations world independently. Each instance maintains its own simulation state, assets, and configurations.
To get current instance number of
SimulationManager:SimulationManager.get_instance_num()To get specific instance:
SimulationManager.get_instance(instance_id).
Currently, multiple instances are not supported for ray tracing rendering backend. Good news is that we are working on adding this feature in future releases.
For more methods and details, refer to the SimulationManager documentation.