Ask Your Question
0

How can publish in TCP while subscribe in UDP?

asked 2016-12-13 16:37:26 -0500

wt70707 gravatar image

updated 2016-12-13 16:45:47 -0500

I have a question on TCP and UDP. As I need do close loop control with message published on ROS: the robot will collect LIDAR data and send to laptop through the topic mechanism; the control variable should publish from the laptop to the robot also through the topic mechanism.

  1. After some study, it seems I should choose UDP, not TCP_NODELAY and surely not TCP. As the default is TCP, so transport hints should be used [ros::Subscriber sub = nh.subscribe("my_topic", 1, callback, ros::TransportHints().udp())]. My question here is on wiki it says "You cannot currently specify the transport hints on the Publisher side. This will likely be an option in the future", if on the publisher side it is still TCP, how can UDP built at the subscribe side? As I understand, UDP means publisher will publish without care if there is connection, am I right?

  2. It also says "The UDP-based transport, which is known as UDPROS and is currently only supported in roscpp, separates message into UDP packets". Does this mean I cannot subscribe using UDP in python program, right?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2016-12-13 19:50:34 -0500

ahendrix gravatar image

1) the publisher can't set the transport type at all; it negotiates the transport based on it's capabilities and what the subscriber requests. This means that if a subscriber requests UDP, and the publisher can publish UDP, the connection between that publisher and that subscriber will be UDP. (other subscribers to the same publisher negotiate separately, so they may use TCP)

2) correct; ROS will not negotiate a UDP connection, and will instead use TCP if the publisher or the subscriber is python.

Also note that if your message size is larger than the UDP MTU, ROSUDP will break your message into multiple UDP packets, and if any of those packets are lost, the entire message is lost. You should do some basic statistics based on your packet loss and number of fragments for each message to determine the resulting message drop rate.

edit flag offensive delete link more

Comments

Thanks a lot!

wt70707 gravatar imagewt70707 ( 2016-12-14 10:12:53 -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

3 followers

Stats

Asked: 2016-12-13 16:37:26 -0500

Seen: 2,090 times

Last updated: Dec 13 '16