ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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

miura gravatar image

Hi, I am trying to implement the simple listener and talker as explained in ROS tutorial link http://wiki.ros.org/ROS/Tutorials/Wri... 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
0

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

Question Tools

3 followers

Stats

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

Seen: 75 times

Last updated: May 15 '21