Open fgadaleta opened 7 months ago
First 2 messages are sent and never received. Why?
Most likely this is due to too relaxed QoS settings.
When both ROS 2 Nodes (under the hood: DDS DomainParticipants) are running, it takes some seconds for Discovery to operate and match (connect) the Publisher to Subscriber. Samples sent during this time are lost.
If you want to receive samples published before the match was made, use e.g. the following QoS:
let reliable_qos = ros2::QosPolicyBuilder::new()
.history(policy::History::KeepLast { depth: 10 })
.reliability(policy::Reliability::Reliable {
max_blocking_time: ros2::Duration::from_millis(100),
})
.durability(policy::Durability::TransientLocal)
.build();
Important elements here are Reliable, TransientLocal, and some reasonable History depth.
Please report if this works for you.
I tried to "play" with such settings on the publisher QoS without success. Without durability the listener receives after ~3 seconds (and misses all the messages until then) With durability the listener blocks after 4 messages.
You need to set reliability = Reliable at both Publisher and Subscriber.
By the DDS specification, using Reliable Publisher and BestEffort Subscriber will match and transmit data, but the connection is BestEffort, and the samples sent during Discovery process are lost.
https://github.com/jhelovuo/ros2-client/blame/db85ada1b9b507c2d4173cb9f8ffba8c42841b23/examples/talker/main.rs#L56C4-L56C4