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 HammerObject

From Leeroopedia
Knowledge Sources
Domains Robotics, Simulation, MJCF_Modeling
Last Updated 2026-02-15 07:00 GMT

Overview

HammerObject is a procedurally generated composite object that creates a realistic hammer model with a handle, head, neck, face, and claw for use in manipulation tasks such as the Handover task.

Description

The HammerObject class extends CompositeObject to programmatically generate a hammer composed of five distinct geometric primitives: a handle (cylinder or box), a cubic head, a cylindrical neck, a cylindrical face, and a rotated box-shaped claw. Each component is positioned relative to the others to form a coherent hammer shape. The handle shape can be configured as either a cylinder or a box via the handle_shape parameter.

Physical properties are randomized within configurable ranges using numpy's random number generator. The handle radius, length, density, and friction are each sampled uniformly from specified ranges. The head density is derived from the handle density multiplied by a configurable head_density_ratio (default 2.0), making the head heavier than the handle as expected for a realistic hammer. The head half-size is also randomly sampled relative to the handle radius.

The hammer supports both textured and plain RGBA rendering. When use_texture=True, realistic materials are applied: "WoodLight" for the handle and "SteelScratched" for the metal parts (head, neck, face, claw). The init_quat property randomly returns one of two orientations (flipped 180 degrees), providing randomized initial placement in tasks. Convenience properties (handle_geoms, head_geoms, face_geoms, claw_geoms, all_geoms) expose the prefix-corrected geom names for collision checking and reward computation.

Usage

Use HammerObject when you need a hammer prop for manipulation tasks, particularly for tool-use or handover scenarios. It is designed for the Handover task but can be used in any environment requiring a hammer-shaped graspable object.

Code Reference

Source Location

Signature

class HammerObject(CompositeObject):
    def __init__(
        self,
        name,
        handle_shape="box",
        handle_radius=(0.015, 0.02),
        handle_length=(0.1, 0.25),
        handle_density=(100, 250),
        handle_friction=(3.0, 5.0),
        head_density_ratio=2.0,
        use_texture=True,
        rgba_handle=None,
        rgba_head=None,
        rgba_face=None,
        rgba_claw=None,
        rng=None,
    )

Import

from robosuite.models.objects.composite.hammer import HammerObject

I/O Contract

Inputs

Name Type Required Description
name str Yes Name of this Hammer object
handle_shape str No Either "box" or "cylinder" for the handle shape. Default: "box"
handle_radius float or 2-array No Specific value or (min, max) range for handle radius. Default: (0.015, 0.02)
handle_length float or 2-array No Specific value or (min, max) range for handle length. Default: (0.1, 0.25)
handle_density float or 2-array No Specific value or (min, max) range for handle density in SI units. Default: (100, 250)
handle_friction float or 2-array No Specific value or (min, max) range for handle friction. Default: (3.0, 5.0)
head_density_ratio float No Ratio of head density to handle density. Default: 2.0
use_texture bool No If True, apply realistic textures instead of RGBA colors. Default: True
rgba_handle 4-array or None No RGBA color for the handle. Default: RED
rgba_head 4-array or None No RGBA color for the head. Default: CYAN
rgba_face 4-array or None No RGBA color for the face. Default: BLUE
rgba_claw 4-array or None No RGBA color for the claw. Default: GREEN
rng np.random.Generator No Random number generator for sampling. Default: np.random.default_rng()

Outputs

Name Type Description
init_quat np.array Random (x, y, z, w) quaternion orientation for initial placement
handle_geoms list of str Prefix-corrected geom names for the handle
head_geoms list of str Prefix-corrected geom names for the head
face_geoms list of str Prefix-corrected geom names for the neck and face
claw_geoms list of str Prefix-corrected geom names for the claw
all_geoms list of str All prefix-corrected geom names for the entire hammer
bottom_offset np.array (0, 0, -handle_radius) offset vector
top_offset np.array (0, 0, handle_radius) offset vector
horizontal_radius float head_halfsize + 0.5 * handle_length

Usage Examples

from robosuite.models.objects.composite.hammer import HammerObject
import numpy as np

# Create a hammer with default randomized properties
hammer = HammerObject(name="my_hammer")

# Create a hammer with specific properties
hammer = HammerObject(
    name="fixed_hammer",
    handle_shape="cylinder",
    handle_radius=0.018,
    handle_length=0.2,
    handle_density=150,
    handle_friction=4.0,
    head_density_ratio=3.0,
    use_texture=False,
    rgba_handle=[0.6, 0.3, 0.1, 1.0],
    rgba_head=[0.8, 0.8, 0.8, 1.0],
)

# Access geom names for collision checking
print(hammer.handle_geoms)
print(hammer.head_geoms)

# Get initial orientation for placement
quat = hammer.init_quat

Related Pages

Page Connections

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