Ask Your Question
5

UDP connection setting

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

Keiya gravatar image

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

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

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 imageKeiya ( 2011-11-27 22:38:13 -0500 )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 imageroehling ( 2011-11-28 02:03:57 -0500 )edit
2

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

dornhege gravatar image

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

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 imageKeiya ( 2011-11-28 01:17:24 -0500 )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 imagedornhege ( 2011-11-28 02:22:59 -0500 )edit
2

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

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 imageKeiya ( 2011-11-27 22:39:14 -0500 )edit
Yes, I got it on Diamondback, I did not try again using Electric since.
Thomas gravatar imageThomas ( 2011-11-28 19:35:04 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 2,857 times

Last updated: Nov 28 '11