mi-task/test/cy-mark/README.md
2025-05-14 23:13:28 +08:00

74 lines
1.6 KiB
Markdown
Raw Permalink 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.

# Cyberdog 标记服务
这个包实现了在Gazebo模拟环境中动态添加标记点的功能。
## 简介
`cyberdog_marker`包提供了一个ROS2服务允许在仿真运行过程中在指定的位置放置一个标记。标记可以是不同颜色的球体便于在仿真环境中标记特定的位置。
## 安装
将本包复制到您的ROS2工作空间的`src`目录下,例如:
```bash
cp -r cy-mark ~/your_workspace/src/cyberdog_marker
```
然后编译:
```bash
cd ~/your_workspace
colcon build --merge-install --symlink-install --packages-select cyberdog_marker
source install/setup.bash
```
## 使用方法
### 启动服务
```bash
ros2 run cyberdog_marker marker_service_node
```
### 使用服务
通过ROS2服务调用放置标记
```bash
ros2 service call /place_marker cyberdog_marker/srv/PlaceMarker "{x: 1.0, y: 2.0, z: 0.5, color: 'red'}"
```
参数说明:
- `x`, `y`, `z`: 标记的位置坐标
- `color`: 标记的颜色,支持 "red", "green", "blue", "yellow"
### 使用Python客户端
也可以使用提供的Python客户端脚本
```bash
# 确保脚本有执行权限
chmod +x marker_client.py
# 运行客户端
./marker_client.py
```
## 服务接口
### 请求
- `float64 x`: X坐标
- `float64 y`: Y坐标
- `float64 z`: Z坐标
- `string color`: 颜色("red", "green", "blue", "yellow"
### 响应
- `bool success`: 操作是否成功
- `string message`: 返回的消息
## 注意事项
- 确保Gazebo已经运行并且`/spawn_entity`服务可用
- 标记是静态物体,不会受到物理引擎影响
- 每次请求会创建一个新的标记,标记会持续存在直到仿真结束