embodichain.lab.sim.sensors#
Sensors attached to the simulation scene.
Camera, StereoCamera, and ContactSensor all derive from BaseSensor and expose batched TensorDict data buffers.
Overview#
Sensors attached to the simulation scene. Every sensor derives from
BaseSensor (itself a BatchEntity),
is configured through a SensorCfg subclass, and maintains a batched
TensorDict data buffer of shape [num_envs]. The built-ins are
Camera (single RGB-D camera with configurable intrinsics/extrinsics),
StereoCamera (a camera pair with a baseline transform and optional
disparity), and ContactSensor (collision detection between rigid
bodies and articulation links via Warp kernels).
Classes
Configuration class for sensors.
Base class for sensor abstraction in the simulation engine.
Configuration class for Camera.
Base class for sensor abstraction in the simulation engine.
Configuration class for StereoCamera.
Base class for sensor abstraction in the simulation engine.
Configuration class for contact sensors.
Configuration for filtering contacts from an articulation's links.
Sensor to get contacts from rigid bodies and articulation links.
Sensor#
- class embodichain.lab.sim.sensors.BaseSensor[source]#
Bases:
BatchEntityBase class for sensor abstraction in the simulation engine.
Sensors should inherit from this class and implement the update and get_data methods.
Methods:
__init__(config[, device, num_instances])Begin interval accumulation for a sensor that samples physics substeps.
destroy()Destroy all entities managed by this batch entity.
get_arena_pose([to_matrix])Get the pose of the sensor in the arena frame.
get_data()Retrieve data from the sensor.
reset([env_ids])Reset the entity to its initial state.
update(**kwargs)Update the sensor state based on the current simulation state.
Sample a sensor that opts into physics substeps.
Attributes:
Whether the environment must sample this sensor each physics substep.
- begin_control_step()[source]#
Begin interval accumulation for a sensor that samples physics substeps.
- Return type:
None
- destroy()#
Destroy all entities managed by this batch entity.
- Return type:
None
- abstract get_arena_pose(to_matrix=False)[source]#
Get the pose of the sensor in the arena frame.
- Parameters:
to_matrix (
bool) – If True, return the pose as a 4x4 transformation matrix; otherwise return(x, y, z, qx, qy, qz, qw).- Return type:
Tensor- Returns:
A tensor representing the pose of the sensor in the arena frame.
- get_data()[source]#
Retrieve data from the sensor.
- Parameters:
copy – If True, return a copy of the data buffer. Defaults to True.
- Return type:
TensorDict- Returns:
The data collected by the sensor.
- property requires_substep_update: bool#
Whether the environment must sample this sensor each physics substep.
- reset(env_ids=None)[source]#
Reset the entity to its initial state.
- Parameters:
env_ids (Sequence[int] | None) – The environment IDs to reset. If None, reset all environments.
- Return type:
None
- class embodichain.lab.sim.sensors.SensorCfg[source]#
Configuration class for sensors.
This class can be extended to include specific sensor configurations.
Classes:
Configuration of the sensor offset relative to the parent frame.
Methods:
from_dict(init_dict)Initialize the configuration from a dictionary.
Get the data types supported by this sensor configuration.
Attributes:
4x4 transformation matrix of the root in local frame.
Position of the root in simulation world frame.
Euler angles (in degree) of the root in simulation world frame.
- class OffsetCfg[source]#
Configuration of the sensor offset relative to the parent frame.
Attributes:
Name of the parent frame.
Position of the sensor in the parent frame.
Orientation in the parent frame as
(x, y, z, w).-
parent:
str|None# Name of the parent frame. If not specified, the sensor will be placed in the arena frame.
This is usually the case when the sensor is not attached to any specific object, eg, link of a robot arm.
-
pos:
Tuple[float,float,float]# Position of the sensor in the parent frame. Defaults to (0.0, 0.0, 0.0).
-
quat:
Tuple[float,float,float,float]# Orientation in the parent frame as
(x, y, z, w). Defaults to identity.
-
parent:
- classmethod from_dict(init_dict)[source]#
Initialize the configuration from a dictionary.
- Return type:
- abstract get_data_types()[source]#
Get the data types supported by this sensor configuration.
- Return type:
List[str]- Returns:
A list of data types that this sensor configuration supports.
- init_local_pose: np.ndarray | None#
4x4 transformation matrix of the root in local frame. If specified, it will override init_pos and init_rot.
- init_pos: tuple[float, float, float]#
Position of the root in simulation world frame. Defaults to (0.0, 0.0, 0.0).
- init_rot: tuple[float, float, float]#
Euler angles (in degree) of the root in simulation world frame. Defaults to (0.0, 0.0, 0.0).
Camera#
- class embodichain.lab.sim.sensors.Camera[source]#
Bases:
BaseSensorBase class for sensor abstraction in the simulation engine.
Sensors should inherit from this class and implement the update and get_data methods.
Methods:
__init__(config[, device])attach_to_parent_nodes(parent_nodes)Attach camera views to one resolved parent node per environment.
Begin interval accumulation for a sensor that samples physics substeps.
destroy()Remove render cameras before releasing their World-owned group.
get_arena_pose([to_matrix])Get the pose of the sensor in the arena frame.
get_data()Retrieve data from the sensor.
Get the camera intrinsics for both left and right cameras.
get_local_pose([to_matrix])Get the local pose of the camera.
look_at(eye, target[, up, env_ids])Set the camera to look at a target point.
reset([env_ids])Reset the entity to its initial state.
set_intrinsics(intrinsics[, env_ids])Set the camera intrinsics for both left and right cameras.
set_local_pose(pose[, env_ids])Set the local pose of the camera.
update(**kwargs)Update the sensor data.
Sample a sensor that opts into physics substeps.
Attributes:
Get the camera group ID in the dexsim world.
Return whether all camera views are attached to parent nodes.
Whether the environment must sample this sensor each physics substep.
- attach_to_parent_nodes(parent_nodes)[source]#
Attach camera views to one resolved parent node per environment.
- Parameters:
parent_nodes (
Sequence[object]) – Parent render nodes ordered by environment index.- Raises:
RuntimeError – If the number of parent nodes does not match the number of camera instances.
ValueError – If any parent node is missing.
- Return type:
None
- begin_control_step()#
Begin interval accumulation for a sensor that samples physics substeps.
- Return type:
None
- destroy()[source]#
Remove render cameras before releasing their World-owned group.
- Return type:
None
- get_arena_pose(to_matrix=False)[source]#
Get the pose of the sensor in the arena frame.
- Parameters:
to_matrix (bool) – If True, return the pose as a 4x4 transformation matrix. If False, return
(x, y, z, qx, qy, qz, qw).- Return type:
Tensor- Returns:
A tensor representing the pose of the sensor in the arena frame.
- get_data()#
Retrieve data from the sensor.
- Parameters:
copy – If True, return a copy of the data buffer. Defaults to True.
- Return type:
TensorDict- Returns:
The data collected by the sensor.
- get_intrinsics()[source]#
Get the camera intrinsics for both left and right cameras.
- Returns:
The intrinsics for the left camera with shape (N, 3, 3).
- Return type:
torch.Tensor
- get_local_pose(to_matrix=False)[source]#
Get the local pose of the camera.
- Parameters:
to_matrix (bool) – If True, return the pose as a 4x4 matrix. If False, return
(x, y, z, qx, qy, qz, qw).- Returns:
The local pose of the camera.
- Return type:
torch.Tensor
- property group_id: int#
Get the camera group ID in the dexsim world.
- Returns:
The camera group ID.
- Return type:
int
- property is_attached: bool#
Return whether all camera views are attached to parent nodes.
- Returns:
True after parent attachment and extrinsics application succeed.
- look_at(eye, target, up=None, env_ids=None)[source]#
Set the camera to look at a target point.
- Parameters:
eye (torch.Tensor) – The position of the camera (eye) with shape (N, 3).
target (torch.Tensor) – The point the camera should look at (target) with shape (N, 3).
up (torch.Tensor | None) – The up direction vector. If None, defaults to [0, 0, 1].
env_ids (Sequence[int] | None) – The environment IDs to set the look at for. If None, set for all environments.
- Return type:
None
- property requires_substep_update: bool#
Whether the environment must sample this sensor each physics substep.
- reset(env_ids=None)[source]#
Reset the entity to its initial state.
- Parameters:
env_ids (Sequence[int] | None) – The environment IDs to reset. If None, reset all environments.
- Return type:
None
- set_intrinsics(intrinsics, env_ids=None)[source]#
Set the camera intrinsics for both left and right cameras.
- Parameters:
intrinsics (torch.Tensor) – The intrinsics for the left camera with shape (4,) / (3, 3) or (N, 4) / (N, 3, 3).
env_ids (Sequence[int] | None) – The environment ids to set the intrinsics. If None, set for all environments.
- Return type:
None
- set_local_pose(pose, env_ids=None)[source]#
Set the local pose of the camera.
Note
The pose uses OpenGL camera axes: +Y is up and -Z is forward.
- Parameters:
pose (torch.Tensor) – The local pose as
(N, 4, 4)matrices or(N, 7)vectors in(x, y, z, qx, qy, qz, qw)order.env_ids (Sequence[int] | None) – The environment IDs to set the pose for. If None, set for all environments.
- Return type:
None
- update(**kwargs)[source]#
Update the sensor data.
- The supported data types are:
color: RGB images with shape (B, H, W, 4) and dtype torch.uint8
depth: Depth images with shape (B, H, W) and dtype torch.float32
mask: Instance segmentation masks with shape (B, H, W) and dtype torch.int32
normal: Normal images with shape (B, H, W, 3) and dtype torch.float32
position: Position images with shape (B, H, W, 3) and dtype torch.float32
- Parameters:
**kwargs – Additional keyword arguments for sensor update.
- Return type:
None
- update_physics_step(dt)#
Sample a sensor that opts into physics substeps.
- Parameters:
dt (
float) – Elapsed physics time in seconds.- Return type:
None
- class embodichain.lab.sim.sensors.CameraCfg[source]#
Bases:
SensorCfgConfiguration class for Camera.
Classes:
Configuration class for camera extrinsics.
Configuration of the sensor offset relative to the parent frame.
Methods:
from_dict(init_dict)Initialize the configuration from a dictionary.
Get the data types supported by this sensor configuration.
Get the view attributes for the camera.
Attributes:
4x4 transformation matrix of the root in local frame.
Position of the root in simulation world frame.
Euler angles (in degree) of the root in simulation world frame.
Role used to group this camera in live visualization previews.
- class ExtrinsicsCfg[source]#
Bases:
OffsetCfgConfiguration class for camera extrinsics.
The extrinsics define the position and orientation of the camera in the 3D world. If eye, target, and up are provided, they will be used to compute the extrinsics. Otherwise, the position and orientation will be set to the defaults.
SimulationManager resolves
parentas a Robot or Articulation link name. Use"<asset_uid>/<link_name>"when the link name is ambiguous. Explicit mounted poses use OpenGL axes (-Z forward, +Y up). Unparented explicit poses use optical axes (+Z forward, +Y down) and are converted inCamera.reset(). Look-at inputs specify viewing direction directly in either case.Attributes:
Name of the parent frame.
Position of the sensor in the parent frame.
Orientation in the parent frame as
(x, y, z, w).Alternative way to specify the camera extrinsics using eye, target, and up vectors.
-
parent:
str|None# Name of the parent frame. If not specified, the sensor will be placed in the arena frame.
This is usually the case when the sensor is not attached to any specific object, eg, link of a robot arm.
-
pos:
Tuple[float,float,float]# Position of the sensor in the parent frame. Defaults to (0.0, 0.0, 0.0).
-
quat:
Tuple[float,float,float,float]# Orientation in the parent frame as
(x, y, z, w). Defaults to identity.
-
up:
Optional[Tuple[float,float,float]]# Alternative way to specify the camera extrinsics using eye, target, and up vectors.
-
parent:
- class OffsetCfg#
Bases:
objectConfiguration of the sensor offset relative to the parent frame.
Attributes:
Name of the parent frame.
Position of the sensor in the parent frame.
Orientation in the parent frame as
(x, y, z, w).-
parent:
str|None# Name of the parent frame. If not specified, the sensor will be placed in the arena frame.
This is usually the case when the sensor is not attached to any specific object, eg, link of a robot arm.
-
pos:
Tuple[float,float,float]# Position of the sensor in the parent frame. Defaults to (0.0, 0.0, 0.0).
-
quat:
Tuple[float,float,float,float]# Orientation in the parent frame as
(x, y, z, w). Defaults to identity.
-
parent:
- classmethod from_dict(init_dict)#
Initialize the configuration from a dictionary.
- Return type:
- get_data_types()[source]#
Get the data types supported by this sensor configuration.
- Return type:
List[str]- Returns:
A list of data types that this sensor configuration supports.
- get_view_attrib()[source]#
Get the view attributes for the camera.
The camera view whcich is used to render the scene Default view attributes for the camera are: [COLOR, DEPTH, MASK] The supported view attributes are:
COLOR: RGBA images
DEPTH: Depth images
MASK: Instance segmentation masks
NORMAL: Normal images
POSITION: Position images with 3D coordinates.
- Return type:
ViewFlags- Returns:
The view attributes for the camera.
- init_local_pose: np.ndarray | None#
4x4 transformation matrix of the root in local frame. If specified, it will override init_pos and init_rot.
- init_pos: tuple[float, float, float]#
Position of the root in simulation world frame. Defaults to (0.0, 0.0, 0.0).
- init_rot: tuple[float, float, float]#
Euler angles (in degree) of the root in simulation world frame. Defaults to (0.0, 0.0, 0.0).
- visualization_role: Literal['sensor', 'record']#
Role used to group this camera in live visualization previews.
Attachment resolution#
SimulationManager.add_sensor() delegates parent-name resolution to the
function below before creating camera views. It accepts a canonical link name
or "<asset_uid>/<link_name>" to distinguish links shared by several assets.
The resolver receives the scene asset mapping explicitly and queries
Articulation.get_link_render_nodes(); it does not look up a global manager.
Camera.attach_to_parent_nodes() then attaches the resolved nodes, reapplies
parent-relative extrinsics, and updates is_attached. Stereo cameras share
this path. Directly constructed cameras require an explicit attachment call.
|
Resolve a canonical Robot or Articulation link in each environment. |
- embodichain.lab.sim.sensors.attachment.resolve_parent_nodes(parent, assets, num_envs)[source]#
Resolve a canonical Robot or Articulation link in each environment.
- Parameters:
parent (
str) – A canonical link name, or"<asset_uid>/<link_name>"to disambiguate links shared by multiple assets.assets (
Mapping[str,Articulation]) – Scene asset UIDs mapped to Articulation or Robot instances.num_envs (
int) – Expected number of camera and asset instances.
- Return type:
list[Node]- Returns:
Parent render nodes ordered by environment index.
- Raises:
ValueError – If the parent link is missing or ambiguous.
RuntimeError – If the asset count differs from
num_envs, or an environment is missing the link or its render node.
Stereo Camera#
- class embodichain.lab.sim.sensors.StereoCamera[source]#
Bases:
CameraBase class for sensor abstraction in the simulation engine.
Sensors should inherit from this class and implement the update and get_data methods.
Methods:
__init__(config[, device])attach_to_parent_nodes(parent_nodes)Attach camera views to one resolved parent node per environment.
Begin interval accumulation for a sensor that samples physics substeps.
destroy()Remove render cameras before releasing their World-owned group.
get_arena_pose([to_matrix])Get the pose of the sensor in the arena frame.
get_data()Retrieve data from the sensor.
Get the camera intrinsics for both left and right cameras.
Get the local pose of the left and right cameras.
get_local_pose([to_matrix])Get the local pose of the camera.
look_at(eye, target[, up, env_ids])Set the camera to look at a target point.
reset([env_ids])Reset the entity to its initial state.
set_intrinsics(intrinsics[, ...])Set the camera intrinsics for both left and right cameras.
set_local_pose(pose[, env_ids])Set the local pose of the camera.
update(**kwargs)Update the sensor data.
Sample a sensor that opts into physics substeps.
Attributes:
Get the camera group ID in the dexsim world.
Return whether all camera views are attached to parent nodes.
Whether the environment must sample this sensor each physics substep.
- attach_to_parent_nodes(parent_nodes)#
Attach camera views to one resolved parent node per environment.
- Parameters:
parent_nodes (
Sequence[object]) – Parent render nodes ordered by environment index.- Raises:
RuntimeError – If the number of parent nodes does not match the number of camera instances.
ValueError – If any parent node is missing.
- Return type:
None
- begin_control_step()#
Begin interval accumulation for a sensor that samples physics substeps.
- Return type:
None
- destroy()#
Remove render cameras before releasing their World-owned group.
- Return type:
None
- get_arena_pose(to_matrix=False)#
Get the pose of the sensor in the arena frame.
- Parameters:
to_matrix (bool) – If True, return the pose as a 4x4 transformation matrix. If False, return
(x, y, z, qx, qy, qz, qw).- Return type:
Tensor- Returns:
A tensor representing the pose of the sensor in the arena frame.
- get_data()#
Retrieve data from the sensor.
- Parameters:
copy – If True, return a copy of the data buffer. Defaults to True.
- Return type:
TensorDict- Returns:
The data collected by the sensor.
- get_intrinsics()[source]#
Get the camera intrinsics for both left and right cameras.
- Returns:
The intrinsics for the left and right cameras with shape (B, 3, 3).
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- get_left_right_arena_pose()[source]#
Get the local pose of the left and right cameras.
- Returns:
The local pose of the left camera with shape (num_envs, 4, 4).
- Return type:
torch.Tensor
- get_local_pose(to_matrix=False)#
Get the local pose of the camera.
- Parameters:
to_matrix (bool) – If True, return the pose as a 4x4 matrix. If False, return
(x, y, z, qx, qy, qz, qw).- Returns:
The local pose of the camera.
- Return type:
torch.Tensor
- property group_id: int#
Get the camera group ID in the dexsim world.
- Returns:
The camera group ID.
- Return type:
int
- property is_attached: bool#
Return whether all camera views are attached to parent nodes.
- Returns:
True after parent attachment and extrinsics application succeed.
- look_at(eye, target, up=None, env_ids=None)#
Set the camera to look at a target point.
- Parameters:
eye (torch.Tensor) – The position of the camera (eye) with shape (N, 3).
target (torch.Tensor) – The point the camera should look at (target) with shape (N, 3).
up (torch.Tensor | None) – The up direction vector. If None, defaults to [0, 0, 1].
env_ids (Sequence[int] | None) – The environment IDs to set the look at for. If None, set for all environments.
- Return type:
None
- property requires_substep_update: bool#
Whether the environment must sample this sensor each physics substep.
- reset(env_ids=None)#
Reset the entity to its initial state.
- Parameters:
env_ids (Sequence[int] | None) – The environment IDs to reset. If None, reset all environments.
- Return type:
None
- set_intrinsics(intrinsics, right_intrinsics=None, env_ids=None)[source]#
Set the camera intrinsics for both left and right cameras.
- Parameters:
intrinsics (torch.Tensor) – The intrinsics for the left camera with shape (4,) / (3, 3) or (B, 4) / (B, 3, 3).
right_intrinsics (torch.Tensor | None) – The intrinsics for the right camera with shape (4,) / (3, 3) or (B, 4) / (B, 3, 3). If None, use the same intrinsics as the left camera.
env_ids (Sequence[int] | None) – The environment ids to set the intrinsics. If None, set for all environments.
- Return type:
None
- set_local_pose(pose, env_ids=None)#
Set the local pose of the camera.
Note
The pose uses OpenGL camera axes: +Y is up and -Z is forward.
- Parameters:
pose (torch.Tensor) – The local pose as
(N, 4, 4)matrices or(N, 7)vectors in(x, y, z, qx, qy, qz, qw)order.env_ids (Sequence[int] | None) – The environment IDs to set the pose for. If None, set for all environments.
- Return type:
None
- update(**kwargs)[source]#
Update the sensor data.
- The supported data types are:
color: RGB images with shape (B, H, W, 4) and dtype torch.uint8
depth: Depth images with shape (B, H, W, 1) and dtype torch.float32
mask: Instance segmentation masks with shape (B, H, W, 1) and dtype torch.int32
normal: Normal images with shape (B, H, W, 3) and dtype torch.float32
position: Position images with shape (B, H, W, 3) and dtype torch.float32
disparity: Disparity images with shape (B, H, W, 1) and dtype torch.float32
- Parameters:
**kwargs – Additional keyword arguments for sensor update.
- Return type:
None
- update_physics_step(dt)#
Sample a sensor that opts into physics substeps.
- Parameters:
dt (
float) – Elapsed physics time in seconds.- Return type:
None
- class embodichain.lab.sim.sensors.StereoCameraCfg[source]#
Bases:
CameraCfgConfiguration class for StereoCamera.
Classes:
Configuration class for camera extrinsics.
Configuration of the sensor offset relative to the parent frame.
Methods:
from_dict(init_dict)Initialize the configuration from a dictionary.
Get the data types supported by this sensor configuration.
Get the view attributes for the camera.
Attributes:
4x4 transformation matrix of the root in local frame.
Position of the root in simulation world frame.
Euler angles (in degree) of the root in simulation world frame.
Get the transformation matrix from left camera to right camera.
Get the transformation matrix from right camera to left camera.
Role used to group this camera in live visualization previews.
- class ExtrinsicsCfg#
Bases:
OffsetCfgConfiguration class for camera extrinsics.
The extrinsics define the position and orientation of the camera in the 3D world. If eye, target, and up are provided, they will be used to compute the extrinsics. Otherwise, the position and orientation will be set to the defaults.
SimulationManager resolves
parentas a Robot or Articulation link name. Use"<asset_uid>/<link_name>"when the link name is ambiguous. Explicit mounted poses use OpenGL axes (-Z forward, +Y up). Unparented explicit poses use optical axes (+Z forward, +Y down) and are converted inCamera.reset(). Look-at inputs specify viewing direction directly in either case.Attributes:
Name of the parent frame.
Position of the sensor in the parent frame.
Orientation in the parent frame as
(x, y, z, w).Alternative way to specify the camera extrinsics using eye, target, and up vectors.
-
parent:
str|None# Name of the parent frame. If not specified, the sensor will be placed in the arena frame.
This is usually the case when the sensor is not attached to any specific object, eg, link of a robot arm.
-
pos:
Tuple[float,float,float]# Position of the sensor in the parent frame. Defaults to (0.0, 0.0, 0.0).
-
quat:
Tuple[float,float,float,float]# Orientation in the parent frame as
(x, y, z, w). Defaults to identity.
-
up:
Optional[Tuple[float,float,float]]# Alternative way to specify the camera extrinsics using eye, target, and up vectors.
-
parent:
- class OffsetCfg#
Bases:
objectConfiguration of the sensor offset relative to the parent frame.
Attributes:
Name of the parent frame.
Position of the sensor in the parent frame.
Orientation in the parent frame as
(x, y, z, w).-
parent:
str|None# Name of the parent frame. If not specified, the sensor will be placed in the arena frame.
This is usually the case when the sensor is not attached to any specific object, eg, link of a robot arm.
-
pos:
Tuple[float,float,float]# Position of the sensor in the parent frame. Defaults to (0.0, 0.0, 0.0).
-
quat:
Tuple[float,float,float,float]# Orientation in the parent frame as
(x, y, z, w). Defaults to identity.
-
parent:
- classmethod from_dict(init_dict)#
Initialize the configuration from a dictionary.
- Return type:
- get_data_types()[source]#
Get the data types supported by this sensor configuration.
- Return type:
List[str]- Returns:
A list of data types that this sensor configuration supports.
- get_view_attrib()#
Get the view attributes for the camera.
The camera view whcich is used to render the scene Default view attributes for the camera are: [COLOR, DEPTH, MASK] The supported view attributes are:
COLOR: RGBA images
DEPTH: Depth images
MASK: Instance segmentation masks
NORMAL: Normal images
POSITION: Position images with 3D coordinates.
- Return type:
ViewFlags- Returns:
The view attributes for the camera.
- init_local_pose: np.ndarray | None#
4x4 transformation matrix of the root in local frame. If specified, it will override init_pos and init_rot.
- init_pos: tuple[float, float, float]#
Position of the root in simulation world frame. Defaults to (0.0, 0.0, 0.0).
- init_rot: tuple[float, float, float]#
Euler angles (in degree) of the root in simulation world frame. Defaults to (0.0, 0.0, 0.0).
- property left_to_right: Tensor#
Get the transformation matrix from left camera to right camera.
- property right_to_left: Tensor#
Get the transformation matrix from right camera to left camera.
- visualization_role: Literal['sensor', 'record']#
Role used to group this camera in live visualization previews.
Contact Sensor#
- class embodichain.lab.sim.sensors.ContactSensor[source]#
Bases:
BaseSensorSensor to get contacts from rigid bodies and articulation links.
The sensor preserves every backend-emitted contact row that passes the backend’s positive-impulse filter. Geometry-only Newton solvers retain all candidate contact rows.
Methods:
__init__(config[, device, owner])Start a new interval without discarding persistent contact timing.
create_history(name, actor_ids, *[, ...])Register a sensor-owned reduction with explicit counterpart filtering.
destroy()Destroy all entities managed by this batch entity.
filter_by_user_ids(item_user_ids[, env_ids])Filter contact report by backend-neutral contact actor IDs.
get_actor_ids(uid[, link_names])Resolve a scene entity's ordered contact IDs for every environment.
get_actor_info(actor_id)Resolve an ID from the
user_idsfield to its Spawn identity.get_arena_pose([to_matrix])Not used.
get_data()Retrieve data from the sensor.
get_local_pose([to_matrix])Get the local pose of the camera.
reset([env_ids])Clear contact samples and histories only for the selected rows.
set_local_pose(pose[, env_ids])Set the local pose of the camera.
update(**kwargs)Update the sensor state based on the current simulation state.
Sample contacts and advance registered histories after physics.
Attributes:
Capabilities reported by the active DexSim contact binding.
Rows lost across the current control interval, or latest standalone update.
Environment IDs of the selected contact actors.
Compatibility map from contact actor ID to environment ID.
Backend-neutral actor IDs selected by the contact query.
Get the maximum total number of contacts across all environments.
Whether this sensor participates in the physics-substep lifecycle.
Get the current total number of contacts across all environments.
- begin_control_step()[source]#
Start a new interval without discarding persistent contact timing.
- Return type:
None
- property contact_capabilities: ContactQueryCapabilities#
Capabilities reported by the active DexSim contact binding.
- create_history(name, actor_ids, *, counterpart_ids=None, include_unknown_counterpart=False, force_threshold=0.0)[source]#
Register a sensor-owned reduction with explicit counterpart filtering.
- Parameters:
name (
str) – Unique history name within the sensor.actor_ids (
Tensor) – Body IDs to monitor, in per-environment order.counterpart_ids (
Tensor|None) – Allowed counterparts; None accepts all contacts.include_unknown_counterpart (
bool) – Also accept unidentified query counterparts.force_threshold (
float) – Minimum contact force in newtons for timing events.
- Return type:
- Returns:
History that automatically enables substep sampling and selected-row reset.
- destroy()#
Destroy all entities managed by this batch entity.
- Return type:
None
- property dropped_contacts: int#
Rows lost across the current control interval, or latest standalone update.
This diagnostic reads device counters only when requested. Query overflow and per-environment scatter overflow are counted separately and summed.
- filter_by_user_ids(item_user_ids, env_ids=None)[source]#
Filter contact report by backend-neutral contact actor IDs.
- Parameters:
item_user_ids (
Tensor) – Actor IDs from this sensor’suser_idsfield.env_ids (
Optional[Sequence[int]]) – Environment IDs to filter. If None, filter all environments.
- Returns:
A TensorDict containing only the filtered contacts for the specified environments.
- Return type:
data
- get_actor_ids(uid, link_names=None)[source]#
Resolve a scene entity’s ordered contact IDs for every environment.
- Parameters:
uid (
str) – Robot, articulation or rigid-object UID in the Spawn scene.link_names (
Optional[Sequence[str]]) – Ordered articulation links; None selects the rigid actor.
- Return type:
Tensor- Returns:
IDs shaped (environments, selected bodies). Global actors are broadcast.
- get_actor_info(actor_id)[source]#
Resolve an ID from the
user_idsfield to its Spawn identity.- Return type:
ContactActorInfo
- get_arena_pose(to_matrix=False)[source]#
Not used.
- Parameters:
to_matrix (
bool) – If True, return the pose as a 4x4 transformation matrix.- Return type:
Tensor|None- Returns:
A tensor representing the pose of the sensor in the arena frame.
- get_data()[source]#
Retrieve data from the sensor.
- Return type:
TensorDict- Returns:
Batched contact data.
positionis in the Arena frame;normalpoints from actor 0 toward actor 1;frictionandimpulseare impulses;distanceis signed separation;user_idscontains backend-neutral contact actor IDs; andis_validmarks rows populated by the latest update. Values in invalid rows are unspecified and may come from an earlier update.
- get_local_pose(to_matrix=False)[source]#
Get the local pose of the camera.
- Parameters:
to_matrix (bool) – If True, return the pose as a 4x4 matrix. If False, return as a quaternion.
- Returns:
The local pose of the camera.
- Return type:
torch.Tensor
- item_env_ids: torch.Tensor | None#
Environment IDs of the selected contact actors.
- item_user_env_ids_map: torch.Tensor | None#
Compatibility map from contact actor ID to environment ID.
- item_user_ids: torch.Tensor | None#
Backend-neutral actor IDs selected by the contact query.
- property max_total_contacts: int#
Get the maximum total number of contacts across all environments.
- Returns:
Maximum total number of contacts.
- Return type:
int
- property requires_substep_update: bool#
Whether this sensor participates in the physics-substep lifecycle.
- reset(env_ids=None)[source]#
Clear contact samples and histories only for the selected rows.
- Parameters:
env_ids (
Optional[Sequence[int]]) – Rows to reset. None selects every row.- Return type:
None
- set_local_pose(pose, env_ids=None)[source]#
Set the local pose of the camera.
Note: The pose should be in the OpenGL coordinate system, which means the Y is up and Z is forward.
- Parameters:
pose (torch.Tensor) – The local pose to set, should be a 4x4 transformation matrix.
env_ids (Sequence[int] | None) – The environment IDs to set the pose for. If None, set for all environments.
- Return type:
None
- property total_current_contacts: int#
Get the current total number of contacts across all environments.
Note
This method returns the total number of contacts detected in the most recent update.
- Returns:
Total number of contacts.
- Return type:
int
- class embodichain.lab.sim.sensors.ContactSensorCfg[source]#
Bases:
SensorCfgConfiguration class for contact sensors.
This class defines the configuration for contact sensors that detect collisions between rigid bodies and articulation links.
Classes:
Configuration of the sensor offset relative to the parent frame.
Attributes:
articulation link contact filter configs
Whether to filter contact only when both actors are in the filter list.
4x4 transformation matrix of the root in local frame.
Position of the root in simulation world frame.
Euler angles (in degree) of the root in simulation world frame.
Maximum number of contacts per environment the sensor can handle.
rigid body contact filter configs
Methods:
from_dict(init_dict)Initialize the configuration from a dictionary.
Get the data types supported by this sensor configuration.
- class OffsetCfg#
Bases:
objectConfiguration of the sensor offset relative to the parent frame.
Attributes:
Name of the parent frame.
Position of the sensor in the parent frame.
Orientation in the parent frame as
(x, y, z, w).-
parent:
str|None# Name of the parent frame. If not specified, the sensor will be placed in the arena frame.
This is usually the case when the sensor is not attached to any specific object, eg, link of a robot arm.
-
pos:
Tuple[float,float,float]# Position of the sensor in the parent frame. Defaults to (0.0, 0.0, 0.0).
-
quat:
Tuple[float,float,float,float]# Orientation in the parent frame as
(x, y, z, w). Defaults to identity.
-
parent:
- articulation_cfg_list: list[ArticulationContactFilterCfg]#
articulation link contact filter configs
- filter_need_both_actor: bool#
Whether to filter contact only when both actors are in the filter list.
- classmethod from_dict(init_dict)#
Initialize the configuration from a dictionary.
- Return type:
- abstract get_data_types()#
Get the data types supported by this sensor configuration.
- Return type:
List[str]- Returns:
A list of data types that this sensor configuration supports.
- init_local_pose: np.ndarray | None#
4x4 transformation matrix of the root in local frame. If specified, it will override init_pos and init_rot.
- init_pos: tuple[float, float, float]#
Position of the root in simulation world frame. Defaults to (0.0, 0.0, 0.0).
- init_rot: tuple[float, float, float]#
Euler angles (in degree) of the root in simulation world frame. Defaults to (0.0, 0.0, 0.0).
- max_contacts_per_env: int#
Maximum number of contacts per environment the sensor can handle.
- rigid_uid_list: list[str]#
rigid body contact filter configs
- class embodichain.lab.sim.sensors.ArticulationContactFilterCfg[source]#
Bases:
objectConfiguration for filtering contacts from an articulation’s links.
This class defines which articulation and which links to monitor for contact events.
Methods:
__init__([articulation_uid, link_name_list])copy(**kwargs)Return a new object replacing specified fields with new values.
from_dict(init_dict)Initialize the configuration from a dictionary.
replace(**kwargs)Return a new object replacing specified fields with new values.
to_dict()Convert an object into dictionary recursively.
validate([prefix])Check the validity of configclass object.
Attributes:
Articulation unique identifier.
link names in the articulation whose contacts need to be filtered.
- __init__(articulation_uid=<factory>, link_name_list=<factory>)#
-
articulation_uid:
str# Articulation unique identifier.
- copy(**kwargs)#
Return a new object replacing specified fields with new values.
This is especially useful for frozen classes. Example usage:
@configclass(frozen=True) class C: x: int y: int c = C(1, 2) c1 = c.replace(x=3) assert c1.x == 3 and c1.y == 2
- Parameters:
obj (
object) – The object to replace.**kwargs – The fields to replace and their new values.
- Return type:
object- Returns:
The new object.
- classmethod from_dict(init_dict)[source]#
Initialize the configuration from a dictionary.
- Parameters:
init_dict (
dict[str,str|list[str]]) – Dictionary containing configuration parameters.- Returns:
The initialized configuration.
- Return type:
-
link_name_list:
list[str]# link names in the articulation whose contacts need to be filtered.
- replace(**kwargs)#
Return a new object replacing specified fields with new values.
This is especially useful for frozen classes. Example usage:
@configclass(frozen=True) class C: x: int y: int c = C(1, 2) c1 = c.replace(x=3) assert c1.x == 3 and c1.y == 2
- Parameters:
obj (
object) – The object to replace.**kwargs – The fields to replace and their new values.
- Return type:
object- Returns:
The new object.
- to_dict()#
Convert an object into dictionary recursively.
Note
Ignores all names starting with “__” (i.e. built-in methods).
- Parameters:
obj (
object) – An instance of a class to convert.- Raises:
ValueError – When input argument is not an object.
- Return type:
dict[str,Any]- Returns:
Converted dictionary mapping.
- validate(prefix='')#
Check the validity of configclass object.
This function checks if the object is a valid configclass object. A valid configclass object contains no MISSING entries.
- Parameters:
obj (
object) – The object to check.prefix (
str) – The prefix to add to the missing fields. Defaults to ‘’.
- Return type:
list[str]- Returns:
A list of missing fields.
- Raises:
TypeError – When the object is not a valid configuration object.
Contact history#
Contact filtering and substep timing are owned by the sensor layer. Tasks select body and counterpart IDs, then consume interval events and completed flight durations without advancing the sensor state.
Sensor-owned contact reduction and timing for a selected set of actors.
Classes:
Accumulate selected contacts across one control interval. |
- class embodichain.lab.sim.sensors.contact_history.ContactHistory[source]#
Accumulate selected contacts across one control interval.
contactandforcedescribe the latest physics sample;found,peak_forceandfirst_contactretain events from every substep.current_air_timemeasures an unfinished flight;last_air_timecaptures its duration on landing, including the landing sampling interval. Reading these tensors never advances time or clears an event.- Parameters:
actor_ids (
Tensor) – Selected body IDs, shaped (environments, bodies).counterpart_ids (
Tensor|None) – Allowed counterpart IDs per environment; None accepts all.include_unknown_counterpart (
bool) – Accept the query’s unknown counterpart (-1) in addition to explicitly selected IDs. This does not identify ground.force_threshold (
float) – Minimum individual contact-force magnitude for a timing event.
Methods:
__init__(actor_ids, *[, counterpart_ids, ...])Clear interval aggregates while retaining contact timing.
reset([env_ids])Clear only selected environment rows, including unfinished timing.
update(data, dt)Reduce a new physics sample and advance timing exactly once.
- __init__(actor_ids, *, counterpart_ids=None, include_unknown_counterpart=False, force_threshold=0.0)[source]#
- begin_control_step()[source]#
Clear interval aggregates while retaining contact timing.
- Return type:
None
Creating a contact history automatically enables physics-substep sampling.
CUDA history reduction consumes compact contact rows and device counts through
sparse Warp kernels. The dropped_contacts diagnostic sums query loss and
scatter overflow across the current control interval; standalone updates
without a history report the most recent sample.