Implementation:Haosulab ManiSkill MultiAgent
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete wrapper class that manages multiple BaseAgent instances as a single unified agent for multi-robot tasks in ManiSkill.
Description
MultiAgent inherits from BaseAgent and Generic[T] (for type hinting of the agents tuple). It stores agents in both a list (self.agents) and a dictionary keyed by {uid}-{index} (self.agents_dict). It exposes a Dict action space where each key maps to an individual agent's action space. All core methods -- set_action(), before_simulation_step(), reset(), get_controller_state()/set_controller_state(), and get_proprioception() -- delegate to each sub-agent. Sensor configs are aggregated from all agents with prefixed UIDs (e.g., {agent_uid}-{index}-{sensor_uid}) to avoid naming collisions.
Usage
Use MultiAgent in multi-robot environments (e.g., two Panda arms cooperating). The environment constructs a MultiAgent from a list of individual BaseAgent instances. Actions are passed as a dictionary keyed by agent identifier, and observations/proprioception are returned in the same format.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/agents/multi_agent.py
- Lines: 1-106
Signature
class MultiAgent(BaseAgent, Generic[T]):
agents: T
def __init__(self, agents: list[BaseAgent]):
Import
from mani_skill.agents.multi_agent import MultiAgent
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| agents | list[BaseAgent] | Yes | List of BaseAgent instances to manage as a unified multi-agent. |
| action | dict[str, Array] | Yes | Dictionary of actions keyed by agent identifier ({uid}-{index}), passed to set_action().
|
| control_mode | list[str] or None | No | List of control mode strings, one per agent, passed to set_control_mode(). None sets defaults.
|
| init_qpos | dict or None | No | Optional dictionary mapping agent UID to initial qpos for reset().
|
Outputs
| Name | Type | Description |
|---|---|---|
| action_space | spaces.Dict | Dictionary action space with one entry per agent, keyed by {uid}-{index}.
|
| single_action_space | spaces.Dict | Unbatched dictionary action space. |
| control_mode | dict[str, str] | Dictionary of current control mode per agent. |
| get_proprioception() | dict[str, dict] | Dictionary of proprioception data per agent. |
| get_controller_state() | dict[str, dict] | Dictionary of controller states per agent. |
Usage Examples
Basic Usage
from mani_skill.agents.multi_agent import MultiAgent
# In a multi-robot environment's _load_agent method:
agent_left = PandaAgent(scene, control_freq=20, agent_idx="0")
agent_right = PandaAgent(scene, control_freq=20, agent_idx="1")
multi_agent = MultiAgent(agents=[agent_left, agent_right])
# Actions are passed as a dict:
action = {
"panda-0": left_arm_action,
"panda-1": right_arm_action,
}
multi_agent.set_action(action)
# Proprioception is returned as a dict:
obs = multi_agent.get_proprioception()
# obs["panda-0"]["qpos"], obs["panda-1"]["qpos"], etc.