文章目录
- 获取源码
- 安装依赖项
- 编译
- 简单场景
- 运行gmapping
- 开启键盘控制
- 通过launch文件来启动gmapping
- Gmapping建图的参数设置
- 地图的保存和加载
- 参考
获取源码
cd ~/catkin_ws/src/
git clone https://gitcode.com/weixin_42990464/wpr_simulation.git
git clone https://gitcode.com/weixin_42990464/waterplus_map_tools.git
git clone https://gitcode.com/weixin_42990464/waterplus_map_tools.git
安装依赖项
ROS Noetic (Ubuntu 20.04)
cd ~/catkin_ws/src/wpr_simulation/scripts
./install_for_noetic.sh
cd ~/catkin_ws/src/wpb_home/wpb_home_bringup/scripts
./install_for_noetic.sh
cd ~/catkin_ws/src/waterplus_map_tools/scripts
./install_for_noetic.sh
编译
cd ~/catkin_ws
catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
简单场景
roslaunch wpr_simulation wpb_stage_robocup.launch
运行gmapping
rosrun gmapping slam_gmappinp
在rviz中添加机器人,map,雷达话题。
开启键盘控制
rosrun wpr_simulation keyboard_vel_ctrl
#键盘控制WPR机器人:
#w - 向前加速
#s - 向后加速
#a - 向左加速
#d - 向右加速
#q - 左旋加速
#e - 右旋加速
#空格 - 刹车
#x - 退出
通过launch文件来启动gmapping
cd ~/catkin_ws/src
catkin_create_pkg slam_pkg roscpp rospy std_msgs
保存rviz配置
在slam_pkg/launch文件中新建gmapping.launch
<launch><include file="$(find wpr_simulation)/launch/wpb_stage_robocup.launch" /><node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" /><node pkg="rviz" type="rviz" name="rviz" args="-d $(find slam_pkg)/rviz/gmapping.rviz" /><node pkg="wpr_simulation" type="keyboard_vel_ctrl" name="keyboard_vel_ctrl" /></launch>
Gmapping建图的参数设置
地图的保存和加载
地图保存
cd ${save_dir}
rosrun map_server map_saver -f map
地图加载
rosrun map_server map_server map.yaml
参考
https://www.bilibili.com/video/BV1wF411Q7Q3/?spm_id_from=333.788&vd_source=667c3d14dbb51ec849c0bc7c38329d10