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

Revision history [back]

Short answer: set ROS_MASTER_URI and ROS_IP on both of your Raspberry Pi and PC using IP address rather than hostname. It should work just fine.

Long answer: Will complete this when I got some time ..

Short answer: set ROS_MASTER_URI and ROS_IP on both of your Raspberry Pi and PC using IP address rather than hostname. It should work just fine.

Long answer: Will complete We only discuss connection in local area network. First we'd better fully understand the communication steps. In brief

  • roscore is started.
  • Publisher is started. Looking for master based on ROS_MASTER_URI. If the publisher and master are on the same PC, you could use localhost, 127.0.0.1, IP, hostname.
  • Publisher need to register its IP on master, based on ROS_IP. if ROS_IP is not explicitly set, it should be hostname. This is very important, because most of the time this part is the cause of improper multi-machine connection.
  • Subscriber is started. Looking for master and master give back the publisher's IP.
  • Subscriber connect to publisher.

So, if all nodes are running on the same PC, there won't be any problem.

If you only setup the ROS_MASTER_URI correctly, you can check the rostopic list on your client PC, because all the topic names are already registered on ROS Master.

Therefore, whether you can rostopic echo or not on your client PC, is determined by the ROS_IP registered on master by the publisher.

Now we only focus on the ROS_IP setup on the publisher's PC, mostly the one roscore is running. This is quite tricky. The pros and cons of IP address is that you can definitely connect using IP, but it may change. Hostname is more user friendly, but your router still need to parse hostname to IP address, and sometimes it doesn't work. If you are under a quite stable network and you know that your router can always parse hostname, only setup the ROS_MASTER_URI on both PCs will do.

So setup ROS_IP using IP address rather than hostname, most of the time will solve the communication problem.

Last but not least, understand how to setup the ROS_MASTER_URI and ROS_IP. ROS_MASTER_URI is only to provide the address of master, you can always set it on your roscore machine to http://localhost:11311. But you MUST setup the ROS_IP using a LAN IP, i.e. 192.168.1.xxx, so a subscriber can find the publisher well.

Pay more attention to the ROS_IP on roscore machine, users often forget to setup the ROS_IP because they take for grant that the subscriber can connect to the subscriber, as it can connect to the master. However, ROS_MASTER_URI on subscriber machine guarantee that it can connect to master, and ROS_IP on publisher machine guarantee subcriber can connect to publisher.


However, this seems does not explain your case when you set all ROS_MASTER_URI and ROS_IP to Pi but your PC's publisher works well. Better check again and give me some feedback..


I got some time think this problem is not well discussed in Wiki. However, in ROS2 this should not be a problem any more ..

Short answer: set ROS_MASTER_URI and ROS_IP on both of your Raspberry Pi and PC using IP address rather than hostname. It should work just fine.

Long answer: We only discuss connection in local area network. First we'd better fully understand the communication steps. In brief

  • roscore is started.
  • Publisher is started. Looking for master based on ROS_MASTER_URI. If the publisher and master are on the same PC, you could use localhost, 127.0.0.1, IP, hostname.
  • Publisher need to register its IP on master, based on ROS_IP. if ROS_IP is not explicitly set, it should be hostname. This is very important, because most of the time this part is the cause of improper multi-machine connection.
  • Subscriber is started. Looking for master and master give back the publisher's IP.
  • Subscriber connect to publisher.

So, if all nodes are running on the same PC, there won't be any problem.

If you only setup the ROS_MASTER_URI correctly, you can check the rostopic list on your client PC, because all the topic names are already registered on ROS Master.

Therefore, whether you can rostopic echo or not on your client PC, is determined by the ROS_IP registered on master by the publisher.

Now we only focus on the ROS_IP setup on the publisher's PC, mostly the one roscore is running. master PC (to be more clear, publisher's PC is where the publisher runs). This is quite tricky. The pros and cons of IP address is that you can definitely connect using IP, but it may change. Hostname is more user friendly, but your router still need to parse hostname to IP address, and sometimes it doesn't work. If you are under a quite stable network and you know that your router can always parse hostname, only setup the ROS_MASTER_URI on both PCs will do.

So setup ROS_IP using IP address rather than hostname, most of the time will solve the communication problem.

Last but not least, understand how to setup the ROS_MASTER_URI and ROS_IP. ROS_MASTER_URI is only to provide the address of master, you can always set it on your roscore machine master PC to http://localhost:11311. But you MUST setup the ROS_IP using a LAN IP, i.e. 192.168.1.xxx, so a remote subscriber can find the publisher well.

Pay more attention to the ROS_IP on roscore machine, master PC, users often forget to setup the ROS_IP because they take for grant that the subscriber can connect to the subscriber, publisher on master PC, as it can connect to the master. However, In fact, ROS_MASTER_URI on subscriber machine guarantee that it can connect to master, and ROS_IP on publisher machine guarantee subcriber can connect to publisher.


However, this seems does not explain your case when you set all ROS_MASTER_URI and ROS_IP to Pi but your PC's publisher works well. Better check again and give me some feedback..


I think this problem is not well discussed in Wiki. However, in ROS2 this should not be a problem any more ..

Short answer: set ROS_MASTER_URI and ROS_IP on both of your Raspberry Pi and PC using IP address rather than hostname. It should work just fine.

Long answer: We only discuss connection in local area network. First we'd better fully understand the communication steps. In brief

  • roscore is started.
  • Publisher is started. Looking for master based on ROS_MASTER_URI. If the publisher and master are on the same PC, you could use localhost, 127.0.0.1, IP, hostname.
  • Publisher need to register its IP on master, based on ROS_IP. if ROS_IP is not explicitly set, it should be hostname. This is very important, because most of the time this part is the cause of improper multi-machine connection.
  • Subscriber is started. Looking for master and master give back the publisher's IP.
  • Subscriber connect to publisher.

So, if all nodes are running on the same PC, there won't be any problem.

If you only setup the ROS_MASTER_URI correctly, you can check the rostopic list on your client PC, because all the topic names are already registered on ROS Master.

Therefore, whether you can rostopic echo or not on your client PC, is determined by the ROS_IP registered on master by the publisher.

Now we only focus on the ROS_IP setup on the publisher's PC, mostly the master PC (to be more clear, publisher's PC is where the publisher runs). This is quite tricky. The pros and cons of IP address is that you can definitely connect using IP, but it may change. Hostname is more user friendly, but your router still need to parse hostname to IP address, and sometimes it doesn't work. work (The router DNS server just does not work perfectly and I really don't know how to solve this). If you are under a quite stable network and you know that your router can always parse hostname, only setup the ROS_MASTER_URI on both PCs will do.

So setup ROS_IP using IP address rather than hostname, most of the time will solve the communication problem.

Last but not least, understand how to setup the ROS_MASTER_URI and ROS_IP. ROS_MASTER_URI is only to provide the address of master, you can always set it on your master PC to http://localhost:11311. But you MUST setup the ROS_IP using a LAN IP, i.e. 192.168.1.xxx, so a remote subscriber can find the publisher well.

Pay more attention to the ROS_IP on master PC, users often forget to setup the ROS_IP because they take for grant that the subscriber can connect to the publisher on master PC, as it can connect to the master. In fact, ROS_MASTER_URI on subscriber machine guarantee that it can connect to master, and ROS_IP on publisher machine guarantee subcriber can connect to publisher.


However, this seems does not explain your case when you set all ROS_MASTER_URI and ROS_IP to Pi but your PC's publisher works well. Better check again and give me some feedback..


I think this problem is not well discussed in Wiki. However, in ROS2 this should not be a problem any more ..