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:ARISE Initiative Robosuite GeneratedObjects

From Leeroopedia
Revision as of 11:59, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/ARISE_Initiative_Robosuite_GeneratedObjects.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Robotics, Simulation, MJCF_Modeling
Last Updated 2026-02-15 07:00 GMT

Overview

The generated_objects module defines three core classes -- CompositeBodyObject, CompositeObject, and PrimitiveObject -- for programmatically constructing MuJoCo simulation objects from geometric primitives without relying on external XML files.

Description

CompositeBodyObject constructs complex objects by combining multiple MujocoObject instances into a single composite body hierarchy. Each sub-object can be attached to a specified parent body with a given position and quaternion offset. The class automatically strips top-level joints from sub-objects before appending them, and maintains an internal mapping of absolute body positions for computing bounding box properties. Joint specifications can be provided for both the top-level body and individual sub-bodies. The locations_relative_to_corner option allows positioning objects relative to the bounding box corner instead of the center.

CompositeObject builds objects from inline geometric primitives (boxes, spheres, cylinders, capsules, ellipsoids) rather than sub-objects. Each geom is specified with a type, size, location, optional quaternion, name, RGBA color, material, friction, density, and solver parameters. The class generates both collision geoms (group 0) and visual geoms (group 1) based on the obj_types parameter. Geom locations can be specified relative to either the center or the corner of the bounding box defined by total_size. This class is the parent for composite objects like HammerObject, PotWithHandlesObject, and HookFrame.

PrimitiveObject is the base class for simple single-geom objects (e.g., boxes, balls, cylinders). It provides a template method _get_object_subtree_() that generates the XML subtree with collision and visual geoms, joints, and a default site. Subclasses only need to override _get_object_subtree() to call the template with the appropriate geom type. It supports custom materials, configurable friction, density, and solver parameters.

Usage

Use CompositeBodyObject when you need to combine multiple existing MujocoObject instances into a single articulated or rigid body. Use CompositeObject when you need to build a multi-geom object from scratch using geometric primitives. Use PrimitiveObject as the base class for simple single-geom objects like BoxObject, BallObject, or CylinderObject.

Code Reference

Source Location

Signature

class CompositeBodyObject(MujocoGeneratedObject):
    def __init__(
        self, name, objects, object_locations,
        object_quats=None, object_parents=None,
        joints="default", body_joints=None, sites=None,
        total_size=None, locations_relative_to_corner=False,
    )

class CompositeObject(MujocoGeneratedObject):
    def __init__(
        self, name, total_size, geom_types, geom_sizes, geom_locations,
        geom_quats=None, geom_names=None, geom_rgbas=None,
        geom_materials=None, geom_frictions=None, geom_condims=None,
        rgba=None, density=100.0, solref=(0.02, 1.0), solimp=(0.9, 0.95, 0.001),
        locations_relative_to_center=False, joints="default", sites=None,
        obj_types="all", duplicate_collision_geoms=True,
    )

class PrimitiveObject(MujocoGeneratedObject):
    def __init__(
        self, name, size=None, rgba=None, density=None, friction=None,
        solref=None, solimp=None, material=None, joints="default",
        obj_type="all", duplicate_collision_geoms=True,
    )

Import

from robosuite.models.objects.generated_objects import (
    CompositeBodyObject,
    CompositeObject,
    PrimitiveObject,
)

I/O Contract

Inputs (CompositeObject)

Name Type Required Description
name str Yes Name of the overall object
total_size list of float Yes (x, y, z) half-size of the bounding box
geom_types list of str Yes MuJoCo geom primitive types (e.g., "box", "cylinder", "sphere")
geom_sizes list Yes Sizes for each geom, matching MuJoCo size conventions
geom_locations list of 3-tuple Yes (x, y, z) location of each geom relative to the bounding box
geom_quats list of 4-tuple or None No (w, x, y, z) quaternion for each geom rotation
geom_names list of str or None No Names for each geom
geom_rgbas list of 4-tuple or None No RGBA colors per geom
geom_materials list of str or None No Material names per geom
geom_frictions list of 3-tuple or None No Friction values (sliding, torsional, rolling) per geom
density float or list of float No Density for all or per geom. Default: 100.0
joints None, "default", or list of dict No Joint specs. "default" adds a free joint. None adds no joints
obj_types str or list of str No "collision", "visual", or "all" per geom. Default: "all"

Inputs (PrimitiveObject)

Name Type Required Description
name str Yes Unique name for this object
size n-tuple of float No Size parameters (1-3 values). Default: [0.05, 0.05, 0.05]
rgba 4-tuple of float No Color. Default: [1, 0, 0, 1]
density float No Density. Default: 1000
friction 3-tuple or float No Friction parameters. Default: [1, 0.005, 0.0001]
material CustomMaterial, "default", or None No Material to apply
joints None, "default", or list of dict No Joint specs. Default: "default" (free joint)
obj_type str No "collision", "visual", or "all". Default: "all"

Outputs

Name Type Description
bottom_offset np.array (0, 0, -total_size[2]) for CompositeObject
top_offset np.array (0, 0, total_size[2]) for CompositeObject
horizontal_radius float L2 norm of total_size[:2] for CompositeObject

Usage Examples

from robosuite.models.objects.generated_objects import CompositeObject, PrimitiveObject
import numpy as np

# Create a composite object with two geoms
composite = CompositeObject(
    name="my_composite",
    total_size=[0.05, 0.05, 0.1],
    geom_types=["box", "cylinder"],
    geom_sizes=[
        np.array([0.04, 0.04, 0.04]),
        np.array([0.02, 0.06]),
    ],
    geom_locations=[
        (0, 0, -0.03),
        (0, 0, 0.04),
    ],
    geom_names=["base", "column"],
    density=500.0,
    locations_relative_to_center=True,
    obj_types="all",
)

# Get the XML element for adding to a world
obj_element = composite.get_obj()

# Check if an object is within the composite's bounding box
in_box = composite.in_box(
    position=np.array([0.5, 0.5, 0.8]),
    object_position=np.array([0.52, 0.52, 0.82])
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment