mcpField
P
physicalai-runtime-running-policy-on-robot

physicalai-runtime-running-policy-on-robot

github.com/openvinotoolkit开发4081 次安装今天更新
代码仓库

关于 physicalai-runtime-running-policy-on-robot

使用 physicalai-runtime 在机器人上运行策略的开发技能,介绍 Python 与 YAML 入口、执行模式、回调及模拟硬件验证。

主要功能

  1. 01Python 与 YAML 配置指南
  2. 02同步与 RTC 执行模式
  3. 03运行时回调指南
  4. 04模拟机器人和相机测试
  5. 05配置与动作验证

适用场景

  1. 01在 Notebook 中运行策略
  2. 02通过 physicalai run 部署
  3. 03无硬件测试运行时

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/openvinotoolkit/physicalai --skill physicalai-runtime-running-policy-on-robot

安装后在 Claude Code 中输入/physicalai-runtime-running-policy-on-robot确认已加载。

详细介绍

在机器人上运行策略

PolicyRuntime(src/physicalai/runtime/runtime.py)负责控制循环;InferenceModel 负责策略计算。执行策略位于 src/physicalai/runtime/execution.py 和 src/physicalai/runtime/rtc_execution.py 中。CLI:src/physicalai/cli/run.py 中的 physicalai run 通过 jsonargparse 从 YAML 实例化。

工作流

  1. 选择 API 还是配置:笔记本和测试使用 Python;可复现部署使用 YAML + physicalai run。

    • 完成标准:入口点符合用户的任务需求。
  2. Python 最简循环(参见 docs/how-to/runtime/run-policy-on-robot.md):

    from 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)
    
    • 完成标准:各组件已连接,且循环在测试或使用伪对象的试运行中正常运行。
  3. YAML 配置——为机器人、模型、相机和执行嵌套设置 class_path / init_args;运行:

    physicalai run --config runtime.yaml --run.duration_s=60
    
  4. 执行模式——根据 docs/how-to/runtime/use-execution-modes.md 选择同步模式还是 RTC;当队列应由 PolicyRuntime 管理时,不要围绕 InferenceModel.select_action 自行构建临时计时逻辑。

  5. 回调——使用运行时回调 API(docs/how-to/runtime/add-runtime-callbacks.md)注册遥测/延迟回调,不要将其放在推理适配器中。

验证循环

uv run pytest tests/unit/runtime/ -q

无法使用硬件时,请使用运行时测试中的伪机器人/相机。

必要检查

  • fps 和相机读取速率保持一致。
  • 动作维度符合机器人 send_action 的预期。
  • 配置中的 class_path 指向的目标无需训练包即可导入。
  • 在 docs/reference/config-schema.md 中记录运行时配置架构的破坏性变更。

参考资料

  • docs/how-to/runtime/run-policy-on-robot.md
  • docs/how-to/config/write-runtime-config.md

评论

支持 Markdown