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

Connect two networks with one roscore

asked 2017-03-07 17:52:03 -0600

luator gravatar image

I have two computers on the robot which are directly connected via ethernet. Let's call them "R1" and "R2". The roscore is running on R1, some of the nodes are on R1, some are on R2. Connection between the two is fine (ROS_MASTER_URI on R2 is set to http://192.168.1.9:11311 ).

R1 is also connected to a wireless network. On this wireless network there is a third computer "PC".

image description

Now I want to run rviz on PC to monitor what is going on on the robot. For this I set ROS_MASTER_URI=http://172.168.1.100:11311 on PC. After this I can see all topics via rostopic list but when I call rostopic echo /topic, I only get messages on topics that are published from R1, not from those published on R2. Accordingly rviz only shows data from R1.

I assume that the problem is, that the connections PC <-> R1 and R1 <-> R2 are in different networks and that I would have to somehow forward messages between the networks. What is the best/easiest way to achieve this?

edit retag flag offensive close merge delete

5 Answers

Sort by » oldest newest most voted
4

answered 2017-03-08 02:47:30 -0600

gvdhoorn gravatar image

updated 2017-03-08 03:02:11 -0600

This is most likely a routing problem, not a ROS problem.

Provided you have everything setup correctly (ie ROS_IP, ROS_MASTER_URI, etc), the most likely cause is that R2 does not know how to get traffic to PC, and PC does not know how to get traffic to R2.

Any Linux machine can be easily turned into a router, which is what would make this work. See this random ServerFault post that talks about this, and this random page that shows you how to enable this. You probably also have to tell all involved hosts in the different networks how to reach the other networks (by adding some static routes).

Note: enabling forwarding like this can change the way your IP stack works, in ways that may not be apparent, so please try to understand what the implications are before you do this.


Also: not sure whether you care, or whether you already know, but 172.168.1.0 is not a network in the private networking ranges (that would be anything in 172.16.0.0 – 172.31.255.255). Your robot is currently using a public IP on its WLAN interface. This might be ok (if that range is actually yours), but I just wanted to mention it.

If you don't need your robot to be on a different network as your PC, then it might make things easier to just put them in the same one. If you need more than 255 hosts in one segment, then you could use a netmask with less than 24 bits.

edit flag offensive delete link more
2

answered 2017-03-12 08:32:49 -0600

wicked88 gravatar image

I had the same problem. Fixed it really easily ! Just check out my question : #q256070

edit flag offensive delete link more
0

answered 2017-03-08 07:17:58 -0600

rastaxe gravatar image

I think the easiest way is to make a VPN.

edit flag offensive delete link more

Comments

1

That would also work, but is a bit overkill ..

gvdhoorn gravatar image gvdhoorn  ( 2017-03-08 07:34:09 -0600 )edit
0

answered 2019-07-05 02:44:46 -0600

Hubson gravatar image

If you will use proper tool for routing it's actually not problem. Please check Husarnet. It's free up to 5 devices in one network. I use it in few of my ROS use case and I have to say it's very useful tool.

edit flag offensive delete link more
0

answered 2018-05-02 10:29:32 -0600

NickCitizen gravatar image

To summarize wicked88's response, do:

sudo route add -net 192.168.1.0 netmask 255.255.255.0 gw 172.168.1.100

on the computer where rviz will be running, in this case, "PC"

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2017-03-07 17:52:03 -0600

Seen: 6,063 times

Last updated: May 02 '18