0
$\begingroup$

Rosanswers logo

I am trying to call ros services but I am unable to call some rosservices...

It works for /rosout/get_loggers but doesn't work with gazebo related services.. rosservice list shows all services.

(I intentionally added spaces between rosrpc and localhost because the system thinks I am posting some URL links and I don't have enough karma)

$ rosservice uri /rosout/get_loggers 
rosrpc: // localhost:59423
$ rosservice type /rosout/get_loggers 
roscpp/GetLoggers
$ rosservice uri /gazebo/unpause_physics
rosrpc : // localhost:41557
$ rosservice type /gazebo/unpause_physics
ERROR: Unable to communicate with service [/gazebo/unpause_physics], address [rosrpc : // localhost:41557]
$ rosservice call /gazebo/unpause_physics
ERROR: Unable to communicate with service [/gazebo/unpause_physics], address [rosrpc : // localhost:41557]

I read about network setup but still not able to figure out what is going on.. Please help.

$ echo $ROS_MASTER_URI 
http : // localhost:11311
$ echo $ROS_HOSTNAME 
localhost

Originally posted by jys on ROS Answers with karma: 212 on 2012-11-15

Post score: 0


Original comments

Comment by jys on 2012-11-16:
rosservice list shows all. Fixing /etc/hosts didn't help.

Comment by Lorenz on 2012-11-18:
Maybe a stupid question but is gazebo running? What's the output of rosservice info /gazebo/unpause_physics?

Comment by jys on 2012-11-19:
I get same error.. Gazebo is running.. It is in "paused" state and GUI botton for "resume" doesn't respond.. Node: /gazebo URI: rosrpc://localhost:36586 ERROR: Unable to communicate with service [/gazebo/unpause_physics], address [rosrpc://localhost:36586]

Comment by Ruben Alves on 2022-02-03:
I was using Husarnet to connect to a remote robot (ROSBot) and could list the services but not call them. In the end, the problem is that I had ROS_IP=127.0.0.1 on my computer and on the robot. After unsetting ROS_IP in my pc and in the robot, it connected fine. Of course, in order for it to work with Husarnet, I also had to set

ROS_IPV6=on
ROS_MASTER_URI=http://master:11311
ROS_HOSTNAME=master # in therobot

And in my computer, I had to set the variables in the same way, but a different ROS_HOSTNAME, of course: ROS_HOSTNAME=myComputerNameHere

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Does rosservice list show the services?

Also I had some trouble with some entries in the /etc/hosts file since the entries there usually overwrite the information from the DNS/DHCP Server. If you have some entries there, you can make a backup of your /etc/hosts file and delete every entry except the following:

127.0.0.1   localhost

At least this was the cause for a similar problem in a network with non-static IP addresses....


Originally posted by michikarg with karma: 2108 on 2012-11-15

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by jys on 2012-11-19:
rosservice list shows all. Fixing /etc/hosts didn't help.

Comment by fbelmonteklein on 2021-02-18:
so, it turns out that ROS register the names of hosts with the variables of the terminal in which the roslaunch/rosrun command was ran. I managed to solve it by executing export ROS_HOSTNAME=xxx.Home, where xxx is the name of the pc that was providing the service. this name (with the home suffix) was provided by the router, so no need to add it to /etc/hosts. That said, changing etc/hosts is a more permanent and possibly better solution.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.