Ask Your Question

SubscriberStatusCallback not called in talker node

asked 2021-05-13 14:43:32 -0500

Ugesh gravatar image

updated 2021-05-15 09:13:51 -0500

Hi, I am trying to implement the simple listener and talker as explained in ROS tutorial link but I have done a small modification, the publishing to the topic will happen, whenever the listener node connects to the talker, otherwise the message will not be published.

Please check the below talker node implementation but some how the callback is not triggered whenever the listener is subscribed to the topic.

void Publisher::CreateTopic(const std::string &topicname, const std::size_t &queue)
    const ros::SubscriberStatusCallback callback_conn = std::bind(&Publisher::SubscriberStatusCallback_connect, this, std::placeholders::_1);
    const ros::SubscriberStatusCallback callback_discon = std::bind(&Publisher::SubscriberStatusCallback_Disconnect, this, std::placeholders::_1);
    chatter_pb = handle.advertise<std_msgs::String>(topicname, queue, callback_conn, callback_discon);
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-05-15 21:45:11 -0500

Ugesh gravatar image

I have found the reason, I have used the ros::spinOnce(); instead of ros::spin() so no callbacks are processed incase of ros::spinOnce() is used.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2021-05-13 14:34:18 -0500

Seen: 23 times

Last updated: May 15