Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add latching field to header #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jobafr
Copy link

@jobafr jobafr commented May 21, 2024

When recording the output of rosrust based nodes using rosbag, the connection header inside the rosbag file contains an empty latching= field, because this field is missing from the original connection header sent by rosrust's publisher.

While upstream rosbag supports parsing this (and interprets it the same as latching=0),

  • The information that a publisher was latching at runtime is lost
  • rosbag-rs (rust parser for rosbag files) outright refuses to parse the connection header, rendering all messages sent by the publisher inaccessible.

rosbag-rs issues:

Code to reproduce the behavior:

rosrust::rosmsg_include!(std_msgs / String,);

fn main() {
    rosrust::init("rosrust_test");

    let publisher_unlatched = rosrust::publish("chatter_unlatched", 1).unwrap();
    for i in 0..=10 {
        publisher_unlatched
            .send(std_msgs::String {
                data: format!("hello unlatched {}", i),
            })
            .unwrap();
        std::thread::sleep(std::time::Duration::from_millis(200));
    }

    let mut publisher_latched = rosrust::publish("chatter_latched", 1).unwrap();
    publisher_latched.set_latching(true);
    for i in 0..=10 {
        publisher_latched
            .send(std_msgs::String {
                data: format!("hello latched {}", i),
            })
            .unwrap();
        std::thread::sleep(std::time::Duration::from_millis(200));
    }
}

Without the patch, the bagfiles end up with an empty latching= header. With the patch, it's either latching=0 or latching=1, depending on whether the publisher was latched or not.

@jobafr
Copy link
Author

jobafr commented Aug 28, 2024

Update: Although rosbag-rs has since merged a PR that makes their parser work with the malformed header, I think this should still be merged here. The information whether a publisher is latched can be useful for all sorts of tools, and can for example be accessed by subscribers through the rospy API (sub.impl.connections[0].is_latched).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant