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 Build Front Legs

From Leeroopedia
Revision as of 12:42, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Google_deepmind_Dm_control_Build_Front_Legs.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Robotics Simulation, Biomechanical Modeling
Last Updated 2026-02-15 04:00 GMT

Overview

The build_front_legs module constructs the front (fore) legs of the dog_v2 walker model as a hierarchical kinematic chain from scapula through fingers, attaching them to the torso body in the MJCF model.

Description

The module provides a single function, create_front_legs, that programmatically builds the left and right front legs of the dog model by adding MJCF elements in a proximal-to-distal sequence. For each side (left and right), the function creates: (1) scapula bodies with bone meshes and three-DOF shoulder joints (supinate, abduct, extend) using default classes for joint parameters; (2) upper arm bodies with humerus meshes and two-DOF shoulder joints (supinate, extend); (3) lower arm bodies with ulna, radius, and accessory bone meshes and single-DOF elbow joints whose axes are derived from site orientations; (4) hand bodies with carpal bone meshes, single-DOF wrist joints, and box collision primitives; and (5) finger bodies with phalanx bone meshes, single-DOF finger joints, and multi-part foot collision geometry plus palm sensor sites.

Positions are accumulated through the chain via a parent_pos tracking dictionary, and left/right mirroring is achieved through side_sign dictionaries that flip translation coordinates. After the kinematic chain construction, the function recompiles physics using mjcf.Physics.from_mjcf_model and uses bound geometry data to place collision primitives for scapulae, upper arms, ulnae, and radii. It returns a list of palm site references for sensor creation by the parent build script.

This is a modular component of the dog_v2 build pipeline, called by build_dog.py. It isolates the anatomically complex front leg construction, which differs significantly from the back legs due to the scapula-shoulder joint hierarchy and the hand/finger structure (versus foot/toe). The separation into its own module maintains code organization across the multi-file dog model builder.

Usage

Use this module when constructing the dog_v2 walker model. It is called internally by the dog build pipeline (build_dog.py) and is not typically invoked directly by users. It should be called after the torso body has been created and default joint classes for scapula_supinate, scapula_abduct, scapula_extend, shoulder_supinate, shoulder_extend, elbow, wrist, and finger have been defined.

Code Reference

Source Location

Signature

def create_front_legs(nails, model, primary_axis, bones, side_sign, parent):
    """Add front legs in the model.

    Args:
        nails: a list of string with the geoms representing nails.
        model: model in which we want to add the front legs.
        primary_axis: a dictionary of numpy arrays representing axis of rotation.
        bones: a list of strings with all the names of the bones.
        side_sign: a dictionary with two axis representing the signs of
            translations.
        parent: parent object on which we should start attaching new components.

    Returns:
        A list of palm sites.
    """

Import

from dm_control.locomotion.walkers.assets.dog_v2.build_front_legs import create_front_legs

I/O Contract

Inputs

Name Type Required Description
nails list[str] Yes A mutable list of geom names representing nails; distal phalanx bones are appended to this list during construction
model mjcf.RootElement Yes The MJCF model to which the front legs will be added
primary_axis dict[str, np.ndarray] Yes Dictionary mapping DOF suffixes (e.g., '_supinate', '_abduct', '_extend') to numpy arrays representing axes of rotation
bones list[str] Yes A list of strings containing all bone mesh names available in the model
side_sign dict[str, np.ndarray] Yes Dictionary with keys '_L' and '_R' mapping to numpy arrays that flip translation coordinates for left/right mirroring
parent mjcf.Element Yes The parent body element (torso) on which to start attaching new components

Outputs

Name Type Description
palm_sites list[mjcf.Element] A list of two palm site elements (left and right), used for sensor creation by the parent build script

Usage Examples

Basic Usage

from dm_control.locomotion.walkers.assets.dog_v2.build_front_legs import create_front_legs
import numpy as np

# Called internally by build_dog.py with model setup already complete:
nails = []
primary_axis = {
    '_supinate': np.array([1.0, 0.0, 0.0]),
    '_abduct': np.array([0.0, 0.0, 1.0]),
    '_extend': np.array([0.0, 1.0, 0.0]),
}
side_sign = {
    '_L': np.array([1, 1, 1]),
    '_R': np.array([-1, 1, 1]),
}

# parent is the torso body, model is the root MJCF element
palm_sites = create_front_legs(nails, model, primary_axis, bones, side_sign, torso)

Related Pages

Page Connections

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