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

Problems with communication between multiple machines

asked 2017-03-03 05:25:44 -0500

wicked88 gravatar image

updated 2017-03-12 06:23:02 -0500

gvdhoorn gravatar image

So, i have this setup in my ros network:

My PC (172.16.49.9) as a publisher of the topic /controlInfo
Robot's PC (172.16.49.1 aka 172.17.1.1) as the ROS Master
Raspberry Pi hardware module (172.17.1.10) as subscriber of the topic /controlInfo

Pi is connected to Robot's PC through ethernet on the 172.17.x.x network. In both Pi and Robot's PC i can list all the nodes, see that /controlInfo is subscribed by 172.17.1.10 and published by 172.16.49.9, and whenever i publish data, i can echo-it in Robot's PC (so, the data reaches the master), but i can't echo-it in Pi.

What's the problem here ? Since i can successfuly communicate between the Robot's PC and the Pi, i can list and everything seems to be correctly setup, why u no work ???

--- EDIT

I made a new test on the machines, as my PC is providing the WLAN for the robot's PC. So, my pc has now ip 172.16.49.254, Robot's PC and Raspberry remains the same. My PC communicates with Robot's PC through WLAN and the raspberry is connected to Robot's PC by ethernet. I made a call to rosnode info (node in raspberry) from the Robot's PC and everything is ok. I made the same command from my PC and, although i can get a lot of info (which stuff it subscribes/publishes) it gives me an error : (pi_hw node is inside raspberry pi, and Robot's PC is the ROS_MASTER, all ROS_IP's are correctly set).

Node [/pihw_node] 
Publications:
* /rosout [rosgraph_msgs/Log]
* /hardwareInfo [minho_team_ros/hardwareInfo]

Subscriptions: 
* /teleop [unknown type] 
* /controlInfo [unknown type]

Services: 
* /requestIMULinTable 
* /requestOmniProps 
* /pihw_node/get_loggers
* /requestKick 
* /pihw_node/set_logger_level 
* /requestResetIMU

contacting node http://172.17.1.10:33608/ ... 
ERROR: Communication with node[http://172.17.1.10:33608/] failed!

It seems i can fetch information about the node (because it may be stored somewhere in Robot's PC) but i cant communicate with Raspberry because my PC can't reach her. I can successfully communicate from my PC to Robot's PC and from Robot's PC to Raspberry.

--- EDIT

Network scheme. It seems My PC and Raspberry need to communicate directly in order for this to work, so i will probably need ip routing.

image description

WLAN : 172.16.49.0/24 Robot's PC Ethernet : 172.17.0.0/16

PC          IP           ROS_MASTER_URI  ROS_IP       ROS_HOSTNAME
My PC       172.16.49.9  172.16.49.1     172.16.49.9  pedro K52Jc
Robot's PC  172.16.49.1  172.16.49.1     172.16.49.1  robot1
Rasp        172.17.1.10  172.16.49.1     172.17.1.10  rasphw1

I truly believe that the only problem here is that Rasp cannot reach directly My PC, so they dont communicate, and it is a normal thing (that they cant reach each other) but i thought ... (more)

edit retag flag offensive close merge delete

Comments

Please add the values of ROS_IP, ROS_HOSTNAME and ROS_MASTER_URI for all involved computers to your question description (edit it). Also please tell us whether you have a dedicated DNS server, a (consumer) rounter or are relying on something like Bonjour or a similar service.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-03 05:42:17 -0500 )edit

Hi. The master in all of them is http://172.16.49.1 (Robot's PC). Im using a consumer router and im not using ROS_HOSTNAME. The weird thing is that the pi node subscribes the node in Robot's pc but doesnt receive the data. For this to happen usually the ROS_IP and master uri have to be set correctly

wicked88 gravatar image wicked88  ( 2017-03-03 07:13:37 -0500 )edit
1

You haven't told us what the values are of ROS_IP on each of the hosts involved.

In most of these cases the involved hosts don't agree on the names that they have and / or report (ie: machine1 broadcasts machine1, but machine2 knows it under machine1.some.domain). Using ROS_IP avoids this.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-03 07:40:48 -0500 )edit

Hi, in my pc ROS_IP is set to 172.16.49.9, in Pis is set to 172.17.1.0 and in Robot's PC to 172.16.49.1 (ethernet ip is 172.17.1.1). Will check on that data on monday and get back gere

wicked88 gravatar image wicked88  ( 2017-03-04 03:46:54 -0500 )edit

Pis is set to 172.17.1.0

Is that a typo? Should it read .10?

gvdhoorn gravatar image gvdhoorn  ( 2017-03-04 04:13:50 -0500 )edit

Yep, it is .10 sorry

wicked88 gravatar image wicked88  ( 2017-03-04 10:44:24 -0500 )edit

@wicked88: the postimg link doesn't work. Could I also ask you to attach images to your question directly? I've given you enough karma to do so.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-12 04:18:41 -0500 )edit

