Add deployment scripts (server launcher + NUC client contract)
Browse files- deploy/client_example.py +36 -0
- deploy/serve_bread.sh +13 -0
deploy/client_example.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Fixed I/O contract for the bread policy — run on the robot NUC.
|
| 2 |
+
|
| 3 |
+
pip install openpi-client (pure-CPU, no jax; vendored in the openpi repo
|
| 4 |
+
under packages/openpi-client if not on PyPI)
|
| 5 |
+
|
| 6 |
+
Input : one obs dict per control step (see below)
|
| 7 |
+
Output: actions (40, 14) — per arm [dxyz(3), axis-angle drot(3), ABS gripper(1)],
|
| 8 |
+
stepwise-chained deltas @30Hz: executor integrates
|
| 9 |
+
T_cmd,k = T_cmd,k-1 @ delta_k starting from T_current.
|
| 10 |
+
Latency matching: measure l = camera->infer->command; start executing at
|
| 11 |
+
step ceil(l * 30) instead of step 0.
|
| 12 |
+
"""
|
| 13 |
+
import numpy as np
|
| 14 |
+
from openpi_client import websocket_client_policy
|
| 15 |
+
|
| 16 |
+
PROMPT = "take the bread out of the bowl and put the bread into the toaster"
|
| 17 |
+
|
| 18 |
+
client = websocket_client_policy.WebsocketClientPolicy(host="GPU_WORKSTATION_IP", port=8000)
|
| 19 |
+
|
| 20 |
+
def get_actions(left_img: np.ndarray, # uint8 HWC (any size; server letterboxes to 224)
|
| 21 |
+
right_img: np.ndarray, # uint8 HWC
|
| 22 |
+
rel_state_20d: np.ndarray, # relative_to_first grasp_site poses, see README
|
| 23 |
+
) -> np.ndarray:
|
| 24 |
+
obs = {
|
| 25 |
+
"left_wrist_image": left_img,
|
| 26 |
+
"right_wrist_image": right_img,
|
| 27 |
+
"state": rel_state_20d.astype(np.float32),
|
| 28 |
+
"prompt": PROMPT,
|
| 29 |
+
}
|
| 30 |
+
return np.asarray(client.infer(obs)["actions"])[:, :14] # (40, 14)
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
a = get_actions(np.zeros((480, 640, 3), np.uint8),
|
| 34 |
+
np.zeros((480, 640, 3), np.uint8),
|
| 35 |
+
np.zeros(20, np.float32))
|
| 36 |
+
print("actions:", a.shape) # smoke test: (40, 14)
|
deploy/serve_bread.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Policy server for pi05-bread-r1-top200. Run on the lab GPU workstation
|
| 3 |
+
# (>=16GB VRAM). The robot NUC connects via openpi_client over LAN.
|
| 4 |
+
#
|
| 5 |
+
# One-time setup on this machine:
|
| 6 |
+
# git clone -b bread-r1 https://github.com/BrianZhengJourney/openpi && cd openpi
|
| 7 |
+
# GIT_LFS_SKIP_SMUDGE=1 uv sync
|
| 8 |
+
# hf download BrianZhengJourney/pi05-bread-r1-top200 --local-dir ~/bread_ckpt
|
| 9 |
+
set -euo pipefail
|
| 10 |
+
CKPT="${1:-$HOME/bread_ckpt/10000}"
|
| 11 |
+
exec uv run scripts/serve_policy.py policy:checkpoint \
|
| 12 |
+
--policy.config=pi05_bread_r1_lora \
|
| 13 |
+
--policy.dir="$CKPT"
|