# RoboCode: Learning Reusable Action Primitives for Robot Manipulation

Robotics.world

> Most current robot manipulation policies predict a chunk of continuous future actions directly from observations, with no explicit mechanism for representing recurring motion patterns that show up…

**arXiv**: 2610.32225 · Preprint · not peer-reviewed

**Published**: 2026-10-23

**Authors**: Xianyue Peng, Devi Amarsaikhan, Iman Soltani

## In plain words

Most current robot manipulation policies predict a chunk of continuous future actions directly from observations, with no explicit mechanism for representing recurring motion patterns that show up across many tasks.

## AI summary

## Overview

**Research area:** Robot manipulation, specifically imitation learning and structured action representations for multi-task behavior cloning.

**Technical level:** Intermediate — readers should be comfortable with behavior cloning, action chunking, and basic vector-quantization/codebook ideas, but the paper's core argument is accessible without deep math.

**Scope:** The paper proposes RoboCode, a two-stage framework that learns a shared, soft-gated codebook of reusable short-horizon action primitives from pooled multi-task demonstrations, and evaluates it on five simulated ManiSkill manipulation tasks against ACT and Diffusion Policy baselines.

## What This Paper Is About

Most current robot manipulation policies predict a chunk of continuous future actions directly from observations, with no explicit mechanism for representing recurring motion patterns that show up across many tasks. The authors argue that demonstrations repeatedly contain short, reusable motion patterns (reaching, lifting, placing, pushing), and that these should be modeled explicitly as an intermediate action representation.

RoboCode's goal is to learn a shared codebook of "primitive" action codes from multi-task demonstration data, represent each action chunk as a weighted blend of several such codes rather than as a single discrete token, and then reuse that frozen codebook as the action interface for task-specific policies.

## Key Contributions

1. **A soft-gated primitive action representation.** Each short-horizon action chunk is represented as a weighted composition of multiple learned primitive codes, selected via cosine similarity and a shifted sigmoid, rather than being assigned to a single discrete code or predicted as raw continuous actions.
2. **A two-stage training framework.** Stage 1 jointly learns an action encoder and a shared primitive interface (codebook, gating operator, decoder) from action chunks pooled across tasks; Stage 2 freezes that interface and trains task-specific observation-to-gate encoders that map state into the shared latent space.
3. **No manual primitives, rewards, or task labels during primitive learning.** The reusable action components are discovered directly from demonstrations, with a loss combining reconstruction, projection, gate sparsity, and codebook diversity terms.
4. **Empirical demonstration of cross-task code reuse and competitive closed-loop control.** Analysis of code activations shows overlapping primitive usage across tasks alongside task-specific codes, and the method attains the highest or tied success rate on all five evaluated ManiSkill tasks.

## Main Findings

- **Accurate action-chunk reconstruction:** The learned primitive interface reconstructs action chunks with an average reconstruction MSE of **0.0187** across the five tasks, ranging from **0.0082** (PickCube) to **0.0378** (PushCube).
- **Strongest closed-loop success rate:** RoboCode achieves an average success rate of **75.6%**, versus **68.8%** for ACT, **41.6%** for DP-Large, and **18.8%** for the compact Diffusion Policy. It has the highest or tied success rate on every task: **80%** LiftPegUpright, **92%** PickCube, **52%** PokeCube, **98%** PushCube, **56%** StackCube.
- **Largest margin over ACT on LiftPegUpright:** Success rises from **56%** (ACT) to **80%** (RoboCode) on that task, and from **86%** to **92%** on PickCube; PushCube is a tie at **98%**.
- **Model capacity alone does not close the gap:** Enlarging Diffusion Policy's U-Net channels from **[24, 64]** to **[64, 128, 256]** (DP-Large, **21.578M** parameters total versus **1.609M** for Diffusion Policy) raises average success from **18.8%** to **41.6%**, but DP-Large still trails ACT and RoboCode on every task. RoboCode's total parameter count is **0.601M**, and ACT's is **1.353M**.
- **Small gate-prediction errors:** Stage 2 average gate MSE is **1.56×10⁻⁴** and average action MSE is **0.0733**. PushCube has the largest offline errors (**0.0378** reconstruction MSE, **0.2236** action MSE), which the authors attribute to the task admitting a broad set of successful trajectories rather than to poor control.
- **Interpretable, structured code semantics:** Inspecting the top-activated validation chunks for individual codes shows distinct temporal patterns — e.g., Code 3 has a two-phase structure with large multi-channel variation early and near-constant commands after roughly steps 8–9; Code 1 shows sustained higher-frequency fluctuation, particularly in the second half of the chunk. The authors read this as codes capturing coordinated multi-dimensional motion patterns rather than discretizing action channels independently.
- **Cross-task sharing plus task specialization:** Using a gate threshold of **0.1**, trajectory-level usage analysis shows Code 15 is frequently used across multiple tasks, PickCube and StackCube share high usage of Codes 2, 3, 4, and 6 (both involve grasping and lifting similarly sized cubes), while Code 29 is activated primarily in StackCube trajectories.
- **Execution speed is mixed:** RoboCode needs the fewest steps to success on PickCube (**14.09**), PushCube (**6.08**), and StackCube (**12.25**), while DP-Large is fastest on PokeCube (**28.62**) and the compact Diffusion Policy has the lowest average on LiftPegUpright (**16.29**, but with only **14%** success on that task).
- **Return is a supplementary signal, not a quality proxy:** RoboCode has the highest average return on PickCube (**7.70**), PokeCube (**7.33**), and StackCube (**8.37**), but ACT leads on LiftPegUpright (**15.14** versus **14.47**) and the compact Diffusion Policy leads on PushCube (**2.61**) despite both ACT and RoboCode reaching **98%** success there.
- **No major overfitting in Stage 1:** Training and validation losses of the shared autoencoder stay closely aligned with no pronounced rise in validation loss; Stage 2 validation losses drop sharply over roughly the first 10–20 epochs and then stabilize at task-dependent levels.

## Methodology in Plain English

The researchers collect successful demonstrations for five tasks and slice every trajectory into overlapping short action chunks using a sliding window (chunk length **H = 16**, stride **s = 4**). Each action is ManiSkill's seven-dimensional end-effector delta-pose command; the state input concatenates task-relevant object/goal information with an 18-dimensional proprioceptive vector (nine joint positions, nine joint velocities).

In Stage 1, they throw all chunks from all tasks into one pool and train a small autoencoder around a shared "codebook" of **K = 32** codes, each of dimension **C = 64**. An encoder compresses a chunk into a latent vector. That vector is compared to every codebook entry by cosine similarity, and a shifted sigmoid (with a sharpness parameter and a similarity threshold) turns those similarities into soft gates. The gates blend the codebook entries into a single combined latent vector, which a shared decoder turns back into an action chunk. Training uses four terms: reconstruct the chunk, keep the blended latent close to the encoder output, keep gate usage sparse, and keep codebook entries mutually distinct (penalizing squared cosine similarity between different codes).

In Stage 2, the codebook, gating operator, and decoder are frozen. For each task, a separate small state encoder is trained to map the current observation into the same latent space, so the frozen interface converts it into gates and then into an action chunk. The training objective matches the predicted gates to the gates the Stage 1 encoder would produce for the expert's future chunk, plus a direct action-matching term. Stage 1 runs for 400 epochs on pooled data; each Stage 2 encoder runs for 200 epochs.

At test time the system runs in a receding-horizon loop: predict a 16-step chunk, execute the first 8 actions, re-observe, and replan, with a maximum episode horizon of 50 environment steps. Baselines (ACT and two Diffusion Policy variants) are trained on the same processed demonstrations with the same state inputs for a controlled comparison.

## Why This Matters

The paper reframes the action representation question in imitation learning: instead of only asking how to regress or denoise action sequences, it asks whether reusable motion structure can sit *inside* the action-generation interface, be shared across tasks, and remain inspectable. If short-horizon motion patterns really are shared across manipulation tasks, an explicit shared primitive layer could reduce per-task data requirements and yield policies whose internal "vocabulary" can be read and audited — a property raw continuous-chunk predictors do not offer. The result that a **0.601M**-parameter model beats a **21.578M**-parameter diffusion baseline on all five tasks is also a reminder that representation structure can matter more than raw capacity in the low-data regime.

Real-world applications:

- **Warehouse pick-and-place and order fulfillment**, where many SKUs share a small set of reaching, grasping, lifting, and placing motions that could be captured as shared primitives across task variants.
- **Assembly and peg-in-hole style manipulation**, where precise, repeatable short-horizon motion segments dominate and primitive reuse across part families is plausible.
- **Household service robots** performing cube-style pick, push, poke, and stack operations, where a compact on-robot policy with an interpretable codebook is easier to validate than a large diffusion model.
- **Multi-task robot fleets or shared policy libraries**, where one frozen primitive interface is trained once and each new task only requires a small state encoder to be added.

Industry relevance: the two-stage split maps naturally onto a "shared foundation plus small per-task head" deployment pattern, and the small parameter counts (**0.601M** total for the method, versus **21.578M** for DP-Large) are attractive for compute- and latency-constrained robot controllers.

## Future Directions

- **Sim-to-real transfer.** The authors explicitly note that the current evaluation is simulation-only and leaves open how the learned primitive interface behaves under real-world perception, dynamics, contact, and control uncertainty. They suggest domain randomization, interactive data collection, and reinforcement-learning-based policy refinement as candidate remedies.
- **Distribution shift in closed-loop execution.** Because Stage 2 encoders are trained purely by offline imitation, the policy can visit states absent from the demonstrations and accumulate compounding prediction errors; how to detect and correct this — for example via interactive data collection — is left open.
- **Understanding and controlling primitive composition.** The relevance of the soft, multi-code composition and of cross-task code sharing is examined only through "controlled ablations and transfer experiments," which the provided paper content mentions but does not report numerically. A clearer account of when soft composition beats hard assignment, and how codebook size **K** and code dimension **C** should be chosen, remains open.
- **Scaling the shared interface.** All experiments use five tasks and **K = 32** codes. Whether the shared codebook remains effective as the number of tasks, embodiments, and motion types grows — and whether task-specific codes (such as Code 29 for StackCube) proliferate — is untested here.
- **Real-robot results and author-contribution note.** The author contributions mention simulation *and* real-robot experiments plus real-robot data collection, but state that "the corresponding results will be included in a future revision of the manuscript"; no real-robot numbers appear in this version.

## Target Audience

Robotics and machine-learning researchers working on imitation learning, multi-task manipulation policies, and structured action representations will get the most from this paper, particularly those comparing chunked-continuous prediction against discretized or codebook-based action interfaces. It is also useful for practitioners choosing an action interface for a multi-task robot deployment, and for readers interested in interpretability of learned policy internals through code-activation analysis. Readers without a background in behavior cloning or codebook/vector-quantization methods will need to consult the cited prior work (ACT, Diffusion Policy, STAR) first.

## Authors’ abstract

Recent robot manipulation policies commonly predict continuous action chunks directly from observations, without explicitly modeling reusable structure in the action space. However, manipulation demonstrations often contain recurring short-horizon motion patterns that are shared across tasks. We introduce \textsc{RoboCode}, which learns these patterns through a shared soft-gated primitive action interface. Rather than assigning each action chunk to a single discrete code,…

[The full abstract on arXiv](https://arxiv.org/abs/2610.32225)

[Read the original paper](https://arxiv.org/abs/2610.32225)

## Related papers

- [RynnVLA-Latent: Scaling Robotic Manipulation Foundation Models with 3D-Grounded Latent Actions](https://robotics.world/paper/rynnvla-latent-scaling-robotic-manipulation-foundation-models-with-3d-2610.34356) 2026-10-25 · cs.RO · Key terms of the title in common
- [TrajWAM: An Efficient Trajectory-Guided World Action Model for Dynamic Robotic Manipulation](https://robotics.world/paper/trajwam-an-efficient-trajectory-guided-world-action-model-for-dynamic-2610.25763) 2026-10-19 · cs.RO · Key terms of the title in common
- [Vision-Language-Delta-Action: Learning Compact Deltas as Actionable Transition Interfaces for Robotic Manipulation](https://robotics.world/paper/vision-language-delta-action-learning-compact-deltas-as-actionable-2610.25874) 2026-10-19 · cs.RO · Key terms of the title in common
- [Robot Learning with Vision-Language-Action Models for Agricultural Manipulation](https://robotics.world/paper/robot-learning-with-vision-language-action-models-for-agricultural-2610.26717) 2026-10-19 · cs.RO · Key terms of the title in common
- [GAWM: A Compact Latent World-Action Model for Multi-Task Robot Manipulation](https://robotics.world/paper/gawm-a-compact-latent-world-action-model-for-multi-task-robot-2610.37091) 2026-10-27 · cs.RO · Key terms of the title in common

---

Canonical: https://robotics.world/paper/robocode-learning-reusable-action-primitives-for-robot-manipulation-2610.32225
