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

how do i set length of message queue for subscriber in rosjava?

asked 2015-02-19 10:06:26 -0500

stark gravatar image

In rosjava we don’t have access to set message queue on subscriber. So rosjava node is not receiving & executing messages in realtime. So anybody here has any workaround to resolve this issue?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2015-03-13 09:47:43 -0500

grieneis gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-19 10:06:26 -0500

Seen: 509 times

Last updated: Mar 13 '15