all ROS_IP's are correctly set

I appreciate your confidence (and I haven't seen your network diagram yet), but isn't this what we're trying to ascertain? :) "Assumptions are .." etc. Could you add a table with ROS_IP, ROS_HOSTNAME, ROS_MASTER_URI and IP and hostname of all involved hosts?

gvdhoorn gravatar image gvdhoorn  ( 2017-03-12 04:20:49 -0500 )edit

2 Answers

Sort by » oldest newest most voted
4

answered 2017-03-12 06:25:45 -0500

gvdhoorn gravatar image

updated 2017-03-12 06:33:08 -0500

I truly believe that the only problem here is that Rasp cannot reach directly My PC, so they dont communicate, and it is a normal thing (that they cant reach each other) [..]

Now that we can see your network diagram: yes, this is a routing problem. Your RPi and your PC are not on the same network, and without "robot's PC" routing between the two networks, they won't be able to communicate.

This is indeed "a normal thing".

but i thought the master acted as a "router"

No, it doesn't. The master is only really involved in discovery and setup of connections between nodes. Dataflows between nodes are direct, the master is not involved.


Edit: you could try adding static routes on both My PC and RPi telling them how to get to the 172.16.49.0 and 172.17.1.0 networks. Robot's PC would then function as the router.

edit flag offensive delete link more

Comments

See #q256435 for a similar question (almost a duplicate really).

gvdhoorn gravatar image gvdhoorn  ( 2017-03-12 06:27:04 -0500 )edit

@gvdhoorn i've read that before ! I will try some options to setup the routing process and hope for the best ! Do you have any experience in doing that ?

wicked88 gravatar image wicked88  ( 2017-03-12 06:59:52 -0500 )edit

@gvdhoorn i managed to set up ip forwarding rules for my Robot's PC and i can successfully receive data from My PC in Raspberry ! link text. Although, i still can't receive data from the PI, (Pc dont ping Pi, but Pi pings PC).

wicked88 gravatar image wicked88  ( 2017-03-12 07:38:45 -0500 )edit

Masquerading (NAT) is exactly what you don't want in this case. You need plain IP forwarding. See whether

sudo route add -net 172.16.49.0 netmask 255.255.255.0 gw 172.17.1.1

on RPi and

sudo route add -net 172.17.1.0 netmask 255.255.0.0 gw 172.16.49.1

on My PC works.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-12 08:18:27 -0500 )edit

Make sure to undo what you did with iptables.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-12 08:19:49 -0500 )edit

@gvdhoorn it can be somehow useful to have the NAT on the Robot's PC because it will allow me to SSH into the Raspberry to, perhaps, update its software with the online connection provided by the masquerade !

wicked88 gravatar image wicked88  ( 2017-03-12 08:35:27 -0500 )edit
0

answered 2017-03-12 08:31:11 -0500

wicked88 gravatar image

@gvdhoorn i managed to do it. I kept those Ip tables commands i did and i just added to My PC :

sudo route add -net 172.17.1.0 netmask 255.255.0.0 gw 172.16.49.1

I'm grateful for your help, this case is closed !

[Summing up for future visitors of this question]

On ROS_MASTER PC, set IP forwarding between eth0 and wlan0, being wlan0 the output interface (like if we wanted to share internet over ethernet connected devices). This step is enough for Raspberry to reach any IP in the WLAN. On host PC (My PC in this case) just add a route to the Raspberry, having the Robot's PC as the gateway.

sudo route add -net ETHERNET_NETWORK_IP netmask ETHERNET_NETWORK_MASK gw ROBOT_PC_IP
edit flag offensive delete link more

Comments

Clients (svc, subs) will most likely not be able to reach servers (svc, pubs) if they are on the 'wrong' side of the NAT with your setup (unless you have a bi-directional NAT, which is unusual).

gvdhoorn gravatar image gvdhoorn  ( 2017-03-12 08:48:49 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-03 05:25:44 -0500

Seen: 6,816 times

Last updated: Mar 12 '17