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

# Teach an xArm6 to Stack Blocks

Teach an xArm6 to stack blocks with robot learning: record demonstrations with an SO-ARM101 leader, train an ACT policy in the cloud, and deploy it.
> Source: https://docs.viam.com/tutorials/xarm-act-stacking/


You'll teach a robot arm a skill by showing it instead of programming it. You move an SO-ARM101 leader arm by hand, the xArm6 copies you, and Viam records each demonstration. Then you train a policy on those recordings, and the xArm6 stacks the blocks by itself.

The leader and follower are different arms, and Viam connects them.





  
  
    
    
    
  


  
  
    
    
    
  
<video class="video-shortcode lozad " preload="none" controls alt="The xArm6, running the trained ACT policy with no human input, picks up the red block, carries it over the green block, lowers it, and lets go, leaving the red block stacked on the green one." style="width: 480px; " data-poster="/tutorials/xarm-act-stacking/policy-rollout-poster.jpg"><source data-src="/tutorials/xarm-act-stacking/policy-rollout.webm" type="video/webm"><source data-src="/tutorials/xarm-act-stacking/policy-rollout.mp4" type="video/mp4">There should have been a video here but your browser does not seem
  to support it.
</video>
<noscript>
  <video class="video-shortcode " preload="none" controls alt="The xArm6, running the trained ACT policy with no human input, picks up the red block, carries it over the green block, lowers it, and lets go, leaving the red block stacked on the green one." style="width: 480px; " poster="/tutorials/xarm-act-stacking/policy-rollout-poster.jpg"><source data-src="/tutorials/xarm-act-stacking/policy-rollout.webm" type="video/webm"><source data-src="/tutorials/xarm-act-stacking/policy-rollout.mp4" type="video/mp4"></video>
</noscript>

## Required hardware {#required-hardware}

- **A uFactory xArm6 with its gripper**, the follower arm that does the stacking.
- **An SO-ARM101 leader arm with its gripper**, which you move by hand to demonstrate the task.
- **An Intel RealSense wrist camera**, mounted on the xArm6. The workshop uses it for color only.
- **A USB webcam**, fixed on a stand beside the table, facing the work area.
- **Two blocks** in contrasting colors, sized for the xArm gripper.
- **An x86 Linux computer** that runs `viam-server` and inference.

## Phases {#phases}

1. **[Platform mental model](/tutorials/xarm-act-stacking/platform-mental-model/)**
2. **[Configure the cell](/tutorials/xarm-act-stacking/configure-the-cell/)**
3. **[Record demonstrations](/tutorials/xarm-act-stacking/record-demonstrations/)**
4. **[Review and build a dataset](/tutorials/xarm-act-stacking/review-and-build-a-dataset/)**
5. **[Train a policy](/tutorials/xarm-act-stacking/train-a-policy/)** (milestone one: a trained model)
6. **[Deploy the policy](/tutorials/xarm-act-stacking/deploy-the-policy/)** (milestone two: an autonomous stack)
7. **[Evaluate and iterate](/tutorials/xarm-act-stacking/evaluate-and-iterate/)** (optional)

When you finish, the **[wrap-up](/tutorials/xarm-act-stacking/wrap-up/)** reviews what you built and points to next steps.

## Plan your day {#plan-your-day}

| Phase                              | Time estimate                                  |
| ---------------------------------- | ---------------------------------------------- |
| 1. Platform mental model           | 20 minutes                                     |
| 2. Configure the cell              | 75 minutes                                     |
| 3. Record demonstrations           | 90 minutes                                     |
| 4. Review and build a dataset      | 30 minutes                                     |
| 5. Train a policy                  | 20 minutes plus a 45 to 60 minute training job |
| 6. Deploy the policy               | 60 minutes                                     |
| 7. Evaluate and iterate (optional) | 90 minutes plus a retrain                      |

The Phase 5 training job runs for 45 to 60 minutes, so submit it before a break.

## Companion code {#companion-code}

The training script is [`viam-labs:lerobot-training`](https://github.com/viam-labs/viam-lerobot-training), already published to the registry, so you don't write it. The other supporting files live in the [viam-devrel/xarm-act-stacking](https://github.com/viam-devrel/xarm-act-stacking) repository, under `config/`: the cell config and the policy and controller configuration.

## Prerequisites {#prerequisites}

The workshop is self-serve, so confirm each of these before you start:

- **A Viam account with an online machine.** Log in at [app.viam.com](https://app.viam.com), [create a machine](/set-up-a-machine/first-machine/), and confirm the green **Live** indicator before you begin.
- **`viam-server` v0.127.0 or later.** Data sequences, which every phase from Phase 3 on depends on, need v0.127.0.
- **`git` and `curl` on the machine.** The policy module needs both to install its dependencies in Phase 6.
- **An xArm6 that's networked and reachable from the machine.**
- **An SO-ARM101 leader that's built and calibrated.** Follow the setup steps in the [SO-ARM101 module](https://app.viam.com/module/devrel/so101-arm) documentation: configure the motors, build the arm, and calibrate it.
- **The Viam CLI, installed and logged in.** See the [Viam CLI documentation](/cli/).
- **Python 3 with pip**, to run the dataset script in Phase 4.
- **Optional: the [pick-and-place workshop](/tutorials/pick-and-place/)**, a gentler introduction to the xArm6.

### Where to start {#where-to-start}

- **Hardware ready and machine online (`viam-server` running):** start at [Phase 1](/tutorials/xarm-act-stacking/platform-mental-model/).
- **Still building your SO-ARM101 leader:** complete the [SO-ARM101 setup](https://app.viam.com/module/devrel/so101-arm) first, then return here for [Phase 1](/tutorials/xarm-act-stacking/platform-mental-model/).

