Ask Your Question

Revision history [back]

It took me a while to figure out what the question is that you're asking, so let me rephrase it: You recorded a rosbag at 100 Hz, and when you replay it, rosbag sends the messages in bursts of 4. You would instead like rosbag to play each single message at once. Correct?

First: Do you really absolutely need to get the messages as fast as possible? Since everything is timestamped in ROS, I can not come up with a reason why you need that, especially when playing back a rosbag (there is no interaction with the external world in that case, so it doesn't really matter if there is a 30 ms delay in producing the answer). For this reason, I don't think this is a bug.

But if you really must try to change this, read on. Your first wireshark screenshot shows that it is indeed the publisher inside rosbag that buffers the messages, not the subscriber inside your test node. Perhaps it's because tcpNoDelay() is not set? Try enabling it in player.cpp:199.

It took me a while to figure out what the question is that you're asking, so let me rephrase it: You recorded a rosbag at 100 Hz, and when you replay it, rosbag sends the messages in bursts of 4. You would instead like rosbag to play each single message at once. Correct?

First: Do you really absolutely need to get the messages as fast as possible? Since everything is timestamped in ROS, I can not come up with a reason why you need that, especially when playing back a rosbag (there is no interaction with the external world in that case, so it doesn't really matter if there is a 30 ms delay in producing the answer). For this reason, I don't think this is a bug.

But if you really must try to change this, read on. Your first wireshark screenshot shows that it is indeed the publisher inside rosbag that buffers the messages, not the subscriber inside your test node. Perhaps it's because tcpNoDelay() is not set? Try enabling it in player.cpp:199.

P.S.: Some more comments:

  • rosbag -i doesn't do disable the buffer; instead, it makes rosbag speed up replay time as fast as it can, instead of running at the same speed as when the rosbag was recorded.
  • When playing back a rosbag, you should usually run rosparam set use_sim_time true, and call rosbag with the --clock option. For the screenshots you made it was correct not to do that (because it actually produced more useful log output), but in general you should always do it.

It took me a while to figure out what the question is that you're asking, so let me rephrase it: You recorded a rosbag at 100 Hz, and when you replay it, rosbag sends the messages in bursts of 4. You would instead like rosbag to play each single message at once. Correct?

First: I don't think this behavior by rosbag is a problem or a bug. Do you really absolutely need to get the messages as fast as possible? Since everything is timestamped in ROS, I can not come up with a reason why you need that, especially when playing back a rosbag (there is no interaction with the external world in that case, so it doesn't really matter if there is a 30 ms delay in producing the answer). For this reason, I don't think this is a bug.answer).

But if you really must try to change this, read on. Your first wireshark screenshot shows that it is indeed the publisher inside rosbag that buffers the messages, not the subscriber inside your test node. Perhaps it's because tcpNoDelay() is not set? Try enabling it in player.cpp:199.. This should reduce the delay, but be less efficient.

P.S.: Some more comments:

  • rosbag -i doesn't do disable the buffer; instead, it makes rosbag speed up replay time as fast as it can, instead of running at the same speed as when the rosbag was recorded.
  • When playing back a rosbag, you should usually run rosparam set use_sim_time true, and call rosbag with the --clock option. For the screenshots you made it was correct not to do that (because it actually produced more useful log output), but in general you should always do it.

It took me a while to figure out what the question is that you're asking, so let me rephrase it: You recorded a rosbag at 100 Hz, and when you replay it, rosbag sends the messages in bursts of 4. You would instead like rosbag to play each single message at once. Correct?

First: I don't think this behavior by rosbag is a problem or a bug. Do you really absolutely need to get the messages as fast as possible? Since everything is timestamped in ROS, I can not come up with a reason why you need that, especially when playing back a rosbag (there is no interaction with the external world in that case, so it doesn't really matter if there is a 30 ms delay in producing the answer).

But if you really must try to change this, read on. Your first wireshark screenshot shows that it is indeed the publisher inside rosbag that buffers the messages, not the subscriber inside your test node. Perhaps it's because tcpNoDelay() is not set? Try enabling it in player.cpp:199. This should reduce the delay, but be less efficient.

P.S.: Some more comments:

  • rosbag -i doesn't do disable the buffer; instead, it makes rosbag speed up replay time as fast as it can, instead of running at the same speed as when the rosbag was recorded.
  • When playing back a rosbag, you should usually run rosparam set use_sim_time true, right after starting the roscore, and call rosbag with the --clock option. For the screenshots you made it was correct not to do that (because it actually produced more useful log output), but in general you should always do it.