Phase 6: Deploy the policy
With a trained xarm-stacking model, you can put it in the loop. You add two services: one that runs the model, and one that reads the cameras, asks the model what to do, and moves the arm. That’s the second milestone: you press start, and the xArm stacks the red block on the green one with no human input.
The controller must feed the policy exactly what it saw in training: the same cameras, the same joint order, the same units, and the same gripper scale. Most failures in this phase come from one of those not matching.
Two services, one loop
The viam-labs:vla module provides two services:
act-policy(viam-labs:vla:policy) runs the model. It knows nothing about the robot. You send it images, joint state, and a task string, and it returns a chunk of actions.act-controller(viam-labs:vla:controller) runs the loop. It reads the cameras and joints, asks the policy for a chunk of actions, clamps them, and moves the arm.
Splitting them lets you test the policy with no robot attached, and develop the control loop with no GPU.
Stop teleop first
Only one thing can drive the xArm at a time, so turn teleop off before you start the controller.
- Open the
teleopservice’s DoCommand test panel and send{"command": "stop"}. - Open the CONTROL tab and set
follower-hometo position 2 (“go to”) to home the xArm. - Move the leader arm out of the workspace. The policy only sees the follower, but you don’t want to knock the leader while the xArm moves.
Add the policy
Your trained model is in the registry, so you can add it from the Blocks dialog. Adding it also adds the viam-labs:vla module and a policy service that points at the model. The full policy and controller configuration is in the companion repo’s config/policy.json.
On the CONFIGURE tab, click + and select Blocks. Search for
xarm-stackingand select your model.Choose the version your training job produced in Phase 5.
Name the policy service
act-policyand click Deploy. Theviam-labs:vlamodule installs automatically as a supporting module.
The service’s
model_pathcomes preconfigured:{ "model_path": "${packages.ml_model.xarm-stacking}" }viam-serverreplaces${packages.ml_model.xarm-stacking}with the real path to the downloaded model before the module sees the config.devicedefaults toauto, which triescuda, thenmps, thencpu. Add it only to force one.The module’s LeRobot version has to match the one that trained your model.
viam-labs:vla0.6.0 runs LeRobot 02655292c, the same as the training container from Phase 5. If the module card shows a newer version, pin it to 0.6.0. The module needscurlandgiton the machine. Withoutcurl, the module’s setup fails. Withoutgit, setup succeeds, butact-policyreports"state": "failed"with an error naminggitwhen it tries to install LeRobot.Save. The model downloads and loads in the background. The first time the policy loads, it also installs PyTorch and LeRobot, which takes several minutes and needs network access. Later loads skip the install. In the
act-policyDoCommand test panel, send this untilstateisready:{ "command": "status" }{ "state": "ready", "error": "" }stateis one ofidle,loading,ready, orfailed. It staysloadingthrough the first install. If it’sfailed,errorsays why.

Ask what the policy needs
The policy knows what it was trained on, so ask it:
{ "command": "specs" }
The response is long, but these are the fields the controller cares about:
{
"policy_type": "act",
"action_dim": 7,
"state_dim": 7,
"image_feature_keys": [
"observation.images.scene_cam",
"observation.images.wrist_cam"
],
"n_action_steps": 20
}
Illustrative output; your values come from your checkpoint.
image_feature_keyslists the cameras the policy expects: here, the scene camera and the wrist camera. The controller refuses to start unless you map every key.state_dimis the length of the state the policy reads. For this workshop it’s 7: six joints plus the gripper.action_dimis the length of the action the policy emits, also 7.n_action_stepsis the number of actions in each chunk, the 20 you set withextrain Phase 5.
Each key is observation.images. plus the camera’s component name, with hyphens and periods replaced by underscores. Match the names you see in specs.
Add the controller
Add the controller service from the same module:
- On the CONFIGURE tab, click + and select Blocks. Search for
vlaand select thegeneric / vla:controllerresult. - Name it
act-controllerand click Add. - Paste these attributes, then save. The
cameraskeys must matchimage_feature_keysfromspecs.
{
"policy_service": "act-policy",
"arm": "xarm",
"task": "stack the red block on the green block",
"cameras": {
"observation.images.scene_cam": "scene-cam",
"observation.images.wrist_cam": "wrist-cam"
},
"state_joint_indices": [0, 1, 2, 3, 4, 5],
"gripper": {
"type": "do_command",
"name": "xarm-gripper",
"read_key": "pos",
"open_value": 850.0,
"closed_value": 0.0
},
"arm_write": "stream",
"fps": 10.0,
"rpc_timeout_s": 12.0,
"state_units": "degrees",
"action_units": "degrees",
"safety": {
"max_vel_degs_per_sec": 60.0,
"max_start_delta_degs": 15.0,
"stop_on_error": true
}
}
policy_serviceandarmname the policy and the xArm.camerasmaps each image feature key fromspecsto a camera. Every key must be covered.state_joint_indicesmaps the arm’s joints, base to wrist, onto the state positions the checkpoint expects. These are indices, not names. The six xArm joints are0to5.gripperadds the seventh channel.read_key,open_value, andclosed_valuemust match thegripper_key,gripper_open, andgripper_closedyou passed in Phase 5. The controller turns the reading into a value from0.0(open) to1.0(closed), the same scale training used.arm_write: "stream"sends the arm a smooth stream of interpolated points, 100 a second by default, instead of one setpoint per tick. With the default,"setpoint", the xArm snaps to each new target 10 times a second and holds it, a visible buzz. The xArm’s servo mode wants 100 Hz or more.fpsis the loop rate. Keep it at10.0to match training.rpc_timeout_sbounds each arm and gripper call. The xArm gripper’ssetblocks until the jaw stops moving, up to 10 seconds. The controller sends gripper writes from a background task, so a slow write never holds up the arm, but a write that times out still stops the run. That’s why this is raised to 12 seconds, above the jaw’s settle time, from the 5-second default for ado_commandgripper.state_unitsandaction_unitsare the units the checkpoint was trained in. Viam arms always report and accept degrees, and this checkpoint trained on the xArm’s joint values in degrees, so"degrees"is right. Both default to"degrees"; they’re shown here to make the choice visible. Set them to"radians"only if your training data was in radians.safety.max_vel_degs_per_secandmax_start_delta_degsuse conservative starting values from the module README’s example: 60 and 15.max_vel_degs_per_seccaps joint speed. The controller derives a per-tick limit from it:60.0 / 10.0 = 6degrees per tick.max_start_delta_degsmakesstartrefuse if the policy’s first action is more than 15 degrees from where the arm is now.stop_on_errorhalts the loop if a camera read or the policy call fails.
task is the instruction the policy receives. ACT ignores it, but the controller refuses to start without one, so set it to the task you recorded in Phase 3. A language-conditioned policy, such as SmolVLA, follows it. There you can also pass a different instruction for one run with {"command": "start", "task": "..."}.
safety.joint_limits_degs is optional. Without it, the controller relies on the xArm driver to enforce joint limits.

How the controller paces the chunks
The policy returns 20 actions at a time, 2 seconds of motion at 10 Hz. The controller places each action on a timeline: action 1 is due one tick after the camera frame it came from, action 2 two ticks after, and so on. Each tick, the arm moves to whichever action is due.
The controller asks for the next chunk before the current one runs out. It measures how long inference takes and fires the next request early enough that the new chunk lands while the arm is still moving, then blends it in over two ticks. When chunks land in time, actions whose moment has passed are skipped, never run late.
If inference takes too long, the next chunk can’t land in time. When twice the inference time, plus four ticks, reaches the 2-second chunk, the controller switches to the sequential regime: the arm finishes each chunk, stops, waits for the next one, then moves again.
Run it
First, learn the way out. This command halts the loop, and the arm stays where it is:
{ "command": "stop" }
Send it to act-controller any time something looks wrong. The xArm also has a physical emergency stop. Keep it within reach for every run, and use it before the arm hits anything.
Now run it.
Place the red and green blocks at one of the start positions you used when recording.
Make sure the arm is at home and nothing is in its path.
In the
act-controllerDoCommand test panel, send:{ "command": "start" }startreturns immediately. It doesn’t wait for the arm to move, so watch the arm and pollstatusto see what happened. Before the arm moves, the controller runs one throwaway inference to warm up the cameras and the policy.Watch the arm. Keep a hand near the emergency stop.
When the stack is complete or the arm goes idle, send
{"command": "stop"}toact-controller. The loop keeps running until it getsstop. Then home the arm: on thefollower-homeswitch, set the position to 2 (“go to”).
Read status
While the loop runs, send {"command": "status"} to act-controller and watch these fields:
| Field | What it tells you |
|---|---|
state | idle, waiting_for_policy, running, stopped, or error. |
regime | overlap or sequential. You want overlap. sequential means inference is too slow, and the arm pauses between chunks. |
measured_fps | The actual loop rate. It should track fps. Well below it means each tick takes too long, for example a slow gripper write. |
avg_latency_s | How long one policy call takes, from camera frame to landed chunk. |
clamp_counts | How many times the safety limits trimmed an action, split into delta, limit, and gripper. Non-zero counts mean trimming. |
starved_ticks | Ticks where the arm held still waiting for a chunk. Under overlap it should stay near zero. |
last_error | The last failed tick’s error. It stays set even if the loop kept going. |
Check clamp_counts first. It should stay near zero. A count that keeps climbing almost always means wrong units or wrong joint order, not a safety margin doing its job. One exception: if your demonstrations moved faster than max_vel_degs_per_sec, clamp_counts.delta climbs even with correct units. Work through it in this order:
- Rule out units and joint order first. Wrong units clamp on every tick from the first one. A speed limit clamps only during fast moves.
- If it’s really speed, raise
max_vel_degs_per_secin small steps, for example 10 degrees per second at a time. Keep it well below the xArm’s rated joint speed, because this clamp is the only velocity bound on the arm. Keep the physical emergency stop within reach. - If the count still climbs only during the fastest moves, you can leave it. The clamp only makes the arm move a little slower than your demonstrations did.
Checkpoint
{"command": "start"} to act-controller. The xArm stacks the red block on the green one with no human input.Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The arm moves the wrong way or by the wrong amount | Wrong units. A mismatch usually shows up as a climbing clamp_counts.delta. | Set state_units and action_units to match the training data, then check state_joint_indices. |
| The gripper never closes | open_value and closed_value are reversed, or don’t match training. Reversed values invert the gripper but stay within 0 to 1, so clamp_counts.gripper won’t show it. | Set them to the gripper_open and gripper_closed values from Phase 5. A reading more than 0.25 outside 0 to 1 is refused and shows in last_error. |
| The arm moves, stops, and moves again | regime is sequential, so inference is too slow for the 2-second chunk. | Check avg_latency_s, and confirm device isn’t cpu on a machine with a GPU. |
| The arm freezes for seconds at a gripper change | You’re running a module version before 0.6.0, where the controller waits for the xArm gripper’s set, which blocks until the jaw settles. | Pin viam-labs:vla to 0.6.0 or later, which writes the gripper from a background task. |
| The run stops at a gripper change | A gripper write took longer than rpc_timeout_s. last_error names the timeout. | Raise rpc_timeout_s. |
| It works only from some start positions | The demonstrations didn’t vary enough. | Record more varied starts in Phase 7. |
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!