Skip to content

[Feature] MicroDuckEnv: robot-conformant policy_observation - #4625

Merged
theap06 merged 4 commits into
mainfrom
microduck/robot-obs
Nov 1, 2026
Merged

theap06 merged 4 commits into
mainfrom
microduck/robot-obs

Conversation

@theap06

@theap06 theap06 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds an opt-in policy_observation entry to MicroDuckEnv (MicroDuckEnv(..., policy_observation=True)): the 61-D vector the MicroDuck robot runtime feeds its policies at 50 Hz.

Slice Robot (policy_observation, 61) Source in observation (56)
0:3 base angular velocity 3:6
3:6 projected gravity 0:3
6:20 joint position - home 11:25
20:34 joint velocity 25:39
34:48 previous action 42:56
48:61 command: vx, vy, wz, head (4), body (6) vx, vy from command, rest zero

Body-frame linear velocity and the gait clock, which the robot cannot measure, are left out. observation is unchanged and stays available as a privileged critic input, so the skill controller, trajectory_metrics, the closed-form gait and the published checkpoints are untouched.

With the option on, the env checks at load time that both the MJCF actuators and the joint definitions (the qpos order the observation reads) follow JOINT_NAMES, and raises otherwise. Today JOINT_NAMES is declared but never checked, so a reordered model would produce a silently permuted vector.

Motivation and Context

The MicroDuck robot (Pollen Robotics) only runs feed-forward ONNX policies on its own 61-D observation (model_api: 1, obs_len: 61 in the manifest of pollen-robotics/microduck-policies). A policy trained on observation cannot run on hardware because it reads linear velocity and a gait clock. This is the first half of making TorchRL-trained MicroDuck policies deployable. #4626 adds export_onnx_policy, which writes feed-forward and LSTM TorchRL policies in the ONNX layout the runtime loads.

Validation against the robot's own policies (scripts not committed):

  • Joint order, STAND pose and the 50 Hz control rate match the metadata of Pollen's shipped ONNX policies exactly.

  • Pollen's velstand.onnx, run in MicroDuckEnv on policy_observation (8 envs, 500 steps, mesh collisions): 100% survival standing, yaw tracking 1.10 / -1.04 rad/s for +-1.0 commands.

  • Mutants on the same rollout: swapping gyro and gravity, or mirroring the legs, gives 0% survival.

  • Forward and lateral tracking of that policy is weak in this env. It was trained with a BAM actuator model and full collision meshes, while MicroDuckEnv uses the XML PD actuators and box proxies by default. That is a dynamics gap to address separately, not a layout issue.

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • New feature (non-breaking change which adds core functionality)

Checklist

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

Add an opt-in ``policy_observation`` entry holding the 61-D vector the
MicroDuck robot runtime feeds its policies: base angular velocity,
projected gravity, joint-position error, joint velocity, previous action
and the 13-D robot command (vx, vy filled from ``command``, yaw rate,
head and body pose left at zero). Linear velocity and the gait clock,
which the robot cannot measure, are left out, so ``observation`` stays
available as a privileged critic input.

With the option on, the env checks that the MJCF actuators drive
``JOINT_NAMES`` in the robot's order instead of silently producing a
permuted vector.
@pytorch-bot

pytorch-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4625

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit bf464f5 with merge base c0ca870 (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 27, 2026
@github-actions github-actions Bot added Environments Adds or modifies an environment wrapper Feature New feature labels Oct 27, 2026
@theap06
theap06 added this pull request to stack #4627 October 27, 2026 09:31
…servation

policy_observation reads joint positions and velocities in qpos order, but
the check only compared the actuator order with JOINT_NAMES. A model whose
actuators follow the robot order while its joints are defined in another
order passed the check and produced a permuted observation. Both orders
must now match. The test adds such a model.
@theap06
theap06 marked this pull request as ready for review October 28, 2026 03:54
Comment thread test/libs/test_mujoco.py Resolved
@theap06
theap06 merged commit fd7f180 into main Nov 1, 2026
129 of 130 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Environments Adds or modifies an environment wrapper Feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants