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

Issue when using rosbag to record concurrent messages from multiple devices to a single topic.

asked 2018-04-10 11:48:55 -0600

Tiz gravatar image

updated 2018-04-23 08:04:26 -0600

Hi All,

I've been struggling with this issue ever since upgrading our kinetic/indigo systems. Brief outline of our software/hardware; 7 laptops (3 on indigo and 4 on kinetic), 3 turtlebot2 platforms and 1 workstation (on indigo). Prior to Dec 2017 everything was working okay and ROS-indigo was used system-wide. However, since Jan 2018 we have been doing a lot of software updates and changes (updated 4 laptops to kinetic). The experiment; we have 3 robots and the workstation PC connected via multimaster-fkie (all on the same network and interacting). We send a bunch of messages from the workstation and the robots perform a bunch of tasks. This all works fine, so I doubt it is a multimaster-fkie problem. We run the following command on the workstation PC

rosbag record -j -o Tasks.yaml_ /experiment /tasks/announce /tasks/award /tasks/status /tasks/new /debug /robot_1/amcl_pose /robot_2/amcl_pose /robot_3/amcl_pose

The /tasks/status topic is the most crucial as it records (time stamp) when the robots perform any action, furthermore all the devices subscribe to this topic. During an experiment if I use rostopic echo /tasks/status (from the workstation) I see all the messages that I should be getting from all the robots. However, later when I play back the rosbag file messages sent to /tasks/status one or more of an entire robot's messages are missing from this topic. When I check the rosbag for other topics there exists messages from all robots (e.g. amcl messages from robot 1,2 etc.). I made a simple script that counts the amount of messages from different topics, from a rosbag file and prints in terminal. Below is the result from one bag file recording -

tasks/status/robot1: 0

tasks/status/robot2: 5

experiment: 8

robot1_amcl: 27

robot2_amcl: 43

I hope the names are easy enough to understand which topic is being referring to, but as can be seen tasks/status contains 0 messages for robot1. Could anyone please let me know their thoughts? Any further information I can supply to help with explaining the problem do let me know!

Please note: The problem with rosbag recording occurs regardless whether only using indigo machines, kinetic machines or a mix of both.

Thank you,


edit retag flag offensive close merge delete


Welcome! Is this any different from your other question #q288187?

jayess gravatar image jayess  ( 2018-04-10 12:12:15 -0600 )edit

Hi, there was an issue when I created my account and I thought the original question didn't post. But I deleted it now (hopefully). Thanks for notifying me!

Tiz gravatar image Tiz  ( 2018-04-11 08:13:27 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-04-23 07:57:39 -0600

Tiz gravatar image

updated 2018-04-23 07:58:30 -0600

Hi All,

I believe I figured out the issue I had with the binary (and API) rosbag record. I realised from here ROS-rosbag-API that the binary and API are not thread-safe. But I had the topic tasks/status which was concurrently being updated by the robot team and workstation. I wrote a python script using the python API, which "proved" to be thread-safe. I have already done tests using my script for recording and it works. Below is a code snippet example:

   # callback function that handles writing to the bag file
   # makes use of 'mutex = Lock()' to acquire and release when the file is being written to
   def tasks_cb(task_msg):

    # subscribe to the topic and call tasks_cb
    tasks_stat = rospy.Subscriber('/tasks/status',
edit flag offensive delete link more


Just trying to understand this: are you using rosbag (ie: the command line tool), or a custom script that makes use of the rosbag infrastructure (ie: the Python/C++ libraries)?

Concurrent publishing to the same topic should not matter for rosbag (the tool).

gvdhoorn gravatar image gvdhoorn  ( 2018-04-24 04:00:41 -0600 )edit

The rosbag binary as I mention above is the command line tool. You're right that concurrent publishing to the same topic SHOULDN'T matter for rosbag. But it does and it did for my experiments. If you wish to replicate it I suggest using +3 machines connected via FKIE publishing to the same topic.

Tiz gravatar image Tiz  ( 2018-04-24 04:24:08 -0600 )edit

Seeing as you report this same setup as working under Indigo this might be a regression. It would be good to report it over at ros/ros_comm/issues.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-24 04:27:32 -0600 )edit

Thanks for the advice. I was considering this, but I wasn't sure it is a significant issue. I might report it later when I have time to sit down and explain the problem in a more concise way.

Tiz gravatar image Tiz  ( 2018-04-24 04:38:42 -0600 )edit

Question Tools



Asked: 2018-04-10 11:48:55 -0600

Seen: 657 times

Last updated: Apr 23 '18