0
$\begingroup$

Rosanswers logo

Indigo, Linux Mint 17

I'm using the commandline rosbag utility to record various topics.

I have two topics /topic1 and /topic2. Topic1 is published before Topic2, like so:

if state==new_state:
      publish_topic_1()

publish_topic_2(state)

So topic1 publishes when we are in the new_state and topic2 just publishes the state, whatever it happens to be. After recording I inspect the bag with rqt_bag. I expect to see topic1 always preceding topic2 switching from another state to "new_state". However, this is not what I see. I often will see topic2 transition to "new_state" before topic1 appears. If I explicitly add a sleep statement after publishing topic1 then they appear in the order I expect.

So:

  • What should I expect for timing topics? Should I expect them to be received and recorded in order? My understanding was that rosbag would handle synchronization of all my data streams.
  • Does adding a Header to each msg type help?
  • Is everything fine and rqt_bag is just broken?

Does it all come to the limitations of record/playback as described here? http://wiki.ros.org/ROS/Tutorials/Recording%20and%20playing%20back%20data#rosbag.2BAC8-Tutorials.2BAC8-Recording_and_playing_back_data.The_limitations_of_rosbag_record.2BAC8-play

If so, does anyone have a solution for ensuring accurate timing in a rosbag? Writing it directly myself rather than publishing and letting rosrecord pick it up?


Originally posted by csherstan on ROS Answers with karma: 122 on 2014-11-07

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

rosbag timestamps and records messages in the order that they're received. If the messages on topic1 are much larger and take longer to serialize and transmit, they may arrive later even if they're queued for transmission first.

Adding a header won't help rosbag order messages properly; it will still use the receive timestamp. That said, having a header with a timestamp is useful for lots of other things. You can also reorder the messages in a bag file based on their header timestamps: http://wiki.ros.org/rosbag/Cookbook


Originally posted by ahendrix with karma: 47576 on 2014-11-07

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by csherstan on 2014-11-07:
Well I've confirmed what you've said with tests. However, it would be really nice if messages were timestamped according to when they were published rather than received. So the callback for a subscriber would now have an extra parameter:

def callback(msg, timestamp):

Comment by ahendrix on 2014-11-07:
If you want timestamps, it's much better to include a Header in your messages, and set it appropriately. This also allows nodes that process and reinterpret data to propagate that timestamp from one message to the next.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.