embodichain.lab.sim.objects

Contents

embodichain.lab.sim.objects#

Classes

Light

Light represents a batch of lights in the simulation.

LightCfg

Configuration for a light asset in the simulation.

RigidObject

RigidObject represents a batch of rigid body in the simulation.

RigidBodyData

Data manager for rigid body with body type of dynamic or kinematic.

RigidObjectCfg

Configuration for a rigid body asset in the simulation.

RigidObjectGroup

RigidObjectGroup represents a batch of rigid bodies in the simulation.

RigidBodyGroupData

Data manager for rigid body group with body type of dynamic or kinematic.

RigidObjectGroupCfg

Configuration for a rigid object group asset in the simulation.

Articulation

Articulation represents a batch of articulations in the simulation.

ArticulationData

GPU data manager for articulation.

ArticulationCfg

Configuration for an articulation asset in the simulation.

Robot

A class representing a batch of robots in the simulation environment.

RobotCfg

RobotCfg(uid: 'Union[str, None]' = <factory>, init_pos: 'tuple[float, float, float]' = <factory>, init_rot: 'tuple[float, float, float]' = <factory>, init_local_pose: 'Optional[np.ndarray]' = <factory>, fpath: 'str' = <factory>, drive_pros: 'JointDrivePropertiesCfg' = <factory>, body_scale: 'Union[tuple, list]' = <factory>, attrs: 'RigidBodyAttributesCfg' = <factory>, fix_base: 'bool' = <factory>, disable_self_collision: 'bool' = <factory>, init_qpos: 'Union[torch.Tensor, np.ndarray, Sequence[float]]' = <factory>, sleep_threshold: 'float' = <factory>, min_position_iters: 'int' = <factory>, min_velocity_iters: 'int' = <factory>, build_pk_chain: 'bool' = <factory>, control_parts: 'Union[Dict[str, List[str]], None]' = <factory>, urdf_cfg: 'Optional[URDFCfg]' = <factory>, solver_cfg: 'Union[SolverCfg, Dict[str, SolverCfg], None]' = <factory>)

Light#

class embodichain.lab.sim.objects.Light[source]#

Bases: BatchEntity

Light represents a batch of lights in the simulation.

Each light supports the following properties:
  • Color (3 floats)

  • Intensity (1 float)

  • Falloff (1 float)

  • Location (3 floats)

Methods:

__init__(cfg[, entities, device])

destroy()

Destroy all entities managed by this batch entity.

get_local_pose([to_matrix])

Get local pose of each light, either as full matrix or translation vector.

reset([env_ids])

Reset the entity to its initial state.

set_color(colors[, env_ids])

Set color for one or more lights.

set_falloff(falloffs[, env_ids])

Set falloff (radius) for one or more lights.

set_intensity(intensities[, env_ids])

Set intensity for one or more lights.

set_local_pose(pose[, env_ids, to_matrix])

Set local pose (translation) for one or more lights.

__init__(cfg, entities=None, device=device(type='cpu'))[source]#
destroy()#

Destroy all entities managed by this batch entity.

Return type:

None

get_local_pose(to_matrix=False)[source]#

Get local pose of each light, either as full matrix or translation vector.

Parameters:

to_matrix (bool, optional) – If True, return poses as 4×4 matrices. If False, return translations only as (x, y, z). Defaults to False.

Returns:

  • If to_matrix=True: Tensor of shape (N, 4, 4), where N == num_instances.

  • If to_matrix=False: Tensor of shape (N, 3), containing translations.

On error or empty instances, returns an empty tensor with shape (0, 4, 4) or (0, 3) respectively, and logs via logger.log_error.

Return type:

torch.Tensor

reset(env_ids=None)[source]#

Reset the entity to its initial state.

Parameters:

env_ids (Optional[Sequence[int]]) – The environment IDs to reset. If None, reset all environments.

Return type:

None

set_color(colors, env_ids=None)[source]#

Set color for one or more lights.

Parameters:
  • colors (torch.Tensor) – Tensor of shape (M, 3) or (3,), representing RGB values. - If shape is (3,), the same color is applied to all targeted instances. - If shape is (M, 3), M must match the number of targeted instances.

  • env_ids (Optional[Sequence[int]]) – Indices of instances to set. If None: - For colors.shape == (3,), applies to all instances. - For colors.shape == (M, 3), M must equal num_instances, applies per-instance.

Return type:

None

set_falloff(falloffs, env_ids=None)[source]#

Set falloff (radius) for one or more lights.

Parameters:
  • falloffs (torch.Tensor) – Tensor of shape (M,), (1,), or scalar (0-dim). - If scalar or shape (1,), the same falloff is applied to all targeted instances. - If shape (M,), M must match the number of targeted instances.

  • env_ids (Optional[Sequence[int]]) – Indices of instances to set. If None: - For scalar/shape (1,), applies to all instances. - For shape (M,), M must equal num_instances, applies per-instance.

Return type:

None

set_intensity(intensities, env_ids=None)[source]#

Set intensity for one or more lights.

Parameters:
  • intensities (torch.Tensor) – Tensor of shape (M,), (1,), or scalar (0-dim). - If scalar or shape (1,), the same intensity is applied to all targeted instances. - If shape (M,), M must match the number of targeted instances.

  • env_ids (Optional[Sequence[int]]) – Indices of instances to set. If None: - For scalar/shape (1,), applies to all instances. - For shape (M,), M must equal num_instances, applies per-instance.

Return type:

None

set_local_pose(pose, env_ids=None, to_matrix=False)[source]#

Set local pose (translation) for one or more lights.

Parameters:
  • pose (torch.Tensor) –

    • If to_matrix=False: shape (3,) or (M, 3), representing (x, y, z).

    • If to_matrix=True: shape (4, 4) or (M, 4, 4); translation extracted automatically.

  • env_ids (Optional[Sequence[int]]) – Indices to set. If None: - For vector input (3,) broadcast to all, or (M,3) with M == num_instances. - For matrix input (4,4) broadcast to all, or (M,4,4) with M == num_instances.

  • to_matrix (bool) – Interpret pose as full 4x4 matrix if True, else as vector(s).

Return type:

None

class embodichain.lab.sim.objects.LightCfg[source]#

Bases: ObjectBaseCfg

Configuration for a light asset in the simulation.

This class extends the base asset configuration to include specific properties for lights,

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

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.

intensity

Intensity of the light source with unit of watts/m^2.

radius

Falloff of the light, only used for point light.

classmethod from_dict(init_dict)#

Initialize the configuration from a dictionary.

Return type:

ObjectBaseCfg

init_local_pose: Optional[ndarray]#

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

intensity: float#

Intensity of the light source with unit of watts/m^2.

radius: float#

Falloff of the light, only used for point light.

Rigid Object#

class embodichain.lab.sim.objects.RigidObject[source]#

Bases: BatchEntity

RigidObject represents a batch of rigid body in the simulation.

There are three types of rigid body:
  • Static: Actors that do not move and are used as the environment.

  • Dynamic: Actors that can move and are affected by physics.

  • Kinematic: Actors that can move but are not affected by physics.

Methods:

__init__(cfg[, entities, device])

add_force_torque([force, torque, pos, env_ids])

Add force and/or torque to the rigid object.

clear_dynamics([env_ids])

Clear the dynamics of the rigid bodies by resetting velocities and applying zero forces and torques.

destroy()

Destroy all entities managed by this batch entity.

get_body_scale([env_ids])

Retrieve the body scale for specified environment instances.

get_local_pose([to_matrix])

Get local pose of the rigid object.

get_user_ids()

Get the user ids of the rigid bodies.

get_vertices([env_ids])

Retrieve the vertices of the rigid objects.

get_visual_material_inst([env_ids])

Get material instances for the rigid object.

reset([env_ids])

Reset the entity to its initial state.

set_attrs(attrs[, env_ids])

Set physical attributes for the rigid object.

set_body_scale(scale[, env_ids])

Set the scale of the rigid body.

set_collision_filter(filter_data[, env_ids])

set collision filter data for the rigid object.

set_local_pose(pose[, env_ids])

Set local pose of the rigid object.

set_visual_material(mat[, env_ids])

Set visual material for the rigid object.

Attributes:

body_data

Get the rigid body data manager for this rigid object.

body_state

Get the body state of the rigid object.

is_non_dynamic

Check if the rigid object is non-dynamic (static or kinematic).

is_static

Check if the rigid object is static.

__init__(cfg, entities=None, device=device(type='cpu'))[source]#
add_force_torque(force=None, torque=None, pos=None, env_ids=None)[source]#

