feat: separate laser API endpoint (POST /api/laser)

This commit is contained in:
dev01
2026-06-01 20:46:46 +08:00
parent a281fd115e
commit bb8724035f
3 changed files with 95 additions and 42 deletions
+27 -11
View File
@@ -109,11 +109,6 @@ curl -X POST http://localhost:8080/api/mode/switch \
curl -X POST http://localhost:8080/api/mode/switch \
-H "Content-Type: application/json" \
-d '{"mode": "debug"}'
# 激光开关
curl -X POST http://localhost:8080/api/mode/switch \
-H "Content-Type: application/json" \
-d '{"mode": "laser_on"}'
```
也可直接通过 ROS2 话题发送:
@@ -122,7 +117,28 @@ curl -X POST http://localhost:8080/api/mode/switch \
ros2 topic pub /gimbal/mode std_msgs/String "data: 'auto'"
```
## 6. 手动控制云台
## 6. 激光控制
```bash
# 开激光
curl -X POST http://localhost:8080/api/laser \
-H "Content-Type: application/json" \
-d '{"action": "on"}'
# 关激光
curl -X POST http://localhost:8080/api/laser \
-H "Content-Type: application/json" \
-d '{"action": "off"}'
```
也可直接通过 ROS2 话题发送:
```bash
ros2 topic pub /gimbal/mode std_msgs/String "data: 'laser_on'"
ros2 topic pub /gimbal/mode std_msgs/String "data: 'laser_off'"
```
## 7. 手动控制云台
```bash
# angular.y = pitch 角速度, angular.z = yaw 角速度
@@ -130,7 +146,7 @@ ros2 topic pub /cmd_gimbal geometry_msgs/Twist \
"{angular: {y: 0.0, z: 0.0}}"
```
## 7. PID 调参(调试模式)
## 8. PID 调参(调试模式)
先切换到 debug 模式,然后通过 `/pid_config` 话题发送参数:
@@ -144,13 +160,13 @@ ros2 topic pub /pid_config std_msgs/String \
参数立即生效,调试完毕后切回 auto 或 manual 模式。
## 8. 查看视觉结果
## 9. 查看视觉结果
浏览器打开 `http://<设备IP>:8080`,可看到:
- 原始图像 + 轮廓标注(result)
- Otsu 二值化 + 闭运算结果(binary)
## 9. 查看话题
## 10. 查看话题
```bash
# 列出所有活跃话题
@@ -164,7 +180,7 @@ ros2 topic hz /vision/target
ros2 topic echo /vision/target
```
## 10. 测试
## 11. 测试
```bash
cd workspace
@@ -179,7 +195,7 @@ colcon test --packages-select gimbal_control_pkg
colcon test-result --all
```
## 11. 故障排查
## 12. 故障排查
| 现象 | 检查项 |
|------|--------|