ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

When does rosbag start capturing messages and why I see the delay in two messages?

asked 2016-03-21 17:14:34 -0600

cybodroid gravatar image

updated 2016-03-21 17:14:51 -0600

I am trying to understand how much time it takes for rosbag to start capturing packet as soon as we type rosbag record -a .

After analyzing packets captured in the wireshark ( see the wireshark packet at ) , I found that before receiving any messages from ros nodes, roscord subscribers do several packet negotiations with ROS MASTER and then closes the connection to directly connect with rosnode to receive message from them (In enclosed wireshark capture file, packet no. 91 to 314). I want to know that during this packet negotiation, are ros messages buffered and once connection is established they are recorded or during this packet negotiation are ros messages dropped?

The reason is my bot publishes position and velocity. Differentiating position should give velocity. When I plot differentiated position and velocity, I find that there is lag of 0.4 second in velocity data and time shifting velocity by 0.4 second matches the differentiated position. Please note that positions and velocity data comes from two different sensor(it means they come from two different ros nodes).

My whole point of discussion is to find out the source of the delay or why I need to do time shift in velocity.

edit retag flag offensive close merge delete


Are you using bag timestamps or message timestamps? One of the goals of message timestamps is to provide the source time for a message, so that even if it's received with some delay, the original time-series data can be reconstructed correctly.

ahendrix gravatar image ahendrix  ( 2016-03-21 19:00:13 -0600 )edit

I am using MATLAB to read rosbag files

cybodroid gravatar image cybodroid  ( 2016-03-21 22:51:25 -0600 )edit

I'm not familiar with the matlab bindings for ROS. I suspect you're using the TimerSeries extraction to read messages, but it's not clear if that method of reading the bag file uses the bag timestamps or the timestamps from the message headers.

ahendrix gravatar image ahendrix  ( 2016-03-21 22:58:29 -0600 )edit

You may want to try including both the header.stamp and your data when you extract data from the bag, and see how the extracted timestamps compare to the header timestamps.

ahendrix gravatar image ahendrix  ( 2016-03-21 22:59:44 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-03-01 12:23:34 -0600

tfoote gravatar image

rosbag connects to publishers like any other node:

No message sent before the connection is established will be buffered or queued in any way. (For the rosbag subscriber, other subscribers with established connections will queue as expected.) Anything sent during the negotiations will be dropped.

As @ahendrix mentions you should make sure to use the embedded timestamps not the time or receipt. And if those are off I would suggest looking at your data sources to make sure that they are applying timestamps correctly and their timesources are synchronized.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-03-21 17:14:34 -0600

Seen: 915 times

Last updated: Mar 01 '19