Principle:Haosulab ManiSkill Registration Pattern
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Software_Architecture, Plugin_Pattern |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
A decorator-based registration pattern maps string identifiers to classes, enabling string-based discovery and instantiation of agents, environments, and assets without direct imports.
Description
The Registration Pattern principle defines how ManiSkill uses global registries populated by decorators to discover and instantiate components by string UID. The pattern appears in two forms: environment registration via @register_env(uid) which populates Gymnasium's and ManiSkill's dual registries, and agent registration via @register_agent(uid) which populates the REGISTERED_AGENTS dictionary. Both decorators associate a string key with a class reference and optional metadata (asset download IDs, default parameters).
This pattern enables configuration-driven composition: a user specifies env_id="PickCube-v1" and robot_uids="panda" as strings, and the framework resolves these to concrete classes at runtime. It also supports automatic asset downloading by linking registered components to downloadable asset packages.
Usage
This principle applies whenever:
- A new environment or agent class must be discoverable by string identifier without requiring the caller to import the class directly.
- Asset download dependencies must be declared alongside the class definition.
- Override and versioning semantics are needed (e.g., re-registering with
override=True).
Theoretical Basis
Global Registry: A module-level dictionary mapping string UIDs to specification objects (EnvSpec or AgentSpec). Registration decorators insert entries; factory functions (gym.make, agent lookup) retrieve them.
Decorator Protocol: The @register_env and @register_agent decorators wrap the target class, adding it to the registry at import time. This is a side-effect-based registration that relies on module import ordering.
Asset Linking: Both decorators accept asset_download_ids parameters that link the registered component to entries in DATA_GROUPS, enabling automatic asset fetching when the component is first instantiated.
Related Pages
- Implementation:Haosulab_ManiSkill_AgentRegistration -- Agent UID registration system with @register_agent decorator.
- Implementation:Haosulab_ManiSkill_Register_Env_Decorator -- Environment registration via @register_env decorator.