Ask Your Question

subscribe callback c not called (c++ )

asked 2020-10-15 17:53:08 -0500

Hussain gravatar image

I have a node publishing a topic in one computer(A). In another computer(B), I am running roscore and a node subscribing to the topic. I can echo the topic in computer B with no problems. I modified copy of listenner.cpp to make a subscriber. The callback never gets fired. Here are the relevant snippets: Publishing:

ros::Publisher level_pub = n.advertise<water_tank::Level>("Level", 1000);


ros::Subscriber sub = n.subscribe("Level", 1000, chatterCallback);

I appreciate your help.

edit retag flag offensive close merge delete


Please check and verify the NetworkSetup Guide in the wiki. Note that you need to set any environment variables in each terminal. Thus, if rostopic echo works, make sure it does in the same terminal as the node.

Also, additionally with rosnode info and rostopic info that everything is connected correctlly. roswtf might also help.

report back with the relevant findings (output, if you missed something in the guide, ...)

mgruhler gravatar image mgruhler  ( 2020-10-16 03:14:50 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-10-16 13:45:32 -0500

duck-development gravatar image

end you main with a


you may read this ros::spin();

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

1 follower


Asked: 2020-10-15 17:53:08 -0500

Seen: 37 times

Last updated: Oct 16