ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

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 ).

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= 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

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 is not a network in the private networking ranges (that would be anything in – 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

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

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

NickCitizen gravatar image

To summarize wicked88's response, do:

sudo route add -net netmask gw

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

edit flag offensive delete link more

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

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



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

gvdhoorn gravatar image gvdhoorn  ( 2017-03-08 07:34:09 -0600 )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



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

Seen: 5,289 times

Last updated: May 02 '18