embodichain.lab.sim.objects#
Classes
Light represents a batch of lights in the simulation. |
|
Configuration for a light asset in the simulation. |
|
RigidObject represents a batch of rigid body in the simulation. |
|
Data manager for rigid body with body type of dynamic or kinematic. |
|
Configuration for a rigid body asset in the simulation. |
|
RigidObjectGroup represents a batch of rigid bodies in the simulation. |
|
Data manager for rigid body group with body type of dynamic or kinematic. |
|
Configuration for a rigid object group asset in the simulation. |
|
Articulation represents a batch of articulations in the simulation. |
|
GPU data manager for articulation. |
|
Configuration for an articulation asset in the simulation. |
|
A class representing a batch of robots in the simulation environment. |
|
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:
BatchEntityLight 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.
- 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:
ObjectBaseCfgConfiguration 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:
4x4 transformation matrix of the root in local frame.
Position of the root in simulation world frame.
Euler angles (in degree) of the root in simulation world frame.
Intensity of the light source with unit of watts/m^2.
Falloff of the light, only used for point light.
- classmethod from_dict(init_dict)#
Initialize the configuration from a dictionary.
- Return type:
-
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:
BatchEntityRigidObject 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 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:
Get the rigid body data manager for this rigid object.
Get the body state of the rigid object.
Check if the rigid object is non-dynamic (static or kinematic).
Check if the rigid object is static.
- 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:
- 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
- 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:
attrs (Union[RigidBodyAttributesCfg, List[RigidBodyAttributesCfg]]) – The physical attributes to set.
env_ids (Optional[Sequence[int]], optional) – Environment indices. If None, then all indices are used.
- 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:
objectData manager for rigid body with body type of dynamic or kinematic.
Note
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:
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:
ObjectBaseCfgConfiguration 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:
Scale of the rigid body in the simulation world frame.
4x4 transformation matrix of the root in local frame.
Position of the root in simulation world frame.
Euler angles (in degree) of the root in simulation world frame.
The maximum number of convex hulls that will be created for the rigid body.
Shape configuration for the rigid body.
Methods:
from_dict(init_dict)Initialize the configuration from a dictionary.
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:
-
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
-
body_scale:
Rigid Object Group#
- class embodichain.lab.sim.objects.RigidObjectGroup[source]#
Bases:
BatchEntityRigidObjectGroup 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 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:
Get the rigid body data manager for this rigid object.
Get the body state of the rigid object.
Check if the rigid object is non-dynamic (static or kinematic).
Get the number of objects in each rigid body instance.
- property body_data: RigidBodyGroupData#
Get the rigid body data manager for this rigid object.
- Returns:
The rigid body data manager.
- Return type:
- 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
- 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:
objectData manager for rigid body group with body type of dynamic or kinematic.
Methods:
__init__(entities, ps, device)Initialize the RigidBodyGroupData.
Attributes:
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:
objectConfiguration 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 for all rigid objects in the group.
File extension for the rigid object assets.
Path to the folder containing the rigid object assets.
Maximum number of rigid objects to initialize from the folder.
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:
-
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:
BatchEntityArticulation 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 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 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:
Get the names of the joints in the articulation.
Get the rigid body data manager for this rigid object.
Get the body state of the articulation.
Get the degree of freedom of the articulation.
Get the names of the actived joints in the articulation.
Get the names of the links in the articulation.
Get the mimic joint ids for the articulation.
Get the mimic joint multipliers for the articulation.
Get the mimic joint offsets for the articulation.
Get the mimic joint parent ids for the articulation.
Get the number of links in the articulation.
Get the name of the root link of the articulation.
Get the root state of the articulation.
- 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:
- 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
- property dof: int#
Get the degree of freedom of the articulation.
- Returns:
The degree of freedom of the articulation.
- Return type:
int
- get_link_pose(link_name, env_ids=None, to_matrix=False)[source]#
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_link_vert_face(link_name)[source]#
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_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]
- property link_names: 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]]
- property num_links: 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
- property root_link_name: str#
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:
objectGPU data manager for articulation.
Methods:
__init__(entities, ps, device)Initialize the ArticulationData.
Attributes:
Get the pose of all links in the articulation.
Get the velocities of all links in the articulation.
Get the joint damping of the articulation.
Get the joint friction of the articulation.
Get the joint stiffness of the articulation.
Get the vertices and faces of all links in the articulation.
Get the current accelerations (qacc) of the articulation.
Get the current forces (qf) of the articulation.
Get the joint effort limits of the articulation.
Get the current positions (qpos) of the articulation.
Get the joint position limits of the articulation.
Get the current velocities (qvel) of the articulation.
Get the joint velocity limits of the articulation.
Get the angular velocity of the root link of the articulation.
Get the linear velocity of the root link of the articulation.
Get the root pose of the articulation.
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.
- property body_link_pose: Tensor#
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
- property body_link_vel: 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
- property link_vert_face: Dict[str, Tuple[Tensor, 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:
ObjectBaseCfgConfiguration 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:
Physical attributes for all links .
Scale of the articulation in the simulation world frame.
Whether to build pytorch-kinematics chain for forward kinematics and jacobian computation.
Whether to enable or disable self-collisions.
Properties to define the drive mechanism of a joint.
Whether to fix the base of the articulation.
Path to the articulation asset file.
4x4 transformation matrix of the root in local frame.
Position of the root in simulation world frame.
Initial joint positions of the articulation.
Euler angles (in degree) of the root in simulation world frame.
[1,255].
[0,255].
[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:
-
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
-
attrs:
Robot#
- class embodichain.lab.sim.objects.Robot[source]#
Bases:
ArticulationA 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 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.
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 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 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:
Get the names of the joints in the articulation.
Get the rigid body data manager for this rigid object.
Get the body state of the articulation.
Get the control parts of the robot.
Get the degree of freedom of the articulation.
Get the names of the actived joints in the articulation.
Get the names of the links in the articulation.
Get the mimic joint ids for the articulation.
Get the mimic joint multipliers for the articulation.
Get the mimic joint offsets for the articulation.
Get the mimic joint parent ids for the articulation.
Get the number of links in the articulation.
Get the name of the root link of the articulation.
Get the root state of the articulation.
- 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:
- 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.
- 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_link_pose(link_name, env_ids=None, to_matrix=False)#
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_link_vert_face(link_name)#
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]]
- 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]
- property link_names: 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]]
- property num_links: 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
- property root_link_name: str#
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:
ArticulationCfgRobotCfg(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:
Configuration for the kinematic solver used in the robot simulation.
Attributes:
Physical attributes for all links .
Scale of the articulation in the simulation world frame.
Whether to build pytorch-kinematics chain for forward kinematics and jacobian computation.
Control parts is the mapping from part name to joint names.
Whether to enable or disable self-collisions.
Properties to define the drive mechanism of a joint.
Whether to fix the base of the articulation.
Path to the articulation asset file.
4x4 transformation matrix of the root in local frame.
Position of the root in simulation world frame.
Initial joint positions of the articulation.
Euler angles (in degree) of the root in simulation world frame.
[1,255].
[0,255].
[0, max_float32]
Solver is used to compute forward and inverse kinematics for the robot.
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:
objectConfiguration for the kinematic solver used in the robot simulation.
Attributes:
The class type of the solver to be used.
The name of the end-effector link for the solver.
Weights for the inverse kinematics nearest calculation.
List of joint names for the solver.
The name of the root/base link for the solver.
The tool center point (TCP) position as a 4x4 homogeneous matrix.
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.
-
end_link_name:
str# 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:
-
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.
-
root_link_name:
str# 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.
-
class_type:
- 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:
- 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.