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

# Phase 3: Record demonstrations

Add a capture control sensor, open the capture-control webapp, and record about 50 teleoperated stacking demonstrations as data sequences.
> Source: https://docs.viam.com/tutorials/xarm-act-stacking/record-demonstrations/


Now you teach by showing. You teleoperate the xArm6 through about 50 stacks, one episode each. The capture-control webapp manages the episodes: it tells the capture control sensor when each one starts and stops, and the sensor turns capture on and off. Each episode becomes one [data sequence](/data/sequences/) of the follower's joints, gripper, and both cameras. You set up capture first, then practice, then record.

## Add the capture control sensor {#add-the-capture-control-sensor}

A capture control sensor tells the data management service what to capture and when. Add one from the `viam:capture-control` module:

1. On the **CONFIGURE** tab, click **+** and select **Blocks**.
2. Search for `capture-control` and select the `sensor / capture-control:capture-control-sensor` result.
3. Name it `demo-capture` and click **Add to machine**. This also adds the `viam:capture-control` module to your config.
4. In the sensor's attributes, list the four things the policy learns from, then save:

```json
{
  "resources": [
    { "resource_name": "xarm", "method": "JointPositions" },
    { "resource_name": "xarm-gripper", "method": "DoCommand" },
    { "resource_name": "wrist-cam", "method": "GetImages" },
    { "resource_name": "scene-cam", "method": "GetImages" }
  ]
}
```

The sensor turns on capture configs that already exist on each component. `cell.json` gives each of the four components a `data_manager` capture config at 10 Hz, disabled, so nothing is captured until the sensor turns it on. The gripper's config also carries the `DoCommand` input `{"get": true}`, which returns the gripper's state, because a capture control entry can't carry an input. For the capture config fields, see the [data capture reference](/data/reference/#capture-and-sync-configuration).

Every listed resource runs at the same 10 Hz, so each frame lines up across the arm, gripper, and both cameras. Training works best when every sequence shares the same rate. While the sensor lists a component, the sensor's frequency overrides that component's own capture frequency. It leaves the rest of your component configuration unchanged. The webapp sends the rate from its **FPS** (frames per second) session setting, which defaults to 10; leave it there. Don't set `default_capture_frequency_hz` on the sensor: a nonzero default captures from when the machine starts until your first episode ends.

For every attribute and command, see [Start and stop capture on demand](/data/capture-sync/capture-on-demand/).

## Connect it to the data manager {#connect-it-to-the-data-manager}

Your machine has no data management service yet, so add one. In JSON mode, add this to the `services` array. It points the service at the sensor with `capture_control_sensor`:

```json
{
  "name": "data-manager",
  "api": "rdk:service:data_manager",
  "model": "rdk:builtin:builtin",
  "attributes": {
    "capture_control_sensor": { "name": "demo-capture", "key": "overrides" }
  }
}
```

The module turns capture off between recordings, so nothing is captured outside an episode.

## Open the capture-control webapp {#open-the-capture-control-webapp}

You start and stop episodes from the webapp. Open it either way:

- Serve it from the machine. Add the `viam-labs:capture-control-webapp` module, version `0.3.0`, then add a `generic` service named `capture-app` with the model `viam-labs:capture-control:webapp`. It serves on port 8888 by default, so open `http://<machine-ip>:8888`.
- Open the hosted app at `https://capture-control-webapp_viam-labs.viamapplications.com`. Choose your organization, then your location, then your machine. The capture-control app loads once you've picked a machine.

The app always signals through `app.viam.com`, so the machine and your browser need internet access.

Under **Robot setup**, choose the home set: `follower-home` and `leader-home`. The app finds the teleop service on its own: it uses any generic service that answers `{"command": "status"}` with a boolean `running`, and it needs exactly one. Your `teleop` service from [Phase 2](/tutorials/xarm-act-stacking/configure-the-cell/) qualifies.

> **Checkpoint:**
> 
> The **Teleop** pill is enabled, and pressing **T** turns teleop on and off. If the app finds no teleop service, or more than one, check that exactly one generic service answers `status`.

## Add the task {#add-the-task}

Click **+ add task**, enter `stack the red block on the green block`, and press **Enter**. It becomes task 1. The number keys 1 to 9 pick the task for the next episode.

![The capture-control webapp's task row: task 1, stack the red block on the green block, next to the + add task field.](/tutorials/xarm-act-stacking/webapp-add-task.png)

Each episode is tagged `task:<task>`, `session:<id>`, and `fps:<fps>`. The `<task>` is whichever task was active when the episode started. Training copies the `task:` tag into the dataset as the episode's instruction. ACT ignores the instruction and learns one behavior from every episode, so record only this one task for an ACT policy. Language-conditioned policies, such as SmolVLA, learn to follow the instruction, so one dataset can hold several tasks.

## Practice before you record {#practice-before-you-record}

Do three or four stacks with teleop on and no session running, and keep going until your motion is smooth. Nothing is captured outside an episode, so practice leaves no data. Don't press **Enter** yet.

## What makes a good demonstration {#what-makes-a-good-demonstration}

The policy copies what you show it, so consistency matters more than speed. For every episode:

- Use one strategy: approach from above, grasp, lift, move, lower, release.
- Move smoothly and steadily, with no pauses or hesitation.
- Start every episode from home.
- Vary the block start positions about evenly across five regions of the work area: center, left, right, near the arm's base, and far from it. Mark the regions with tape if that helps you spread the starts. On the reference cell, one of the first model's failed rollouts started with the red block near the base, the region its demonstrations used least.
- Keep people and extra objects out of the scene camera's view.
- Discard a botched episode rather than "fixing" it mid-stack.

## Record about 50 episodes {#record-about-50-episodes}

Record in sessions of 10 episodes, the webapp's default session size, with a break between sessions. Use these keys:

| Key       | Action                                                                |
| --------- | --------------------------------------------------------------------- |
| **Enter** | Start the session.                                                    |
| **Space** | End the episode and start the next one.                               |
| **H**     | Home both arms between episodes. It doesn't work while recording.     |
| **T**     | Toggle teleop. While recording, it stops teleop and ends the episode. |
| **Esc**   | Stop the session.                                                     |

After **H**, teleop stays off and the next episode waits for **Space**. Take hold of the leader first, then press **T**.

![The capture-control webapp during a recording session: the scene-cam and wrist-cam views above the episode counter, the active task, and the session settings.](/tutorials/xarm-act-stacking/webapp-recording.png)

> **Checkpoint:**
> 
> On the [Viam app](https://app.viam.com)'s **DATA** page, the machine shows about 50 sequences tagged `task:stack the red block on the green block`. To view sequences, see [Sequences](/data/sequences/#view-sequences).

![The SEQUENCES tab on the DATA page, listing recorded episodes from armfarm15-main with their resources and their task, session, and fps tags.](/tutorials/xarm-act-stacking/sequences-list.png)

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


