Implementation:Haosulab ManiSkill AgentRegistration
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete agent registration system that maps string UIDs to agent classes and their associated downloadable assets in ManiSkill.
Description
This module provides the agent registration system for ManiSkill. It defines the AgentSpec dataclass (holding agent_cls and asset_download_ids), a global REGISTERED_AGENTS dictionary serving as the registry, and the @register_agent() decorator. The decorator registers an agent class by its uid attribute, storing the AgentSpec in the REGISTERED_AGENTS dict and also registering asset download IDs in the global assets.DATA_GROUPS so that robot assets can be automatically downloaded when needed. The decorator supports an optional override parameter to replace existing registrations.
Usage
Apply the @register_agent() decorator to any BaseAgent subclass to make it discoverable by string UID throughout the ManiSkill framework. This enables string-based agent instantiation (e.g., robot_uids="panda") used by environments, and links agents to their downloadable asset packages.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/agents/registration.py
- Lines: 1-45
Signature
@dataclass
class AgentSpec:
agent_cls: type[BaseAgent]
asset_download_ids: list[str]
REGISTERED_AGENTS: dict[str, AgentSpec] = {}
def register_agent(asset_download_ids: list[str] = [], override=False):
"""A decorator to register agents into ManiSkill so they can be used easily by string uid."""
Import
from mani_skill.agents.registration import register_agent, REGISTERED_AGENTS, AgentSpec
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| asset_download_ids | list[str] | No | List of asset download IDs associated with the agent. Defaults to empty list. |
| override | bool | No | If True, allows overriding an already registered agent. Defaults to False. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Callable | The decorator function that registers the agent class and returns it unchanged. |
| REGISTERED_AGENTS | dict[str, AgentSpec] | Global registry mapping agent UIDs to their AgentSpec (class + asset IDs). |
Usage Examples
Basic Usage
from mani_skill.agents.registration import register_agent
from mani_skill.agents.base_agent import BaseAgent
@register_agent(asset_download_ids=["my_robot_assets"])
class MyRobot(BaseAgent):
uid = "my_robot"
urdf_path = "path/to/my_robot.urdf"
@property
def _controller_configs(self):
# ... define controllers ...
pass
# Now the robot can be used by string UID in environments:
# env = gym.make("MyTask-v1", robot_uids="my_robot")