physicalai-runtime-running-policy-on-robot
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRunning a Policy on a Robot
在机器人上运行策略
PolicyRuntimesrc/physicalai/runtime/runtime.pyInferenceModelsrc/physicalai/runtime/execution.pysrc/physicalai/runtime/rtc_execution.pyphysicalai runsrc/physicalai/cli/run.pyPolicyRuntimesrc/physicalai/runtime/runtime.pyInferenceModelsrc/physicalai/runtime/execution.pysrc/physicalai/runtime/rtc_execution.pysrc/physicalai/cli/run.pyphysicalai runWorkflow
工作流程
-
Choose API vs config: Python for notebooks/tests; YAML +for reproducible deployment.
physicalai run- Done when: entry point matches the user's task.
-
Python minimal loop (see):
docs/how-to/runtime/run-policy-on-robot.mdpythonfrom physicalai.runtime import PolicyRuntime, SyncExecution from physicalai.inference import InferenceModel from physicalai.robot import SO101 from physicalai.capture import UVCCamera runtime = PolicyRuntime( fps=30, robot=SO101(port="/dev/ttyACM0"), model=InferenceModel("./exports/act_policy"), cameras={"wrist": UVCCamera(device="/dev/video0", width=640, height=480)}, execution=SyncExecution(), ) with runtime: runtime.run(duration_s=60)- Done when: components connect and the loop runs in a test or dry-run with fakes.
-
YAML config — nest/
class_pathfor robot, model, cameras, execution; run:init_argsbashphysicalai run --config runtime.yaml --run.duration_s=60 -
Execution mode — pick sync vs RTC per; do not build ad-hoc timing around
docs/how-to/runtime/use-execution-modes.mdwhenInferenceModel.select_actionshould own the queue.PolicyRuntime -
Callbacks — register via runtime callback APIs () for telemetry/latency, not inside inference adapters.
docs/how-to/runtime/add-runtime-callbacks.md
-
选择API或配置文件:在笔记本/测试场景使用Python代码;在可复现的部署场景使用YAML配置 +命令。
physicalai run- 完成标志:入口点与用户任务匹配。
-
Python最小化循环(参考):
docs/how-to/runtime/run-policy-on-robot.mdpythonfrom physicalai.runtime import PolicyRuntime, SyncExecution from physicalai.inference import InferenceModel from physicalai.robot import SO101 from physicalai.capture import UVCCamera runtime = PolicyRuntime( fps=30, robot=SO101(port="/dev/ttyACM0"), model=InferenceModel("./exports/act_policy"), cameras={"wrist": UVCCamera(device="/dev/video0", width=640, height=480)}, execution=SyncExecution(), ) with runtime: runtime.run(duration_s=60)- 完成标志:组件成功连接,且循环在测试环境或使用模拟设备的试运行中正常运行。
-
YAML配置 —— 为机器人、模型、摄像头、执行器嵌套/
class_path;运行命令:init_argsbashphysicalai run --config runtime.yaml --run.duration_s=60 -
执行模式 —— 根据选择同步模式或RTC模式;当
docs/how-to/runtime/use-execution-modes.md应管理队列时,不要围绕PolicyRuntime构建临时计时逻辑。InferenceModel.select_action -
回调函数 —— 通过运行时回调API(参考)注册遥测/延迟相关回调,不要在推理适配器内部实现。
docs/how-to/runtime/add-runtime-callbacks.md
Validation loop
验证循环
bash
uv run pytest tests/unit/runtime/ -qUse fake robots/cameras from runtime tests when hardware is unavailable.
bash
uv run pytest tests/unit/runtime/ -q当硬件不可用时,使用运行时测试中的模拟机器人/摄像头。
Required checks
必要检查
- and camera read rates are consistent.
fps - Action dimensions match robot expectations.
send_action - Config targets are importable without training packages.
class_path - Document breaking changes to runtime config schema in .
docs/reference/config-schema.md
- 与摄像头读取速率保持一致。
fps - 动作维度符合机器人的预期。
send_action - 配置中的目标无需依赖训练包即可导入。
class_path - 在中记录运行时配置架构的重大变更。
docs/reference/config-schema.md
References
参考资料
docs/how-to/runtime/run-policy-on-robot.mddocs/how-to/config/write-runtime-config.md
docs/how-to/runtime/run-policy-on-robot.mddocs/how-to/config/write-runtime-config.md