一、 在gazebo中构建一个用于建图和导航的虚拟环境,可以使用Building Editor工具创建,也可以使用其他功能包中已有的虚拟环境;将前面作业完成的带传感器的移动机器人(小车)模型放置到虚拟环境中,使用gmapping 和 hector_slam功能包实现SLAM仿真建立完成的地图上,实现基于move_base和amcl功能包的机器人自主导航仿真。
gmapping和hector_hector包文件
链接:https://pan.baidu.com/s/1EXYq0NG0wW8jIzQS3HSMlw
提取码:80cn
下载gmapping
sudo apt-get install ros-melodic-gmapping
启动gmapping演示
```bash
roslaunch mbot_gazebo mbot_laser_nav_gazebo.launch
roslaunch mbot_navigation gmapping_demo.launch
roslaunch mbot_teleop mbot_teleop.launch
控制机器人绕环境旋转一周
保存pgm(首先下载server)
sudo apt-get install ros-melodic-map-server
保存地图
rosrun map_server map_saver -f cloister_gmapping
关闭启动项
在根目录可见:
sudo apt-get install ros-melodic-hector-slam
roslaunch mbot_gazebo mbot_laser_nav_gazebo.launch
roslaunch mbot_navigation hector_demo.launch
roslaunch mbot_teleop mbot_teleop.launch
保存图片
rosrun map_server map_saver -f cloister_hector
sudo apt-get install ros-melodic-navigation
roslaunch rbx1_bringup fake_turtlebot.launch
roslaunch rbx1_nav fake_move_base_map_with_obstacles.launch
rosrun rviz rviz -d `rospack find rbx1_nav `/nav_obstacles.rviz
rosrun rbx1_nav move_base_square.py
导航仿真
roslaunch mbot_gazebo mbot_laser_nav_gazebo.launch
roslaunch mbot_navigation nav_cloister_demo.launch
调整位置
通过2D nav goal让机器人动起来
躲避实时的障碍物(在模拟环境加入障碍物)
roslaunch mbot_gazebo mbot_laser_nav_gazebo.launch
roslaunch mbot_navigation exploring_slam_demo.launch
roslaunch mbot_gazebo mbot_laser_nav_gazebo.launch
roslaunch mbot_navigation exploring_slam_demo.launch
rosrun mbot_navigation exploring_slam.py