embodichain.lab.sim.sim_manager#
Overview#
SimulationManager is the central handle around the DexSim scene. It
owns the physics world and the object/sensor registry, drives the simulation
step, owns its profiler, and exposes capture hooks and visualization
configuration. Downstream components (environments, planners, IK solvers, the
visualization runtime) look up the active manager through its class-level
instance registry instead of passing it around explicitly.
Native entity interaction defaults on when the first native window opens.
Set SimulationManagerCfg(enable_entity_gizmo=False) to opt out, or call
sim.disable_entity_gizmo() at runtime. Explicit enable/disable calls and
custom DexSim controller settings survive window close/reopen. Pure headless
and Viser runs do not automatically create native gizmos.
SimulationManagerCfg.robot_ik_gizmo defaults to GizmoCfg() and registers
robot control parts with configured IK-chain/TCP metadata during normal updates.
Native IK activates on the first I press by default; Viser constructs its solver on
the first drag and requires visualization.allow_commands. Registration does
not write drive targets. Set this field to None to opt out or select
GizmoCfg(ik_solver="embodichain") to reuse configured solvers. Explicit
enable_gizmo() settings override automatic defaults, and disable_gizmo()
prevents automatic recreation. GizmoCfg(ik_start_enabled=True) activates
native IK on the first update with an open window, as used by the robot tutorial.
Classes
Global Embodied AI simulation manager. |
|
Global robot simulation configuration. |
- class embodichain.lab.sim.sim_manager.SimulationManager[source]#
Bases:
objectGlobal Embodied AI simulation manager.
- This class is used to manage the global simulation environment and simulated assets.
- assets loading, creation, modification and deletion.
assets include rigid objects, soft objects, articulations, robots, sensors and lights.
- manager the scenes and the simulation environment.
parallel scenes simulation on both CPU and GPU.
create and setup the rendering related settings, eg. environment map, lighting, materials, etc.
physics simulation management, eg. time step, manual update, etc.
interactive control via gizmo and window callbacks events.
- Parameters:
sim_config (SimulationManagerCfg, optional) – simulation configuration. Defaults to SimulationManagerCfg().
Attributes:
Get the arena offsets for all arenas.
Get all assets uid in the simulation.
Check if the physics simulation is using GPU.
Get the number of arenas in the simulation.
Return current visualization service and client health.
Return the overlays included in every Viser scene frame.
Return the active visualization runtime, if one has been started.
Return visualization telemetry, or
Nonebefore startup.Methods:
__init__([sim_config, render_cfg, ...])__new__(cls[, sim_config, render_cfg, ...])Create or return the instance based on instance_id.
add_articulation(cfg)Add an articulation to the scene.
add_cloth_object(cfg)Add a cloth object to the scene.
add_custom_window_control(controls)Add one or more custom window input controls.
add_light(cfg)Create a light in the scene.
add_rigid_object(cfg)Add a rigid object to the scene.
Add a rigid object group to the scene.
add_robot(cfg)Add a Robot to the scene.
add_sensor(sensor_cfg)General interface to add a sensor to the scene and returns a handle.
add_soft_object(cfg)Add a soft object to the scene.
Return whether the native DexSim window may be opened.
capture_visualization([force, ...])Capture current scene data for the configured visualizer.
capture_visualization_safely([force, ...])Update visualization without allowing failures to stop simulation.
Close the simulation window.
create_rigid_constraint(cfg[, env_ids])Create a fixed constraint between two RigidObjects.
Create a visual material with given configuration.
destroy([exit_process])No longer destructs C++ objects in place due to lingering deep local variables; instead, packages itself into a destruction task, submits to the cleanup queue, and waits for top-level delayed consumption.
Disable native object interaction, including future window opens.
disable_gizmo(uid[, control_part])Disable a Gizmo and prevent its automatic recreation.
draw_marker(cfg)Draw visual markers in the simulation scene for debugging and visualization.
enable_entity_gizmo([config])Enable DexSim entity control and exclude the EmbodiChain ground.
enable_gizmo(uid[, control_part, gizmo_cfg])Register Gizmo control for a simulation target.
enable_physics(enable)Enable or disable physics simulation.
Register
pto print the current viewer camera pose.enable_window_record_hotkey([save_path, ...])Register the
rkey to start/stop viewer recording.export_usd(fpath)Export the current simulation scene to a USD file.
Run pending destruction tasks and wait for their scenes to disappear.
get_articulation(uid)Get an articulation by its unique ID.
Get current articulation uid list
get_asset(uid)Get an asset by its UID.
Return active axes for backend-neutral visualization.
get_cloth_object(uid)Get a cloth object by its unique ID.
Get current cloth body uid list
get_env([arena_index])Get the arena or env by index.
get_gizmo(uid[, control_part])Return an active Gizmo.
Return a stable snapshot of active Gizmo IDs and controllers.
get_instance([instance_id])Get the instance of SimulationManager by id.
Get the number of instantiated SimulationManager instances.
get_light(uid)Get a light by its UID.
Get current light uid list
get_rigid_constraint(name)Get a rigid constraint by its base name.
Get the list of registered constraint base names.
get_rigid_object(uid)Get a rigid object by its unique ID.
Get a rigid object group by its unique ID.
Get current rigid body group uid list
Get current rigid body uid list
get_robot(uid)Get a Robot by its unique ID.
Retrieves a list of unique identifiers (UIDs) for all robots in the V2 system.
get_sensor(uid)Get a sensor by its UID.
Get current sensor uid list
get_soft_object(uid)Get a soft object by its unique ID.
Get current soft body uid list
get_texture_cache([key])Get the texture from the global texture cache.
get_visual_material(uid)Get visual material by UID.
has_gizmo(uid[, control_part])Check if a gizmo exists for the given UID and control part.
Check if there is any non-static rigid object in the simulation.
Initialize the GPU physics simulation.
is_instantiated([instance_id])Check if the instance has been created.
Check whether the viewer window is currently recording.
List active Gizmo IDs and availability.
Mark scene topology dirty and return its new local revision.
Open the native DexSim simulation window when allowed.
print_window_camera_pose([convert_to_look_at])Print the current viewer camera pose as reusable Python code.
Apply queued Viser click-pick commands on the simulation thread.
Apply queued Viser Gizmo commands on the simulation thread.
Publish current scene topology when Viser is active.
remove_asset(uid)Remove an asset by its UID.
remove_marker(name)Remove markers (including axis) with the given name.
remove_rigid_constraint(name[, env_ids])Remove a rigid constraint by name.
render_camera_group(group_ids)Render all camera group in the simulation.
reset([instance_id])Reset the instance.
reset_objects_state([env_ids, excluded_uids])Reset the state of the simulated assets given the environment IDs and excluded UIDs.
Set default background.
Set default global lighting for the scene.
set_default_renderer([renderer, gpu_id])Set the global default renderer used by new simulations.
set_emission_light([color, intensity])Set environment emission light.
set_gizmo_visibility(uid, visible[, ...])Set Gizmo visibility by target UID and optional control part.
set_ground_plane_visibility(visible)_summary_
set_indirect_lighting(name)Set indirect lighting.
set_texture_cache(key, texture)Set the texture to the global texture cache.
set_visualization_overlays(overlays)Set persistent overlays for automatic Viser captures.
Start the configured live visualizer and publish the current scene.
start_window_record([save_path, fps, ...])Start asynchronously recording the simulation to a video buffer.
Stop the visualization server and release its worker thread.
stop_window_record([save_path])Stop the active viewer recording and save frames in the background.
toggle_gizmo_visibility(uid[, control_part])Toggle Gizmo visibility and return the new state, if it exists.
toggle_window_record([save_path, fps, ...])Toggle viewer recording on or off.
update([physics_dt, step])Advance physics explicitly and publish the resulting simulation state.
Register robot controls, process interaction, and update active Gizmos.
wait_scene_destruction([timeout_ms])A public helper to wait for the underlying C++ scenes (dexsim.World) to destruct completely.
Wait for all background video export threads to finish.
- SUPPORTED_SENSOR_TYPES = {'Camera': <class 'embodichain.lab.sim.sensors.camera.Camera'>, 'ContactSensor': <class 'embodichain.lab.sim.sensors.contact_sensor.ContactSensor'>, 'StereoCamera': <class 'embodichain.lab.sim.sensors.stereo.StereoCamera'>}#
- __init__(sim_config=SimulationManagerCfg(width=1920, height=1080, headless=False, enable_entity_gizmo=True, robot_ik_gizmo=GizmoCfg(axis_length_x=0.2, axis_length_y=0.2, axis_length_z=0.2, axis_size=0.01, rings_radius=0.15, rings_size=0.01, ik_solver='dexsim', ik_root_link_name=None, ik_end_link_name=None, ik_tcp_pose=None, ik_iterations=24, ik_device=None, ik_gizmo_scale=1.5, ik_toggle_key=<InputKey.SCANCODE_I: 12>, ik_start_enabled=False), render_cfg=RenderCfg(renderer='auto', spp=1, dlss=DLSSCfg(dlss_enabled=True, offscreen_dlss_enabled=True, rayreconstruction_enabled=True, upscale_enabled=True, dlss_quality=2, upsample_ratio=None, render_width=0, render_height=0, target_width=0, target_height=0, exposure_compensation=1.0, frame_time_delta_ms=0.0), tone_mapping_enabled=False, tone_mapping_exposure=1.0), gpu_id=0, thread_mode=<ThreadMode.RENDER_SHARE_ENGINE: 0>, cpu_num=1, num_envs=1, arena_space=5.0, physics_dt=0.01, profiler=None, sim_device='cpu', physics_config=PhysicsCfg(gravity=array([ 0. , 0. , -9.81]), bounce_threshold=2.0, enable_ccd=False, length_tolerance=0.05, speed_tolerance=0.25), gpu_memory_config=GPUMemoryCfg(temp_buffer_capacity=16777216, max_rigid_contact_count=524288, max_rigid_patch_count=262144, heap_capacity=67108864, found_lost_pairs_capacity=33554432, found_lost_aggregate_pairs_capacity=1024, total_aggregate_pairs_capacity=1024), window_record=WindowRecordCfg(enable_hotkey=True, save_path=None, fps=20, max_memory=1024, video_prefix='viewer_record'), window_camera_pose=WindowCameraPoseCfg(enable_hotkey=True, convert_to_look_at=True), visualization=VisualizationCfg(backend='none', scene_fps=15.0, env_ids=[0], max_visible_envs=None, point_cloud_max_points=100000, sensor_image_fps=2.0, soft_body_fps=5.0, allow_commands=False, viser_server=ViserServerCfg(host='127.0.0.1', port=8080, label='EmbodiChain', verbose=False))))[source]#
- static __new__(cls, sim_config=SimulationManagerCfg(width=1920, height=1080, headless=False, enable_entity_gizmo=True, robot_ik_gizmo=GizmoCfg(axis_length_x=0.2, axis_length_y=0.2, axis_length_z=0.2, axis_size=0.01, rings_radius=0.15, rings_size=0.01, ik_solver='dexsim', ik_root_link_name=None, ik_end_link_name=None, ik_tcp_pose=None, ik_iterations=24, ik_device=None, ik_gizmo_scale=1.5, ik_toggle_key=<InputKey.SCANCODE_I: 12>, ik_start_enabled=False), render_cfg=RenderCfg(renderer='auto', spp=1, dlss=DLSSCfg(dlss_enabled=True, offscreen_dlss_enabled=True, rayreconstruction_enabled=True, upscale_enabled=True, dlss_quality=2, upsample_ratio=None, render_width=0, render_height=0, target_width=0, target_height=0, exposure_compensation=1.0, frame_time_delta_ms=0.0), tone_mapping_enabled=False, tone_mapping_exposure=1.0), gpu_id=0, thread_mode=<ThreadMode.RENDER_SHARE_ENGINE: 0>, cpu_num=1, num_envs=1, arena_space=5.0, physics_dt=0.01, profiler=None, sim_device='cpu', physics_config=PhysicsCfg(gravity=array([ 0. , 0. , -9.81]), bounce_threshold=2.0, enable_ccd=False, length_tolerance=0.05, speed_tolerance=0.25), gpu_memory_config=GPUMemoryCfg(temp_buffer_capacity=16777216, max_rigid_contact_count=524288, max_rigid_patch_count=262144, heap_capacity=67108864, found_lost_pairs_capacity=33554432, found_lost_aggregate_pairs_capacity=1024, total_aggregate_pairs_capacity=1024), window_record=WindowRecordCfg(enable_hotkey=True, save_path=None, fps=20, max_memory=1024, video_prefix='viewer_record'), window_camera_pose=WindowCameraPoseCfg(enable_hotkey=True, convert_to_look_at=True), visualization=VisualizationCfg(backend='none', scene_fps=15.0, env_ids=[0], max_visible_envs=None, point_cloud_max_points=100000, sensor_image_fps=2.0, soft_body_fps=5.0, allow_commands=False, viser_server=ViserServerCfg(host='127.0.0.1', port=8080, label='EmbodiChain', verbose=False))))[source]#
Create or return the instance based on instance_id.
- add_articulation(cfg)[source]#
Add an articulation to the scene.
- Parameters:
cfg (ArticulationCfg) – Configuration for the articulation.
- Returns:
The added articulation instance handle.
- Return type:
- add_cloth_object(cfg)[source]#
Add a cloth object to the scene.
- Parameters:
cfg (ClothObjectCfg) – Configuration for the cloth object.
- Returns:
The added cloth object instance handle.
- Return type:
- add_custom_window_control(controls)[source]#
Add one or more custom window input controls.
This method registers additional
ObjectManipulatorinstances with the simulation window so they can handle input events alongside any default controls.- Parameters:
controls (list[ObjectManipulator]) – A list of initialized ObjectManipulator instances to add to the current window. Each control will be registered via
window.add_input_control. If no window is available, the controls are not added and a warning is logged.- Return type:
None
- add_light(cfg)[source]#
Create a light in the scene.
Supports six light types:
"point","sun","direction","spot","rect", and"mesh". SeeLightCfgfor type-specific configuration fields.Attention
"sun"and"direction"lights are global scene lights (infinite-distance directional light sources). They are created as a single instance on the root environment, not batched per environment. All other types are created as per-environment batched lights.
- add_rigid_object(cfg)[source]#
Add a rigid object to the scene.
- Parameters:
cfg (RigidObjectCfg) – Configuration for the rigid object.
- Returns:
The added rigid object instance handle.
- Return type:
- add_rigid_object_group(cfg)[source]#
Add a rigid object group to the scene.
- Parameters:
cfg (RigidObjectGroupCfg) – Configuration for the rigid object group.
- Return type:
- add_sensor(sensor_cfg)[source]#
General interface to add a sensor to the scene and returns a handle.
- Parameters:
sensor_cfg (SensorCfg) – configuration for the sensor.
- Returns:
The added sensor instance handle.
- Return type:
- add_soft_object(cfg)[source]#
Add a soft object to the scene.
- Parameters:
cfg (SoftObjectCfg) – Configuration for the soft object.
- Returns:
The added soft object instance handle.
- Return type:
- property arena_offsets: Tensor#
Get the arena offsets for all arenas.
- Returns:
The arena offsets of shape (num_arenas, 3).
- Return type:
torch.Tensor
- property asset_uids: List[str]#
Get all assets uid in the simulation.
The assets include lights, sensors, robots, rigid objects and articulations.
- Returns:
list of all assets uid.
- Return type:
List[str]
- can_open_native_window()[source]#
Return whether the native DexSim window may be opened.
The Viser backend owns visualization while it is configured or running, so a native window must not be opened for the same simulation.
- Return type:
bool- Returns:
Trueunless the Viser backend is configured or running.
- capture_visualization(force=False, *, capture_camera_images=True)[source]#
Capture current scene data for the configured visualizer.
- Parameters:
force (
bool) – Whether to bypass visualization frame-rate limiting.capture_camera_images (
bool) – Whether camera images may be captured.
- Return type:
bool- Returns:
Whether scene or camera data was captured.
- capture_visualization_safely(force=False, *, capture_camera_images=True)[source]#
Update visualization without allowing failures to stop simulation.
The first visualization failure is logged and subsequent captures are skipped until the runtime is restarted.
- Parameters:
force (
bool) – Whether to bypass visualization frame-rate limiting.capture_camera_images (
bool) – Whether camera images may be captured.
- Return type:
None
- create_rigid_constraint(cfg, env_ids=None)[source]#
Create a fixed constraint between two RigidObjects.
Binds
rigid_object_a’s entity[i] torigid_object_b’s entity[i] within arena[i], for each env inenv_ids. Local frames default to welding the objects at their current relative pose:local_frame_adefaults to identity (object A’s origin) andlocal_frame_bdefaults toinv(pose_B) @ pose_A(computed per env), so the offset is preserved rather than the two origins being pulled together. Pass explicit frames to define a specific joint frame.- Parameters:
cfg (
RigidConstraintCfg) – The constraint configuration.env_ids (
Union[Sequence[int],Tensor,None]) – Target environment indices. Accepts a tensor (as passed by theEventManager) or a sequence of ints. None -> all arenas.
- Return type:
- Returns:
The created
RigidConstraint.- Raises:
RuntimeError – If either object is missing, the name is already in use, a frame shape is invalid, or dexsim fails to create a handle.
- create_visual_material(cfg)[source]#
Create a visual material with given configuration.
- Parameters:
cfg (VisualMaterialCfg) – configuration for the visual material.
- Returns:
the created visual material instance handle.
- Return type:
- destroy(exit_process=None)[source]#
No longer destructs C++ objects in place due to lingering deep local variables; instead, packages itself into a destruction task, submits to the cleanup queue, and waits for top-level delayed consumption.
- Parameters:
exit_process (bool | None) – Whether to call os._exit(0) after queuing the destruction task. If None, reads EMBODICHAIN_SIM_EXIT_PROCESS.
- Return type:
None
- disable_entity_gizmo()[source]#
Disable native object interaction, including future window opens.
Call
enable_entity_gizmo()to explicitly re-enable interaction. Robot IK controllers and Viser command permissions are independent.- Return type:
None
- disable_gizmo(uid, control_part=None)[source]#
Disable a Gizmo and prevent its automatic recreation.
- Parameters:
uid (
str) – Target asset UID.control_part (
str|None) – Robot control part. Omit to disable every part of a robot.
- Return type:
None
- draw_marker(cfg)[source]#
Draw visual markers in the simulation scene for debugging and visualization.
Drawing markers does not advance physics. Call
capture_visualization()to publish them to Viser without stepping.- Parameters:
cfg (MarkerCfg) –
Marker configuration with the following key parameters: - name (str): Unique identifier for the marker group - marker_type (str): Type of marker (“axis” currently supported) - axis_xpos (np.ndarray | List[np.ndarray]): 4x4 transformation matrices
for marker positions and orientations
axis_size (float): Thickness of axis arrows
axis_len (float): Length of axis arrows
arena_index (int): Arena index for placement (-1 for global)
- Returns:
List of created marker handles, False if invalid input, None if no poses provided.
- Return type:
List[MeshObject]
Example
`python cfg = MarkerCfg(name="test_axis", marker_type="axis", axis_xpos=np.eye(4)) markers = sim.draw_marker(cfg) `
- enable_entity_gizmo(config=None)[source]#
Enable DexSim entity control and exclude the EmbodiChain ground.
Called automatically on the first native window unless disabled in
SimulationManagerCfg. Explicit calls also work headlessly. DexSim retains this controller and its configuration across window close/reopen; reopening does not reapply the default configuration.- Parameters:
config (
EntityGizmoConfig|None) – Native DexSim entity-Gizmo configuration.- Return type:
EntityGizmoManipulator- Returns:
The active world-owned entity Gizmo manipulator.
- enable_gizmo(uid, control_part=None, gizmo_cfg=None)[source]#
Register Gizmo control for a simulation target.
Robot controls support native windows and Viser; native IK activates on the configured toggle key. Explicit configuration takes precedence over automatically registered controls.
- enable_physics(enable)[source]#
Enable or disable physics simulation.
- Parameters:
enable (bool) – whether to enable physics simulation.
- Return type:
None
- enable_window_camera_pose_hotkey(convert_to_look_at=True)[source]#
Register
pto print the current viewer camera pose.- Parameters:
convert_to_look_at (
bool) – Print awindow.set_look_at(...)call when true, which is the default. Set false to print the raw matrix.- Return type:
bool- Returns:
Whether the control is registered on an available window.
- enable_window_record_hotkey(save_path=None, fps=20, max_memory=1024, video_prefix='viewer_record')[source]#
Register the
rkey to start/stop viewer recording.- Return type:
bool
- export_usd(fpath)[source]#
Export the current simulation scene to a USD file.
- Parameters:
fpath (str) – The file path to save the USD file.
- Returns:
True if export is successful, False otherwise.
- Return type:
bool
- static flush_cleanup_queue()[source]#
Run pending destruction tasks and wait for their scenes to disappear.
An empty queue means that no manager requested destruction. In that case, returning immediately is important: other managers may still own live worlds, and waiting for the global world count to reach zero would block until the timeout even though there is nothing to clean up.
- Return type:
None
- get_articulation(uid)[source]#
Get an articulation by its unique ID.
- Parameters:
uid (str) – The unique ID of the articulation.
- Returns:
The articulation instance if found, otherwise None.
- Return type:
Articulation | None
- get_articulation_uid_list()[source]#
Get current articulation uid list
- Returns:
list of articulation uid.
- Return type:
List[str]
- get_asset(uid)[source]#
Get an asset by its UID.
The asset can be a light, sensor, robot, rigid object or articulation.
- Parameters:
uid (str) – The UID of the asset.
- Returns:
The asset instance if found, otherwise None.
- Return type:
Light | BaseSensor | Robot | RigidObject | Articulation | None
- get_axis_marker_items()[source]#
Return active axes for backend-neutral visualization.
- Return type:
tuple[tuple[str,tuple[MeshObject,...],float,float],...]- Returns:
Tuples containing the marker name, native handles, axis length, and axis radius for each active marker group.
- get_cloth_object(uid)[source]#
Get a cloth object by its unique ID.
- Parameters:
uid (str) – The unique ID of the cloth object.
- Returns:
The cloth object instance if found, otherwise None.
- Return type:
ClothObject | None
- get_cloth_object_uid_list()[source]#
Get current cloth body uid list
- Returns:
list of cloth body uid.
- Return type:
List[str]
- get_env(arena_index=-1)[source]#
Get the arena or env by index.
If arena_index is -1, return the global env. If arena_index is valid, return the corresponding arena.
- Parameters:
arena_index (int, optional) – the index of arena to get, -1 for global env. Defaults to -1.
- Returns:
The arena or global env.
- Return type:
dexsim.environment.Arena
- get_gizmo(uid, control_part=None)[source]#
Return an active Gizmo.
- Parameters:
uid (
str) – Target asset UID.control_part (
str|None) – Robot control part, if applicable.
- Return type:
Gizmo|None- Returns:
Gizmo instance if found, otherwise
None.
- get_gizmo_items()[source]#
Return a stable snapshot of active Gizmo IDs and controllers.
- Return type:
tuple[tuple[str,Gizmo],...]
- classmethod get_instance(instance_id=0)[source]#
Get the instance of SimulationManager by id.
- Parameters:
instance_id (int) – The instance id. Defaults to 0.
- Returns:
The instance.
- Return type:
- Raises:
RuntimeError – If the instance has not been created yet.
- classmethod get_instance_num()[source]#
Get the number of instantiated SimulationManager instances.
- Returns:
The number of instances.
- Return type:
int
- get_light(uid)[source]#
Get a light by its UID.
- Parameters:
uid (str) – The UID of the light.
- Returns:
The light instance if found, otherwise None.
- Return type:
Light | None
- get_light_uid_list()[source]#
Get current light uid list
- Returns:
list of light uid.
- Return type:
List[str]
- get_rigid_constraint(name)[source]#
Get a rigid constraint by its base name.
- Parameters:
name (
str) – The base constraint name.- Return type:
RigidConstraint|None- Returns:
The constraint, or None if not found.
- get_rigid_constraint_uid_list()[source]#
Get the list of registered constraint base names.
- Returns:
list of constraint names.
- Return type:
List[str]
- get_rigid_object(uid)[source]#
Get a rigid object by its unique ID.
- Parameters:
uid (str) – The unique ID of the rigid object.
- Returns:
The rigid object instance if found, otherwise None.
- Return type:
RigidObject | None
- get_rigid_object_group(uid)[source]#
Get a rigid object group by its unique ID.
- Parameters:
uid (str) – The unique ID of the rigid object group.
- Returns:
The rigid object group instance if found, otherwise None.
- Return type:
RigidObjectGroup | None
- get_rigid_object_group_uid_list()[source]#
Get current rigid body group uid list
- Returns:
list of rigid body group uid.
- Return type:
List[str]
- get_rigid_object_uid_list()[source]#
Get current rigid body uid list
- Returns:
list of rigid body uid.
- Return type:
List[str]
- get_robot(uid)[source]#
Get a Robot by its unique ID.
- Parameters:
uid (str) – The unique ID of the robot.
- Returns:
The robot instance if found, otherwise None.
- Return type:
Robot | None
- get_robot_uid_list()[source]#
Retrieves a list of unique identifiers (UIDs) for all robots in the V2 system.
- Returns:
A list containing the UIDs of the robots.
- Return type:
list
- get_sensor(uid)[source]#
Get a sensor by its UID.
- Parameters:
uid (str) – The UID of the sensor.
- Returns:
The sensor instance if found, otherwise None.
- Return type:
BaseSensor | None
- get_sensor_uid_list()[source]#
Get current sensor uid list
- Returns:
list of sensor uid.
- Return type:
List[str]
- get_soft_object(uid)[source]#
Get a soft object by its unique ID.
- Parameters:
uid (str) – The unique ID of the soft object.
- Returns:
The soft object instance if found, otherwise None.
- Return type:
SoftObject | None
- get_soft_object_uid_list()[source]#
Get current soft body uid list
- Returns:
list of soft body uid.
- Return type:
List[str]
- get_texture_cache(key=None)[source]#
Get the texture from the global texture cache.
- Parameters:
key (str | None, optional) – The key of the texture. If None, return None. Defaults to None.
- Returns:
The texture if found, otherwise None.
- Return type:
torch.Tensor | list[torch.Tensor] | None
- get_visual_material(uid)[source]#
Get visual material by UID.
- Parameters:
uid (str) – uid of visual material.
- Return type:
- has_gizmo(uid, control_part=None)[source]#
Check if a gizmo exists for the given UID and control part.
- Parameters:
uid (str) – Object UID to check
control_part (str | None, optional) – Control part name for robots. Defaults to None.
- Returns:
True if gizmo exists, False otherwise.
- Return type:
bool
- has_non_static_rigid_object()[source]#
Check if there is any non-static rigid object in the simulation.
- Returns:
True if there is at least one non-static rigid object, False otherwise.
- Return type:
bool
- classmethod is_instantiated(instance_id=0)[source]#
Check if the instance has been created.
- Returns:
True if the instance exists, False otherwise.
- Return type:
bool
- property is_use_gpu_physics: bool#
Check if the physics simulation is using GPU.
- is_window_recording()[source]#
Check whether the viewer window is currently recording.
- Return type:
bool
- list_gizmos()[source]#
List active Gizmo IDs and availability.
- Return type:
dict[str,bool]- Returns:
Mapping from
uid[:control_part]to availability.
- notify_visualization_topology_changed()[source]#
Mark scene topology dirty and return its new local revision.
- Return type:
int
- property num_envs: int#
Get the number of arenas in the simulation.
- Returns:
number of arenas.
- Return type:
int
- open_window()[source]#
Open the native DexSim simulation window when allowed.
Viser owns visualization while it is configured or running. In that case this method safely skips the native window so launchers do not need a separate Viser condition.
- Return type:
bool- Returns:
Truewhen the native window is open, otherwiseFalse.
- print_window_camera_pose(convert_to_look_at=True)[source]#
Print the current viewer camera pose as reusable Python code.
- Parameters:
convert_to_look_at (
bool) – Printwindow.set_look_at(...)by default. Set false to print the raw 4x4 pose matrix instead.- Return type:
str|None- Returns:
The printed snippet, or
Nonewhen no viewer window is open.
- process_pick_commands()[source]#
Apply queued Viser click-pick commands on the simulation thread.
A non-empty pick attaches a picker-owned Gizmo to the clicked node; an empty pick (clicking empty space) clears it. Only one picker-owned Gizmo is kept at a time and user-created Gizmos are never touched.
- Return type:
int- Returns:
Number of pick commands drained from the visualization runtime.
- process_visualization_commands()[source]#
Apply queued Viser Gizmo commands on the simulation thread.
- Return type:
int- Returns:
Number of commands accepted for active Gizmos.
- refresh_visualization()[source]#
Publish current scene topology when Viser is active.
- Return type:
SceneManifest|None
- remove_asset(uid)[source]#
Remove an asset by its UID.
The asset can be a light, sensor, robot, rigid object or articulation.
Note
Currently, lights and sensors are not supported to be removed.
- Parameters:
uid (str) – The UID of the asset.
- Returns:
True if the asset is removed successfully, otherwise False.
- Return type:
bool
- remove_marker(name)[source]#
Remove markers (including axis) with the given name.
- Parameters:
name (str) – The name of the marker to remove.
- Returns:
True if the marker was removed successfully, False otherwise.
- Return type:
bool
- remove_rigid_constraint(name, env_ids=None)[source]#
Remove a rigid constraint by name.
With
env_ids=Nonethe constraint is removed from every arena and dropped from the registry. With a subset, only those arenas are cleared; the registry entry is kept until all handles become None.- Parameters:
name (
str) – The base constraint name.env_ids (
Union[Sequence[int],Tensor,None]) – Subset of arenas to clear. Accepts a tensor (as passed by theEventManager) or a sequence of ints. None -> all.
- Return type:
bool- Returns:
True if the constraint was found (and removed or partially removed), False if the name is unknown.
- render_camera_group(group_ids)[source]#
Render all camera group in the simulation.
- Parameters:
group_ids (list[int]) – The list of camera group ids to render.
- Return type:
None
Note: This interface is only valid when Ray Tracing rendering backend is enabled.
- classmethod reset(instance_id=0)[source]#
Reset the instance.
This allows creating a new instance with different configuration.
- Return type:
None
- reset_objects_state(env_ids=None, excluded_uids=None)[source]#
Reset the state of the simulated assets given the environment IDs and excluded UIDs.
- Parameters:
env_ids (Sequence[int] | None) – The environment IDs to reset. If None, reset all environments.
excluded_uids (Sequence[str] | None) – List of asset UIDs to exclude from resetting. If None, reset all assets.
- Return type:
None
- set_default_global_lighting()[source]#
Set default global lighting for the scene.
Configures both the environment emission (ambient) light and a directional light to provide default scene illumination. The directional light is a global scene light (infinite distance) pointing downward along the -Z axis.
- Return type:
None
- classmethod set_default_renderer(renderer='auto', gpu_id=0)[source]#
Set the global default renderer used by new simulations.
This updates
embodichain.lab.sim.cfg.DEFAULT_RENDERER, which is consulted byembodichain.lab.sim.utility.render_utils.select_default_renderer()whenrender_cfg.renderer="auto"is resolved duringSimulationManagerconstruction.- Parameters:
renderer (
str) – The renderer to set. One of"auto","hybrid","fast-rt", or"rt". When"auto", the renderer is resolved immediately from the detected GPU viaembodichain.lab.sim.utility.render_utils.select_default_renderer().gpu_id (
int) – The CUDA device index to query whenrenderer="auto".
- Return type:
str- Returns:
The resolved renderer name that was set as the default.
- set_emission_light(color=None, intensity=None)[source]#
Set environment emission light.
- Parameters:
color (Sequence[float] | None) – color of the light.
intensity (float | None) – intensity of the light.
- Return type:
None
- set_gizmo_visibility(uid, visible, control_part=None)[source]#
Set Gizmo visibility by target UID and optional control part.
- Return type:
None
- set_ground_plane_visibility(visible)[source]#
_summary_
- Parameters:
visible (bool) – _description_
- Return type:
None
- set_indirect_lighting(name)[source]#
Set indirect lighting.
- Parameters:
name (str) – name of path of the indirect lighting.
- Return type:
None
- set_texture_cache(key, texture)[source]#
Set the texture to the global texture cache.
- Parameters:
key (str) – The key of the texture.
texture (Union[torch.Tensor, List[torch.Tensor]]) – The texture data.
- Return type:
None
- set_visualization_overlays(overlays)[source]#
Set persistent overlays for automatic Viser captures.
The overlays remain active across
update()calls until replaced or cleared withNone. When Viser is running, the new overlays are published immediately.- Parameters:
overlays (
SceneOverlays|None) – Backend-neutral overlays to publish with every frame, orNoneto clear all persistent overlays.- Return type:
None
- start_visualization()[source]#
Start the configured live visualizer and publish the current scene.
- Return type:
VisualizationRuntime|None
- start_window_record(save_path=None, fps=20, max_memory=1024, video_prefix='viewer_record', pose_provider=None, fixed_pose=None, look_at=None, use_sim_time=None)[source]#
Start asynchronously recording the simulation to a video buffer.
The recorder can either follow the live viewer camera or run without a window by using a fixed pose or a pose callback supplied by the caller.
- Parameters:
save_path (
str|None) – Optional output path for the recorded video.fps (
int) – Target output frames per second. Must be positive.max_memory (
int) – Maximum buffered frame memory in MB. Must be positive.video_prefix (
str) – File name prefix used whensave_pathis not provided.pose_provider (
Optional[Callable[[],ndarray]]) – Optional callback that returns the current camera pose.fixed_pose (
ndarray|None) – Optional fixed 4x4 camera pose matrix.look_at (
tuple[Sequence[float],Sequence[float],Sequence[float]] |None) – Optional(eye, target, up)tuple used to derive a fixed pose.use_sim_time (
bool|None) – Whether to capture frames from simulation time instead of wall time. Defaults to headless mode when no viewer window exists.
- Returns:
True if recording starts successfully, otherwise False.
- Return type:
bool
- stop_visualization()[source]#
Stop the visualization server and release its worker thread.
- Return type:
None
- stop_window_record(save_path=None)[source]#
Stop the active viewer recording and save frames in the background.
- Return type:
bool
- toggle_gizmo_visibility(uid, control_part=None)[source]#
Toggle Gizmo visibility and return the new state, if it exists.
- Return type:
bool|None
- toggle_window_record(save_path=None, fps=20, max_memory=1024, video_prefix='viewer_record')[source]#
Toggle viewer recording on or off.
- Return type:
bool
- update(physics_dt=None, step=10)[source]#
Advance physics explicitly and publish the resulting simulation state.
Each substep applies pending Gizmo controls before advancing the world, then updates simulation time, recording, and browser visualization. Physics does not advance in the background while the caller is idle.
- Parameters:
physics_dt (float | None, optional) – the time step for physics simulation. Defaults to None.
step (int, optional) – the number of steps to update physics. Defaults to 10.
- Return type:
None
- update_gizmos()[source]#
Register robot controls, process interaction, and update active Gizmos.
- Return type:
None
- property visualization_health: RuntimeHealth#
Return current visualization service and client health.
- property visualization_overlays: SceneOverlays | None#
Return the overlays included in every Viser scene frame.
- property visualization_runtime: VisualizationRuntime | None#
Return the active visualization runtime, if one has been started.
- property visualization_stats: RuntimeStats | None#
Return visualization telemetry, or
Nonebefore startup.
Native point-cloud visualization
- SimulationManager.visualize_point_cloud(points, colors=None, point_size=2.0, name='point_cloud')[source]#
Visualize a static point cloud in the native simulation viewer.
Each invocation creates a separate native point-cloud object. This convenience API is intended for static data, not incremental or streaming updates.
- Parameters:
points (
Tensor|ndarray) – Point positions with shape(N, 3).colors (
Tensor|ndarray|None) – Optional per-point RGB or RGBA colors with shape(N, 3)or(N, 4). Values in[0, 255]are normalized to[0, 1]. The alpha channel of RGBA input is ignored by the native renderer. Defaults to green.point_size (
float) – Native renderer point size. Defaults to2.0.name (
str) – Name assigned to the native point-cloud object.
- Return type:
PointCloud- Returns:
The native DexSim point-cloud handle.
- Raises:
RuntimeError – If there is no active simulation environment.
ValueError – If the points or colors do not have a supported shape.
- class embodichain.lab.sim.sim_manager.SimulationManagerCfg[source]#
Bases:
objectGlobal robot simulation configuration.
Attributes:
The distance between each arena when building multiple arenas.
The number of CPU threads to use for the simulation engine.
Enable native object interaction when the first native window opens.
The gpu index that the simulation engine will be used.
The GPU memory configuration parameters.
Whether to run without an automatically opened native window.
The height of the simulation window.
The number of parallel environments (arenas) to simulate.
The physics configuration parameters.
The time step for the physics simulation.
Optional simulation profiler.
The rendering configuration parameters.
Automatically register robot parts with configured IK chain/TCP metadata.
The device for the physics simulation.
The threading mode for the simulation engine.
Live browser visualization settings.
The width of the simulation window.
Interactive viewer camera-pose printing settings.
Viewer window recording settings (hotkey, paths, FPS, memory budget).
-
arena_space:
float# The distance between each arena when building multiple arenas.
-
cpu_num:
int# The number of CPU threads to use for the simulation engine.
-
enable_entity_gizmo:
bool# Enable native object interaction when the first native window opens.
Headless and Viser simulations do not automatically create native gizmos. Explicit runtime enable/disable calls take precedence over this default; reopening a window preserves the current DexSim controller state. Robot IK interaction is controlled separately by
robot_ik_gizmo.
-
gpu_id:
int# The gpu index that the simulation engine will be used.
Note: it will affect the gpu physics device if using gpu physics.
-
gpu_memory_config:
GPUMemoryCfg# The GPU memory configuration parameters.
-
headless:
bool# Whether to run without an automatically opened native window.
This is forced to
Truewhen the Viser backend is enabled. Viser and the native DexSim window are mutually exclusive; browser Gizmos do not require a native window.
-
height:
int# The height of the simulation window.
-
num_envs:
int# The number of parallel environments (arenas) to simulate.
-
physics_config:
PhysicsCfg# The physics configuration parameters.
-
physics_dt:
float# The time step for the physics simulation.
-
profiler:
ProfilerCfg|None# Optional simulation profiler.
Nonedisables profiling.Standalone calls to
SimulationManager.update()are recorded below asim_updateroot. When the manager is owned by an environment, the same profiler instance composes with the environment’s step/reset hierarchy.
-
robot_ik_gizmo:
GizmoCfg|None# Automatically register robot parts with configured IK chain/TCP metadata.
Native controls activate on the first I press; Viser creates its IK solver on the first drag and requires
visualization.allow_commands. Pure headless and multi-environment simulations do not register controls. Defaults to DexSim IK. UseGizmoCfg(ik_solver="embodichain")to reuse configured solvers such as Pink, orNoneto disable automatic setup.GizmoCfg(ik_start_enabled=True)explicitly activates native controls on their first update with an open window, without waiting for I.
-
sim_device:
Union[str,device]# The device for the physics simulation. Can be ‘cpu’, ‘cuda’, or a torch.device object.
-
thread_mode:
ThreadMode# The threading mode for the simulation engine.
RENDER_SHARE_ENGINE: The rendering thread shares the same thread with the simulation engine.
RENDER_SCENE_SHARE_ENGINE: The rendering thread and scene update thread share the same thread with the simulation engine.
-
visualization:
VisualizationCfg# Live browser visualization settings.
-
width:
int# The width of the simulation window.
-
window_camera_pose:
WindowCameraPoseCfg# Interactive viewer camera-pose printing settings.
-
window_record:
WindowRecordCfg# Viewer window recording settings (hotkey, paths, FPS, memory budget).
-
arena_space: