Taking Tianbot as an example, the open source code is as follows:
https://github.com/tianbot/tianbot_mini
Download Fusion Mapping Package
sudo apt-get install ros-melodic-multirobot-map-merge
1. Generate multiple machines in the gazebo simulation map,
roslaunch tianbot_mini simulation.launch robot_name:=rbmn_01 //This step is to generate gazebo map and generate a car in the map
roslaunch abc_swarm spawn_robot.launch robot_name:=rbmn_02 //This step is to generate another car
2. Open the map for the two cars respectively
roslaunch tianbot_mini slam.launch robot_name:=rbmn_01
roslaunch tianbot_mini slam.launch robot_name:=rbmn_02 //Open mapping for two robots respectively
3. Transform the coordinates of the /map of the two vehicles to the world
rosrun tf static_transform_publisher 0 0 0 0 0 0 world tbmn_01/map 20
rosrun tf static_transform_publisher 0 0 0 0 0 0 world tbmn_02/map 20
Finally, such a tf tree is formed
4. Turn on the map fusion node
roslaunch abc_swarm map_merge.launch robot_name_1:=rbmn_01 robot_name_2:=rbmn_02
Finally, open a rviz and open the map topic. The generated map is the merged map of the two cars.