physicalai-runtime-adding-a-robot-integration
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAdding a Robot Integration
添加机器人集成
Robots satisfy the structural protocol in — no base class inheritance required. References: , (WidowX). Connection helpers: ; validation: .
Robotsrc/physicalai/robot/interface.pysrc/physicalai/robot/so101/src/physicalai/robot/trossen/src/physicalai/robot/connect.pysrc/physicalai/robot/verify.py机器人需满足中的结构化协议——无需继承基类。参考示例:、(WidowX机械臂)。连接辅助工具:;验证工具:。
src/physicalai/robot/interface.pyRobotsrc/physicalai/robot/so101/src/physicalai/robot/trossen/src/physicalai/robot/connect.pysrc/physicalai/robot/verify.pyWorkflow
工作流程
- Read and an existing integration (SO-101 for serial servos, WidowX for arms).
references/robot-protocol.md- Done when: required methods and observation shape are listed.
- Implement connect lifecycle: idempotent ,
connect(),disconnect().is_connected() - Observations: return a type exposing ,
joint_positions(timestamp), optionaltime.monotonic()/sensor_data; implementimagesproperty when inference expects more than positions.state - Actions: with
send_action(action, *, goal_time=...)shape matching training data conventions; document joint order viaaction.joint_names - Optional extra in (
pyproject.toml,physicalai[so101]); lazy-import vendor SDKs.physicalai[trossen] - Export public class from when user-facing.
physicalai.robot - Tests under with mocked hardware.
tests/unit/robot/- Done when: passes.
uv run pytest tests/unit/robot -k <name>
- Done when:
- Verification CLI/docs — wire patterns if the robot supports automated checks.
verify.py
- **阅读**及现有集成示例(面向串行舵机的SO-101、面向机械臂的WidowX)。
references/robot-protocol.md- 完成标志:列出所需方法和观测数据格式。
- 实现连接生命周期:幂等的、
connect()、disconnect()方法。is_connected() - 观测数据:返回一个包含、
joint_positions(timestamp)的类型,可选择性包含time.monotonic()/sensor_data;当推理需要位置之外的更多信息时,实现images属性。state - 动作控制:方法,其中
send_action(action, *, goal_time=...)的格式需匹配训练数据约定;通过action记录关节顺序。joint_names - 可选扩展包:在中配置(
pyproject.toml、physicalai[so101]);延迟导入厂商SDK。physicalai[trossen] - 导出:若面向用户使用,需从导出公开类。
physicalai.robot - 测试:在下编写基于硬件模拟的测试。
tests/unit/robot/- 完成标志:执行测试通过。
uv run pytest tests/unit/robot -k <name>
- 完成标志:执行
- 验证CLI/文档:如果机器人支持自动化检查,按照的模式进行配置。
verify.py
Required checks
必查项
- at runtime (
isinstance(robot, Robot)protocol).@runtime_checkable - No action sent when disconnected.
- Joint count and stay stable across connect/disconnect.
joint_names - Security: validate user-supplied port/path strings; no shell invocation with unsanitized device paths.
- 运行时需检查(
isinstance(robot, Robot)协议)。@runtime_checkable - 未连接状态下不得发送动作指令。
- 关节数量和在连接/断开过程中需保持稳定。
joint_names - 安全性:验证用户提供的端口/路径字符串;不得使用未净化的设备路径执行shell命令。
References
参考资料
references/robot-protocol.mddocs/explanation/robots.md
references/robot-protocol.mddocs/explanation/robots.md