ros2_rust icon indicating copy to clipboard operation
ros2_rust copied to clipboard

Minimal publisher does not receive messages from message_demo

Open nnmm opened this issue 3 years ago • 5 comments

The message_demo package sends two messages of type rclrs_example_msgs::msg::VariousTypes on the topic "topic". When the minimal_subscriber is modified to receive messages of that type, however, none are received when the message_demo runs.

When it's the minimal_publisher that publishes those messages, they are received fine.

It's not because of QoS settings, they both use the default. It's also not because the message_demo exits too soon – adding a thread::sleep() at the end doesn't make a difference.

nnmm avatar Jul 31 '22 16:07 nnmm

I pushed the modified minimal pub/sub to the issue_241 branch.

nnmm avatar Jul 31 '22 16:07 nnmm

fyi @ros2-rust/dev

nnmm avatar Aug 01 '22 11:08 nnmm

If you put the publishing portion of your message_demo into a while loop, the subscriber seems to be able to detect it.

while context.ok() {
    println!("Sending idiomatic message.");
    idiomatic_publisher.publish(rclrs_example_msgs::msg::VariousTypes::default())?;
    rclrs::spin_once(&node, None)?;
    println("Sending RMW-native message.");
    direct_publisher.publish(rclrs_example_msgs::msg::rmw::VariousTypes::default())?;
    rclrs::spin_once(&node, None)?;
    std::thread::sleep(std::time::Duration::from_millis(1000));
}

jhdcs avatar Aug 01 '22 13:08 jhdcs

Interesting @jhdcs, though of course it should also work if we don't loop.

nnmm avatar Aug 01 '22 18:08 nnmm

I tried adding a sleep

  • after the context creation
  • after the node creation
  • after the publisher creation

I found out that only cases 2 and 3 work. So, something about node creation seems to be lagging behind, probably inside FastRTPS, since I don't think rcl or rmw do something weird/asynchronous during node creation.

nnmm avatar Aug 16 '22 11:08 nnmm

Update (I thought of this long ago but did not write it down): I think this is just a case of discovery of remote publishers/subscriptions taking a bit of time, which is expected.

nnmm avatar Oct 15 '22 13:10 nnmm