0
$\begingroup$

Rosanswers logo

Hello folks,

I'm trying to connect a publisher node which is on Windows and a subscriber node on Ubuntu where a master node is on Raspbian; Windows PC(publisher) - Raspbian RaspberryPi(master) - Ubuntu PC(subscriber). (I just ported ros_comm and several core libraries to Visual Studio environment.)

The problem is, when I run a subscriber node on Windows PC and publisher node on Ubuntu PC, it worked. However, when the publisher-subscriber order is reversed (Windows PC has a publisher.. vice versa) it doesn't seem to work. The nodes are listed correctly through rostopic list command.

My question is, how the subscriber node and publisher node are connected in socket level? Does subscriber connect to publisher which is running as server? or both connect to each others?

Thanks a lot in advance. I've been helped so much from this gorgeous forum.

Antonio

----------------------Resolved---------------------------------------------------------------------------------------------------------------- For people who would encounter problems like this I leave this message.

I found that I set the ROS_HOSTNAME in Windows which was ip-formatted string(ex. 1.1.20.20). It was even wrong ip.

In ROS, host ip address is resolved in this order: ROS_HOSTNAME -> ROS_IP -> gethostname ...

So be aware using env variables. If you use multiple machines connected via ROS, you must set above variables correctly .

In addition to that, you should off the firewall! :)

Useful reference for understanding how connections are established: source code - ros_comm/ publication.cpp, subscription.cpp and related codes.

Below is technical overview doc in ROS wiki. This illustrates well how connections are made. http://wiki.ros.org/ROS/Technical%20Overview image description http://wiki.ros.org/ROS/Technical%20Overview?action=AttachFile&do=get&target=master-node-example.png


Originally posted by Kay Park on ROS Answers with karma: 25 on 2016-06-15

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Hey,

So I went over the ROS Documentation and this is what I understood from it.

As the documentation says,

publish() in roscpp is asynchronous, and only does work if there are subscribers connected on that topic. publish() itself is meant to be very fast, so it does as little work as possible:

  1. Serialize the message to a buffer
  2. Pushes that buffer onto a queue for later processing

The queue it's pushed onto is then serviced as soon as possible by one of roscpp's internal threads, where it gets put onto a queue for each connected subscriber -- this second set of queues are the ones whose size is set with the queue_size parameter in advertise(). If one of these queues fills up the oldest message will be dropped before adding the next message to the queue.

It looks like the publisher and the subscriber do not directly interact. Instead, they use two queues. Publisher simply pushes data to q1 and the subscriber retrieves data from q2. Data transfer from q1->q2 is implicit and taken care of by the roscpp internals.

I'm not sure what you mean by the socket level connection between the subscriber and the publisher but I don't think there is such a connection between those two like client - server. Instead, both the subscriber and publisher will be connecting to the ROS master.


Originally posted by janindu with karma: 849 on 2016-06-15

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Kay Park on 2016-06-15:
I surfed source codes in ros_comm and found that they(sub & pub) made connection .

The description you quoted seems right but based on code content the queues seem to be managed in nodes. (check out pendingConnectionDone method in subscription.cpp )

Thank you very much for investing your time!

Comment by janindu on 2016-06-16:
Yes. Thank you. I'm reading more into this and learned a lot of new stuff. So apparently data does not go through the master. Master only provides names of publishers to subscribers so that the subscriber can directly connect to the publisher using TCP/UDP. I had a completely wrong understanding

Comment by chukcha2 on 2016-09-06:
Am I misunderstanding the quoted text from documentation, or does it really say that queue_size parameter in advertise() sets the size of q2. I expected that is would set the size of q1. I'd expect that q2 size would be set by subscribe()'s queue_size parameter. What am I missing?

Comment by janindu on 2016-09-06:
queue_size parameter in advertise() sets the size of q1 and in subscribe() sets q2.

Comment by chukcha2 on 2016-09-07:
Thanks @janindu. So the doc quoted above is wrong/misleading.

Comment by janindu on 2016-09-07:
Not really. I think there's a miscommunication here. q1, q2 are mentioned in my explanation of the document quote. Doc is right.

Comment by chukcha2 on 2016-09-08:
To me it sounds like the doc (wrongly) says that queue_size parameter in advertise() controls the "second set of queues" that you call q2 (the one the message is moved to by internal roscpp thread). I think it should say that the parameter controls the size of the queue that publish() pushes onto.

Comment by chukcha2 on 2016-09-12:
FYI. I asked this question explicitly here

$\endgroup$
0
$\begingroup$

Rosanswers logo

I think roscore's master node manage the activity of subscriber node and publisher node. your problem is not only the node, but also multi systems to communicate with each other. maybe you need to care about master and slave machines.


Originally posted by asimay_y with karma: 255 on 2016-06-15

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Kay Park on 2016-06-15:
Yes I should check the system itself other than just checking out ROS.

Thank you very much for investing your time!

$\endgroup$

Your Answer

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