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 Parse AMC

From Leeroopedia
Knowledge Sources
Domains Motion Capture, Data Processing, Physics Simulation
Last Updated 2026-02-15 04:00 GMT

Overview

The parse_amc module parses CMU motion capture .amc files and converts them into MuJoCo-compatible qpos and qvel arrays with time resampling to match simulation timesteps.

Description

This utility module bridges external CMU motion capture data with MuJoCo simulations. The parse function reads raw .amc files frame-by-frame, extracting numerical joint angle values from the custom AMC text format. Each frame consists of numbered lines followed by joint name and value pairs.

The convert function orchestrates the full pipeline: it first parses the file, then maps AMC joint values to MuJoCo qpos indices using joint name matching via the Amcvals2qpos callable class. This class handles the coordinate transformation between CMU's coordinate system and MuJoCo's, applying a length conversion factor of 0.056444, axis remapping (swapping y and z axes), and Euler-to-quaternion conversion for root orientation. The conversion uses a predefined CMU joint order of 62 degrees of freedom.

After conversion, the raw frames are resampled to the desired simulation timestep using cubic spline interpolation (scipy.interpolate.splrep/splev). Velocities are computed via finite differences, with special handling of quaternion orientations using mj_quatdiff for rotational degrees of freedom. The output is a Converted named tuple containing qpos, qvel, and time arrays.

Usage

Use this module when importing CMU motion capture data into the humanoid_CMU environment for imitation learning, motion analysis, or reference trajectory generation. Pass a .amc file path along with a physics instance and desired timestep.

Code Reference

Source Location

Signature

MOCAP_DT = 1.0 / 120.0
CONVERSION_LENGTH = 0.056444

Converted = collections.namedtuple('Converted', ['qpos', 'qvel', 'time'])

def convert(file_name, physics, timestep):
    """Converts the parsed .amc values into qpos and qvel values and resamples."""

def parse(file_name):
    """Parses the amc file format."""

class Amcvals2qpos:
    """Callable that converts .amc values for a frame to MuJoCo qpos format."""
    def __init__(self, index2joint, joint_order): ...
    def __call__(self, amc_val): ...

Import

from dm_control.suite.utils import parse_amc

I/O Contract

Inputs

Name Type Required Description
file_name str Yes Path to the .amc motion capture file
physics mujoco.Physics Yes The corresponding MuJoCo physics instance (for joint name mapping)
timestep float Yes Desired output interval between resampled frames in seconds

Outputs

Name Type Description
Converted.qpos np.ndarray Converted positional variables, shape (nq, ntime)
Converted.qvel np.ndarray Converted velocity variables, shape (nv, ntime-1)
Converted.time np.ndarray Corresponding time values for the resampled frames

Usage Examples

from dm_control.suite.utils import parse_amc
from dm_control import mujoco

# Load a humanoid physics instance
physics = mujoco.Physics.from_xml_path('humanoid_CMU.xml')

# Convert an AMC file to MuJoCo format
converted = parse_amc.convert(
    file_name='path/to/motion.amc',
    physics=physics,
    timestep=0.01
)

# Access the converted data
print("qpos shape:", converted.qpos.shape)
print("qvel shape:", converted.qvel.shape)
print("Time range:", converted.time[0], "to", converted.time[-1])

# Parse raw AMC frames without conversion
raw_frames = parse_amc.parse('path/to/motion.amc')
print("Number of frames:", len(raw_frames))

Related Pages

Page Connections

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