embodichain.lab.sim.sensors

Contents

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

SensorCfg

Configuration class for sensors.

BaseSensor

Base class for sensor abstraction in the simulation engine.

CameraCfg

Configuration class for Camera.

Camera

Base class for sensor abstraction in the simulation engine.

StereoCameraCfg

Configuration class for StereoCamera.

StereoCamera

Base class for sensor abstraction in the simulation engine.

ContactSensorCfg

Configuration class for contact sensors.

ArticulationContactFilterCfg

Configuration for filtering contacts from an articulation's links.

ContactSensor

Sensor to get contacts from rigid body and articulation links.

Sensor#

class embodichain.lab.sim.sensors.BaseSensor[source]#

Bases: BatchEntity

Base 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])

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.

__init__(config, device=device(type='cpu'))[source]#
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.

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.

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

abstract update(**kwargs)[source]#

Update the sensor state based on the current simulation state.

This method is called periodically to ensure the sensor data is up-to-date.

Parameters:

**kwargs – Additional keyword arguments for sensor update.

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:

OffsetCfg

Configuration of the sensor offset relative to the parent frame.

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

get_data_types()

Get the data types supported by this sensor configuration.

Attributes:

init_local_pose

4x4 transformation matrix of the root in local frame.

init_pos

Position of the root in simulation world frame.

init_rot

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:

parent

Name of the parent frame.

pos

Position of the sensor in the parent frame.

quat

Orientation of the sensor in the parent frame as a quaternion (w, x, y, z).

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 of the sensor in the parent frame as a quaternion (w, x, y, z). Defaults to (1.0, 0.0, 0.0, 0.0).

classmethod from_dict(init_dict)[source]#

Initialize the configuration from a dictionary.

Return type:

SensorCfg

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: BaseSensor

Base 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.

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.

get_intrinsics()

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.

Attributes:

group_id

Get the camera group ID in the dexsim world.

is_attached

Check if the camera is attached to a parent entity.

__init__(config, device=device(type='cpu'))[source]#
attach_to_parent_nodes(parent_nodes)[source]#

Attach camera views to one resolved parent node per environment.

SimulationManager calls this after resolving extrinsics.parent. Cameras constructed directly can be attached by supplying their parent render nodes explicitly.

Parameters:

parent_nodes (Sequence[Node]) – Parent render nodes ordered by environment index.

Raises:
  • RuntimeError – If the parent count differs from the camera count.

  • ValueError – If any parent node is missing.

Return type:

None

destroy()#

Destroy all entities managed by this batch entity.

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.

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 as a quaternion.

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#

Check if the camera is attached to a parent entity.

Returns:

True if the camera is attached to a parent entity, False otherwise.

Return type:

bool

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

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 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

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

class embodichain.lab.sim.sensors.CameraCfg[source]#

Bases: SensorCfg

Configuration class for Camera.

Classes:

ExtrinsicsCfg

Configuration class for camera extrinsics.

OffsetCfg

Configuration of the sensor offset relative to the parent frame.

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

get_data_types()

Get the data types supported by this sensor configuration.

get_view_attrib()

Get the view attributes for the camera.

Attributes:

init_local_pose

4x4 transformation matrix of the root in local frame.

init_pos

Position of the root in simulation world frame.

init_rot

Euler angles (in degree) of the root in simulation world frame.

visualization_role

Role used to group this camera in live visualization previews.

class ExtrinsicsCfg[source]#

Bases: OffsetCfg

Configuration 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 parent as a Robot or Articulation link name. Use "<asset_uid>/<link_name>" when the link name is ambiguous.

Attributes:

parent

Name of the parent frame.

pos

Position of the sensor in the parent frame.

quat

Orientation of the sensor in the parent frame as a quaternion (w, x, y, z).

up

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 of the sensor in the parent frame as a quaternion (w, x, y, z). Defaults to (1.0, 0.0, 0.0, 0.0).

up: Optional[Tuple[float, float, float]]#

Alternative way to specify the camera extrinsics using eye, target, and up vectors.

class OffsetCfg#

Bases: object

Configuration of the sensor offset relative to the parent frame.

Attributes:

parent

Name of the parent frame.

pos

Position of the sensor in the parent frame.

quat

Orientation of the sensor in the parent frame as a quaternion (w, x, y, z).

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 of the sensor in the parent frame as a quaternion (w, x, y, z). Defaults to (1.0, 0.0, 0.0, 0.0).

classmethod from_dict(init_dict)#

Initialize the configuration from a dictionary.

Return type:

SensorCfg

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_parent_nodes(parent, assets, num_envs)

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: Camera

Base 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.

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.

get_intrinsics()

Get the camera intrinsics for both left and right cameras.

get_left_right_arena_pose()

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.

Attributes:

group_id

Get the camera group ID in the dexsim world.

is_attached

Check if the camera is attached to a parent entity.

__init__(config, device=device(type='cpu'))[source]#
attach_to_parent_nodes(parent_nodes)#

Attach camera views to one resolved parent node per environment.

SimulationManager calls this after resolving extrinsics.parent. Cameras constructed directly can be attached by supplying their parent render nodes explicitly.

Parameters:

parent_nodes (Sequence[Node]) – Parent render nodes ordered by environment index.

Raises:
  • RuntimeError – If the parent count differs from the camera count.

  • ValueError – If any parent node is missing.

Return type:

None

destroy()#

Destroy all entities managed by this batch entity.

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.

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 as a quaternion.

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#

Check if the camera is attached to a parent entity.

Returns:

True if the camera is attached to a parent entity, False otherwise.

Return type:

bool

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

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 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

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

class embodichain.lab.sim.sensors.StereoCameraCfg[source]#

Bases: CameraCfg

Configuration class for StereoCamera.

