Implementation:Haosulab ManiSkill SapienUtils
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, SAPIEN |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool for SAPIEN-specific utility functions including object lookup, URDF configuration validation, camera setup, and pose/tensor operations.
Description
The sapien_utils.py module provides utility functions that interface directly with the SAPIEN simulation engine. These utilities are used extensively across ManiSkill for object management, configuration, and rendering setup.
Object Lookup:
get_obj_by_name()-- Find a SAPIEN object (Entity, Link, etc.) by name from a list, optionally enforcing uniqueness.get_objs_by_names()-- Find multiple objects by a list of names, returning them in the requested order.get_obj_by_type()-- Find objects by their Python type.
Configuration Validation:
check_urdf_config()-- Validate URDF loader configuration dictionaries against allowed keys (material, density, link).apply_urdf_config()-- Apply a URDF config dict to a URDFLoader, setting material properties (static/dynamic friction, restitution, density) and per-link overrides.
Camera Utilities:
set_shader_pack()-- Set the global shader pack for the SAPIEN render system.- Camera model matrix computation from mount pose and local pose.
Pose and Tensor Operations:
to_tensor()/to_numpy()-- Wrappers for device-aware data conversion.compute_total_pose()-- Compute world-frame poses from entity chain.
Usage
Import from mani_skill.utils.sapien_utils when you need to interact with SAPIEN objects directly, look up entities by name, or configure URDF loading parameters.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/utils/sapien_utils.py
Signature
def get_obj_by_name(objs: list[T], name: str, is_unique=True) -> T: ...
def get_objs_by_names(objs: list[T], names: list[str]) -> list[T]: ...
def get_obj_by_type(objs: list[T], target_type: T, is_unique=True) -> T: ...
def check_urdf_config(urdf_config: dict) -> None: ...
def apply_urdf_config(loader: URDFLoader, urdf_config: dict) -> None: ...
Import
from mani_skill.utils import sapien_utils
# or
from mani_skill.utils.sapien_utils import get_obj_by_name, check_urdf_config
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| objs | list[T] | Yes | List of SAPIEN objects to search (entities, links, etc.) |
| name | str | Yes | Name to search for |
| is_unique | bool | No | Whether name must be unique (default True) |
| urdf_config | dict | Yes | URDF loader configuration dictionary |
Outputs
| Name | Type | Description |
|---|---|---|
| return | T or None | Matched SAPIEN object, or None if not found |
| return | list[T] | List of matched objects (for get_objs_by_names) |
Usage Examples
Basic Usage
from mani_skill.utils.sapien_utils import get_obj_by_name
# Find an actor by name in a scene
actor = get_obj_by_name(scene.get_all_actors(), "target_cube")
# Find a link by name in an articulation
link = get_obj_by_name(articulation.get_links(), "gripper_link")