Rosbag playback for mapping

Hi I have an error of “Warning: TF_OLD_DATA ignoring data from the past for frame wheel_right_link at time 2661.3 according to authority unknown_publisher
Possible reasons are listed at tf/Errors explained - ROS Wiki
when trying to playback a rosbag on gmapping, how do I solve it?


Possible the TF of the frames are not being published. Check that in case

Not sure if I should revive this topic, but I have the exact same problem.

From what I understand, this is because the time in the bag is not in sync with the time of the ROS environment (I think I restarted everything, but I’m not sure how I can check this)

Via Google, I found that you could add the --clock parameter to the rosbag play instruction. I think that worked, but I still got warnings: [ WARN] [1642020570.372611393, 249.248319400]: Detected jump back in time of 471.933s. Clearing TF buffer.

I suppose this is ok, but I really have no idea.

BTW: that section also contains a sentence in Spanish, probably it was left there by accident, or some one forgot to translate it: [esto no puede funcionar porque no estas grabando la odometria]


Now I understand the issue more or less.

So when you record rosbags, it is supposed that you don’t have anything else running when you run them, because the timeframes of everything will be in the past, related to the clock of let’s say in this case the Gazebo simulation.

@PeterFromM as far as I understand, the “”–clock"" argument will publish the clock time, which might give less errros but all teh other elements of the bag will still have timestamps of the past.

This section, is teaching you this method to generate maps OFFLINE let’s say from the robot or simulation. But it’s really not meant to be used while there is a robot or simulation still running.

Therefore you have to stop your robot publishing or in this case, pause the gazebo simulation.

To do that you have to execute the following command:

rosservice call /gazebo/pause_physics

To check that its really paused, we will check the clock topic . It shouldn’t publish anything:

$ rostopic echo /clock
WARNING: no messages received and simulated time is active.
Is /clock being published?

Now we can generate the map using ONLY the rosbag data. Start the gmapping like so:

WebShell 1

rosrun gmapping slam_gmapping scan:=kobuki/laser/scan

As @PeterFromM states, we need to tell the rosbag to publish the clock topic, otherwise by default it takes the one published in the system, which in this case is not publishing anything and wouldn’t allow us to generate the map. So use this command:

WebShell 2

rosbag play --clock mylaserdata.bag

And now the topic clock should start to publish. Now the mapping will start without issues and when the rosbag play finished, WITHOUT closing the gmaping command, in another terminal execute teh save map :slight_smile:

WebShell 3

rosrun map_server map_saver -f map_name

I will Update the notebooks to take this into account. Thanks for the insight @PeterFromM

Thanks @duckfrost2 I will try this out myself (I still have lots to learn, so thanks for the detailed explanation)