Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Haosulab ManiSkill MJCFLoader

From Leeroopedia
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 name attribute (e.g., "robot-articulation-0" or just "robot").
  • Optionally disables self-collisions by setting collision group bits.
  • Returns a ParsedMJCFData TypedDict 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 Articulation object.
  • Accepts scene_idxs to 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

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