Phase 2: Configure the cell

Here you build the cell and get the leader steering the follower. You set up the hardware, paste in one config that defines every resource, then review each resource and edit the values that depend on your setup. You’re done when moving the leader moves the xArm6.

Set up the cell

Clear a work area on the table in front of the xArm6. Mount the RealSense camera on the xArm6 wrist.

Mount the scene webcam to the side of the stacking area, about 90 degrees from the direction the xArm reaches, raised and angled down at 30 to 45 degrees. Where you put it decides what the policy can see:

  • Not in front of the arm. A camera facing the xArm’s base sees the forearm and wrist cover the stack at the moment of release, which is exactly when the policy needs to see whether the blocks line up.
  • From the side, the arm enters the frame from one edge and the stack stays visible under the gripper. The angle also shows height, so the camera sees the red block sitting on the green one.
  • Raised and angled down, the frame shows mostly table rather than the room behind it, and the gripper stays in view while it lifts and carries the block. People and objects moving in the background are noise the policy has to learn to ignore.

Place the blocks at the farthest corners of where you’ll scatter them and check they stay in frame. Then lock the mount. The policy learns this exact viewpoint, so don’t move the camera between recording and deployment.

The workshop cell: the xArm6 at the edge of a white table with the red and green blocks in front of it, the scene webcam on a clamped stand to the side, the SO-ARM101 leader arm on the near corner, and a laptop running the capture-control webapp.

Place the leader arm where you can reach it comfortably and where it can’t hit the follower’s workspace. Where you put it matters in Edit the teleop mapping, when you describe its position to the teleop service.

Add the cell config

The companion repo’s config/cell.json holds every resource in this phase, so instead of adding them one by one, you paste it into your machine config and edit the values that differ per cell.

  1. Open your machine’s CONFIGURE tab and switch to JSON mode.
  2. Replace the contents with config/cell.json from the companion repo.
  3. Save.

Pasting replaces the machine’s whole config, so start from a new machine, or copy anything you want to keep first.

The machine's CONFIGURE tab after pasting cell.json, listing xarm, xarm-gripper, wrist-cam, scene-cam, leader-arm, leader-gripper, follower-home, leader-home, teleop, and the other resources.

The resource names in cell.json are the names every later phase uses, so don’t rename them. Edit only the values that differ per cell, in each resource’s card or in JSON mode:

  • The xArm host IP address.
  • The RealSense serial_number.
  • The webcam’s video_path.
  • The leader’s serial port.
  • The teleop mapping.

Each step below shows the part of the resource to review, and how to find the value to fill in. Change only the values the step names.

Review the follower: xArm6 and gripper

The xArm6 is the follower. The viam:ufactory module provides both the arm and the gripper. The gripper’s arm attribute makes the arm a dependency of the gripper, because the gripper shares the arm’s connection.

Edit the host on xarm to your arm’s IP address. It’s printed on the sticker on the xArm control box. The computer running viam-server must be on the same subnet as the arm. For how to set that up over a direct Ethernet cable, see the viam:ufactory module’s networking notes.

{
  "host": "192.168.1.100"
}

The gripper config points at the arm:

{
  "arm": "xarm"
}

The gripper also has a frame with parent: "xarm", 105 mm out from the flange and turned 180 degrees, with a box geometry around the jaws so the motion planner accounts for their size. The frame matters because teleop drives the gripper frame (follower_component), so the gripper’s tool center point, not the arm’s flange, tracks the leader. For the general concept, see Arm and end effector frames.

Open the CONTROL tab and find the xarm test card. GetJointPositions shows the arm’s current joint angles. Under MoveToJointPositions, jog one joint with its -5° or +5° button.

Checkpoint

GetJointPositions shows the arm’s joint angles, and jogging a joint moves the physical xArm6. If nothing moves, confirm host is correct and check the LOGS tab for a connection error.

Review the cameras

There are two cameras. Edit the RealSense’s serial_number and the webcam’s video_path to match your hardware.

wrist-cam is the RealSense, configured for color only. That way GetImages returns no depth image, and training sees exactly two image features: wrist-cam and scene-cam. Both cameras run at 640 by 480, which is plenty for the policy and keeps every frame small.

{
  "serial_number": "<your-realsense-serial>",
  "sensors": ["color"],
  "width_px": 640,
  "height_px": 480
}

To find the serial number, use the RealSense module’s discovery service:

  1. On the CONFIGURE tab, click +, select Blocks, search for realsense, and add the realsense/discovery service. Save.
  2. Open the service’s TEST panel. It lists each connected RealSense with its serial_number filled in.
  3. Copy the serial_number into wrist-cam. Don’t add the suggested component, because wrist-cam already exists.
  4. Delete the discovery service and save.

Plug the RealSense into a USB 3 port with a USB 3 cable. Over USB 2, it can stall and return stale frames or none at all.

The RealSense mounted on the xArm6's wrist above the gripper, looking down at the red and green blocks on the table.

scene-cam is a USB webcam. Set its device path:

{
  "video_path": "<your-webcam-video-path>"
}

To find the path, use the find-webcams discovery service:

  1. On the CONFIGURE tab, click +, select Blocks, search for find-webcams, and add the discovery / find-webcams:webcam-discovery service. Save.
  2. Open the service’s TEST panel. It lists each connected webcam with its video_path.
  3. Copy your webcam’s video_path into scene-cam. Don’t add the suggested component.
  4. Delete the discovery service and save.

For more ways to find the path, see Using video_path.

Open the CONTROL tab and check each camera card. With the arm at home, the views should look like this: the wrist camera looks straight down at the work area, and the scene camera sees the blocks from the side, with the arm entering from one edge.

Two 640 by 480 camera frames. Left, the wrist-cam view straight down at the green and red blocks, with the gripper fingertips at the bottom edge. Right, the scene-cam view from the side, with the arm base at the left and both blocks on the table.

Checkpoint

Both wrist-cam and scene-cam show a live color image. The wrist-cam card shows color only. If a card is blank, check the LOGS tab for a camera error and confirm the video_path.

Edit the leader: SO-ARM101 arm and gripper

The config adds leader-arm and leader-gripper, the hand-guided SO-ARM101. You only need to edit its serial port.

To find the port, use the SO-ARM101 module’s discovery service:

  1. On the CONFIGURE tab, click +, select Blocks, search for so101, and add the so101-arm/discovery service. Save.
  2. With the leader connected and powered, open the service’s TEST panel. It returns a suggested arm config with the detected port filled in.
  3. Copy the port into leader-arm. Don’t add the suggested components, because your config already has them.
  4. Delete the discovery service and save.
{
  "port": "/dev/ttyUSB0",
  "manual_mode": {
    "release_torque": true
  }
}

Leave manual_mode.release_torque set to true. In manual mode the leader’s servos turn off torque completely, so the arm moves freely in your hand and holds its pose through gearbox friction. Without it, manual mode keeps the servos stiff enough to fight gravity, and the leader feels heavy to guide.

The leader gripper is the SO-ARM101’s sixth servo on the same serial bus, so its config points at the arm:

{
  "arm": "leader-arm"
}

You need both because teleop’s leader_gripper and follower_gripper mirror the jaw. Closing the leader’s jaw closes the xArm gripper.

Review the teleop service

The teleop service reads the leader’s tool pose, maps it into the follower’s frame, and hands it to the motion service, which plans the xArm’s joints. It’s the viam:teleop module’s viam:teleop:leader-follower model, a generic service. Review its config:

{
  "leader_arm": "leader-arm",
  "leader_gripper": "leader-gripper",
  "follower_component": "xarm-gripper",
  "follower_gripper": "xarm-gripper",
  "leader_tool_offset_mm": { "x": 0, "y": 0, "z": 100 },
  "tool_orientation": {
    "type": "ov_degrees",
    "value": { "x": 0, "y": 0, "z": 1, "th": -90 }
  },
  "leader_hold": "manual",
  "leader_gripper_commands": {
    "on_start": [{ "command": "set_torque", "enable": false }]
  },
  "leader_gripper_read_command": { "command": "get_position" },
  "leader_gripper_read_key": "position_percentage",
  "follower_gripper_mode": "command",
  "follower_gripper_command": { "set": "$steps" },
  "gripper_range": 850,
  "gripper_invert": false
}

follower_component is the frame the motion service positions, so it’s the gripper. follower_gripper is the gripper that mirrors the leader’s jaw. Both point to xarm-gripper.

leader_tool_offset_mm moves the mirrored point out to the tip of the stock SO-ARM101 leader handle. Without it, leader rotations pivot the follower off its tip.

tool_orientation is a fixed rotation that reconciles the two arms’ tool conventions. The SO-ARM101’s tool frame sits a quarter turn from the xArm gripper’s, so without it the xArm’s gripper is turned 90 degrees from the leader’s.

leader_hold: "manual" puts the leader in manual mode while teleop runs, so you can move it by hand. The set_torque command frees the leader’s gripper trigger at the same time.

The gripper attributes mirror the jaw proportionally:

  • Every tick, the service sends leader_gripper_read_command to the leader gripper and reads its opening, from 0 to 100, at leader_gripper_read_key.
  • follower_gripper_mode: "command" sends follower_gripper_command to the xArm gripper, with $steps replaced by the opening scaled to gripper_range. The xArm gripper’s range is 0 to 850.
  • Without "command" mode, the default open_close mode only opens or closes the follower, at 60 and 40 percent. Proportional mirroring gives the policy a smoother gripper signal to learn from.
  • If squeezing the leader’s trigger opens the xArm gripper instead of closing it, set gripper_invert to true.

The service caps how fast the follower moves, at 250 mm per second and 180 degrees per second by default (max_speed_mm_per_s and max_rotation_deg_per_s). You can’t turn the caps off. If you move the leader faster, the xArm lags behind it.

Edit the teleop mapping

You already set gripper_invert and leader_tool_offset_mm in the previous step. Three more attributes place the leader relative to the xArm, and they depend on where you put the leader in Set up the cell.

  • scale multiplies the leader’s translation about its base, so a desktop arm can span the follower’s larger workspace. The default is 1.
  • origin_translation_mm is the position of the leader’s base in the follower’s world frame, in millimeters, as {x, y, z}.
  • origin_orientation is the orientation of the leader’s base in the follower’s world frame, in the same syntax as a frame’s orientation (for example ov_degrees).
{
  "scale": 2.5,
  "origin_translation_mm": { "x": 0, "y": 0, "z": 0 },
  "origin_orientation": {
    "type": "ov_degrees",
    "value": { "x": 0, "y": 0, "z": 1, "th": 0 }
  }
}

cell.json sets align_on_start to true, so you can tune these:

{
  "align_on_start": true
}

On start, the leader drives itself to match the follower’s pose. If the mapping is wrong, you see the offset as a visible mismatch between the two arms. Without align_on_start, nothing moves on start: the service absorbs any offset between the arms, which hides a wrong mapping. For every attribute and its default, see the teleop module’s documentation.

Tune in a short loop:

  1. Send start.
  2. Move the leader along one axis.
  3. Compare the directions of the leader and the xArm.
  4. If the arms are offset, adjust origin_translation_mm. The SO-ARM101 can’t reach every pose the xArm can, so pick an origin that puts the xArm’s home pose in the middle of the leader’s reach: origin_translation_mm is the xArm’s home position minus scale times the leader’s tip position.
  5. If an axis is reversed or swapped, fix the sign or rotation in origin_orientation. If the arm covers too much or too little distance, adjust scale.
  6. Send stop, save, and repeat.

Review the home poses

The config adds two erh:vmodutils:arm-position-saver switches, follower-home and leader-home. Don’t create them. Move each arm to a safe home pose, then save that pose to its switch.

The quickest way to pose an arm is by hand. On the CONTROL tab, find the xarm card’s ManualMode row and click Enter. Manual mode starts after the Enable after delay, 5 seconds by default, which gives you time to put a hand on the arm, and ends on its own once the Enabled for time runs out. Guide the end of the arm to a home pose: the gripper raised above the middle of the work area, pointing down, with both blocks in view of the wrist camera. Click Exit. Do the same on the leader-arm card, posing the leader to match the xArm.

Lift the xArm clear of the table before you turn on manual mode. If it touches something as it goes compliant, the controller stops it with error C37 and leaves it stiff.

To save a pose, find the switch’s card and set it to position 1 (“update config”). Set it to position 2 (“go to”) to confirm the arm returns there. Position 0 is the idle state. Save with position 1 before you use position 2. For more on the switch, see Phase 3 of the pick-and-place tutorial.

In Phase 3, the H key in the capture-control webapp stops teleop and moves each arm to its saved pose between episodes.

Checkpoint

Open the teleop service’s DoCommand test panel and send {"command": "start"}. Move the leader. The xArm moves in the same direction. Close the leader’s jaw and the xArm gripper closes. Then send {"command": "stop"}. If the directions are wrong, return to the tuning loop.

If it doesn’t move

Send {"command": "status"} to the teleop service. The response has a top-level running and one entry under pairs for each leader and follower pair. Without a pairs attribute, your one pair is named main. These fields of pairs.main matter:

  • stopped_reason says why the last session ended: stopped, session_lost, pipeline_error, or max_errors. Start here.
  • pipeline_error is the motion service’s error, for example a planner failure or an arm fault. Any pipeline error ends the session, and start refuses until it clears.
  • last_error is the most recent error in the teleop loop itself, such as a failed leader read.
  • rejected counts leader readings thrown out as outliers because they jumped too far, too fast. A climbing count usually means a loose leader cable or a noisy servo.
  • speed_limited counts ticks where the speed caps held the xArm back. It climbs when you move the leader quickly, which is expected.
  • align_position_error_mm is how far the leader ended up from the follower’s mapped pose after align_on_start. A large value means the mapping or the leader’s reach is off. To make start refuse a large gap, set align_max_position_error_mm.