0
$\begingroup$

Rosanswers logo

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?


Originally posted by wt70707 on ROS Answers with karma: 11 on 2016-12-13

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

  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.


Originally posted by ahendrix with karma: 47576 on 2016-12-13

This answer was ACCEPTED on the original site

Post score: 7


Original comments

Comment by wt70707 on 2016-12-14:
Thanks a lot!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.