Implementation:Haosulab ManiSkill MujocoObject
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, Scene_Building |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool providing the base MujocoObject class that mimics robosuite's MujocoXMLObject for loading and managing MJCF-based objects in ManiSkill's SAPIEN simulation.
Description
The MujocoObject class serves as the foundational object representation for RoboCasa fixtures, bridging between MJCF XML descriptions and SAPIEN's actor/articulation system. It is adapted from robosuite's MujocoXMLObject class.
Key functionality:
- MJCF Loading -- Uses SAPIEN's MJCF loader to parse XML model files from the RoboCasa asset directory. Visual group 1 is used for rendering (group 0 is for collisions). The loader produces either an
actor_builderorarticulation_builder. - Pose management -- Tracks position (
pos), quaternion (quat), and providesset_pos(),set_euler(), and rotation property (rot). - Scaling --
set_scale(scale)applies uniform or per-axis scaling to all visual records, collision records, joint poses, and bounds sites. Handles cylinder/capsule shapes differently from box shapes (scaling radius and length vs. scale vector). - Bounding sites -- Parses exterior and interior bounding box sites (
ext_p0/px/py/pz,int_p0/px/py/pz) from the XML for spatial calculations. - Bounding box --
get_bbox_points()computes 8 bounding box corner points with optional translation and rotation. - Offset properties --
bottom_offset,top_offset, andhorizontal_radiusread from MJCF sites with scale applied.
A helper function site_pos(elem) extracts position from an XML element's "pos" attribute.
Usage
Base class for Fixture, CabinetPanel, Handle, and other RoboCasa components. Not typically instantiated directly.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/utils/scene_builder/robocasa/fixtures/mujoco_object.py
Signature
def site_pos(elem) -> np.ndarray: ...
class MujocoObject:
def __init__(self, scene: ManiSkillScene, xml: Optional[str], name: str,
pos: np.ndarray = None, scale: float = 1): ...
@property
def rot(self) -> float: ...
def set_pos(self, pos): ...
def set_euler(self, euler): ...
def set_scale(self, scale): ...
def get_bbox_points(self, trans=None, rot=None) -> list: ...
@property
def bottom_offset(self) -> np.ndarray: ...
@property
def top_offset(self) -> np.ndarray: ...
@property
def horizontal_radius(self) -> np.ndarray: ...
Import
from mani_skill.utils.scene_builder.robocasa.fixtures.mujoco_object import MujocoObject
I/O Contract
| Method/Property | Input | Output | Description |
|---|---|---|---|
__init__ |
scene, xml, name, pos, scale |
MujocoObject instance | Loads MJCF, creates actor/articulation builder |
set_scale |
scale: float or array |
None | Applies scale to visuals, collisions, joints, sites |
get_bbox_points |
trans, rot (optional) |
list of 8 3D points |
Computes 8-corner bounding box |
bottom_offset |
-- | np.ndarray |
Bottom site position (scaled) |
top_offset |
-- | np.ndarray |
Top site position (scaled) |
Usage Examples
# MujocoObject is typically used as a base class
class MyFixture(MujocoObject):
def __init__(self, scene, xml, name, **kwargs):
super().__init__(scene, xml, name, **kwargs)
# Access bounding information
bbox = self.get_bbox_points()
print(f"Bottom: {self.bottom_offset}")
print(f"Top: {self.top_offset}")