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

猜你喜欢

转载自blog.csdn.net/weixin_42990464/article/details/134580033