Classes:

ExtrinsicsCfg

Configuration class for camera extrinsics.

OffsetCfg

Configuration of the sensor offset relative to the parent frame.

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

get_data_types()

Get the data types supported by this sensor configuration.

get_view_attrib()

Get the view attributes for the camera.

Attributes:

init_local_pose

4x4 transformation matrix of the root in local frame.

init_pos

Position of the root in simulation world frame.

init_rot

Euler angles (in degree) of the root in simulation world frame.

left_to_right

Get the transformation matrix from left camera to right camera.

right_to_left

Get the transformation matrix from right camera to left camera.

visualization_role

Role used to group this camera in live visualization previews.

class ExtrinsicsCfg#

Bases: OffsetCfg

Configuration 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 parent as a Robot or Articulation link name. Use "<asset_uid>/<link_name>" when the link name is ambiguous.

Attributes:

parent

Name of the parent frame.

pos

Position of the sensor in the parent frame.

quat

Orientation of the sensor in the parent frame as a quaternion (w, x, y, z).

up

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 of the sensor in the parent frame as a quaternion (w, x, y, z). Defaults to (1.0, 0.0, 0.0, 0.0).

up: Optional[Tuple[float, float, float]]#

Alternative way to specify the camera extrinsics using eye, target, and up vectors.

class OffsetCfg#

Bases: object

Configuration of the sensor offset relative to the parent frame.

Attributes:

parent

Name of the parent frame.

pos

Position of the sensor in the parent frame.

quat

Orientation of the sensor in the parent frame as a quaternion (w, x, y, z).

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 of the sensor in the parent frame as a quaternion (w, x, y, z). Defaults to (1.0, 0.0, 0.0, 0.0).

classmethod from_dict(init_dict)#

Initialize the configuration from a dictionary.

Return type:

SensorCfg

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: BaseSensor

Sensor to get contacts from rigid body and articulation links.

Methods:

__init__(config[, device])

destroy()

Destroy all entities managed by this batch entity.

filter_by_user_ids(item_user_ids[, env_ids])

Filter contact report by specific user IDs.

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])

Reset the entity to its initial state.

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.

Attributes:

item_env_ids

Environment ids of the contact filter items.

item_user_env_ids_map

Map from dexsim userid to environment id.

item_user_ids

Dexsim userid of the contact filter items.

max_total_contacts

Get the maximum total number of contacts across all environments.

total_current_contacts

Get the current total number of contacts across all environments.

__init__(config, device=device(type='cpu'))[source]#
destroy()#

Destroy all entities managed by this batch entity.

Return type:

None

filter_by_user_ids(item_user_ids, env_ids=None)[source]#

Filter contact report by specific user IDs.

Parameters:
  • item_user_ids (torch.Tensor) – Tensor of user IDs to filter by.

  • env_ids (Sequence[int] | None) – 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_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

Returns:

A tensor representing the pose of the sensor in the arena frame.

get_data()[source]#

Retrieve data from the sensor.

Returns:

{

“position”: Tensor of float32 (num_envs, num_contacts, 3) representing the contact positions, “normal”: Tensor of float32 (num_envs, num_contacts, 3) representing the contact normals, “friction”: Tensor of float32 (num_envs, num_contacts, 3) representing the contact friction, “impulse”: Tensor of float32 (num_envs, num_contacts) representing the contact impulses, “distance”: Tensor of float32 (num_envs, num_contacts) representing the contact distances, “user_ids”: Tensor of int32 (num_envs, num_contacts, 2) representing contact user ids

, use rigid_object.get_user_id() and find which object it belongs to.

”is_valid”: Tensor of bool (num_envs, num_contacts) indicating which contacts are valid.

}

Return type:

Dict

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 contact filter items.

item_user_env_ids_map: torch.Tensor | None#

Map from dexsim userid to environment id.

item_user_ids: torch.Tensor | None#

Dexsim userid of the contact filter items.

property max_total_contacts: int#

Get the maximum total number of contacts across all environments.

Returns:

Maximum total number of contacts.

Return type:

int

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_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

update(**kwargs)[source]#

Update the sensor state based on the current simulation state.

This method is called periodically to ensure the sensor data is up-to-date.

Parameters:

**kwargs – Additional keyword arguments for sensor update.

Return type:

None

class embodichain.lab.sim.sensors.ContactSensorCfg[source]#

Bases: SensorCfg

Configuration class for contact sensors.

This class defines the configuration for contact sensors that detect collisions between rigid bodies and articulation links.

Classes:

OffsetCfg

Configuration of the sensor offset relative to the parent frame.

Attributes:

articulation_cfg_list

articulation link contact filter configs

filter_need_both_actor

Whether to filter contact only when both actors are in the filter list.

init_local_pose

4x4 transformation matrix of the root in local frame.

init_pos

Position of the root in simulation world frame.

init_rot

Euler angles (in degree) of the root in simulation world frame.

max_contacts_per_env

Maximum number of contacts per environment the sensor can handle.

rigid_uid_list

rigid body contact filter configs

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

get_data_types()

Get the data types supported by this sensor configuration.

class OffsetCfg#

Bases: object

Configuration of the sensor offset relative to the parent frame.

Attributes:

parent

Name of the parent frame.

pos

Position of the sensor in the parent frame.

quat

Orientation of the sensor in the parent frame as a quaternion (w, x, y, z).

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 of the sensor in the parent frame as a quaternion (w, x, y, z). Defaults to (1.0, 0.0, 0.0, 0.0).

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:

SensorCfg

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: object

Configuration 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_uid

Articulation unique identifier.

link_name_list

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, Union[str, List[str]]]) – Dictionary containing configuration parameters.

Returns:

The initialized configuration.

Return type:

ArticulationContactFilterCfg

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.