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

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);

Subscriber:

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

I appreciate your help.

edit retag flag offensive close merge delete

Comments

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
1

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

duck-development gravatar image

end you main with a

ros::spin();

you may read this http://wiki.ros.org/ROS/Tutorials/Wri... ros::spin();

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 134 times

Last updated: Oct 16 '20