Gmapping takes in a large number of scans, but ignores most of them in order to minimize computation time.
If you ran the bag file and ran gmapping, it is unlikely that you will get the exact same map because the scans that gmapping will process are likely to be different.
Another thing to consider. Does your bag file contain map messages? These wouldn't interfere with the gmapping algorithm, but the result on rviz would look strange because you're getting maps from two different sources.
If you recorded a bag without gmapping running, then played back the bag with gmapping running, you will probably get the same result each time you run gmapping because you are running it in a more controlled environment.
Originally posted by Sebastian with karma: 363 on 2016-04-04
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by niraj007 on 2016-04-05:
Hi Sebastian,
Thanks for the great idea. I will record without gmapping running and post the result. I am not sure about the map messages inside the bag. I would appreciate again if I can know the way to check.
Comment by mgruhler on 2016-04-05:
Check which topics are in a bagfile: rosbag info <BAGFILE>
.
Only publish some topics: rosbag play <BAGFILE> --topics <TOPICS>
See also http://wiki.ros.org/rosbag/Commandline
Comment by niraj007 on 2016-04-07:
Sebastien suggestion it works well. First I run rosrun gmapping
and rosbag record scan tf
, then I move the Turtlebot2 around, stop the rosbag record. Later I play rosbag with gmapping running, I could generate a same map as before. Thanks a lot to everyone.