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

UDP connection setting

asked 2011-11-24 06:10:33 -0600

Keiya gravatar image

updated 2014-01-28 17:10:52 -0600

ngrennan gravatar image

Hi there,

I am trying to get the video stream from camera of robot via UDP connection. I use follow subscriber;

ros::Subscriber sub_image = nh.subscribe("get/image", 1, imageCallback, ros::TransportHints().udp());

This code should select UDP connection.
However, bellow message sometimes appears.

a message of over a gigabyte was predicted in tcpros...

And, I checked the connection status by ping, but UDP connection was not used.
How do I set connection as UDP and check connection setting? I think ros::TransportHints().udp() is not enough to do that.

Thanks in advance,
Keiya

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
5

answered 2011-11-27 21:59:16 -0600

If you are transmitting uncompressed images, UDP is probably a bad idea anyway, especially if anything wireless is involved.

A 640x480 image with RGBA color amounts to 1.2M data. Assuming a frame size of 1500 bytes per packet, you have to transmit about 820 packets per image. UDP has no fail-safe for transmission errors. Assuming a packet loss rate of 0.1%, you have just a 44 percent (0.999^820) chance of transmitting a single image intact.

edit flag offensive delete link more

Comments

1
I am transmitting compressed image by image_transport republisher. The reason why I am trying to use UDP is that I do not care about frames of what happened seconds ago. But anyway, thank you for your advice!
Keiya gravatar image Keiya  ( 2011-11-27 22:38:13 -0600 )edit
You could limit the subscriber queue size, or even better, throw away frames which are too old based on the message timestamp.
roehling gravatar image roehling  ( 2011-11-28 02:03:57 -0600 )edit
2

answered 2011-11-28 00:44:25 -0600

dornhege gravatar image

updated 2011-11-28 00:44:37 -0600

One reason that setting udp but getting TCP is that it is only a transport hint, i.e., if UDP isn't available for some reason, it will fallback to TCP. Maybe that is what happened.

edit flag offensive delete link more

Comments

You mean that I should do something except transport hint, do you? OK, I will check what is happened in my computer and network.
Keiya gravatar image Keiya  ( 2011-11-28 01:17:24 -0600 )edit
It's just a possible reason. As far as the documentation goes you cannot force this on the ROS site, but it should be taken if possible.
dornhege gravatar image dornhege  ( 2011-11-28 02:22:59 -0600 )edit
2

answered 2011-11-27 19:59:01 -0600

Thomas gravatar image

I think this is the right way to use UDP. However, I had troubles too with UDP when dealing with images. It seems that the UDP code is much more unstable than the TCP one. So for now I reverted to using TCP as I am lacking time to investigate further.

edit flag offensive delete link more

Comments

Do you also find the message "a message of over a gigabyte was predicted in tcpros..."?
Keiya gravatar image Keiya  ( 2011-11-27 22:39:14 -0600 )edit
Yes, I got it on Diamondback, I did not try again using Electric since.
Thomas gravatar image Thomas  ( 2011-11-28 19:35:04 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2011-11-24 06:10:33 -0600

Seen: 3,964 times

Last updated: Nov 28 '11