Implementation:Google deepmind Dm control Walker Rescale
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Physics Simulation |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
The Walker Rescale module provides utility functions for rescaling walker MJCF models by adjusting positions, geom sizes, and body masses throughout the body subtree hierarchy.
Description
The rescale_subtree function recursively traverses all children of a body element, scaling pos attributes by a position_factor and size attributes by a size_factor. For geoms that use the fromto attribute (specifying start and end points), it correctly recomputes both the midpoint position and the extent by decomposing the fromto into its center and half-range, scaling each independently, then reconstructing the fromto values. Sensor elements are intentionally skipped during traversal to avoid corrupting sensor references.
The rescale_humanoid function applies rescale_subtree specifically to humanoid walker models, starting from the parent of the root body. If size_factor is not specified, it defaults to match position_factor. An optional mass parameter enables target mass scaling: the function compiles a temporary physics instance to read the current subtree mass, computes the ratio needed to reach the target mass, and then scales all body inertial masses, geom masses, or geom densities by that factor. For geoms without an explicit mass, the density is scaled instead (defaulting to MuJoCo's standard 1000 kg/m^3 if unset).
Usage
Use rescale_subtree when you need fine-grained control over scaling specific body subtrees, such as when adapting a walker to match motion capture subject proportions via WalkerInfo. Use rescale_humanoid for whole-walker rescaling, such as the CMUHumanoidPositionControlledV2020 variant which uses rescale_humanoid(self, 1.2, 1.2, 70) to scale the model to realistic human size.
Code Reference
Source Location
- Repository: Google_deepmind_Dm_control
- File: dm_control/locomotion/walkers/rescale.py
- Lines: 1-60
Signature
def rescale_subtree(body, position_factor, size_factor):
def rescale_humanoid(walker, position_factor, size_factor=None, mass=None):
Import
from dm_control.locomotion.walkers.rescale import rescale_subtree
from dm_control.locomotion.walkers.rescale import rescale_humanoid
I/O Contract
Inputs (rescale_subtree)
| Name | Type | Required | Description |
|---|---|---|---|
| body | mjcf body element | Yes | The root body of the subtree to rescale |
| position_factor | float | Yes | Factor by which to multiply all pos attributes
|
| size_factor | float | Yes | Factor by which to multiply all size attributes
|
Inputs (rescale_humanoid)
| Name | Type | Required | Description |
|---|---|---|---|
| walker | Walker | Yes | The humanoid walker entity to rescale |
| position_factor | float | Yes | Factor by which to multiply all body positions |
| size_factor | float | No | Factor by which to multiply all geom sizes (defaults to position_factor if None) |
| mass | float | No | Target total mass in kg; if specified, all masses/densities are scaled to achieve this total |
Outputs
| Name | Type | Description |
|---|---|---|
| rescale_subtree return | None | Modifies the MJCF body subtree in-place |
| rescale_humanoid return | None | Modifies the walker's MJCF model in-place |
Usage Examples
from dm_control.locomotion.walkers.rescale import rescale_subtree, rescale_humanoid
# Rescale a specific body subtree
body = walker.mjcf_model.find('body', 'upper_arm')
subtree_root = body.parent
rescale_subtree(subtree_root, position_factor=1.1, size_factor=1.05)
# Rescale an entire humanoid walker to realistic size
# (as used in CMUHumanoidPositionControlledV2020)
rescale_humanoid(walker, position_factor=1.2, size_factor=1.2, mass=70)
# Rescale with size matching position factor (size_factor defaults)
rescale_humanoid(walker, position_factor=0.9, mass=55)