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

Revision history [back]

click to hide/show revision 1
initial version

As Kircheis answered in this question, you can set the message queue size when you add a message listener to your subscriber.

The rosjava Listener.java tutorial creates a listener like this:

Subscriber<std_msgs.String> subscriber = connectedNode.newSubscriber("chatter", std_msgs.String._TYPE);
subscriber.addMessageListener(new MessageListener<std_msgs.String>() {
  @Override
  public void onNewMessage(std_msgs.String message) {
    log.info("I heard: \"" + message.getData() + "\"");
  }
});

When adding the message listener, you can specify a queue size:

int queueSize = 10;
subscriber.addMessageListener(new MessageListener<std_msgs.String>() {
  @Override
  public void onNewMessage(std_msgs.String message) {
    log.info("I heard: \"" + message.getData() + "\"");
  }
}, queueSize);

If you do not specify a queue size, the default size is 1.