Implementation:Google deepmind Dm control Scaled Actuators
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Physics Simulation |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
The Scaled Actuators module provides utility functions for creating MuJoCo position and velocity actuators whose control signals are affinely mapped from a normalized range to desired physical ranges.
Description
This module defines two functions, add_position_actuator and add_velocity_actuator, that create general actuators with biastype='affine'. The key idea is to map a normalized control range (typically [-1, 1]) to a desired physical range (joint position limits or velocity bounds) via an affine transformation computed from the slope and intercept of the mapping.
For add_position_actuator, the gain and bias parameters are computed as: g0 = kp * slope, b0 = kp * (qposrange[0] - slope * ctrlrange[0]), b1 = -kp, b2 = 0, where slope = (qposrange[1] - qposrange[0]) / (ctrlrange[1] - ctrlrange[0]). This is equivalent to MuJoCo's built-in <position> actuator with a pre-applied affine control transformation.
For add_velocity_actuator, the computation is analogous but with velocity-specific bias: b1 = 0, b2 = -kv. Both functions validate that the target element is a joint, tendon, or site, and reject disallowed keyword arguments that would conflict with the computed parameters (such as biastype, gainprm, biasprm, ctrllimited, and explicit target specifications).
By normalizing control ranges to [-1, 1], these actuators simplify policy learning: the agent always operates in the same control space regardless of the physical joint limits, which is a standard technique in reinforcement learning for locomotion.
Usage
Use these functions when building position-controlled or velocity-controlled walkers that need normalized control inputs. They are particularly important for the CMU humanoid walkers and any walker that uses position or velocity servos with joint-limit-aware scaling.
Code Reference
Source Location
- Repository: Google_deepmind_Dm_control
- File: dm_control/locomotion/walkers/scaled_actuators.py
- Lines: 1-128
Signature
def add_position_actuator(target, qposrange, ctrlrange=(-1, 1),
kp=1.0, **kwargs):
def add_velocity_actuator(target, qvelrange, ctrlrange=(-1, 1),
kv=1.0, **kwargs):
Import
from dm_control.locomotion.walkers.scaled_actuators import add_position_actuator
from dm_control.locomotion.walkers.scaled_actuators import add_velocity_actuator
I/O Contract
Inputs (add_position_actuator)
| Name | Type | Required | Description |
|---|---|---|---|
| target | mjcf element | Yes | A PyMJCF joint, tendon, or site element to be controlled |
| qposrange | sequence of two floats | Yes | Allowed range of target position [min, max] |
| ctrlrange | sequence of two floats | No | Allowed range of the control signal (default: (-1, 1)) |
| kp | float | No | Gain parameter for the position actuator (default: 1.0) |
| **kwargs | dict | No | Additional MJCF actuator attributes (excluding disallowed ones) |
Inputs (add_velocity_actuator)
| Name | Type | Required | Description |
|---|---|---|---|
| target | mjcf element | Yes | A PyMJCF joint, tendon, or site element to be controlled |
| qvelrange | sequence of two floats | Yes | Allowed range of target velocity [min, max] |
| ctrlrange | sequence of two floats | No | Allowed range of the control signal (default: (-1, 1)) |
| kv | float | No | Gain parameter for the velocity actuator (default: 1.0) |
| **kwargs | dict | No | Additional MJCF actuator attributes (excluding disallowed ones) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | mjcf actuator element | The created general actuator element added to the MJCF model
|
Usage Examples
from dm_control.locomotion.walkers.scaled_actuators import (
add_position_actuator, add_velocity_actuator)
# Add a position actuator to a joint with normalized control
joint = walker.mjcf_model.find('joint', 'knee')
pos_actuator = add_position_actuator(
target=joint,
qposrange=(-1.57, 0.0), # joint limits in radians
ctrlrange=(-1, 1), # normalized control range
kp=50.0, # proportional gain
name='knee_pos',
)
# Add a velocity actuator to a joint
vel_actuator = add_velocity_actuator(
target=joint,
qvelrange=(-5.0, 5.0), # velocity limits in rad/s
ctrlrange=(-1, 1),
kv=10.0, # velocity gain
name='knee_vel',
)