When exactly is a connect callback of a publisher called?
Hi all,
I would like to know when precisely the connect_cb
is being invoked, specified in
Publisher ros::NodeHandle::advertise(const std::string & topic,
uint32_t queue_size,
const SubscriberStatusCallback & connect_cb,
const SubscriberStatusCallback & disconnect_cb = SubscriberStatusCallback(),
const VoidConstPtr & tracked_object = VoidConstPtr(),
bool latch = false
)
(see http://docs.ros.org/melodic/api/roscp...). More specifically, I know that if I do a NodeHandle:advertise()
, the underlying (TCP) connection is not established directly, i. e., upon returning from advertise()
, subscribers may not already be connected even if they are already "there" (= known to the master) since this clearly also takes time. So, publishing messages right after the advertise()
can causes messages not being received by all "relevant nodes" at that time. (IIRC, this issue has been discussed frequently here on ros.answers.org and one nasty workaround is a delay after the advertise.) Assume I know about the existance of another node that will eventually/finally subscribe to the advertised topic. (Please, I don't want to discuss here that this may not be the idea of a decoupled communication concept, i.e., what pub/sub was designed for.)
TL;DR: Is it safe to assume that once the above mentioned connect_cb
is triggered, the underlying TCP connection _must_ have been established so that publishing messages using the returned ros::Publisher
object will definitely deliver the message to the node denoted by ros::SingleSubscriberPublisher::getSubscriberName()
(= argument of the callback)?
I was already grep'ping through ROS' source code but was not able to find the location where the callbacks are being invoked.
Thanks you very much!