Add force and/or torque to the rigid object.

TODO: Currently, apply force at position pos is not supported.

Note: there are a few different ways to apply force and torque:
  • If pos is specified, the force is applied at that position.

  • if not pos is specified, the force and torque are applied at the center of mass of the rigid body.

Parameters:
  • force (Optional[torch.Tensor] = None) – The force to add with shape (N, 3). Defaults to None.

  • torque (Optional[torch.Tensor], optional) – The torque to add with shape (N, 3). Defaults to None.

  • pos (Optional[torch.Tensor], optional) – The position to apply the force at with shape (N, 3). Defaults to None.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

Return type:

None

property body_data: RigidBodyData | None#

Get the rigid body data manager for this rigid object.

Returns:

The rigid body data manager.

Return type:

RigidBodyData

property body_state: Tensor#

Get the body state of the rigid object.

The body state of a rigid object is represented as a tensor with the following format: [x, y, z, qw, qx, qy, qz, lin_x, lin_y, lin_z, ang_x, ang_y, ang_z]

If the rigid object is static, linear and angular velocities will be zero.

Returns:

The body state of the rigid object with shape (N, 13), where N is the number of instances.

Return type:

torch.Tensor

clear_dynamics(env_ids=None)[source]#

Clear the dynamics of the rigid bodies by resetting velocities and applying zero forces and torques.

Parameters:

env_ids (Optional[Sequence[int]]) – Environment indices. If None, then all indices are used.

Return type:

None

destroy()[source]#

Destroy all entities managed by this batch entity.

Return type:

None

get_body_scale(env_ids=None)[source]#

Retrieve the body scale for specified environment instances.

Parameters:

env_ids (Optional[Sequence[int]]) – A sequence of environment instance IDs. If None, retrieves the body scale for all instances.

Returns:

A tensor containing the body scales of the specified instances, with shape (N, 3) dtype int32 and located on the specified device.

Return type:

torch.Tensor

get_local_pose(to_matrix=False)[source]#

Get local pose of the rigid object.

Parameters:

to_matrix (bool, optional) – If True, return the pose as a 4x4 matrix. If False, return as (x, y, z, qw, qx, qy, qz). Defaults to False.

Returns:

The local pose of the rigid object with shape (N, 7) or (N, 4, 4) depending on to_matrix.

Return type:

torch.Tensor

get_user_ids()[source]#

Get the user ids of the rigid bodies.

Returns:

A tensor of shape (num_envs,) representing the user ids of the rigid bodies.

Return type:

torch.Tensor

get_vertices(env_ids=None)[source]#

Retrieve the vertices of the rigid objects.

Parameters:

env_ids (Optional[Sequence[int]]) – A sequence of environment IDs for which to retrieve vertices. If None, retrieves vertices for all instances.

Returns:

A tensor containing the user IDs of the specified rigid objects with shape (N, num_verts, 3).

Return type:

torch.Tensor

get_visual_material_inst(env_ids=None)[source]#

Get material instances for the rigid object.

Parameters:

env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

Returns:

List of material instances.

Return type:

List[MaterialInst]

property is_non_dynamic: bool#

Check if the rigid object is non-dynamic (static or kinematic).

Returns:

True if the rigid object is non-dynamic, False otherwise.

Return type:

bool

property is_static: bool#

Check if the rigid object is static.

Returns:

True if the rigid object is static, False otherwise.

Return type:

bool

reset(env_ids=None)[source]#

Reset the entity to its initial state.

Parameters:

env_ids (Optional[Sequence[int]]) – The environment IDs to reset. If None, reset all environments.

Return type:

None

set_attrs(attrs, env_ids=None)[source]#

Set physical attributes for the rigid object.

Parameters:
Return type:

None

set_body_scale(scale, env_ids=None)[source]#

Set the scale of the rigid body.

Parameters:
  • scale (torch.Tensor) – The scale to set with shape (N, 3).

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

Return type:

None

set_collision_filter(filter_data, env_ids=None)[source]#

set collision filter data for the rigid object.

Parameters:
  • filter_data (torch.Tensor) – [N, 4] of int. First element of each object is arena id. If 2nd element is 0, the object will collision with all other objects in world. 3rd and 4th elements are not used currently.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used. Defaults to None.

Return type:

None

set_local_pose(pose, env_ids=None)[source]#

Set local pose of the rigid object.

Parameters:
  • pose (torch.Tensor) – The local pose of the rigid object with shape (N, 7) or (N, 4, 4).

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

Return type:

None

set_visual_material(mat, env_ids=None)[source]#

Set visual material for the rigid object.

Parameters:
  • mat (VisualMaterial) – The material to set.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

Return type:

None

class embodichain.lab.sim.objects.RigidBodyData[source]#

Bases: object

Data manager for rigid body with body type of dynamic or kinematic.

Note

  1. The pose data managed by dexsim is in the format of (qx, qy, qz, qw, x, y, z), but in SimulationManager, we use (x, y, z, qw, qx, qy, qz) format.

Methods:

__init__(entities, ps, device)

Initialize the RigidBodyData.

Attributes:

vel

Get the linear and angular velocities of the rigid bodies.

__init__(entities, ps, device)[source]#

Initialize the RigidBodyData.

Parameters:
  • entities (List[MeshObject]) – List of MeshObjects representing the rigid bodies.

  • ps (PhysicsScene) – The physics scene.

  • device (torch.device) – The device to use for the rigid body data.

property vel: Tensor#

Get the linear and angular velocities of the rigid bodies.

Returns:

The linear and angular velocities concatenated, with shape (N, 6).

Return type:

torch.Tensor

class embodichain.lab.sim.objects.RigidObjectCfg[source]#

Bases: ObjectBaseCfg

Configuration for a rigid body asset in the simulation.

This class extends the base asset configuration to include specific properties for rigid bodies, such as physical attributes and collision group.

Attributes:

body_scale

Scale of the rigid body in the simulation world frame.

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_convex_hull_num

The maximum number of convex hulls that will be created for the rigid body.

shape

Shape configuration for the rigid body.

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

to_dexsim_body_type()

Convert the body type to dexsim ActorType.

body_scale: Union[tuple, list]#

Scale of the rigid body in the simulation world frame.

classmethod from_dict(init_dict)#

Initialize the configuration from a dictionary.

Return type:

ObjectBaseCfg

init_local_pose: Optional[ndarray]#

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_convex_hull_num: int#

The maximum number of convex hulls that will be created for the rigid body.

If max_convex_hull_num is set to larger than 1, the rigid body will be decomposed into multiple convex hulls using coacd alogorithm. Reference: SarahWeiii/CoACD

shape: ShapeCfg#

Shape configuration for the rigid body.

to_dexsim_body_type()[source]#

Convert the body type to dexsim ActorType.

Return type:

ActorType

Rigid Object Group#

class embodichain.lab.sim.objects.RigidObjectGroup[source]#

Bases: BatchEntity

RigidObjectGroup represents a batch of rigid bodies in the simulation.

Methods:

__init__(cfg[, entities, device])

clear_dynamics([env_ids])

Clear the dynamics of the rigid bodies by resetting velocities and applying zero forces and torques.

destroy()

Destroy all entities managed by this batch entity.

get_local_pose([to_matrix])

Get local pose of the rigid object group.

get_user_ids()

Get the user ids of the rigid body group.

reset([env_ids])

Reset the entity to its initial state.

set_collision_filter(filter_data[, env_ids])

set collision filter data for the rigid object group.

set_local_pose(pose[, env_ids, obj_ids])

Set local pose of the rigid object group.

set_visual_material(mat[, env_ids])

Set visual material for the rigid object group.

Attributes:

body_data

Get the rigid body data manager for this rigid object.

body_state

Get the body state of the rigid object.

is_non_dynamic

Check if the rigid object is non-dynamic (static or kinematic).

num_objects

Get the number of objects in each rigid body instance.

__init__(cfg, entities=None, device=device(type='cpu'))[source]#
property body_data: RigidBodyGroupData#

Get the rigid body data manager for this rigid object.

Returns:

The rigid body data manager.

Return type:

RigidBodyGroupData

property body_state: Tensor#

Get the body state of the rigid object.

The body state of a rigid object is represented as a tensor with the following format: [x, y, z, qw, qx, qy, qz, lin_x, lin_y, lin_z, ang_x, ang_y, ang_z]

If the rigid object is static, linear and angular velocities will be zero.

Returns:

The body state of the rigid object with shape (num_instances, num_objects, 13),

where N is the number of instances.

Return type:

torch.Tensor

clear_dynamics(env_ids=None)[source]#

