基于ROS Noetic的导航系统,使用Cartographer进行定位,通过TF和rosbridge接口控制move_base实现路径点导航。
专为使用Cartographer定位的ROS Noetic导航系统设计。通过TF获取位姿,通过rosbridge与move_base交互。
必须启动 rosbridge_server:
bash
source /opt/ros/noetic/setup.bash
roslaunch rosbridge_server rosbridge_tcp.launch
Cartographer导航系统:
bash
# 示例启动命令(根据实际项目调整)
roslaunch robot_navigation navigation_with_cartographer_cpp.launch
如果没有运行rosbridge,所有导航命令都会失败!
特性原版 (AMCL)Cartographer版定位算法AMCLCartographer位姿获取/amcl_pose TopicTF变换地图格式.pgm + .yaml``.pbstream重定位自动需手动设置初始位姿
text
ros-noetic-nav-cartographer/
├── SKILL.md # 本说明文档
├── waypoints.json # Cartographer专用航点
└── scripts/
├── waypoints_manager.py # 航点管理
├── nav.py # 导航脚本(单点+巡航)
└── get_pose_tf.py # 通过TF获取位姿
在 TOOLS.md 中添加:
markdown
### ROS Noetic Navigation - Cartographer
- workspace: ~/robot5 # 根据实际项目调整
- rosbridge_host: localhost
- rosbridge_port: 9090
- pose_tf_target: base_link # 小车坐标系
- pose_tf_source: map # 地图坐标系
- waypoints_file: ~/.openclaw/workspace/skills/ros-noetic-nav-cartographer/waypoints.json
- map_file: ~/robot5/src/robot_navigation/maps/my_map.pbstream
bash
# 基本查询
python3 scripts/get_pose_tf.py
# 指定坐标系
python3 scripts/get_pose_tf.py --target-frame base_footprint --source-frame map
# JSON格式输出
python3 scripts/get_pose_tf.py --json
bash
# 列出所有航点
python3 scripts/waypoints_manager.py list
# 添加航点
python3 scripts/waypoints_manager.py add 充电座 --x 0.0 --y 0.0 --yaw 0
python3 scripts/waypoints_manager.py add 客厅 --x 3.0 --y 2.0 --yaw 90
# 获取航点
python3 scripts/waypoints_manager.py get 客厅
# 删除航点
python3 scripts/waypoints_manager.py remove 客厅
bash
# 使用命名航点
python3 scripts/nav.py goto 客厅
# 自然语言命令
python3 scripts/nav.py cmd "去客厅"
bash
# 巡航多个航点
python3 scripts/nav.py cruise 卧室 餐厅 书房
# 自然语言命令
python3 scripts/nav.py cmd "去卧室 餐厅 书房"
bash
python3 scripts/nav.py goto 客厅 --host 192.168.1.100 --port 9090
参数说明默认值--hostrosbridge主机localhost--portrosbridge端口9090--timeout导航超时(秒)180--target-frameTF目标坐标系(小车)base_link--source-frameTF源坐标系(地图)map
启动rosbridge: bash
roslaunch rosbridge_server rosbridge_tcp.launch
启动Cartographer导航: bash
roslaunch robot_navigation navigation_with_cartographer_cpp.launch
在RViz中手动重定位(2D Pose Estimate)
驾驶小车到目标位置,记录航点: bash
# 获取当前位置
python3 scripts/get_pose_tf.py
# 保存航点
python3 scripts/waypoints_manager.py add 客厅 --x <x值> --y <y值> --yaw <角度>
测试导航: bash
python3 scripts/nav.py goto 客厅
map -> base_link 变换bash
# 检查rosbridge是否运行
curl http://localhost:9090
# 启动rosbridge
roslaunch rosbridge_server rosbridge_tcp.launch
bash
# 检查TF树
rosrun tf view_frames
# 检查Cartographer是否正常发布TF
rostopic echo /tf
# 检查话题
rostopic list | grep cartographer
bash
# 检查move_base状态
rostopic echo /move_base/status
# 检查目标是否发布
rostopic echo /move_base_simple/goal