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

Sending subsequent messages in rosjava leads to message loss [solved]

asked 2013-08-23 04:27:07 -0600

Kircheis gravatar image

updated 2013-08-27 00:46:16 -0600

Hi!

I encountered some problems with the ROSJava listener. I have a very simple node in ROS that sends two subsequent messages through the same publisher/topic. When i'm looking at the topic through "rostopic echo" all messages are send in their order and none is lost. But the ROSJava Listener only gets the first message and occasionally the second. Some of the messages appear to be lost. When i'm putting manually some time in between the two publish attempts the listener starts receiving all messages in order and none is lost.

Heres a log example. Thats what i'm getting on the topic:

data: 1: Message_1
---
data: 1: Message_2
---
data: 2: Message_1
---
data: 2: Message_2
---
data: 3: Message_1
---
data: 3: Message_2
---
data: 4: Message_1
---
data: 4: Message_2
---
data: 5: Message_1
---
data: 5: Message_2
---
data: 6: Message_1
---
data: 6: Message_2
---
data: 7: Message_1
---
data: 7: Message_2
---
data: 8: Message_1
---
data: 8: Message_2
---
data: 9: Message_1
---
data: 9: Message_2
---
data: 10: Message_1
---
data: 10: Message_2
---
data: 11: Message_1
---
data: 11: Message_2
---
data: 12: Message_1
---
data: 12: Message_2
---
data: 13: Message_1
---
data: 13: Message_2
---
data: 14: Message_1
---
data: 14: Message_2
---
data: 15: Message_1
---
data: 15: Message_2
---
data: 16: Message_1
---
data: 16: Message_2
---
data: 17: Message_1
---
data: 17: Message_2
---
data: 18: Message_1
---
data: 18: Message_2
---
data: 19: Message_1
---
data: 19: Message_2
---
data: 20: Message_1
---
data: 20: Message_2
---
data: 21: Message_1
---
data: 21: Message_2
---
data: 22: Message_1
---
data: 22: Message_2
---
data: 23: Message_1
---
data: 23: Message_2
---
data: 24: Message_1
---
data: 24: Message_2
---
data: 25: Message_1
---
data: 25: Message_2
---
data: 26: Message_1
---
data: 26: Message_2
---
data: 27: Message_1
---
data: 27: Message_2
---
data: 28: Message_1
---
data: 28: Message_2
---
data: 29: Message_1
---
data: 29: Message_2

And heres what the listener gets:

INFO: I heard: "1: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "2: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "2: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "3: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "4: Message_1"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "4: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "5: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "6: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "7: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "8: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "9: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node.RosoutLogger info
INFO: I heard: "10: Message_2"
Aug 23, 2013 1:04:57 PM org.ros.internal.node ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-08-27 00:06:32 -0600

Kircheis gravatar image

updated 2013-08-27 00:47:04 -0600

So i found a solution. If you use the standard "addMessageListener" method for a subscriber than the internal queue size will be set to 1 (see for example DefaultSubscriber.java). Luckily you can set it yourself with the second "addMessageListener" method which offers a limit parameter. A simple int for the queue size.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-08-23 04:27:07 -0600

Seen: 957 times

Last updated: Aug 27 '13