Clear the dynamics of the rigid bodies by resetting velocities and applying zero forces and torques.

Parameters:

env_ids (Optional[Sequence[int]]) – Environment indices. If None, then all indices are used.

Return type:

None

destroy()[source]#

Destroy all entities managed by this batch entity.

Return type:

None

get_local_pose(to_matrix=False)[source]#

Get local pose of the rigid object group.

Parameters:

to_matrix (bool, optional) – If True, return the pose as a 4x4 matrix. If False, return as (x, y, z, qw, qx, qy, qz). Defaults to False.

Returns:

The local pose of the rigid object with shape (num_instances, num_objects, 7) or (num_instances, num_objects, 4, 4) depending on to_matrix.

Return type:

torch.Tensor

get_user_ids()[source]#

Get the user ids of the rigid body group.

Returns:

A tensor of shape (num_envs, num_objects) representing the user ids of the rigid body group.

Return type:

torch.Tensor

property is_non_dynamic: bool#

Check if the rigid object is non-dynamic (static or kinematic).

Returns:

True if the rigid object is non-dynamic, False otherwise.

Return type:

bool

property num_objects: int#

Get the number of objects in each rigid body instance.

Returns:

The number of objects in each rigid body instance.

Return type:

int

reset(env_ids=None)[source]#

Reset the entity to its initial state.

Parameters:

env_ids (Optional[Sequence[int]]) – The environment IDs to reset. If None, reset all environments.

Return type:

None

set_collision_filter(filter_data, env_ids=None)[source]#

set collision filter data for the rigid object group.

Parameters:
  • filter_data (torch.Tensor) – [N, 4] of int. First element of each object is arena id. If 2nd element is 0, the object will collision with all other objects in world. 3rd and 4th elements are not used currently.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used. Defaults to None.

Return type:

None

set_local_pose(pose, env_ids=None, obj_ids=None)[source]#

Set local pose of the rigid object group.

Parameters:
  • pose (torch.Tensor) – The local pose of the rigid object group with shape (num_instances, num_objects, 7) or (num_instances, num_objects, 4, 4).

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

  • obj_ids (Optional[Sequence[int]], optional) – Object indices within the group. If None, all objects are set. Defaults to None.

Return type:

None

set_visual_material(mat, env_ids=None)[source]#

Set visual material for the rigid object group.

Parameters:
  • mat (VisualMaterial) – The material to set.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

Return type:

None

class embodichain.lab.sim.objects.RigidBodyGroupData[source]#

Bases: object

Data manager for rigid body group with body type of dynamic or kinematic.

Methods:

__init__(entities, ps, device)

Initialize the RigidBodyGroupData.

Attributes:

vel

Get the linear and angular velocities of the rigid bodies.

__init__(entities, ps, device)[source]#

Initialize the RigidBodyGroupData.

Parameters:
  • entities (List[List[MeshObject]]) – List of List MeshObjects representing the rigid body group.

  • ps (PhysicsScene) – The physics scene.

  • device (torch.device) – The device to use for the rigid body group data.

property vel: Tensor#

Get the linear and angular velocities of the rigid bodies.

Returns:

The linear and angular velocities concatenated, with shape (num_instances, num_objects, 6).

Return type:

torch.Tensor

class embodichain.lab.sim.objects.RigidObjectGroupCfg[source]#

Bases: object

Configuration for a rigid object group asset in the simulation.

Rigid object groups can be initialized from multiple rigid object configurations specified in a folder. If folder_path is specified, user should provide a RigidObjectCfg in rigid_objects as a template configuration for all objects in the group.

