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

Revision history [back]

Your callback is publishing on the same topic it is listening on, so the first time it receives anything it will publish and trigger it self forever:

...

rostopic hz /same_topic subscribed to [/same_topic] average rate: 18782.573 (!)

The queue size is just one so only randomly can a competing publisher inject a message into the infinite loop, it has to beat the self published message into the queue.

Your callback is publishing on the same topic it is listening on, so the first time it receives anything it will publish and trigger it self forever:

[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] [ I got some data]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[14] [I heard this data: [0]]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] [ I got some data]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[14] [I heard this data: [0]]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] [ I got 
...

rostopic hz /same_topic subscribed to [/same_topic] average rate: 18782.573 18782.57

3

(!)

The queue size is just one so only randomly can a competing publisher inject a message into the infinite loop, it has to beat the self published message into the queue.

Your callback is publishing on the same topic it is listening on, so the first time it receives anything it will publish and trigger it self forever:

[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] [ I got some data]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[14] [I heard this data: [0]]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] [ I got some data]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[14] [I heard this data: [0]]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] [ I got 
...

It prints out fine on my system, but maybe yours can't keep up with it?

rostopic hz /same_topic
subscribed to [/same_topic]
average rate: 18782.57

3

(!)

The queue size is just one so only randomly can a competing publisher inject a message into the infinite loop, it has to beat the self published message into the queue.

Your callback is publishing on the same topic it is listening on, so the first time it receives anything it will publish and trigger it self forever:

[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] :[17] [ I got some data]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[14] :[14] [I heard this data: [0]]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] :[17] [ I got some data]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[14] :[14] [I heard this data: [0]]
[[/node] [/home/lucasw/ros/answers_catkin_ws/src/tmp/src/recurse.cpp]:[17] :[17] [ I got 
...

It prints out fine on my system, but maybe yours can't keep up with it?

rostopic hz /same_topic
subscribed to [/same_topic]
average rate: 18782.57

(!)

The queue size is just one so only randomly can a competing publisher inject a message into the infinite loop, it has to beat the self published message into the queue.