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

rospy subscriber buffer length

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

Sentinal_Bias gravatar image

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

Hi

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

2 Answers

Sort by ยป oldest newest most voted
3

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

fergs gravatar image

updated 2021-08-26 12:35:47 -0500

lucasw 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

Comments

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
-1

answered 2021-08-03 19:50:13 -0500

For your question about which is easier to code, In my opinion as a newbie myself the answer is python Because: - it doesn't require you to modify package.xml whenever you make an executable - you don't have to catkin_make every time you want to update your code - python is easier when it comes to image processing :D

edit flag offensive delete link more

Question Tools

Stats

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

Seen: 6,921 times

Last updated: Aug 26 '21