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

subscriber callback

asked 2014-04-23 02:34:10 -0500

dneuhold gravatar image

Hi guys,

I am using a subscriber with a callback. It works fine for a while but then the program suddenly stops. My process does not die but stops/freezes.

This is what I do ...

sub = nh.subscribe("topic_name", 10000, &Callback, this);


I operate two robots with the same code and most of the time one stops receiving data from the callback. The other one proceeds as suggested. I realized that the subscribing works but the process freezes during the spinOnce().

Does anyone have an idea?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-04-23 04:38:33 -0500

dornhege gravatar image

You are only using spinOnce. This will only handle messages once. If you want to continuously receive messages call this in a loop or use ros::spin.

edit flag offensive delete link more


I just need to receive messages once at this position. The strange part is that the program stops/freezes after executing the nh.subscribe.

dneuhold gravatar image dneuhold  ( 2014-04-23 05:20:58 -0500 )edit

Can you try setting the queue size to 1.

dornhege gravatar image dornhege  ( 2014-04-23 05:29:18 -0500 )edit

Question Tools

1 follower


Asked: 2014-04-23 02:34:10 -0500

Seen: 332 times

Last updated: Apr 23 '14