Files
craic/tools/README.md
2026-05-27 02:20:09 +08:00

44 lines
1016 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# tools — 调试 & 测试工具
## 文件
| 文件 | 说明 |
|------|------|
| `udp_server.py` | UDP 回显服务器,监听 `0.0.0.0:8888`,用于测试 UDP 通讯协议 |
## 使用
### UDP 回显服务器
启动服务器,接收来自 ESP32 或 ROS 2 键盘遥控节点的 UDP 指令并打印:
```bash
python tools/udp_server.py
```
发送测试指令验证协议格式:
```bash
# 底盘指令
echo 'XYW:100:0:0:XZHY' | nc -u 127.0.0.1 8888
# 机械臂指令
echo 'JXB:-10:90:0:0:45:0:0:0:EZHY' | nc -u 127.0.0.1 8888
# 激光指令
echo 'LASERON' | nc -u 127.0.0.1 8888
```
### 协议测试流程
1. 启动 `python tools/udp_server.py`
2. 修改 ROS 2 节点参数指向本机:`udp_ip:=127.0.0.1`
3. 运行 ROS 2 键盘遥控节点,观察服务器收到的指令
4. 确认协议格式正确后,将目标 IP 改为实际设备地址
```bash
# 示例ROS 2 键盘遥控 → 本地回显
ros2 run udp_teleop keyboard_control \
--ros-args -p udp_ip:=127.0.0.1 -p udp_port:=8888
```