ros2_rust
ros2_rust copied to clipboard
Minimal publisher does not receive messages from message_demo
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.
I pushed the modified minimal pub/sub to the issue_241 branch.
fyi @ros2-rust/dev
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));
}
Interesting @jhdcs, though of course it should also work if we don't loop.
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.
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.