embodichain.lab.sim.utility#
Utility Functions#
This module contains utility functions for simulation, mesh processing, and URDF handling.
Submodules
Simulation Utils#
Functions:
|
Create cube objects in the specified environments or arenas. |
|
Create sphere objects in the specified environments or arenas. |
Get the number of arenas in the default dexsim world. |
|
Get all arenas in the default dexsim world. |
|
|
Get the dexsim drive type from a string. |
Check if Ray Tracing rendering backend is enabled in the default dexsim world. |
|
|
Load mesh objects from configuration. |
|
Set articulation configuration for a list of dexsim articulations. |
- embodichain.lab.sim.utility.sim_utils.create_cube(envs, size, uid='cube')[source]#
Create cube objects in the specified environments or arenas.
- Parameters:
envs (List[Union[Env, Arena]]) – List of environments or arenas to create cubes in.
size (List[float]) – Size of the cube as [length, width, height] in meters.
uid (str, optional) – Unique identifier for the cube objects. Defaults to “cube”.
- Returns:
List of created cube mesh objects.
- Return type:
List[MeshObject]
- embodichain.lab.sim.utility.sim_utils.create_sphere(envs, radius, resolution=20, uid='sphere')[source]#
Create sphere objects in the specified environments or arenas.
- Parameters:
envs (List[Union[Env, Arena]]) – List of environments or arenas to create spheres in.
radius (float) – Radius of the sphere in meters.
resolution (int, optional) – Resolution of the sphere mesh. Defaults to 20.
uid (str, optional) – Unique identifier for the sphere objects. Defaults to “sphere”.
- Returns:
List of created sphere mesh objects.
- Return type:
List[MeshObject]
- embodichain.lab.sim.utility.sim_utils.get_dexsim_arena_num()[source]#
Get the number of arenas in the default dexsim world.
- Returns:
The number of arenas in the default world, or 0 if no world is found.
- Return type:
int
- embodichain.lab.sim.utility.sim_utils.get_dexsim_arenas()[source]#
Get all arenas in the default dexsim world.
- Returns:
A list of arenas in the default world, or an empty list if no world is found.
- Return type:
List[dexsim.environment.Arena]
- embodichain.lab.sim.utility.sim_utils.get_dexsim_drive_type(drive_type)[source]#
Get the dexsim drive type from a string.
- Parameters:
drive_type (str) – The drive type as a string.
- Returns:
The corresponding DriveType enum.
- Return type:
DriveType
- embodichain.lab.sim.utility.sim_utils.is_rt_enabled()[source]#
Check if Ray Tracing rendering backend is enabled in the default dexsim world.
- Returns:
True if Ray Tracing rendering is enabled, False otherwise.
- Return type:
bool
- embodichain.lab.sim.utility.sim_utils.load_mesh_objects_from_cfg(cfg, env_list, cache_dir=None)[source]#
Load mesh objects from configuration.
- Parameters:
cfg (RigidObjectCfg) – Configuration for the rigid object.
env_list (List[Arena]) – List of arenas to load the objects into.
cache_dir (Optional[str], optional) – Directory for caching convex decomposition files. Defaults to None
- Returns:
List of loaded mesh objects.
- Return type:
List[MeshObject]
- embodichain.lab.sim.utility.sim_utils.set_dexsim_articulation_cfg(arts, cfg)[source]#
Set articulation configuration for a list of dexsim articulations.
- Parameters:
arts (List[Articulation]) – List of dexsim articulations to configure.
cfg (ArticulationCfg) – Configuration object containing articulation settings.
- Return type:
None
Mesh Utils#
Functions:
|
Export a combined mesh from all links of one or more articulations to a mesh file format. |
- embodichain.lab.sim.utility.mesh_utils.export_articulation_mesh(articulation, output_path='./articulation.obj', link_names=None, base_xpos=None, base_link_name=None, **kwargs)[source]#
Export a combined mesh from all links of one or more articulations to a mesh file format.
This function retrieves the link geometries and poses from the given articulation(s), transforms each link mesh to its world pose, merges them into a single mesh, and exports the result to the specified file path. The export format is inferred from the file extension (e.g., .obj, .ply, .stl, .glb, .gltf).
- Parameters:
articulation (dexsim.engine.Articulation or list) – The articulation object or list of articulations.
output_path (str) – The output file path including the file name and extension. Supported extensions: .obj, .ply, .stl, .glb, .gltf.
link_names (list[str] or dict[Any, list[str]], optional) – Specify which links to export. If None, export all links.
base_xpos (np.ndarray, optional) – 4x4 homogeneous transformation matrix. All meshes will be transformed into this base pose coordinate system.
base_link_name (str, optional) – If specified, use the pose of this link as the base pose. The link will be searched from all link_names of all articulations.
- Returns:
The combined Open3D mesh object of all articulations.
- Return type:
o3d.geometry.TriangleMesh