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:Google deepmind Dm control Duplo

From Leeroopedia
Knowledge Sources
Domains Reinforcement_Learning, Robotics, Manipulation
Last Updated 2026-02-15 04:00 GMT

Overview

A Composer entity representing a 2x4 Duplo brick with physically realistic stud-based interlocking mechanics, configurable separation forces, and per-episode stud size randomization.

Description

The Duplo class extends composer.Entity and loads its MJCF model from an external XML file (duplo2x4.xml). The brick features a 2x4 grid of studs on top and corresponding holes on the bottom, enabling realistic snap-fit interlocking behavior between bricks. The separation force required to pull bricks apart is controlled by the stud radius, which is randomized at the start of each episode.

The _build method accepts several configuration options. The easy_align flag switches studs from cylinders to capsules, making alignment easier for robotic manipulation. The flanges flag enables bottom flanges that allow partially overlapping brick configurations at the cost of more expensive dynamics. The variation parameter (a float from 0.0 to 1.0) controls the range of stud size randomization: a value of 1.0 produces a distribution of separation forces matching empirical measurements from real Duplo bricks, while 0.0 yields a deterministic force near the mode of the empirical distribution. Stud size parameters are looked up from pre-calibrated tables indexed by the (easy_align, flanges) combination.

DuploObservables provides five sensor-based observables: position, orientation, linear velocity, angular velocity, and force, all backed by MuJoCo sensors defined in the XML model.

Usage

Use Duplo as a prop in Composer manipulation tasks involving brick stacking, assembly, or placement. Configure easy_align and flanges based on the desired difficulty and physical fidelity. Adjust variation to control the range of separation force randomization for domain randomization training.

Code Reference

Source Location

Signature

class Duplo(composer.Entity):
    def _build(self, easy_align=False, flanges=True, variation=0.0,
               color=(1., 0., 0.)):
        ...
    def initialize_episode_mjcf(self, random_state):
        ...
    @property
    def studs(self):
        ...
    @property
    def holes(self):
        ...
    @property
    def mjcf_model(self):
        ...

class DuploObservables(composer.Observables, composer.FreePropObservableMixin):
    def position(self):
        ...
    def orientation(self):
        ...
    def linear_velocity(self):
        ...
    def angular_velocity(self):
        ...
    def force(self):
        ...

Import

from dm_control.entities.props.duplo import Duplo

I/O Contract

Inputs (_build)

Name Type Required Description
easy_align bool No If True, use capsule studs for easier alignment (default False)
flanges bool No If True, enable bottom flanges for partial-overlap connections (default True)
variation float No Controls stud size randomization range from 0.0 (deterministic) to 1.0 (full empirical range) (default 0.0)
color tuple of 3 floats No RGB color values between 0 and 1 (default red: (1., 0., 0.))

Outputs

Name Type Description
studs numpy.ndarray (2, 4) of mjcf.Element Site elements corresponding to the 8 studs
holes numpy.ndarray (2, 4) of mjcf.Element Site elements corresponding to the 8 holes
position observable numpy.ndarray Brick position from sensor data
orientation observable numpy.ndarray Brick orientation from sensor data
linear_velocity observable numpy.ndarray Brick linear velocity from sensor data
angular_velocity observable numpy.ndarray Brick angular velocity from sensor data
force observable numpy.ndarray Force sensor data on the brick

Stud Size Parameters

The stud radius is sampled uniformly between computed lower and upper bounds based on the configuration:

easy_align flanges minimum lower_quartile maximum
False False 0.004685 0.004781 0.004898
False True 0.004609 0.004647 0.004716
True False 0.004754 0.004844 0.004953
True True 0.004695 0.004717 0.004765

The variation parameter interpolates between the lower quartile (at 0.0) and the full min/max range (at 1.0).

Usage Examples

from dm_control.entities.props.duplo import Duplo

# Create a red Duplo brick with default settings
brick = Duplo()

# Create a blue brick with easier alignment and full force variation
easy_brick = Duplo(easy_align=True, flanges=True, variation=1.0,
                   color=(0., 0., 1.))

# Access studs and holes
print(brick.studs.shape)  # (2, 4)
print(brick.holes.shape)  # (2, 4)

# The stud radius is randomized at episode start
# (called automatically by the Composer environment)
import numpy as np
rng = np.random.RandomState(42)
brick.initialize_episode_mjcf(rng)

Related Pages

Page Connections

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