Dimensionality of the Observation Space for the Microduck RL Policy: The 61‑Dimensional Standard

The Microduck RL policy uses a fixed 61‑dimensional observation vector for the actor, enabling interchangeable ONNX policies across different tasks without tensor reshaping.

The pollen-robotics/microduck_rl repository implements a standardized observation protocol that remains constant across its entire policy family. Understanding the dimensionality of the observation space for the Microduck RL policy is essential for training compatible actors, debugging environment configurations, and deploying exported models to hardware.

Anatomy of the 61‑Dimensional Observation Vector

The observation space decomposes into six distinct sensor and command slots. According to the source code in src/mjlab_microduck/tasks/symmetry.py, the 61‑dim tensor is built by concatenating the following components in strict order:

  • gyro (3 dimensions): Raw IMU angular velocity readings.
  • projected_gravity (3 dimensions): Gravity vector projection relative to the robot frame.
  • joint_pos (14 dimensions): Current positions of the 14 servo motors.
  • joint_vel (14 dimensions): Current velocities of the 14 servo motors.
  • last_action (14 dimensions): The previous motor commands sent to the hardware.
  • command (13 dimensions): Target twist commands (typically 3D) combined with head orientation (4D) and body orientation (6D); the remaining slots are zero‑padded to reach 13.

Summing these components yields 3 + 3 + 14 + 14 + 14 + 13 = 61 dimensions. This layout is硬编码 (hardcoded) and identical across all environments, from velocity tracking to standing tasks.

Where the 61‑Dimension Layout is Defined

The fixed observation schema is documented in AGENTS.md, which explicitly states: "Obs layout is 61D (actor) and shared across the whole policy family…"

In src/mjlab_microduck/tasks/symmetry.py, the concrete tensor assembly logic concatenates the six slots listed above. Environment configuration files reinforce this standard; for example, src/mjlab_microduck/tasks/microduck_velocity_rollers_env_cfg.py contains comments noting "same observation 61D (interchangeable at runtime)." Similar definitions appear in microduck_velocity_env_cfg.py and microduck_velstand_env_cfg.py, ensuring every task inherits the identical 61‑dimensional structure.

Validating Observation Dimensions in Python

When you instantiate any Microduck environment, the actor observation dictionary returns a tensor of shape (batch_size, 61).

from mjlab_microduck.tasks.microduck_velocity_rollers_env_cfg import make_microduck_velocity_rollers_env_cfg
from mjlab_microduck import mjlab

# Build the config and instantiate the env

cfg = make_microduck_velocity_rollers_env_cfg()
env = mjlab.make_env(cfg)

# Reset and inspect the first observation

obs = env.reset()
print("Actor observation shape:", obs["actor"].shape)  # → (1, 61)

# Shape remains constant during rollout

for _ in range(5):
    action = env.sample_action()
    obs, reward, done, info = env.step(action)
    print(obs["actor"].shape)  # → always (1, 61)

For deployed policies, the exported ONNX model expects the same fixed input dimension:

import onnxruntime as ort

session = ort.InferenceSession("microduck_policy.onnx")
input_shape = session.get_inputs()[0].shape
print("ONNX expected input shape:", input_shape)  # → [None, 61]

Implications for Cross‑Task Policy Deployment

The rigid dimensionality of the observation space for the Microduck RL policy ensures that an actor trained on one task—such as velocity tracking—can be exported and immediately executed in different environments like microduck_velstand or microduck_velocity_rollers without architectural modification. Because every environment emits the exact same 61‑D vector, ONNX files are interchangeable at runtime, simplifying deployment pipelines and reducing model management overhead.

Summary

  • The Microduck RL policy consumes a 61‑dimensional observation vector for all actor inputs.
  • The vector comprises gyro (3), projected gravity (3), joint positions (14), joint velocities (14), last action (14), and commands (13).
  • This layout is hardcoded in src/mjlab_microduck/tasks/symmetry.py and enforced across all task configurations.
  • The fixed shape enables zero‑shot transfer of ONNX exported policies between diverse Microduck tasks.

Frequently Asked Questions

What are the exact components of the 61‑dimensional observation vector?

The vector concatenates six tensors in fixed order: 3D gyroscope angular velocity, 3D projected gravity, 14D joint positions, 14D joint velocities, 14D previous actions, and 13D high‑level commands (3D twist plus 4D head and 6D body orientation with zero‑padding).

Can I modify the observation space size for custom tasks?

Altering the observation dimension would break compatibility with the existing policy family and pretrained ONNX exports. The codebase strictly enforces the 61‑dimensional standard to guarantee that any exported actor can run on any Microduck environment without reshaping.

How does the fixed 61D layout affect ONNX model exports?

Exported ONNX policies expect input tensors of shape [batch, 61]. Because all environments in pollen-robotics/microduck_rl output this exact shape, you can swap ONNX files between tasks—such as swapping a velocity policy into a standing environment—without recompiling the model or changing inference client code.

Where is the observation vector assembled in the source code?

The definitive assembly logic resides in src/mjlab_microduck/tasks/symmetry.py, which handles tensor concatenation and symmetry mirroring. Environment‑specific configurations in files like src/mjlab_microduck/tasks/microduck_velocity_rollers_env_cfg.py instantiate the observation buffers that populate these 61 dimensions according to the standard.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →