> For AI agents: guidance on navigating Viam documentation is available at https://docs.viam.com/llms.txt.

# Phase 1: Platform mental model

How demonstration-based robot learning maps onto Viam, and what the policy sees and does.
> Source: https://docs.viam.com/tutorials/xarm-act-stacking/platform-mental-model/


Before you touch any hardware, get the mental model for the whole workshop: how teaching by demonstration works, which Viam piece handles each stage, and what the policy sees and does. Every later phase builds one stage of that loop.

## Programming by demonstration {#programming-by-demonstration}

Instead of writing code that says how to stack a block, you show the robot. That's imitation learning: you record what a person does, and a model learns to map observations (camera images plus joint state) to actions (the next joint positions).

This workshop uses ACT, which stands for Action Chunking with Transformers. ACT predicts a chunk of future actions at once instead of one action at a time, so small errors don't compound from one step to the next and the motion comes out smooth. It also learns from few demonstrations: on the reference cell, 58 were enough for a policy that stacks the block.

## The loop on Viam {#the-loop-on-viam}

Teaching by demonstration is a loop of five stages:

![The robot learning loop as five circles in a ring. Stage 1, Teleop, uses teleop and leader-arm to drive xarm. Stage 2, Record, uses demo-capture, data-manager, and capture-app. Stage 3, Curate, uses review:keep tags and the xarm-stacking-v1 dataset. Stage 4, Train, runs lerobot-training to produce xarm-stacking. Stage 5, Deploy, runs act-policy and act-controller. A dashed arrow from Deploy back to Teleop reads Evaluate, record more.](/tutorials/xarm-act-stacking/diagram-loop.svg)

Each stage maps to a Viam piece and to the phase of this workshop where you build it:

1. **Teleop**, in [Phase 2](/tutorials/xarm-act-stacking/configure-the-cell/): the leader-follower teleop service lets you steer the xArm6 with a leader arm.
2. **Record**, in [Phase 3](/tutorials/xarm-act-stacking/record-demonstrations/): the capture control sensor and the capture-control webapp record each demonstration as one [data sequence](/data/sequences/), using [capture on demand](/data/capture-sync/capture-on-demand/).
3. **Curate**, in [Phase 4](/tutorials/xarm-act-stacking/review-and-build-a-dataset/): you review the episodes and build a sequence dataset from the keepers.
4. **Train**, in [Phase 5](/tutorials/xarm-act-stacking/train-a-policy/): a [custom training job](/train/custom-training-scripts/) trains the policy on a cloud GPU.
5. **Deploy**, in [Phase 6](/tutorials/xarm-act-stacking/deploy-the-policy/): the `viam-labs:vla` policy and controller services run the trained model on the machine.

The dashed arrow is [Phase 7](/tutorials/xarm-act-stacking/evaluate-and-iterate/): you score the deployed policy, record demonstrations aimed at its failures, and go around the loop again.

## Two arms, one policy {#two-arms-one-policy}

The leader arm is 5-DOF (degrees of freedom) and the xArm6 is 6-DOF, so copying joint angles from one to the other doesn't work. The leader-follower teleop service maps the leader's tool pose into the follower's frame, and the motion service's teleop pipeline solves the xArm's joints and streams them to the arm.

The policy only ever sees the follower's joints and cameras; the leader is just a way to steer the arm. You could steer with a different leader arm, or with a pose tracker through the `viam:teleop` module's `clutch` model, and keep recording for the same policy.

## What the policy sees and does {#what-the-policy-sees-and-does}

|             | Contents                                                                                                                   |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- |
| Observation | `wrist-cam` and `scene-cam` images, six xArm joint angles, and the gripper position normalized from 0 (open) to 1 (closed) |
| Action      | The next six joint angles plus the gripper value                                                                           |

Both run at 10 Hz.

> **Checkpoint:**
> 
> Open your machine in the [Viam app](https://app.viam.com). The machine shows the green **Live** indicator. You can name the five stages of the loop and the arm whose joints the policy learns. If the machine isn't Live, start `viam-server` before continuing.

<nav class="workshop-nav" aria-label="Workshop phase navigation"><p class="workshop-progress">Phase 1 of 7</p><div class="workshop-nav-links"><a class="workshop-nav-prev" href="/tutorials/xarm-act-stacking/">&larr; Previous</a><a class="workshop-nav-next" href="/tutorials/xarm-act-stacking/configure-the-cell/">Next &rarr;</a></div>
</nav>


