Using rosservice across multiple machines
I am attempting to distribute my graph across multiple machines, M1 and M2. The IP of M1 is 192.168.0.80 and the IP of M2 is 192.168.0.79.
In the /etc/hosts file on M1, I have set:
192.168.0.79 machine2
And in the /etc/hosts file on M2, I have:
192.168.0.80 machine1
I am able to ping machine1 from machine2 and vice versa.
So then, I set up my launch file to use multiple machines with the following .machine file:
<launch>
<machine name="M1" address="machine1" ros-root="$(env ROS_ROOT)" ros-package-path="$(env ROS_PACKAGE_PATH)" user="m1user" default="true"></machine>
<machine name="M2" address="machine2" ros-root="$(env ROS_ROOT)" ros-package-path="$(env ROS_PACKAGE_PATH)" user="m2user">
<env name="ROS_MASTER_URI" value="http://machine1:11311" />
</machine>
</launch>
When I launch, everything connects fine, all of the nodes launch correctly, and I am able to do 'rostopic list' and 'rosservice list' to see all topics and services. Additionally, I am able to 'rostopic echo' any topic that is running in the graph.
The problem that I am having is that I am only able to call a service from a node that is running on the master machine, i.e. M1. For example, a service named "enableteleop" is running in my robotteleop node on the master machine, and I can call this service from either machine. However, if I try to call a service that is from a node on the second machine using either machine, I receive the following error:
> rosservice call /reset_odometry
> ERROR: Unable to communicate with service [/reset_odometry], address [rosrpc://machine2:56068]
I have tried setting the ROSIP and/or ROSHOSTNAME environment variables of both machines in every combination that I can think of, and still no luck. So my question is, how do I get around this problem? Does ROS require that all services be on the same machine as the roscore?
EDIT:
The output of 'rosservice info /reset_odometry' is as follows:
Node: /locator
URI: rosrpc://machine2:42244
ERROR: Unable to communicate with service [/reset_odometry], address [rosrpc://machine2:42244]
The output of roswtf is:
* service [/reset_odometry] appears to be malfunctioning: Unable to communicate with service [/reset_odometry], address [rosrpc://machine2:42244]
~ Brian
Asked by DimitriProsser on 2011-08-31 03:54:32 UTC
Answers
Distributing services across different machines shouldn't be a problem. What's the output of rosservice info /reset_odometry
and roswtf
? Does it maybe give any valuable information?
Asked by Lorenz on 2011-08-31 04:26:23 UTC
Comments
I was just using that node and service as an example. I have about 6 nodes and 12 services all doing the same thing. And I know they're alived because I can echo some topics that they publish to.
Asked by DimitriProsser on 2011-08-31 05:01:07 UTC
Which node is actually providing this service? Are you sure it didn't die with something like a segfault? In that cause, roswtf should give something like:
Asked by Lorenz on 2011-08-31 04:43:08 UTC
Which node is actually providing this service? Are you sure it didn't die with something like a segfault? In that cause, roswtf should give something like: ERROR Could not contact the following nodes: ...
Asked by Lorenz on 2011-08-31 04:43:07 UTC
I've placed the results in an edit to the original question
Asked by DimitriProsser on 2011-08-31 04:34:41 UTC
you might have to add both hostname/ip cominations to each /etc/hosts file, i.e.
192.168.0.80 machine1
192.168.0.79 machine2
The problem could be that machine1
refers to 127.0.0.1 / 127.0.0.1 in machine1's hosts file. Local communication works, but when roscore tries to resolve the address when negotiating a connection between machine1 and machine2, it would still report 127.0.0.1 ...
Hope that helps! Markus
Asked by Markus Achtelik on 2011-08-31 04:59:46 UTC
Comments
Unfortunately, that didn't help. I get the same errors.
Asked by DimitriProsser on 2011-08-31 05:45:23 UTC
I'm experiencing exactly the same issue. The two machines seem to be able to communicate just fine (rostopic list/echo works fine), and the master is able to call services that are running on itself. However, an identical service call from a different machine to the master results in the error that you posted.
Have you been able to resolve the issue?
Asked by rschoen on 2011-10-13 16:10:32 UTC
Comments
I have not been able to fix this issue yet
Asked by DimitriProsser on 2011-10-14 03:10:07 UTC
Running ros across multiple machines -whether you call a service or not- is actually not a big problem thanks to the rosmaster.
What we did in our lab is as follows:
on the central/host/master computer:
export ROS_MASTER_URI=http://master_machine_name:11311
export ROS_IP=master_machine_ip
on the client computer(s):
export ROS_MASTER_URI=http://master_machine_ip:11311
export ROS_IP=client_machine_ip
You may also need to add master_machine_ip master_machine_name
mapping to /etc/hosts
file on the client machines so that they can ping master_machine_name
.
Asked by Kadir Firat Uyanik on 2012-01-30 04:44:18 UTC
Comments
Hmm, so you didn't figure out what the problem was, or did you? I was having similar problems but I think it was partly because I had different usernames on different machines, or at least making a new account with the same username fixed some problems for me.
Asked by Ibrahim on 2012-01-12 13:24:02 UTC
Yes and yes.
Asked by DimitriProsser on 2012-01-12 01:51:47 UTC
Did you ever figure this out? Out of curiosity, are your usernames the same on both machines? Also is passwordless ssh set up both ways?
Asked by Ibrahim on 2012-01-11 21:06:35 UTC
Hey, 5 years later and now I have the same problem... Did you (or anyone else) find a solution in the meantime?
Asked by Felix Widmaier on 2017-03-07 11:25:57 UTC
Unable to get this working, I have setup ros ip and master uri, I am able to get rospy_tutorials listener and talker working across the two computers. I can list the services also but not call them.
Asked by rudasi on 2017-04-16 21:25:57 UTC