实时调试机器狗控制数据的 Web 界面,通过 ZMQ 从控制器获取数据,在浏览器中显示实时曲线和 3D 模型。
[机器狗控制器] [研发笔记本] WheeledQuadruped └─ ZMQ PUB :5755 ─────────→ server.py Protobuf 数据 ├─ ZMQ SUB ├─ HTTP :8080 └─ WebSocket ──→ 浏览器 ├─ Chart.js 曲线 └─ Three.js 3D
dog_debugger/ ├── proto/ │ ├── dog_debug.proto # Protobuf 数据定义 │ ├── dog_debug.pb.h/cc # C++ 生成代码 │ └── dog_debug_pb2.py # Python 生成代码 ├── dog_debug_publisher.h # C++ ZMQ 发布者(header-only) ├── server.py # Python 中间件服务器 ├── index.html # 浏览器调试界面 ├── test_publisher.py # 测试用模拟发布者 ├── requirements.txt # Python 依赖 └── README.md # 本文档
cd dog_debugger
python3.10 -m pip install -r requirements.txt
注意: 如果系统有多个 Python 版本,请使用 python3.10 或 python3 确保使用正确版本。
终端 1 - 启动模拟发布者:
python3.10 test_publisher.py --port 5755 --freq 100
终端 2 - 启动调试服务器:
python3.10 server.py --http-port 8080
浏览器:
打开 http://localhost:8080,输入 IP localhost,点击"连接"
机器狗控制器端: 重新编译 WheeledQuadruped 插件(已自动集成 ZMQ 发布):
cd /home/seer/project/x86/3.4.8.0019_dog
# 重新构建项目
./build.sh # 或使用你的构建脚本
研发笔记本端:
cd dog_debugger
python3.10 server.py --http-port 8080
浏览器:
打开 http://localhost:8080,输入机器狗 IP(如 192.168.1.100),点击"连接"
| 字段 | 类型 | 大小 | 说明 |
|---|---|---|---|
timestamp | double | 1 | Unix 时间戳(秒) |
commands | float[] | 3 | 控制指令 [x, y, rotate] |
imu_ang_vel | float[] | 3 | IMU 角速度 [rot_x, rot_y, rot_z] |
imu_lin_acc | float[] | 3 | IMU 线加速度 [acc_x, acc_y, acc_z] |
joint_pos | float[] | 12 | 关节位置(前 12 个关节) |
joint_vel | float[] | 16 | 关节速度(全 16 个关节) |
action | float[] | 16 | 推理输出动作(全 16 个) |
dog_mode | string | - | 工作模式:"none" / "infer" / "hoverToWalk" |
[0-3] ABAD 关节: FBL, FAR, RBL, RAR [4-7] HIP 关节: FBL, FAR, RBL, RAR [8-11] KNEE 关节: FBL, FAR, RBL, RAR [12-15] FOOT 关节: FBL, FAR, RBL, RAR
BackMotion() 调用频率(通常 100Hz)server.py 是否正常运行BackMotion()test_publisher.py 验证通信链路缺少 ZMQ 头文件:
# 检查 zmq.h 是否存在
ls /home/seer/project/x86/3.4.8.0019_dog/plugins/RBKSim/include/zmq.h
缺少 libzmq.so:
# 检查库文件
ls /home/seer/project/x86/3.4.8.0019_dog/bin/libraries/linux/x86_64/release/3rdlib/libzmq.so
# 重新生成 Python protobuf 代码
cd dog_debugger
protoc --python_out=. proto/dog_debug.proto
proto/dog_debug.protoprotoc --cpp_out=. --python_out=. proto/dog_debug.proto
C++ 端(WheeledQuadruped.cpp):
m_debug_publisher = std::make_unique<dog_debug::DogDebugPublisher>(5556); // 改为 5556
Python 端:
python server.py --http-port 8080 # HTTP 端口
# ZMQ 端口在浏览器连接时指定
内部项目,仅供 RoboKit 开发使用。