Implementation:Haosulab ManiSkill MJCFLoader
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, Model Loading |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool for loading MJCF (MuJoCo XML) files into ManiSkill with support for parallel environment building.
Description
The mjcf_loader.py module provides the public MJCFLoader class, which extends the internal SAPIEN MJCF loader with ManiSkill-specific parallelization and naming support.
MJCFLoader extends the internal _mjcf_loader.MJCFLoader with:
scene-- ManiSkillScene reference for parallel building.name-- Base name for loaded articulations and actors.disable_self_collisions-- Flag to disable self-collision between links.
parse() method:
- Calls the parent MJCF parser to get articulation/actor builders and cameras.
- Assigns names based on the loader's
nameattribute (e.g., "robot-articulation-0" or just "robot"). - Optionally disables self-collisions by setting collision group bits.
- Returns a
ParsedMJCFDataTypedDict with articulation_builders, actor_builders, and cameras.
load() method:
- Parses the MJCF file, builds the first articulation across specified sub-scenes, and returns a single
Articulationobject. - Accepts
scene_idxsto control which parallel environments receive the loaded object.
Usage
Primary interface for loading MJCF robot models and articulated objects into ManiSkill environments during scene building.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/utils/building/mjcf_loader.py
Signature
class ParsedMJCFData(TypedDict):
articulation_builders: list[ArticulationBuilder]
actor_builders: list[ActorBuilder]
cameras: list[Any]
class MJCFLoader(SAPIENMJCFLoader):
scene: ManiSkillScene
name: str = None
disable_self_collisions: bool = False
def parse(self, mjcf_file, package_dir=None) -> ParsedMJCFData: ...
def load(self, mjcf_file, package_dir=None, name=None, scene_idxs=None) -> Articulation: ...
Import
from mani_skill.utils.building.mjcf_loader import MJCFLoader
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| mjcf_file | str | Yes | Path to the MJCF XML file |
| package_dir | str | No | Base directory for asset resolution |
| name | str | No | Name for the loaded articulation |
| scene_idxs | list[int] | No | Sub-scene indices to build in |
Outputs
| Name | Type | Description |
|---|---|---|
| Articulation | Articulation | The loaded articulation ready for simulation |
| ParsedMJCFData | dict | Builders and cameras from parse() |
Usage Examples
Basic Usage
from mani_skill.utils.building.mjcf_loader import MJCFLoader
loader = MJCFLoader()
loader.scene = env.scene
loader.name = "shadow_hand"
loader.disable_self_collisions = True
articulation = loader.load("shadow_hand.xml")
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment