Run a VLA policy
A vision-language-action (VLA) policy looks at camera images and a task instruction and returns where the robot's tool should go next. PLEM runs such a policy for you: its policy executor sends camera frames and the robot state to the model's own inference server, turns the actions it returns into a timed path, and moves the arm through jog. You write one config file and call one action.
What you provide:
- The policy server. Start the model's official inference server (GR00T or openpi) and optimize it yourself (TensorRT or other). PLEM does not ship or run models.
- The cameras. Any node that publishes
sensor_, on the same device by default. The executor subscribes to a camera topic when a run first uses it and keeps that subscription while the executor runs: a driver that processes a stream only while someone subscribes keeps processing it between runs.msgs/ Image - The config file (
schema: policy/): the server address, the model's names for its inputs and outputs, and the camera topics. The robot is not in the file: the action you call names it.v1
The executor
The executor is on by default. Every robot of a launch serves /<robot>/, whether the stack comes up from the plem start screen or with ros2 launch, and its jog engine follows the path the executor sends. The executor moves nothing until a goal comes, and subscribes to no camera and no /tf until then. Your policy server, and often your camera stack, run beside it as your own processes.
The policy path has not been verified on a robot yet. Before the first run, check one reply of your server and lower the policy caps (Reference setup).
To leave the executor out, add policy_ to the launch. The executor reads the robot description when the stack starts: one URDF root, one arm chain in the SRDF, and the link jog's tcp_ names. A robot that lacks one of them stops the whole launch with that message; launch it with policy_. The other arguments are those of Launching directly. For one Neuromeka arm without the executor:
ros2 launch neuromeka_robot_driver robot.launch.py robots:=robot1 serials:=<serial> masters:=0 policy_executor:=false
A login shell sources only /opt/, which does not include the packages under /opt/: plem_, the robot drivers and plem.. In the shell where you launch the stack or run Python against it, source them too:
for f in /opt/plem/vendors/*/*/setup.bash; do source "$f"; done
plem policy needs none of this: its command sources them itself.
Install the client for your server
| Server | server: scheme | Client library |
|---|---|---|
GR00T PolicyServer (ZMQ) | gr00t+zmq:// | python3-zmq, python3-msgpack, python3-msgpack-numpy (below) |
| openpi websocket server | openpi+ws:// | openpi-client, installed with pip (below) |
GR00T client libraries
On the device that runs the robot stack, check that the three libraries import, and install them from apt when they do not. Without them the GR00T client does not load: a goal ends preflight_, and its detail gives this command. plem policy check does not load the client, so it passes either way. The apt names are the same on JP6 and JP7:
python3 -c "import zmq, msgpack, msgpack_numpy"
sudo apt install python3-zmq python3-msgpack python3-msgpack-numpy
openpi client
Install it with pip as the user that runs the robot stack, then check that it imports:
pip install --user openpi-client
python3 -c "import openpi_client"
Without it an openpi goal ends preflight_, and its detail gives the install command.
This was checked on JP6 (Ubuntu 22.04) only. On JP7 (Ubuntu 24.04) the system Python refuses pip install outside a virtual environment (PEP 668), and no command for it has been checked yet.
openpi-client requires numpy<2 and websockets>=11. pip can put a newer numpy 1.x and websockets into your user site-packages, and every Python program of that user then imports those instead of the system ones. Install it only on a device that runs openpi, and check that your other Python code still works. Only the client of the config's scheme is loaded, so a GR00T config runs without openpi-client.
The config file
A config for a GR00T model with a front and a wrist camera:
schema: policy/v1
server: gr00t+zmq://127.0.0.1:5555
fps: 30
chunk: {action_horizon: 16, execution_horizon: 8, request_ahead: 2}
action:
arm: {key: eef_9d, rep: eef_pose, rotation: rot6d}
gripper: {key: gripper, range: [0, 1], force_n: 40}
state:
arm: {key: eef_9d}
gripper: {key: gripper, range: [0, 1], open_width_m: 0.152}
cameras:
front: {key: front, topic: /front/front/color/image_raw}
wrist: {key: wrist, topic: /wrist/wrist/color/image_raw}
language: {key: annotation.human.task_description}
image: {size: 256, letterbox: true}
An openpi model takes one flat input and returns one actions array, so each part names its columns with slice:
schema: policy/v1
server: openpi+ws://127.0.0.1:8000
fps: 30
chunk: {action_horizon: 16, execution_horizon: 8}
action:
arm: {key: actions, slice: [0, 9], rep: eef_pose, rotation: rot6d}
gripper: {key: actions, slice: [9, 10], range: [0, 1], force_n: 40}
state:
arm: {key: observation/state, slice: [0, 9]}
gripper: {key: observation/state, slice: [9, 10], range: [0, 1], open_width_m: 0.152}
cameras:
front: {key: observation/image, topic: /front/front/color/image_raw}
wrist: {key: observation/wrist_image, topic: /wrist/wrist/color/image_raw}
language: {key: prompt}
image: {size: 224, letterbox: true}
| Key | Meaning |
|---|---|
server | The scheme picks the client (table above); host and port are the server's |
fps | Policy steps per second, as the model was trained. A step may not be longer than the 0.2 s jog follows a path without a new one, so below 5 plem policy check refuses the file and a goal with it ends config_ |
chunk. · chunk. | Steps the server predicts per request, and how many of them run before the next chunk takes over. The execution horizon is below the action horizon: the rows after it cover the inference delay |
chunk. | Ask for the next chunk when this many steps are left. Default 2 |
action. | What the arm action means: eef_, a TCP pose, eef_, a TCP move per policy step, or joint_, the arm's joint positions (below). The server's own declaration does not decide it (which rep) |
state. · joints | What the arm state is: eef_ (the default), the measured TCP pose, or joint_, the measured joints. joints is the arm's joint count, for joint_ only (below) |
action. · state. | [open, closed]: the model's gripper values for open and for closed, in either order ([1, 0] for a model that calls closed 0). The gripper closes once 3 action values in a row within a chunk are past the midpoint toward closed, and opens the same way. The run's first decision always goes to the gripper, because the width cannot tell whether it is holding something wide. The state gives the measured width on its own range: the open width is open, width 0 is closed. No default |
action. · state. | The closing force and open width the model was trained with. No default |
cameras. | The model's image key and the sensor_ topic |
language. | Where the instruction goes. Leave it out for a model without one |
image | Optional. The executor resizes every frame to this square size in pixels (cv2 INTER_); letterbox: true keeps the aspect ratio and pads black. Without it each frame goes to the server as it came: resize the way the model was trained, in the server or by publishing the camera at that resolution, which also spares moving large frames (images) |
limits. | Refuse the run while jog's speed scale is below this. No default (no floor) |
limits. | Brake when the latency is above this many steps for 3 chunks in a row. Default (action_, the most latency with no empty step |
key is the model's own name for a value, and slice: [start, end] picks its columns when parts share one key. Any other key is refused, so a typo never falls back to a default.
The gripper's force and width are training conditions: a state halfway along range means half of the width the model saw open, and a different width or force replays a different grasp. The gripper on the robot is checked only to see that it can reproduce them (gripper_).
Check a file before the robot moves. The check needs no server and no robot, and names every problem with its key and the fix:
plem policy check gr00t.yaml
plem policy check --json gr00t.yaml # one JSON document for scripts ("format": "plem-policy-check/1")
Example files are installed in the examples folder of the plem_ share directory (ros2 pkg prefix --share plem_).
Joint positions
A model trained on the arm's joint positions instead of a TCP pose sets rep: joint_ and gives the arm's joint count in joints. It has no rotation. The state's arm takes a rep too: eef_, the default, or joint_. The action and the state choose theirs independently.
schema: policy/v1
server: gr00t+zmq://127.0.0.1:5555
fps: 30
chunk: {action_horizon: 16, execution_horizon: 8, request_ahead: 2}
action:
arm: {key: single_arm, rep: joint_position, joints: 6}
gripper: {key: gripper, range: [0, 1], force_n: 40}
state:
arm: {key: single_arm, rep: joint_position, joints: 6}
gripper: {key: gripper, range: [0, 1], open_width_m: 0.152}
cameras:
front: {key: front, topic: /front/front/color/image_raw}
wrist: {key: wrist, topic: /wrist/wrist/color/image_raw}
language: {key: annotation.human.task_description}
image: {size: 256, letterbox: true}
- Order and unit. Positions are in radians, one column per joint, in the arm's order: its movable joints from the base to the TCP. The executor's
arm_parameter lists them, and the launch sets it from the robot description. To see them:joints ros2 param get /robot1/.run_ policy_ executor arm_ joints - Joint count.
jointsmust be the robot arm's joint count, or the goal endsarm_. A joint action and a joint state give the same count.mismatch plem policy checkhas no robot, so it checks only that the two agree. - Motion. The measured joints come from the robot's
joint_. Each row is an absolute joint target; there is no joint counterpart ofstates eef_. The targets go to jog ondelta jog/, and jog moves the arm within its joint limits, its speed scale and the policy caps on the TCP (Policy contract).joint_ plan
Images
PLEM does not decide how a model sees its cameras: the resize, crop and filter belong with the training.
- Without
imageeach frame goes to the server as an RGBuint8array as it came. GR00T's policy server resizes in its own processor. openpi's official clients resize on the client before they send (openpi_, 224 in openpi's examples), and its server resizes only a frame of another size.client. image_ tools. resize_ with_ pad - With
imagethe executor resizes every frame with cv2INTER_(and pads black withAREA letterbox: true). It is close to openpi's client resize, not the same (that one uses PIL bilinear). Use it when the model was trained on frames resized this way. - Large frames cost CPU. The executor takes every frame of every camera in Python. Have the camera driver publish at the resolution the model was trained with and name that topic in
cameras. The executor does not process frames on the GPU.
Run it
From the command line, no code:
plem policy run /abs/path/gr00t.yaml "stack the red box on the green box" --seconds 30 --robot robot1
It prints progress, then the outcome, reason and detail. Ctrl+C cancels the run and the command waits for the result; how the robot stopped is in the outcome (Results). Exit codes: 0 FINISHED, 130 when Ctrl+C stopped a run that ended CANCELED or FINISHED, 2 a usage error, 1 any other end, a run that braked after Ctrl+C included.
From Python, in a shell with the robot packages sourced (above):
from plem.policy import Policy, PolicyError
policy = Policy("/abs/path/gr00t.yaml", robot="robot1")
result = policy.run("stack the red box on the green box", seconds=30)
print(result.outcome.name, result.reason)
From C++, a behavior tree or another language, send a plem_ goal to /<robot>/: config (the absolute path on the device that runs the executor), instruction and duration_.
Python API
Policy(config, robot=) holds its own ROS context and spin thread, so your code needs no rclpy. run() blocks until the run ends.
policy.run(instruction, seconds=seconds, until=None, on_progress=None)
secondsis motion time and must be given by keyword; it has no default. It is counted in the policy steps run and rounded up to a whole step. Time spent waiting for inference or the gripper does not count, so the wall-clock time is longer. It is not a measurement of how long the TCP moved.FINISHEDmeans the time was used up, not that the task succeeded. A policy cannot tell that the task is done. Judge it yourself.untilis a function of no arguments.run()calls it about 20 times a second, on the thread that calledrun(); once it returns True,run()asks for the stop (cancels the goal) and waits for the result. Keep it quick: a slowuntiloron_spaces the calls out and so delays the stop. Run a slow check (a vision model, say) on its own thread and letprogress untilread the flag it sets.on_gets aprogress Progress(elapsed, seconds, latency, inference time) for each feedback. It runs on the same thread asuntil.- Results.
run()returns aResultforFINISHEDandCANCELEDand raisesPolicyError(outcome,reason,detail) for every other end. A sequence that does not check the outcome therefore does not continue after a failed run. After a stop request, no result within 30 s also raisesPolicyError: the robot may not have stopped. - Stopping. An exception from
untiloron_,progress policy.from another thread, or Ctrl+C on the main thread all ask for the stop (cancel the goal) and wait for the result. If that result iscancel() CANCELEDorFINISHED,run()returns it, or after Ctrl+C raisesKeyboardInterrupt. If it isBRAKEDor any other end, or no result comes within 30 s,run()raisesPolicyError, after Ctrl+C too. A stop that comes as the run ends on its own can still returnFINISHED, so branch on the result, not on why you stopped. A stop asked before the goal was sent returnsCANCELEDwith reasonnot_, made by the client and not by the executor.sent - One run at a time.
run()during a run raisesRuntimeError.
import threading
from plem.policy import Policy, PolicyError
done = threading.Event() # set by your own checker thread (a vision model, a sensor)
with Policy("/abs/path/gr00t.yaml", robot="robot1") as policy:
try:
result = policy.run("stack the red box on the green box", seconds=30,
until=done.is_set, on_progress=print)
except PolicyError as e:
print("run failed:", e.outcome, e.reason, e.detail)
- Canceling an asyncio task.
await asyncio.works, but canceling the awaiting task leaves the thread and the goal running. Callto_ thread(policy. run, ...) policy.to stop them.cancel() - Killing the process outright (
kill -9). Nothing is canceled: the run goes on until its time is used up or the executor stops it.
Policy contract
The model's action is where the robot's TCP goes, how far it moves, or the arm's joint positions. A command meant for one specific controller is not accepted. The executor applies no model-specific correction, but it does not pass the rows through unchanged either: it skips the rows a chunk's latency has already passed, blends up to the first 8 rows of a new chunk into the rest of the previous one, and starts an eef_ move from the last target, pulled back toward the measured TCP when that target runs too far ahead: more than the usual tracking lag (about 50 ms of motion) plus 5 mm or 0.05 rad. Within that lag the moves add up as labelled; where the arm falls further behind (a low policy cap, contact) it moves less than the labels add up to. A joint target is absolute, so it is not pulled back.
-
Frame. Poses are in the robot base frame, in metres.
-
rot6d. The first two rows of the rotation matrix, row by row:
[r11, r12, r13, r21, r22, r23]. -
State.
armis 9 columns[x, y, z, rot6d], the measured TCP pose, or withrep: joint_the measured joints, one column per joint;position gripperis 1 column, the measured width onstate.from open to closed.gripper. range -
Arm action,
eef_:pose [x, y, z, rot6d], the TCP target pose. -
Arm action,
eef_:delta [dx, dy, dz, rot6d(dR)], the move over one policy step: target position = position +[dx, dy, dz], target rotation =dR · R, both in base axes. -
Arm action,
joint_: the joint target positions in radians, in the arm's joint order (Joint positions).position -
Speed. The targets go through jog, so jog's speed limits and speed scale apply, for joint targets as well. A run never changes the speed scale. To run policies slower than manual jog, lower the jog engine's policy caps. They act on policy runs only; manual jog keeps its caps. Each is above 0 and at most the manual cap (0.25 m/s, 1.0 rad/s), and a higher value is refused. They hold until the stack restarts:
ros2 param set /robot1/jog_engine plan_max_tcp_linear_speed 0.1 # m/s, TCP originros2 param set /robot1/jog_engine plan_max_tcp_angular_speed 0.5 # rad/s
Which rep the reply is
rep is what the reply your server actually sends means, not how the data was labelled. Training transforms sit in between: a model trained on relative actions may still reply with absolute ones, because its server turns them back. Whether it does depends on your training configuration, not on the PLEM adapter.
| Your server replies with | rep |
|---|---|
| The TCP pose to reach, in the base frame | eef_ |
| The TCP move over one policy step, in base axes | eef_ |
| The joint positions to reach | joint_ |
GR00T, an arm group declared RELATIVE and trained with use_ on (the official fine-tuning sets it) | The server turns the reply back into absolute values from the state you sent: eef_ for an EEF group, joint_ for joints. Check one reply |
openpi with AbsoluteActions in the output transforms | Absolute too: eef_ or joint_, by what the model predicts |
| Moves relative to the chunk's first state that the server does not turn back, or joint velocities | Not supported. Turn them into targets on the server side |
repNumbers made for one controller's input do not mean any rep. Isaac Lab's relative IK command (IK-Rel), for example, is a step that its scaled differential IK carries out only in part. Declared as eef_, it moves the arm much further than the demonstrations did. Label the data with the TCP target or the move the TCP made.
Policy server contract
| GR00T | openpi | |
|---|---|---|
| Server | The official PolicyServer (gr00t/) | The official websocket server (openpi/) |
| Protocol | ZMQ REQ/REP, msgpack with numpy arrays | Websocket, one msgpack frame per request and reply |
| Protocol taken from | GR00T 944fe70 | openpi 15a9616 |
The protocol follows these upstream commits. The adapters' tests talk to a fake server that speaks it, not to the official servers.
- Batch 1. One observation per request, one time step.
- Same host by default. Every millisecond of network round trip comes out of the latency budget.
- Latency budget. The executor judges each chunk in steps of time: the policy steps since it was requested, whether the arm ran a row in them or not, plus the age the camera frame had at the request times
fps. A chunk skips the rows that latency has passed (Real-Time Chunking calls it the delay); one taken while the arm stands still, at the start or after a gripper wait, skips only the frame's age. The next request goes out withrequest_rows left, and until its chunk comes the arm runs those and then the spare rows past the execution horizon, so in steady state no step goes empty while the latency is at mostahead (action_steps. That is the default limit: above it for 3 chunks in a row, the run brakes (horizon − execution_ horizon + request_ ahead) / 2 latency) instead of going on stalling between chunks.chunk.is the rows the server returns. A higher limit is allowed: the arm then pauses between chunks while it waits. At 16, 8 and 2 rows and 30 Hz it is 5 steps, at most about 167 ms for inference, round trip and frame age together; a larger action horizon leaves more (40, 16 and 2: 13 steps). Set a lower limit for a model that acts worse on older frames. The feedback's latency (action_ horizon effective_) is a different number, the age of the observation when its chunk arrived, so it does not show the brake measure directly.latency_ s - Timing. The executor reads the server's inference time when it reports one (openpi
server_, GR00Ttiming. infer_ ms policy_inms infowhen a wrapper adds it) and shows it as feedback. - Errors. A server error (GR00T
{"error": …}, an openpi traceback frame) or a malformed reply brakes the run (policy_); on the first inference the run endserror warmup_.failed
Reference setup: start the model's official server on the device, point server: at it and check the file. Before the first run, send the server one observation of the arm standing still and read the reply as the file says (which rep): units, frame, direction and size should match where the arm is. Then lower the policy caps (Speed), run with a short seconds first and watch the latency in the feedback.
Results and reasons
| Outcome | The robot | Resume with |
|---|---|---|
FINISHED | Used up duration_, then stopped (below) | — |
REJECTED | Refused before the run started its motion. first_ cannot rule out a move under 1 mm or 0.01 rad | Fix the cause, send again |
STOPPED | Ended early without a protective stop | Send again once the cause is gone |
BRAKED | The executor requested a protective stop. detail says when the request failed or robot_ did not report BRAKED. Brake engagement per joint is not checked | Check the robot, then set_; first reset_ if safety_ shows PROTECTIVE_STOP (Stops and recovery) |
CANCELED | Canceled by the caller | — |
What the executor confirms before it answers
A goal that ends before the executor asks jog for the session returns at once, with nothing stopped or checked, because nothing was armed: a bad config, a refused check, a cancel or shutdown during the checks, or arm_ when jog is missing or says no. From the arm request on, every end first stops the path and cancels any gripper command. If another jog user armed jog during the run, the session is theirs: the executor does not release it or wait for the arm, and detail says so. Otherwise, for FINISHED, STOPPED, CANCELED and REJECTED the executor then waits for jog to confirm releasing the session and for the arm to come to rest within 3 s. If either is not confirmed, the outcome becomes BRAKED (disarm_, not_), so a cancel can end BRAKED. For BRAKED it requests a protective stop, and asks jog to release the session unless another jog user armed it; detail notes a failed request, or robot_ not reporting BRAKED within 2 s. Brake engagement per joint is never checked. Last, it waits up to 2 s for the canceled gripper command to end, and answers even when it has not (detail says so).
Reasons
reason is a short stable code to branch on; detail says what happened and how to fix it.
| Reason | Outcome | What happened | What to do |
|---|---|---|---|
duration_ | FINISHED | The run used up its time | Judge whether the task succeeded |
canceled | CANCELED | The caller canceled the goal | — |
busy | REJECTED | Another goal is running | Wait for it or cancel it |
invalid_ | REJECTED | duration_ is not a finite number above 0 | Give the motion time in seconds |
config_ | REJECTED | The config path is relative | Give the absolute path on the device that runs the executor |
config_ | REJECTED | The file does not load | plem policy check <file> lists every problem |
speed_ | REJECTED | Jog's speed scale is below limits. | Raise it on the pendant, or lower the floor |
gripper_ | REJECTED | The config has a gripper part, but the robot has no gripper set or none is ready | Set the gripper in the robot's profile and check its driver, or drop the gripper parts |
gripper_ | REJECTED | open_ or force_ is outside what the gripper can do | Use a gripper that can reproduce the training values |
frame_ | REJECTED | No robot base transform, or jog's TCP in another frame | Check that the robot description is published |
server_ | REJECTED | The policy server did not answer | Start the server, check server: |
camera_ | REJECTED | A camera topic published no fresh frame | Check the camera driver and topic |
camera_ | REJECTED | A frame the executor cannot read (encoding, row padding) | Publish rgb8 or bgr8 without row padding |
arm_ | REJECTED | The config's arm is in joint positions, but the executor has no arm_ parameter, or joints is not the robot arm's joint count | Launch with the executor on (the default, above), which sets arm_; run a model trained on this arm |
joints_ | REJECTED | The config's arm is in joint positions, and no joint_ with every arm joint came within 5 s | Check that the robot stack is running (its joint_) |
session_ | REJECTED | An earlier run's jog session was not confirmed released, and it still does not release | Check that jog is running (jog/) and what holds the robot, then send again |
arm_ | REJECTED | Jog did not take the session (detail says why) | Release the arm from other jog users, check the mode |
no_ | REJECTED | No measured TCP after arming | Check that jog is running |
first_ | REJECTED | After the run's first path went out, and before the arm was seen to move (1 mm or 0.01 rad), jog counted a dropped command in this session. Jog does not say whose command it was. The robot was stopped first (detail: jog's reason) | Fix jog's reason, for example a first target too far from where the arm stands; keep other jog users off the arm |
warmup_ | REJECTED | The first inference gave no chunk in time | Check the server log; warm the model up |
preflight_ | REJECTED | An error before the executor asked jog for the session, including a client library the config's server needs that is not installed | Read detail: install the library it names (Install); otherwise report it |
shutdown | STOPPED | The executor is shutting down | — |
jog_ | STOPPED | Jog stopped the run, another jog user took the session, or jog counted a dropped command in this session after the arm moved or before the run's first path went out (detail: jog's reason) | Fix jog's reason; keep other jog users off the arm during a run |
jog_ | STOPPED | A joint limit or collision pair holds the arm | Move the arm clear, adjust the task |
invalid_ | BRAKED | The model's arm row decodes to no pose (for example a degenerate rotation) | Check the model's output |
inference_ | BRAKED | No action for more than 10 steps | Check the server's load and connection |
latency | BRAKED | Latency over the limit 3 chunks in a row | Speed up the server, or lower chunk. to leave more rows for the delay |
camera_ | BRAKED | A camera stopped delivering frames | Check the camera |
tcp_ | BRAKED | The measured TCP stopped arriving | Check jog and the robot stack |
joints_ | BRAKED | The measured joints (joint_) stopped arriving | Check the robot stack |
policy_ | BRAKED | The server reported an error or sent a malformed reply | Check the server log and the config's keys |
gripper_ | BRAKED | A gripper command did not finish within 8 s. A gripper that refuses or fails a command ends exception | Check the gripper |
safety_ | BRAKED | The safety state left NORMAL | Recover as for any safety stop |
exception | BRAKED | An unexpected error while running, including a gripper command the gripper refused or failed | Read detail; for a gripper, check the gripper, otherwise report it |
not_ | BRAKED | The arm was not at rest within 3 s of the stop | Check the robot before resuming |
disarm_ | BRAKED | Jog did not confirm releasing the session; the brake stop asks once more | If that was not confirmed either, the next goal releases it first (session_ if it cannot) |