The first knowledge of the ROS series gmapping and the first knowledge of ros gmapping
Introduction
The gmaping package provided by ROS is used to generate maps. It is an implementation of the famous open source OpenSlam package under the ROS framework. This package provides Slam for the laser device, and builds a grid-based 2D map based on the input and posture data of the laser device. It needs to listen to many topics from the ROS system and output a Topic -- map (nav_msgs/OccupancyGrid), which is also the input Topic of RViz.
Procedure: Download gmaping and sample data
sudo apt-get install ros-indigo-slam-gmapping
wget http://pr.willowgarage.com/data/gmapping/basic_localization_stage.bag
Start ROS master
This is the first step for all ROS operations, just like starting up.
roscore
After the terminal is started, it is suspended and another terminal is opened for other programs.
Set ROS system time
Configure ROS to enable the time in the replay data instead of the local time, which affects the output results of all the time APIs of the system. By default, ROS uses the ubuntu system time, that is, the wall clock time (wall clock ). However, when replaying a history file, the history time is recorded, so we need to tell ROS to enable the simulation time from now on.
rosparam set use_sim_time true
Start gmapping
Start gmapping and listen for messages sent from scan_base topic. This topic is released by the simulator.
rosrun gmapping slam_gmapping scan:=base_scan
After the terminal is started, it is suspended and another terminal is opened for other programs.
Start RViz
Start RViz, click add (lower left), select map in the pop-up list, and click OK. An empty map is displayed.
rosrun rviz rviz
The most critical step is to tell RViz what is the topic that generates the map information. As we have mentioned earlier, the topic output by gmapping is/map, so it is configured as/map.
After the terminal is started, it is suspended and another terminal is opened for other programs.
Start the simulator to replay data
rosbag play --clock basic_localization_stage.bag
Now you can see the dynamic creation of the map in RViz.