Ask Your Question

rospy subscriber buffer length

asked 2013-03-09 16:58:48 -0500

Sentinal_Bias gravatar image

updated 2013-03-09 17:59:33 -0500


This is from the C++ subscriber tutorial

   * The second parameter to the subscribe() function is the size of the message
   * queue.  If messages are arriving faster than they are being processed, this
   * is the number of messages that will be buffered up before beginning to throw
   * away the oldest ones.
  ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);

In the python tutorial it is

rospy.Subscriber("chatter", String, callback)

//This declares that your node subscribes to the chatter topic which is of type std_msgs.msgs.String. When new messages are received, callback is invoked with the *message as the first argument.

I am wondering if the python version supports a message queue?

Also why is the same method different between C++ and Python for instance in the python subscriber you have to declare what type of message you are subscribing to...

Is this because python is an interpreted language?

Also do you find it easier to code in python over C++ in terms of development time for a ROS project?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-09 21:58:54 -0500

fergs gravatar image

In rospy, queue_size can be used a named parameter:

x = rospy.Subscriber("topic_name", String, callback, queue_size = 10)

See the API docs for rospy. I think this is considered an advanced topic that isn't frequently used, and as such hasn't really been covered in the tutorials.

edit flag offensive delete link more


Oh i see, it was in the C++ tutorial, the API mentioned that there could be problems if multiple nodes subscribe to the topic, which wont be a problem in my case. Well this is good i guess i can remove my circular buffer code.

Sentinal_Bias gravatar image Sentinal_Bias  ( 2013-03-09 23:14:25 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-03-09 16:58:48 -0500

Seen: 5,716 times

Last updated: Mar 09 '13