Implementation:Google deepmind Dm control Legacy Base Walker
| Knowledge Sources | |
|---|---|
| Domains | Robotics Simulation, Reinforcement Learning |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
⚠️ LEGACY CODE: This module is explicitly self-identified as legacy. See Heuristic:Google_deepmind_Dm_control_Warning_Deprecated_Legacy_Base_Walker for details.
The legacy_base module defines the Walker and WalkerObservables base classes that extend the core walker interface with richer observables, contact detection, initializer support, and utility methods used by most concrete walker implementations in dm_control.
Description
The Walker class extends base.Walker and adds several important features: initializer support (accepting single or multiple WalkerInitializer objects via the _build method), a reinitialize_pose method for episode resets, an aliveness metric returning a float in [-1, 0] (defaults to 0.0), an abstract ground_contact_geoms property for specifying which geoms should contact the ground, after_compile for computing end-effector and body geom ID sets, end_effector_contacts/body_contacts/collect_contacts for analyzing MuJoCo contact forces between geom pairs, after_substep for explicit subtree velocity computation via mj_subtreeVel, actuator_force accessor, and mocap joint ordering utilities.
The WalkerObservables class extends base.WalkerObservables with a comprehensive set of observables: joints_vel for joint velocities, body_height for root body height, end_effectors_pos with frame sensors for egocentric end-effector positions, world_zaxis for orientation, velocimeter/force/torque/touch/rangefinder sensor observables, an egocentric_camera observable, position and orientation observables, and convenience observables for reward computation including veloc_forward, veloc_strafe, veloc_up, torso_xvel, torso_yvel, gyro_backward_roll, gyro_rightward_roll, gyro_anticlockwise_spin, and prev_action. Helper methods add_egocentric_vector and add_egocentric_xmat allow transforming world-frame observables into the walker's egocentric frame. Semantic groupings bundle observables into proprioception, kinematic_sensors, and dynamic_sensors categories.
Usage
Use this module as the base class for concrete walker implementations that need rich sensory observables, contact detection, and initializer support. Most walkers in the dm_control locomotion suite (including the CMU Humanoid, Ant, Rodent, and FruitFly) inherit from this class rather than from base.Walker directly.
Code Reference
Source Location
- Repository: Google_deepmind_Dm_control
- File: dm_control/locomotion/walkers/legacy_base.py
- Lines: 1-380
Signature
class Walker(base.Walker):
def _build(self, initializer=None): ...
def reinitialize_pose(self, physics, random_state): ...
def aliveness(self, physics): ...
def after_compile(self, physics, unused_random_state): ...
def end_effector_contacts(self, physics): ...
def body_contacts(self, physics): ...
def collect_contacts(self, physics, geom_ids): ...
def after_substep(self, physics, random_state): ...
def actuator_force(self, physics): ...
class WalkerObservables(base.WalkerObservables):
def joints_vel(self): ...
def body_height(self): ...
def end_effectors_pos(self): ...
def world_zaxis(self): ...
def sensors_velocimeter(self): ...
def sensors_force(self): ...
def sensors_torque(self): ...
def sensors_touch(self): ...
def sensors_rangefinder(self): ...
def egocentric_camera(self): ...
def add_egocentric_vector(self, name, world_frame_observable, ...): ...
def add_egocentric_xmat(self, name, xmat_observable, ...): ...
Import
from dm_control.locomotion.walkers import legacy_base
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| initializer | WalkerInitializer or iterable | No | One or more initializer objects for pose resets; defaults to UprightInitializer |
Outputs
| Name | Type | Description |
|---|---|---|
| Walker instance | Walker | A base walker with contact detection, initializer support, and rich observable infrastructure |
| WalkerObservables instance | WalkerObservables | Observable set with proprioception, kinematic, and dynamic sensor groups |
Usage Examples
Basic Usage
from dm_control.locomotion.walkers import legacy_base
# Subclass Walker for a custom walker implementation
class MyWalker(legacy_base.Walker):
def _build(self, **kwargs):
# Load MJCF model, set self._mjcf_root
super()._build()
@property
def mjcf_model(self):
return self._mjcf_root
@property
def ground_contact_geoms(self):
return (self._mjcf_root.find('geom', 'left_foot'),
self._mjcf_root.find('geom', 'right_foot'))
@property
def end_effectors(self):
return (self._mjcf_root.find('body', 'left_foot'),
self._mjcf_root.find('body', 'right_foot'))
@property
def egocentric_camera(self):
return self._mjcf_root.find('camera', 'egocentric')
Using Contact Detection
# After compilation, in a task callback:
contacts = walker.end_effector_contacts(physics)
# contacts is a dict: {(geom1_id, geom2_id): force_magnitude}
body_contacts = walker.body_contacts(physics)
# body_contacts excludes end effector geoms