Gmapping is a ROS packages that allows to create 2-d occupancy grid maps from laser and pose data collected by a mobile robot using SLAM algorithms. This is a very crucial package for our project, and will have to run on each robot.
What do you need to have gmapping running ?
First of all, you need the hardware, which should be a mobile robot that can provide odometry data and has a horizontally fixed laser sensor. You can also run it with a simulated robot, for example with the stdr 2d environment. as in the example on right.
Running gmapping in a simulation
If you run the stdr simulation, with one robot that has a laser sensor, you can run the following command :
rosrun gmapping slam_gmapping scan:=/robot0/laser_0 _base_frame:="/robot0" map:=/gmapping/map1
this will create a new node called slam_gmapping, which will publish the map on a topic called gmapping/map2. WIth rviz, you can see the map, as in the example below :
If you want to add another gmapping node that would be subscribed to a second robot, you need to launch it with a .launch file, with a different name. Otherwise, ROS will shutdown the nodes if you try running two instances with the same name.
An example of a .launch file for running a second gmapping can be seen below :
as you can see, the name is changed to "slam_gmapping_2" and the parameters are set according to the topics from the second robot. It will publish the map data and map metadata on the topics called
/gmapping/map2 and gmapping/metadata2 .
The whole system architecture should look identical to this one :
In rviz you can visualize both maps in the same environment. However, this will be two completely different unmerged maps. In order to have a unique global map, you need to use map merging packages and algorithms. In a future post we will write more about these kind of packages, together with a small tutorial on how to use them.