ros_comm icon indicating copy to clipboard operation
ros_comm copied to clipboard

some fixes for the --repeat_latched option

Open 1r0b1n0 opened this issue 3 years ago • 7 comments

This should fix some problems with #1850 : 1 The repeat_latched member variable bool was left in an uninitialized/random state. On my machine, even without specifying "--repeat_latched", it was sometimes activated.

2 When repeating the latched messages in splitted bags, these should still be published as latched.

Steps to reproduce : Start the following in several terminals :

  • roscore
  • publish a latched topic : rostopic pub -l /chatter_latched std_msgs/String "data: 'blabla'"
  • publish a periodic topic : rostopic pub -r 2 /periodic std_msgs/Empty
  • launch a rosbag record : rosrun rosbag record -a --repeat-latched --duration 5 --split

after ~15 seconds stop all the nodes and the rosbag record

without the fix : when playing a splitted bag rosrun rosbag play [...]_1.bag -s 2 : running rostopic echo /chatter_latched will show nothing

with this fix : when playing a splitted bag rosrun rosbag play [...]_1.bag -s 2 : running rostopic echo /chatter_latched will show the message, because it is latched

1r0b1n0 avatar Nov 04 '21 08:11 1r0b1n0

Nice catch, thx a lot! My 2c: I guess I would prefer the initialization to set the repeat_latched to true. As such, every bag is "contained" in itself by default. Or are there points against that?

https://github.com/ros/ros_comm/blob/785826e1235182046d7b44026208f9633a9112a8/tools/rosbag/src/recorder.cpp#L100

tkazik avatar Jan 17 '22 13:01 tkazik

Hi, I agree in my opinion the better choice would be to enable repeat_latched by default. In this case the "--repeat-latched" option can be removed/ignored.

1r0b1n0 avatar Feb 09 '22 09:02 1r0b1n0

Can this be merged please? It contains essential fixes.

Martin-Oehler avatar May 06 '22 10:05 Martin-Oehler

Hi @mjcarroll what do you think about this? Should we enable repeat-latched by default and remove the argument or keep the choice? At least, the uninitialized variable issue should be merged, this is a bugfix. Do you want a separate PR?

romainreignier avatar Feb 13 '23 13:02 romainreignier

At least, the uninitialized variable issue should be merged, this is a bugfix. Do you want a separate PR?

Yes please, I have no issues with that part. I'll need a moment to think about the other part.

mjcarroll avatar Feb 13 '23 14:02 mjcarroll

I created #2314 that will only fix the undefined variable.

1r0b1n0 avatar Feb 15 '23 08:02 1r0b1n0

This PR has now been updated to only include the connection_header when writing a latched topic to a bag file. This allows to keep the latched info so rosbag play can publish it as latched.

romainreignier avatar Feb 20 '23 09:02 romainreignier