For example: ```python rigid_object_group: RigidObjectGroupCfg(

folder_path=”path/to/folder”, max_num=5, rigid_objects={

“template_obj”: RigidObjectCfg(
shape=MeshCfg(

fpath=””, # fpath will be ignored when folder_path is specified

), body_type=”dynamic”,

)

}

)

Attributes:

body_type

Body type for all rigid objects in the group.

ext

File extension for the rigid object assets.

folder_path

Path to the folder containing the rigid object assets.

max_num

Maximum number of rigid objects to initialize from the folder.

rigid_objects

Configuration for the rigid objects in the group.

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

body_type: Literal['dynamic', 'kinematic']#

Body type for all rigid objects in the group.

ext: str#

File extension for the rigid object assets.

This is only used when folder_path is specified.

folder_path: Optional[str]#

Path to the folder containing the rigid object assets.

This is used to initialize multiple rigid object configurations from a folder.

classmethod from_dict(init_dict)[source]#

Initialize the configuration from a dictionary.

Return type:

RigidObjectGroupCfg

max_num: int#

Maximum number of rigid objects to initialize from the folder.

This is only used when folder_path is specified.

rigid_objects: Dict[str, RigidObjectCfg]#

Configuration for the rigid objects in the group.

Articulation#

class embodichain.lab.sim.objects.Articulation[source]#

Bases: BatchEntity

Articulation represents a batch of articulations in the simulation.

An articulation is a collection of rigid bodies connected by joints. The joints can be either fixed or actuated. The joints can be of different types, such as revolute or prismatic.

For fixed-base articulation, it can be a robot arm, door, etc. For floating-base articulation, it can be a humanoid, drawer, etc.

Parameters:
  • cfg (ArticulationCfg) – Configuration for the articulation.

  • entities (List[_Articulation], optional) – List of articulation entities.

  • device (torch.device, optional) – Device to use (CPU or CUDA).

Methods:

__init__(cfg[, entities, device])

clear_dynamics([env_ids])

Clear the dynamics of the articulation.

compute_fk(qpos[, link_names, ...])

Compute the forward kinematics (FK) for the given joint positions.

compute_jacobian(qpos[, end_link_name, ...])

Compute the Jacobian matrix for the given joint positions using the pk_serial_chain.

destroy()

Destroy all entities managed by this batch entity.

get_link_pose(link_name[, env_ids, to_matrix])

Get the pose of a specific link in the articulation.

get_link_vert_face(link_name)

Get the vertices and faces of a specific link in the articulation.

get_local_pose([to_matrix])

Get local pose (root link pose) of the articulation.

get_qpos()

Get the current positions (qpos) of the articulation.

get_qvel()

Get the current velocities (qvel) of the articulation.

get_user_ids()

Get the user ids of the articulation.

get_visual_material_inst([env_ids, link_names])

Get visual material instances for the rigid object.

reallocate_body_data()

Reallocate body data tensors to match the current articulation state in the GPU physics scene.

reset([env_ids])

Reset the entity to its initial state.

set_collision_filter(filter_data[, env_ids])

set collision filter data for the rigid object.

set_drive([stiffness, damping, max_effort, ...])

Set the drive properties for the articulation.

set_local_pose(pose[, env_ids])

Set local pose of the articulation.

set_qf(qf[, joint_ids, env_ids])

Set the generalized efforts (qf) of the articulation.

set_qpos(qpos[, joint_ids, env_ids, target])

Set the joint positions (qpos) or target positions for the articulation.

set_qvel(qvel[, joint_ids, env_ids, target])

Set the velocities (qvel) or target velocities of the articulation.

set_visual_material(mat[, env_ids, link_names])

Set visual material for the rigid object.

Attributes:

all_joint_names

Get the names of the joints in the articulation.

body_data

Get the rigid body data manager for this rigid object.

body_state

Get the body state of the articulation.

dof

Get the degree of freedom of the articulation.

joint_names

Get the names of the actived joints in the articulation.

link_names

Get the names of the links in the articulation.

mimic_ids

Get the mimic joint ids for the articulation.

mimic_multipliers

Get the mimic joint multipliers for the articulation.

mimic_offsets

Get the mimic joint offsets for the articulation.

mimic_parents

Get the mimic joint parent ids for the articulation.

num_links

Get the number of links in the articulation.

root_link_name

Get the name of the root link of the articulation.

root_state

Get the root state of the articulation.

__init__(cfg, entities=None, device=device(type='cpu'))[source]#
property all_joint_names: List[str]#

Get the names of the joints in the articulation.

Returns:

The names of the joints in the articulation.

Return type:

List[str]

property body_data: ArticulationData#

Get the rigid body data manager for this rigid object.

Returns:

The rigid body data manager.

Return type:

RigidBodyData

property body_state: Tensor#

Get the body state of the articulation.

Returns:

The body state of the articulation with shape (N, num_links, 13).

Return type:

torch.Tensor

clear_dynamics(env_ids=None)[source]#

Clear the dynamics of the articulation.

Parameters:

env_ids (Optional[Sequence[int]]) – Environment indices. If None, then all indices are used.

Return type:

None

compute_fk(qpos, link_names=None, end_link_name=None, root_link_name=None, to_dict=False, **kwargs)[source]#

Compute the forward kinematics (FK) for the given joint positions.

Parameters:
  • qpos (torch.Tensor) – Joint positions. Shape can be (dof,) for a single configuration or (batch_size, dof) for batched configurations.

  • link_names (Union[str, list[str], tuple[str]], optional) – Names of the links for which FK is computed. If None, all links are considered.

  • end_link_name (str, optional) – Name of the end link for which FK is computed. If None, all links are considered.

  • root_link_name (str, optional) – Name of the root link for which FK is computed. Defaults to None.

  • to_dict (bool, optional) – If True, returns the FK result as a dictionary of Transform3d objects. Defaults to False.

  • **kwargs – Additional keyword arguments for customization.

Raises:
  • RuntimeError – If the pk_chain is not initialized.

  • TypeError – If an invalid type is provided for link_names.

  • ValueError – If the shape of the resulting matrices is unexpected.

Returns:

The homogeneous transformation matrix/matrices for the specified links.

Shape is (batch_size, 4, 4) for batched input or (4, 4) for single input. If to_dict is True, returns a dictionary of Transform3d objects instead.

Return type:

torch.Tensor

compute_jacobian(qpos, end_link_name=None, root_link_name=None, locations=None, jac_type='full')[source]#

Compute the Jacobian matrix for the given joint positions using the pk_serial_chain.

Parameters:
  • qpos (torch.Tensor) – The joint positions. Shape can be (dof,) for a single configuration or (batch_size, dof) for batched configurations.

  • end_link_name (str, optional) – The name of the end link for which the Jacobian is computed. Defaults to the last link in the chain.

  • root_link_name (str, optional) – The name of the root link for which the Jacobian is computed. Defaults to the first link in the chain.

  • locations (Union[torch.Tensor, np.ndarray], optional) – Offset points relative to the end-effector frame for which the Jacobian is computed. Shape can be (batch_size, 3) or (3,) for a single offset. Defaults to None (origin of the end-effector frame).

  • jac_type (str, optional) – Specifies the part of the Jacobian to return: - ‘full’: Returns the full Jacobian (6, dof) or (batch_size, 6, dof). - ‘trans’: Returns only the translational part (3, dof) or (batch_size, 3, dof). - ‘rot’: Returns only the rotational part (3, dof) or (batch_size, 3, dof). Defaults to ‘full’.

Raises:
  • RuntimeError – If the pk_chain is not initialized.

  • ValueError – If an invalid jac_type is provided.

Returns:

The Jacobian matrix. Shape depends on the input:
  • For a single link: (6, dof) or (batch_size, 6, dof).

  • For multiple links: (num_links, 6, dof) or (num_links, batch_size, 6, dof).

The shape also depends on the jac_type parameter.

Return type:

torch.Tensor

destroy()[source]#

Destroy all entities managed by this batch entity.

Return type:

None

property dof: int#

Get the degree of freedom of the articulation.

Returns:

The degree of freedom of the articulation.

Return type:

int

Get the pose of a specific link in the articulation.

Parameters:
  • link_name (str) – The name of the link.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

  • to_matrix (bool, optional) – If True, return the pose as a 4x4 matrix. If False, return as (x, y, z, qw, qx, qy, qz). Defaults to False.

Returns:

The pose of the specified link with shape (N, 7) or (N, 4, 4) depending on to_matrix.

Return type:

torch.Tensor

Get the vertices and faces of a specific link in the articulation.

Parameters:

link_name (str) – The name of the link.

Returns:

  • vertices (torch.Tensor): The vertices of the specified link with shape (V, 3).

  • faces (torch.Tensor): The faces of the specified link with shape (F, 3).

Return type:

Tuple[torch.Tensor, torch.Tensor]

get_local_pose(to_matrix=False)[source]#

Get local pose (root link pose) of the articulation.

Parameters:

to_matrix (bool, optional) – If True, return the pose as a 4x4 matrix. If False, return as (x, y, z, qw, qx, qy, qz). Defaults to False.

Returns:

The local pose of the articulation with shape (N, 7) or (N, 4, 4) depending on to_matrix.

Return type:

torch.Tensor

get_qpos()[source]#

Get the current positions (qpos) of the articulation.

Return type:

Tensor

get_qvel()[source]#

Get the current velocities (qvel) of the articulation.

Returns:

The current velocities of the articulation.

Return type:

torch.Tensor

get_user_ids()[source]#

Get the user ids of the articulation.

Returns:

The user ids of the articulation with shape (N, num_link).

Return type:

torch.Tensor

get_visual_material_inst(env_ids=None, link_names=None)[source]#

Get visual material instances for the rigid object.

Parameters:
  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

  • link_names (Optional[List[str]], optional) – List of link names to filter materials. If None, returns materials for all links.

Returns:

A list where each element corresponds to an environment and contains a dictionary mapping link names to their VisualMaterialInst.

Return type:

List[Dict[str, VisualMaterialInst]]

property joint_names: List[str]#

Get the names of the actived joints in the articulation.

Returns:

The names of the actived joints in the articulation.

Return type:

List[str]

Get the names of the links in the articulation.

Returns:

The names of the links in the articulation.

Return type:

List[str]

property mimic_ids: List[int | None]#

Get the mimic joint ids for the articulation.

Returns:

The mimic joint ids.

Return type:

List[Optional[int]]

property mimic_multipliers: List[float]#

Get the mimic joint multipliers for the articulation.

Returns:

The mimic joint multipliers.

Return type:

List[float]

property mimic_offsets: List[float]#

Get the mimic joint offsets for the articulation.

Returns:

The mimic joint offsets.

Return type:

List[float]

property mimic_parents: List[int | None]#

Get the mimic joint parent ids for the articulation.

Returns:

The mimic joint parent ids.

Return type:

List[Optional[int]]

Get the number of links in the articulation.

Returns:

The number of links in the articulation.

Return type:

int

reallocate_body_data()[source]#

Reallocate body data tensors to match the current articulation state in the GPU physics scene.

Return type:

None

reset(env_ids=None)[source]#

Reset the entity to its initial state.

Parameters:

env_ids (Optional[Sequence[int]]) – The environment IDs to reset. If None, reset all environments.

Return type:

None

Get the name of the root link of the articulation.

Returns:

The name of the root link.

Return type:

str

property root_state: Tensor#

Get the root state of the articulation.

Returns:

The root state of the articulation with shape (N, 13).

Return type:

torch.Tensor

set_collision_filter(filter_data, env_ids=None)[source]#

set collision filter data for the rigid object.

Parameters:
  • filter_data (torch.Tensor) – [N, 4] of int. First element of each object is arena id. If 2nd element is 0, the object will collision with all other objects in world. 3rd and 4th elements are not used currently.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used. Defaults to None.

Return type:

None

set_drive(stiffness=None, damping=None, max_effort=None, max_velocity=None, friction=None, drive_type='force', joint_ids=None, env_ids=None)[source]#

Set the drive properties for the articulation.

Parameters:
  • stiffness (torch.Tensor) – The stiffness of the joint drive with shape (len(env_ids), len(joint_ids)).

  • damping (torch.Tensor) – The damping of the joint drive with shape (len(env_ids), len(joint_ids)).

  • max_effort (torch.Tensor) – The maximum effort of the joint drive with shape (len(env_ids), len(joint_ids)).

  • max_velocity (torch.Tensor) – The maximum velocity of the joint drive with shape (len(env_ids), len(joint_ids)).

  • friction (torch.Tensor) – The joint friction coefficient with shape (len(env_ids), len(joint_ids)).

  • drive_type (str, optional) – The type of drive to apply. Defaults to “force”.

  • joint_ids (Optional[Sequence[int]], optional) – The joint indices to apply the drive to. If None, applies to all joints. Defaults to None.

  • env_ids (Optional[Sequence[int]], optional) – The environment indices to apply the drive to. If None, applies to all environments. Defaults to None.

Return type:

None

set_local_pose(pose, env_ids=None)[source]#

Set local pose of the articulation.

Parameters:
  • pose (torch.Tensor) – The local pose of the articulation with shape (N, 7) or (N, 4, 4).

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

Return type:

None

set_qf(qf, joint_ids=None, env_ids=None)[source]#

Set the generalized efforts (qf) of the articulation.

Parameters:
  • qf (torch.Tensor) – The generalized efforts with shape (N, dof).

  • joint_ids (Optional[Sequence[int]], optional) – Joint indices to apply the efforts. If None, applies to all joints.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. Defaults to all indices.

Return type:

None

set_qpos(qpos, joint_ids=None, env_ids=None, target=True)[source]#

Set the joint positions (qpos) or target positions for the articulation.

Parameters:
  • qpos (torch.Tensor) – Joint positions with shape (N, dof), where N is the number of environments.

  • joint_ids (Optional[Sequence[int]], optional) – Joint indices to apply the positions. If None, applies to all joints.

  • env_ids (Optional[Sequence[int]]) – Environment indices to apply the positions. Defaults to all environments.

  • target (bool) – If True, sets target positions for simulation. If False, updates current positions directly.

Raises:

ValueError – If the length of env_ids does not match the length of qpos.

Return type:

None

set_qvel(qvel, joint_ids=None, env_ids=None, target=True)[source]#

Set the velocities (qvel) or target velocities of the articulation.

Parameters:
  • qvel (torch.Tensor) – The velocities with shape (N, dof).

  • joint_ids (Optional[Sequence[int]], optional) – Joint indices to apply the velocities. If None, applies to all joints.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. Defaults to all indices.

  • True (If)

  • False (sets target positions for simulation. If)

  • directly. (updates current positions)

Raises:

ValueError – If the length of env_ids does not match the length of qvel.

Return type:

None

set_visual_material(mat, env_ids=None, link_names=None)[source]#

Set visual material for the rigid object.

Parameters:
  • mat (VisualMaterial) – The material to set.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

  • link_names (Optional[List[str]], optional) – List of link names to apply the material to. If None, applies to all links.

Return type:

None

class embodichain.lab.sim.objects.ArticulationData[source]#

Bases: object

GPU data manager for articulation.

Methods:

__init__(entities, ps, device)

Initialize the ArticulationData.

Attributes:

body_link_pose

Get the pose of all links in the articulation.

body_link_vel

Get the velocities of all links in the articulation.

joint_damping

Get the joint damping of the articulation.

joint_friction

Get the joint friction of the articulation.

joint_stiffness

Get the joint stiffness of the articulation.

link_vert_face

Get the vertices and faces of all links in the articulation.

qacc

Get the current accelerations (qacc) of the articulation.

qf

Get the current forces (qf) of the articulation.

qf_limits

Get the joint effort limits of the articulation.

qpos

Get the current positions (qpos) of the articulation.

qpos_limits

Get the joint position limits of the articulation.

qvel

Get the current velocities (qvel) of the articulation.

qvel_limits

Get the joint velocity limits of the articulation.

root_ang_vel

Get the angular velocity of the root link of the articulation.

root_lin_vel

Get the linear velocity of the root link of the articulation.

root_pose

Get the root pose of the articulation.

root_vel

Get the velocity of the root link of the articulation.

__init__(entities, ps, device)[source]#

Initialize the ArticulationData.

Parameters:
  • entities (List[_Articulation]) – List of DexSim Articulation objects.

  • ps (PhysicsScene) – The physics scene.

  • device (torch.device) – The device to use for the articulation data.

Get the pose of all links in the articulation.

Returns:

The poses of the links in the articulation with shape (N, num_links, 7).

Return type:

torch.Tensor

Get the velocities of all links in the articulation.

Returns:

The poses of the links in the articulation with shape (N, num_links, 6).

Return type:

torch.Tensor

property joint_damping: Tensor#

Get the joint damping of the articulation.

Returns:

The joint damping of the articulation with shape (N, dof).

Return type:

torch.Tensor

property joint_friction: Tensor#

Get the joint friction of the articulation.

Returns:

The joint friction of the articulation with shape (N, dof).

Return type:

torch.Tensor

property joint_stiffness: Tensor#

Get the joint stiffness of the articulation.

Returns:

The joint stiffness of the articulation with shape (N, dof).

Return type:

torch.Tensor

Get the vertices and faces of all links in the articulation.

Returns:

  • key (str): The name of the link.

  • vertices (torch.Tensor): The vertices of the specified link with shape (V, 3).

  • faces (torch.Tensor): The faces of the specified link with shape (F, 3).

Return type:

Dict[str, Tuple[torch.Tensor, torch.Tensor]]

property qacc: Tensor#

Get the current accelerations (qacc) of the articulation.

Returns:

The current accelerations of the articulation with shape of (num_instances, dof).

Return type:

torch.Tensor

property qf: Tensor#

Get the current forces (qf) of the articulation.

Returns:

The current forces of the articulation with shape of (num_instances, dof).

Return type:

torch.Tensor

property qf_limits: Tensor#

Get the joint effort limits of the articulation.

Returns:

The joint effort limits of the articulation with shape (N, dof).

Return type:

torch.Tensor

property qpos: Tensor#

Get the current positions (qpos) of the articulation.

Returns:

The current positions of the articulation with shape of (num_instances, dof).

Return type:

torch.Tensor

property qpos_limits: Tensor#

Get the joint position limits of the articulation.

Returns:

The joint position limits of the articulation with shape (N, dof, 2).

Return type:

torch.Tensor

property qvel: Tensor#

Get the current velocities (qvel) of the articulation.

Returns:

The current velocities of the articulation with shape of (num_instances, dof).

Return type:

torch.Tensor

property qvel_limits: Tensor#

Get the joint velocity limits of the articulation.

Returns:

The joint velocity limits of the articulation with shape (N, dof).

Return type:

torch.Tensor

property root_ang_vel: Tensor#

Get the angular velocity of the root link of the articulation.

Returns:

The angular velocity of the root link with shape of (num_instances, 3).

Return type:

torch.Tensor

property root_lin_vel: Tensor#

Get the linear velocity of the root link of the articulation.

Returns:

The linear velocity of the root link with shape of (num_instances, 3).

Return type:

torch.Tensor

property root_pose: Tensor#

Get the root pose of the articulation.

Returns:

The root pose of the articulation with shape of (num_instances, 7).

Return type:

torch.Tensor

property root_vel: Tensor#

Get the velocity of the root link of the articulation.

Returns:

The velocity of the root link, concatenating linear and angular velocities.

Return type:

torch.Tensor

class embodichain.lab.sim.objects.ArticulationCfg[source]#

Bases: ObjectBaseCfg

Configuration for an articulation asset in the simulation.

This class extends the base asset configuration to include specific properties for articulations, such as joint drive properties, physical attributes.

Attributes:

attrs

Physical attributes for all links .

body_scale

Scale of the articulation in the simulation world frame.

build_pk_chain

Whether to build pytorch-kinematics chain for forward kinematics and jacobian computation.

disable_self_collision

Whether to enable or disable self-collisions.

drive_pros

Properties to define the drive mechanism of a joint.

fix_base

Whether to fix the base of the articulation.

fpath

Path to the articulation asset file.

init_local_pose

4x4 transformation matrix of the root in local frame.

init_pos

Position of the root in simulation world frame.

init_qpos

Initial joint positions of the articulation.

init_rot

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

min_position_iters

[1,255].

min_velocity_iters

[0,255].

sleep_threshold

[0, max_float32]

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

attrs: RigidBodyAttributesCfg#

Physical attributes for all links .

body_scale: Union[tuple, list]#

Scale of the articulation in the simulation world frame.

build_pk_chain: bool#

Whether to build pytorch-kinematics chain for forward kinematics and jacobian computation.

disable_self_collision: bool#

Whether to enable or disable self-collisions.

drive_pros: JointDrivePropertiesCfg#

Properties to define the drive mechanism of a joint.

fix_base: bool#

Whether to fix the base of the articulation.

Set to True for articulations that should not move, such as a fixed base robot arm or a door. Set to False for articulations that should move freely, such as a mobile robot or a humanoid robot.

fpath: str#

Path to the articulation asset file.

classmethod from_dict(init_dict)#

Initialize the configuration from a dictionary.

Return type:

ObjectBaseCfg

init_local_pose: Optional[ndarray]#

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_qpos: Union[Tensor, ndarray, Sequence[float]]#

Initial joint positions of the articulation.

If None, the joint positions will be set to zero. If provided, it should be a array of shape (num_joints,).

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

min_position_iters: int#

[1,255].

Type:

Number of position iterations the solver should perform for this articulation. Range

min_velocity_iters: int#

[0,255].

Type:

Number of velocity iterations the solver should perform for this articulation. Range

sleep_threshold: float#

[0, max_float32]

Type:

Energy below which the articulation may go to sleep. Range

Robot#

class embodichain.lab.sim.objects.Robot[source]#

Bases: Articulation

A class representing a batch of robots in the simulation environment.

Robot is a specific type of articulation that can have additional properties or methods. - control_parts: Specify the parts that can be controlled in a different manner. Different part may have

different joint ids, drive properties, pyhsical attributes, kinematic solvers or motion planners.

  • solvers: Specify the kinematic solvers for the robot.

  • planners: Specify the motion planner for the robot.

Methods:

__init__(cfg, entities[, device])

build_pk_serial_chain()

Build the kinematic serial chain for the robot.

clear_dynamics([env_ids])

Clear the dynamics of the articulation.

compute_batch_fk(qpos, name[, env_ids, ...])

Compute the forward kinematics of the robot given joint positions and optionally a specific part name.

compute_batch_ik(pose, joint_seed, name[, ...])

Compute the inverse kinematics of the robot given joint positions and optionally a specific part name.

compute_fk(qpos[, name, link_names, ...])

Compute the forward kinematics of the robot given joint positions and optionally a specific part name.

compute_ik(pose[, joint_seed, name, ...])

Compute the inverse kinematics of the robot given joint positions and optionally a specific part name.

compute_jacobian(qpos[, end_link_name, ...])

Compute the Jacobian matrix for the given joint positions using the pk_serial_chain.

destroy()

Destroy all entities managed by this batch entity.

get_control_part_base_pose([name, env_ids, ...])

Retrieves the base pose of the control part for a specified robot.

get_joint_ids([name, remove_mimic])

Get the joint ids of the robot for a specific control part.

get_link_pose(link_name[, env_ids, to_matrix])

Get the pose of a specific link in the articulation.

get_link_vert_face(link_name)

Get the vertices and faces of a specific link in the articulation.

get_local_pose([to_matrix])

Get local pose (root link pose) of the articulation.

get_proprioception()

Gets robot proprioception information, primarily for agent state representation in robot learning scenarios.

get_qpos()

Get the current positions (qpos) of the articulation.

get_qvel()

Get the current velocities (qvel) of the articulation.

get_solver([name])

Get the kinematic solver for a specific control part.

get_user_ids()

Get the user ids of the articulation.

get_visual_material_inst([env_ids, link_names])

Get visual material instances for the rigid object.

init_solver(cfg)

Initialize the kinematic solver for the robot.

reallocate_body_data()

Reallocate body data tensors to match the current articulation state in the GPU physics scene.

reset([env_ids])

Reset the entity to its initial state.

set_collision_filter(filter_data[, env_ids])

set collision filter data for the rigid object.

set_drive([stiffness, damping, max_effort, ...])

Set the drive properties for the articulation.

set_local_pose(pose[, env_ids])

Set local pose of the articulation.

set_qf(qf[, joint_ids, env_ids])

Set the generalized efforts (qf) of the articulation.

set_qpos(qpos[, joint_ids, env_ids, target])

Set the joint positions (qpos) or target positions for the articulation.

set_qvel(qvel[, joint_ids, env_ids, target])

Set the velocities (qvel) or target velocities of the articulation.

set_visual_material(mat[, env_ids, link_names])

Set visual material for the rigid object.

Attributes:

all_joint_names

Get the names of the joints in the articulation.

body_data

Get the rigid body data manager for this rigid object.

body_state

Get the body state of the articulation.

control_parts

Get the control parts of the robot.

dof

Get the degree of freedom of the articulation.

joint_names

Get the names of the actived joints in the articulation.

link_names

Get the names of the links in the articulation.

mimic_ids

Get the mimic joint ids for the articulation.

mimic_multipliers

Get the mimic joint multipliers for the articulation.

mimic_offsets

Get the mimic joint offsets for the articulation.

mimic_parents

Get the mimic joint parent ids for the articulation.

num_links

Get the number of links in the articulation.

root_link_name

Get the name of the root link of the articulation.

root_state

Get the root state of the articulation.

__init__(cfg, entities, device=device(type='cpu'))[source]#
property all_joint_names: List[str]#

Get the names of the joints in the articulation.

Returns:

The names of the joints in the articulation.

Return type:

List[str]

property body_data: ArticulationData#

Get the rigid body data manager for this rigid object.

Returns:

The rigid body data manager.

Return type:

RigidBodyData

property body_state: Tensor#

Get the body state of the articulation.

Returns:

The body state of the articulation with shape (N, num_links, 13).

Return type:

torch.Tensor

build_pk_serial_chain()[source]#

Build the kinematic serial chain for the robot.

Return type:

None

This method is mainly used for robot learning scenarios, for example:
  • Imitation learning dataset generation.

clear_dynamics(env_ids=None)#

Clear the dynamics of the articulation.

Parameters:

env_ids (Optional[Sequence[int]]) – Environment indices. If None, then all indices are used.

Return type:

None

compute_batch_fk(qpos, name, env_ids=None, to_matrix=False)[source]#

Compute the forward kinematics of the robot given joint positions and optionally a specific part name. The output pose will be in the local arena frame.

Parameters:
  • qpos (Optional[Union[torch.tensor, np.ndarray]]) – Joint positions of the robot, (n_envs, n_batch, num_joints).

  • name (str, optional) – The name of the control part to compute the FK for. If None, the default part is used.

  • env_ids (Sequence[int], optional) – The environment ids to compute the FK for. If None, all environments are used.

  • to_matrix (bool, optional) – If True, returns the transformation in the form of a 4x4 matrix.

Returns:

The forward kinematics result with shape (n_envs, batch, 7) or (n_envs, batch, 4, 4) if to_matrix is True.

Return type:

torch.Tensor

compute_batch_ik(pose, joint_seed, name, env_ids=None)[source]#

Compute the inverse kinematics of the robot given joint positions and optionally a specific part name. The input pose should be in the local arena frame.

Parameters:
  • pose (torch.Tensor) – The end effector pose of the robot, (n_envs, n_batch, 7) or (n_envs, n_batch, 4, 4).

  • joint_seed (torch.Tensor, optional) – The joint positions to use as a seed for the IK computation, (n_envs, n_batch, dof). If None, the zero joint positions will be used as the seed.

  • name (str) – The name of the control part to compute the IK for. If None, the default part is used.

  • env_ids (Optional[Sequence[int]]) – Environment indices to apply the positions. Defaults to all environments.

Returns:

Success Tensor with shape (n_envs, n_batch) Qpos Tensor with shape (n_envs, n_batch, dof).

Return type:

Tuple[torch.Tensor, torch.Tensor]

compute_fk(qpos, name=None, link_names=None, end_link_name=None, root_link_name=None, env_ids=None, to_matrix=False)[source]#

Compute the forward kinematics of the robot given joint positions and optionally a specific part name. The output pose will be in the local arena frame.

Parameters:
  • qpos (Optional[Union[torch.tensor, np.ndarray]]) – Joint positions of the robot, (n_envs, num_joints).

  • name (str, optional) – The name of the control part to compute the FK for. If None, the default part is used.

  • link_names (List[str], optional) – The names of the links to compute the FK for. If None, all links are used.

  • end_link_name (str, optional) – The name of the end link to compute the FK for. If None, the default end link is used.

  • root_link_name (str, optional) – The name of the root link to compute the FK for. If None, the default root link is used.

  • env_ids (Sequence[int], optional) – The environment ids to compute the FK for. If None, all environments are used.

  • to_matrix (bool, optional) – If True, returns the transformation in the form of a 4x4 matrix.

Returns:

The forward kinematics result with shape (n_envs, 7) or (n_envs, 4, 4) if to_matrix is True.

Return type:

torch.Tensor

compute_ik(pose, joint_seed=None, name=None, env_ids=None, return_all_solutions=False)[source]#

Compute the inverse kinematics of the robot given joint positions and optionally a specific part name. The input pose should be in the local arena frame.

Parameters:
  • pose (torch.Tensor) – The end effector pose of the robot, (n_envs, 7) or (n_envs, 4, 4).

  • joint_seed (torch.Tensor, optional) – The joint positions to use as a seed for the IK computation, (n_envs, dof). If None, the zero joint positions will be used as the seed.

  • name (str, optional) – The name of the control part to compute the IK for. If None, the default part is used.

  • env_ids (Optional[Sequence[int]]) – Environment indices to apply the positions. Defaults to all environments.

  • return_all_solutions (bool, optional) – Whether to return all IK solutions or just the best one. Defaults to False.

Returns:

The success Tensor with shape (n_envs, ) and qpos Tensor with shape (n_envs, max_results, dof).

Return type:

Tuple[torch.Tensor, torch.Tensor]

compute_jacobian(qpos, end_link_name=None, root_link_name=None, locations=None, jac_type='full')#

Compute the Jacobian matrix for the given joint positions using the pk_serial_chain.

Parameters:
  • qpos (torch.Tensor) – The joint positions. Shape can be (dof,) for a single configuration or (batch_size, dof) for batched configurations.

  • end_link_name (str, optional) – The name of the end link for which the Jacobian is computed. Defaults to the last link in the chain.

  • root_link_name (str, optional) – The name of the root link for which the Jacobian is computed. Defaults to the first link in the chain.

  • locations (Union[torch.Tensor, np.ndarray], optional) – Offset points relative to the end-effector frame for which the Jacobian is computed. Shape can be (batch_size, 3) or (3,) for a single offset. Defaults to None (origin of the end-effector frame).

  • jac_type (str, optional) – Specifies the part of the Jacobian to return: - ‘full’: Returns the full Jacobian (6, dof) or (batch_size, 6, dof). - ‘trans’: Returns only the translational part (3, dof) or (batch_size, 3, dof). - ‘rot’: Returns only the rotational part (3, dof) or (batch_size, 3, dof). Defaults to ‘full’.

Raises:
  • RuntimeError – If the pk_chain is not initialized.

  • ValueError – If an invalid jac_type is provided.

Returns:

The Jacobian matrix. Shape depends on the input:
  • For a single link: (6, dof) or (batch_size, 6, dof).

  • For multiple links: (num_links, 6, dof) or (num_links, batch_size, 6, dof).

The shape also depends on the jac_type parameter.

Return type:

torch.Tensor

property control_parts: Dict[str, List[str]] | None#

Get the control parts of the robot.

destroy()[source]#

Destroy all entities managed by this batch entity.

Return type:

None

property dof: int#

Get the degree of freedom of the articulation.

Returns:

The degree of freedom of the articulation.

Return type:

int

get_control_part_base_pose(name=None, env_ids=None, to_matrix=False)[source]#

Retrieves the base pose of the control part for a specified robot.

Parameters:
  • name (Optional[str]) – The name of the control part the solver adhere to. If None, the default solver is used.

  • env_ids (Optional[Sequence[int]]) – A sequence of environment IDs to specify the environments. If None, all indices are used.

  • to_matrix (bool) – If True, returns the pose in the form of a 4x4 matrix.

Return type:

Tensor

Returns:

The pose of the specified link in the form of a matrix.

get_joint_ids(name=None, remove_mimic=False)[source]#

Get the joint ids of the robot for a specific control part.

Parameters:
  • name (str, optional) – The name of the control part to get the joint ids for. If None, the default part is used.

  • remove_mimic (bool, optional) – If True, mimic joints will be excluded from the returned joint ids. Defaults to False.

Returns:

The joint ids of the robot for the specified control part.

Return type:

List[int]

Get the pose of a specific link in the articulation.

Parameters:
  • link_name (str) – The name of the link.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

  • to_matrix (bool, optional) – If True, return the pose as a 4x4 matrix. If False, return as (x, y, z, qw, qx, qy, qz). Defaults to False.

Returns:

The pose of the specified link with shape (N, 7) or (N, 4, 4) depending on to_matrix.

Return type:

torch.Tensor

Get the vertices and faces of a specific link in the articulation.

Parameters:

link_name (str) – The name of the link.

Returns:

  • vertices (torch.Tensor): The vertices of the specified link with shape (V, 3).

  • faces (torch.Tensor): The faces of the specified link with shape (F, 3).

Return type:

Tuple[torch.Tensor, torch.Tensor]

get_local_pose(to_matrix=False)#

Get local pose (root link pose) of the articulation.

Parameters:

to_matrix (bool, optional) – If True, return the pose as a 4x4 matrix. If False, return as (x, y, z, qw, qx, qy, qz). Defaults to False.

Returns:

The local pose of the articulation with shape (N, 7) or (N, 4, 4) depending on to_matrix.

Return type:

torch.Tensor

get_proprioception()[source]#

Gets robot proprioception information, primarily for agent state representation in robot learning scenarios.

The default proprioception information includes:
  • qpos: Joint positions.

  • qvel: Joint velocities.

  • qf: Joint efforts.

Returns:

A dictionary containing the robot’s proprioception information

Return type:

Dict[str, torch.Tensor]

get_qpos()#

Get the current positions (qpos) of the articulation.

Return type:

Tensor

get_qvel()#

Get the current velocities (qvel) of the articulation.

Returns:

The current velocities of the articulation.

Return type:

torch.Tensor

get_solver(name=None)[source]#

Get the kinematic solver for a specific control part.

Parameters:

name (str, optional) – The name of the control part to get the solver for. If None, the default part is used.

Returns:

The kinematic solver for the specified control part, or None if not found.

Return type:

Optional[BaseSolver]

get_user_ids()#

Get the user ids of the articulation.

Returns:

The user ids of the articulation with shape (N, num_link).

Return type:

torch.Tensor

get_visual_material_inst(env_ids=None, link_names=None)#

Get visual material instances for the rigid object.

Parameters:
  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

  • link_names (Optional[List[str]], optional) – List of link names to filter materials. If None, returns materials for all links.

Returns:

A list where each element corresponds to an environment and contains a dictionary mapping link names to their VisualMaterialInst.

Return type:

List[Dict[str, VisualMaterialInst]]

init_solver(cfg)[source]#

Initialize the kinematic solver for the robot.

Parameters:

cfg (Union[SolverCfg, Dict[str, SolverCfg]]) – The configuration for the kinematic solver.

Return type:

None

property joint_names: List[str]#

Get the names of the actived joints in the articulation.

Returns:

The names of the actived joints in the articulation.

Return type:

List[str]

Get the names of the links in the articulation.

Returns:

The names of the links in the articulation.

Return type:

List[str]

property mimic_ids: List[int | None]#

Get the mimic joint ids for the articulation.

Returns:

The mimic joint ids.

Return type:

List[Optional[int]]

property mimic_multipliers: List[float]#

Get the mimic joint multipliers for the articulation.

Returns:

The mimic joint multipliers.

Return type:

List[float]

property mimic_offsets: List[float]#

Get the mimic joint offsets for the articulation.

Returns:

The mimic joint offsets.

Return type:

List[float]

property mimic_parents: List[int | None]#

Get the mimic joint parent ids for the articulation.

Returns:

The mimic joint parent ids.

Return type:

List[Optional[int]]

Get the number of links in the articulation.

Returns:

The number of links in the articulation.

Return type:

int

reallocate_body_data()#

Reallocate body data tensors to match the current articulation state in the GPU physics scene.

Return type:

None

reset(env_ids=None)#

Reset the entity to its initial state.

Parameters:

env_ids (Optional[Sequence[int]]) – The environment IDs to reset. If None, reset all environments.

Return type:

None

Get the name of the root link of the articulation.

Returns:

The name of the root link.

Return type:

str

property root_state: Tensor#

Get the root state of the articulation.

Returns:

The root state of the articulation with shape (N, 13).

Return type:

torch.Tensor

set_collision_filter(filter_data, env_ids=None)#

set collision filter data for the rigid object.

Parameters:
  • filter_data (torch.Tensor) – [N, 4] of int. First element of each object is arena id. If 2nd element is 0, the object will collision with all other objects in world. 3rd and 4th elements are not used currently.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used. Defaults to None.

Return type:

None

set_drive(stiffness=None, damping=None, max_effort=None, max_velocity=None, friction=None, drive_type='force', joint_ids=None, env_ids=None)#

Set the drive properties for the articulation.

Parameters:
  • stiffness (torch.Tensor) – The stiffness of the joint drive with shape (len(env_ids), len(joint_ids)).

  • damping (torch.Tensor) – The damping of the joint drive with shape (len(env_ids), len(joint_ids)).

  • max_effort (torch.Tensor) – The maximum effort of the joint drive with shape (len(env_ids), len(joint_ids)).

  • max_velocity (torch.Tensor) – The maximum velocity of the joint drive with shape (len(env_ids), len(joint_ids)).

  • friction (torch.Tensor) – The joint friction coefficient with shape (len(env_ids), len(joint_ids)).

  • drive_type (str, optional) – The type of drive to apply. Defaults to “force”.

  • joint_ids (Optional[Sequence[int]], optional) – The joint indices to apply the drive to. If None, applies to all joints. Defaults to None.

  • env_ids (Optional[Sequence[int]], optional) – The environment indices to apply the drive to. If None, applies to all environments. Defaults to None.

Return type:

None

set_local_pose(pose, env_ids=None)#

Set local pose of the articulation.

Parameters:
  • pose (torch.Tensor) – The local pose of the articulation with shape (N, 7) or (N, 4, 4).

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

Return type:

None

set_qf(qf, joint_ids=None, env_ids=None)#

Set the generalized efforts (qf) of the articulation.

Parameters:
  • qf (torch.Tensor) – The generalized efforts with shape (N, dof).

  • joint_ids (Optional[Sequence[int]], optional) – Joint indices to apply the efforts. If None, applies to all joints.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. Defaults to all indices.

Return type:

None

set_qpos(qpos, joint_ids=None, env_ids=None, target=True)#

Set the joint positions (qpos) or target positions for the articulation.

Parameters:
  • qpos (torch.Tensor) – Joint positions with shape (N, dof), where N is the number of environments.

  • joint_ids (Optional[Sequence[int]], optional) – Joint indices to apply the positions. If None, applies to all joints.

  • env_ids (Optional[Sequence[int]]) – Environment indices to apply the positions. Defaults to all environments.

  • target (bool) – If True, sets target positions for simulation. If False, updates current positions directly.

Raises:

ValueError – If the length of env_ids does not match the length of qpos.

Return type:

None

set_qvel(qvel, joint_ids=None, env_ids=None, target=True)#

Set the velocities (qvel) or target velocities of the articulation.

Parameters:
  • qvel (torch.Tensor) – The velocities with shape (N, dof).

  • joint_ids (Optional[Sequence[int]], optional) – Joint indices to apply the velocities. If None, applies to all joints.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. Defaults to all indices.

  • True (If)

  • False (sets target positions for simulation. If)

  • directly. (updates current positions)

Raises:

ValueError – If the length of env_ids does not match the length of qvel.

Return type:

None

set_visual_material(mat, env_ids=None, link_names=None)#

Set visual material for the rigid object.

Parameters:
  • mat (VisualMaterial) – The material to set.

  • env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.

  • link_names (Optional[List[str]], optional) – List of link names to apply the material to. If None, applies to all links.

Return type:

None

class embodichain.lab.sim.objects.RobotCfg[source]#

Bases: ArticulationCfg

RobotCfg(uid: ‘Union[str, None]’ = <factory>, init_pos: ‘tuple[float, float, float]’ = <factory>, init_rot: ‘tuple[float, float, float]’ = <factory>, init_local_pose: ‘Optional[np.ndarray]’ = <factory>, fpath: ‘str’ = <factory>, drive_pros: ‘JointDrivePropertiesCfg’ = <factory>, body_scale: ‘Union[tuple, list]’ = <factory>, attrs: ‘RigidBodyAttributesCfg’ = <factory>, fix_base: ‘bool’ = <factory>, disable_self_collision: ‘bool’ = <factory>, init_qpos: ‘Union[torch.Tensor, np.ndarray, Sequence[float]]’ = <factory>, sleep_threshold: ‘float’ = <factory>, min_position_iters: ‘int’ = <factory>, min_velocity_iters: ‘int’ = <factory>, build_pk_chain: ‘bool’ = <factory>, control_parts: ‘Union[Dict[str, List[str]], None]’ = <factory>, urdf_cfg: ‘Optional[URDFCfg]’ = <factory>, solver_cfg: ‘Union[SolverCfg, Dict[str, SolverCfg], None]’ = <factory>)

Classes:

SolverCfg

Configuration for the kinematic solver used in the robot simulation.

Attributes:

attrs

Physical attributes for all links .

body_scale

Scale of the articulation in the simulation world frame.

build_pk_chain

Whether to build pytorch-kinematics chain for forward kinematics and jacobian computation.

control_parts

Control parts is the mapping from part name to joint names.

disable_self_collision

Whether to enable or disable self-collisions.

drive_pros

Properties to define the drive mechanism of a joint.

fix_base

Whether to fix the base of the articulation.

fpath

Path to the articulation asset file.

init_local_pose

4x4 transformation matrix of the root in local frame.

init_pos

Position of the root in simulation world frame.

init_qpos

Initial joint positions of the articulation.

init_rot

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

min_position_iters

[1,255].

min_velocity_iters

[0,255].

sleep_threshold

[0, max_float32]

solver_cfg

Solver is used to compute forward and inverse kinematics for the robot.

urdf_cfg

URDF assembly configuration which allows for assembling a robot from multiple URDF components.

Methods:

build_pk_serial_chain([device])

Build the serial chain from the URDF file.

from_dict(init_dict)

Initialize the configuration from a dictionary.

class SolverCfg#

Bases: object

Configuration for the kinematic solver used in the robot simulation.

Attributes:

class_type

The class type of the solver to be used.

end_link_name

The name of the end-effector link for the solver.

ik_nearest_weight

Weights for the inverse kinematics nearest calculation.

joint_names

List of joint names for the solver.

root_link_name

The name of the root/base link for the solver.

tcp

The tool center point (TCP) position as a 4x4 homogeneous matrix.

urdf_path

The file path to the URDF model of the robot.

Methods:

from_dict(init_dict)

Initialize the configuration from a dictionary.

class_type: str#

The class type of the solver to be used.

The name of the end-effector link for the solver.

This defines the target link for forward/inverse kinematics calculations. Must match a link name in the URDF file.

classmethod from_dict(init_dict)#

Initialize the configuration from a dictionary.

Return type:

SolverCfg

ik_nearest_weight: Optional[List[float]]#

Weights for the inverse kinematics nearest calculation.

The weights influence how the solver prioritizes closeness to the seed position when multiple solutions are available.

joint_names: Optional[list[str]]#

List of joint names for the solver.

If None, all joints in the URDF will be used. If specified, only these named joints will be included in the kinematic chain.

The name of the root/base link for the solver.

This defines the starting point of the kinematic chain. Must match a link name in the URDF file.

tcp: Union[Tensor, ndarray]#

The tool center point (TCP) position as a 4x4 homogeneous matrix.

This represents the position and orientation of the tool in the robot’s end-effector frame.

urdf_path: Optional[str]#

The file path to the URDF model of the robot.

attrs: RigidBodyAttributesCfg#

Physical attributes for all links .

body_scale: Union[tuple, list]#

Scale of the articulation in the simulation world frame.

build_pk_chain: bool#

Whether to build pytorch-kinematics chain for forward kinematics and jacobian computation.

build_pk_serial_chain(device=device(type='cpu'), **kwargs)[source]#

Build the serial chain from the URDF file.

Note

This method is usually used in imitation dataset saving (compute eef pose from qpos using FK) and model training (provide a differentiable FK layer or loss computation).

Parameters:
  • device (torch.device) – The device to which the chain will be moved. Defaults to CPU.

  • **kwargs – Additional arguments for building the serial chain.

Returns:

The serial chain of the robot for specified control part.

Return type:

Dict[str, pk.SerialChain]

control_parts: Union[Dict[str, List[str]], None]#

Control parts is the mapping from part name to joint names.

For example, {‘left_arm’: [‘joint1’, ‘joint2’], ‘right_arm’: [‘joint3’, ‘joint4’]} If no control part is specified, the robot will use all joints as a single control part.

Note

  • if control_parts is specified, solver_cfg must be a dict with part names as

    keys corresponding to the control parts name.

  • The joint names in the control parts support regular expressions, e.g., ‘joint[1-6]’.

    After initialization of robot, the names will be expanded to a list of full joint names.

disable_self_collision: bool#

Whether to enable or disable self-collisions.

drive_pros: JointDrivePropertiesCfg#

Properties to define the drive mechanism of a joint.

fix_base: bool#

Whether to fix the base of the articulation.

Set to True for articulations that should not move, such as a fixed base robot arm or a door. Set to False for articulations that should move freely, such as a mobile robot or a humanoid robot.

fpath: str#

Path to the articulation asset file.

classmethod from_dict(init_dict)[source]#

Initialize the configuration from a dictionary.

Return type:

RobotCfg

init_local_pose: Optional[np.ndarray]#

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_qpos: Union[torch.Tensor, np.ndarray, Sequence[float]]#

Initial joint positions of the articulation.

If None, the joint positions will be set to zero. If provided, it should be a array of shape (num_joints,).

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

min_position_iters: int#

[1,255].

Type:

Number of position iterations the solver should perform for this articulation. Range

min_velocity_iters: int#

[0,255].

Type:

Number of velocity iterations the solver should perform for this articulation. Range

sleep_threshold: float#

[0, max_float32]

Type:

Energy below which the articulation may go to sleep. Range

solver_cfg: Union[SolverCfg, Dict[str, SolverCfg], None]#

Solver is used to compute forward and inverse kinematics for the robot.

urdf_cfg: Optional[URDFCfg]#

URDF assembly configuration which allows for assembling a robot from multiple URDF components.