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 Dog

From Leeroopedia
Revision as of 12:42, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Google_deepmind_Dm_control_Build_Dog.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

This script serves as the top-level orchestrator that assembles the complete dog walker MuJoCo model by coordinating all sub-module build steps for torso, neck, legs, tail, actuators, skin, and sensors.

Description

The build_dog module is the central build script and main entry point for constructing the dog_v2 walker model, one of the most complex locomotion agents in dm_control. It loads a base XML model (dog_base.xml) and all bone meshes from the dog_assets directory, temporarily placing each bone in the worldbody to extract its position and bounding size via physics compilation.

The script then delegates construction to specialized sub-modules in sequence: build_torso.create_torso (torso, lumbar spine, pelvis), build_neck.create_neck (cervical spine, skull, jaw), build_back_legs.create_back_legs (hind legs), build_front_legs.create_front_legs (front legs with shoulders), and build_tail.create_tail (caudal spine). After assembling the skeleton, it merges multi-mesh bodies (ribcage, jaw, skull) into unified meshes for efficiency, adds torque actuators via add_torque_actuators.add_motors, and excludes self-collision pairs both automatically (by detecting contacts at the initial pose) and manually (for known problematic pairs like cervical vertebrae with upper arms, pelvis with lower legs, etc.).

The script optionally generates a skin mesh via create_skin.create, adds sensors (accelerometer, velocimeter, gyro, touch sensors on paws, force sensors on anchors), and finalizes the XML with cleanup steps including hash removal from filenames, insertion of a compiler element for local mesh/texture paths, removal of root class attributes, and cosmetic formatting. The script is configurable via absl flags for degrees-of-freedom per vertebra (lumbar_dofs_per_vertebra, cervical_dofs_per_vertebra, caudal_dofs_per_vertebra) and skin generation (make_skin).

Usage

Run this script as a standalone command-line tool to regenerate the dog.xml model file. The modular delegation pattern allows each anatomical subsystem to be developed and tested independently while this script handles integration, contact exclusion, actuation, sensing, and final XML export.

Code Reference

Source Location

Signature

# Flags
flags.DEFINE_boolean('make_skin', True, 'Whether to make a new dog_skin.skn')
flags.DEFINE_float('lumbar_dofs_per_vertebra', 1.5, ...)
flags.DEFINE_float('cervical_dofs_per_vertebra', 1.5, ...)
flags.DEFINE_float('caudal_dofs_per_vertebra', 1, ...)

BASE_MODEL = 'dog_base.xml'
ASSET_RELPATH = '../../../../suite/dog_assets'

def exclude_contacts(model): ...
def main(argv): ...

Import

# This is a standalone build script, not typically imported.
# Run directly:
# python dm_control/locomotion/walkers/assets/dog_v2/build_dog.py

# Sub-modules used by this script:
from dm_control.locomotion.walkers.assets.dog_v2 import add_torque_actuators
from dm_control.locomotion.walkers.assets.dog_v2 import build_back_legs
from dm_control.locomotion.walkers.assets.dog_v2 import build_front_legs
from dm_control.locomotion.walkers.assets.dog_v2 import build_neck
from dm_control.locomotion.walkers.assets.dog_v2 import build_tail
from dm_control.locomotion.walkers.assets.dog_v2 import build_torso
from dm_control.locomotion.walkers.assets.dog_v2 import create_skin

I/O Contract

Inputs

Name Type Required Description
dog_base.xml XML file Yes Base MuJoCo model with defaults, compiler settings, and material definitions
Bone meshes .obj/.stl files Yes Bone mesh files (prefixed with BONE) in the dog_assets directory
dog_skin.msh mesh file Yes Skin mesh file for the visual appearance of the dog
skin_texture.png image file Yes Texture file applied to the dog skin
--make_skin bool flag No Whether to regenerate dog_skin.skn (default: True)
--lumbar_dofs_per_vertebra float flag No DOFs per lumbar vertebra (default: 1.5)
--cervical_dofs_per_vertebra float flag No DOFs per cervical vertebra (default: 1.5)
--caudal_dofs_per_vertebra float flag No DOFs per caudal vertebra (default: 1.0)

Outputs

Name Type Description
dog.xml XML file Complete physics-ready MuJoCo model of the dog walker with torso, neck, legs, tail, actuators, skin, sensors, and contact exclusions

Usage Examples

Basic Usage

# Run as a standalone script to generate dog.xml:
# python build_dog.py

# With custom flags:
# python build_dog.py --lumbar_dofs_per_vertebra=2.0 --make_skin=False

# The exclude_contacts function can be used independently:
from dm_control.locomotion.walkers.assets.dog_v2.build_dog import exclude_contacts
from dm_control import mjcf

model = mjcf.from_path('dog_base.xml')
# ... build model ...
exclude_contacts(model)  # Auto-detect and exclude colliding pairs

Related Pages

Page Connections

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