Robotics StackExchange | Archived questions

Remote PC cannot connect to ROS Master

I cannot carry out gmapping from a remote PC. I can ssh thr turtlebot. I can ping it. and I can ping the remote PC from the turtlebot. But when I roslaunch turtlebot_rviz_launchers view_navigation.launch, I get:

ERROR:unable to contact ROS master  at [http://10.130.240.48:11311]

I made sure the ROS_MASTER_URI in the bashrc script of the remote PC is the IP of the turtlebot. I have no clue what's going on. I made sure to source my workspace in the terminal I tried to launch the file from. When I try to rostopic list it says ERROR: Unable to communicate with master !

Asked by distro on 2022-09-09 23:45:01 UTC

Comments

Are you sure, roscore is running at 10.130.240.48?

Asked by ravijoshi on 2022-09-10 01:16:25 UTC

@ravijoshi the roscore on remote PC also cannot communicate with that IP.

Asked by distro on 2022-09-10 14:18:58 UTC

the roscore on remote PC also cannot communicate with that IP

Sorry, this isn't very clear. Let me make sure that we are on the same page. As per the reported error, we need to confirm that the roscore is running at 10.130.240.48. If there is no roscore at 10.130.240.48, the error totally makes sense.

Asked by ravijoshi on 2022-09-10 21:36:44 UTC

There is no roscore at 10.130.240.48

Asked by distro on 2022-09-10 22:55:12 UTC

That explains the error you are receiving. I assume 10.130.240.48 is the IP address of TurtleBot. Can you please restart the bot and check if roscore is invoked? For example, you may use the following commands:

$ pgrep ros
26065
26088
26113

OR

$ ps -ef | grep ros
ravi       26065   25859 61 13:01 pts/1    00:00:01 /usr/bin/python3 /opt/ros/noetic/bin/roscore
ravi       26088   26065 64 13:01 ?        00:00:01 /usr/bin/python3 /opt/ros/noetic/bin/rosmaster --core -p 11311 -w 3 __log:=/home/ravi/.ros/log/6ddf1d30-3186-11ed-b895-15d8be443cc3/master.log
ravi       26113   26065  0 13:01 ?        00:00:00 /opt/ros/noetic/lib/rosout/rosout __name:=rosout __log:=/home/ravi/.ros/log/6ddf1d30-3186-11ed-b895-15d8be443cc3/rosout-1.log
ravi       26133   25835  0 13:01 pts/0    00:00:00 grep --color=auto ros

Asked by ravijoshi on 2022-09-10 23:09:43 UTC

@ravijoshi Do I roscore in turtlebot or remote PC?

Asked by distro on 2022-09-13 18:06:48 UTC

The networking and roscore related information is mentioned in turtlebot's documentation. I strongly suggest going through the documentation. May I request you to read and understand from [1] and [2]?

Asked by ravijoshi on 2022-09-14 05:25:21 UTC

@ravijoshi none of these links gives me information about the roscore information you are talking about. I can't roscore from remote PC because it can't communicate woth ros master. I can roscore from turtlebot2 but I dont see how that helps me in anyway. I can ping the turtelbot2 IP address from remote PC and I can ping the remote PC IP from turtlebot2. I can also ssh. I don't know what the problem possibly could be.

Asked by distro on 2022-09-20 22:36:18 UTC

Answers

Make sure to do export all ROS network variables (ROS_MASTER_URI, ROS_IP, ROS_HOSTNAME)

You can put something similar in the .bashrc of your ROS MASTER (exchange wlp2s0 with your device name)

 ip_addr="$(ip addr show wlp2s0 | grep "inet " | awk '{print $2}')"
 ip_addr="${ip_addr::-3}"
 export ROS_MASTER_URI="http://$ip_addr:11311"
 export ROS_IP="$ip_addr"
 export ROS_HOSTNAME="$ip_addr"

On the other computer do the same but set the ROS_MASTER_URI by hand

If this does not work you can also add the IP of the master in your /etc/hosts file.

See here for more: http://wiki.ros.org/ROS/NetworkSetup

Asked by GeorgNo on 2022-09-21 05:16:15 UTC

Comments

@GeorgNo I fogured out the problem, I set my HOSTNAME and Master on my turtlebot to localhost, and did the same thing with HOSTNAME on remote PC so it kept looping. I localhost to the actual IPs. I didn't know setting to localhost did that.

Asked by distro on 2022-09-22 01:18:01 UTC