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

Reconnect to ROSCORE

asked 2011-07-26 04:04:14 -0500

We are developing a robot that has some processing done off-board, for that we rely on a WiFi connection and a dynamic DNS for the robot's laptop. On the desktop side I've configured it to connect to the laptop but there are problems when the laptop disconnect and reconnect to the WiFi, despite the dynamic DNS. I've created a ping thread similar to "rostopic ping", that I can use to detect possible disconnections, but I haven't found a way to reconnect to roscore.

Any help on how could I reconnect to roscore?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2011-08-27 10:07:07 -0500

kwc gravatar image

Unless you are actively creating new publishers/subscribers, there is no need to 'reconnect' to a roscore. The roscore acts as a DNS server -- it just stores lookup information. There is no connection that is maintained between your node and the roscore.

It would be helpful if you described why you believe you need to reconnect.

edit flag offensive delete link more


In my situation, I am running a ros client on a windows machine without ssh access. so roslaunch cannot start the node remotely. Instead I start the node once and hope the node to re-announce itself everytime I restart the whole "launch" when the "DNS" server is fresh.
tingfan gravatar image tingfan  ( 2011-08-27 20:15:19 -0500 )edit
That use case isn't well supported -- in general, you want something that restarts the entire Python process if possible. There is an experimental package called ronin that restarts a remote publisher, but it's far from stable:
kwc gravatar image kwc  ( 2011-08-28 06:34:15 -0500 )edit
In my case I have ROSCORE running on-board the robot, and some process run off-board. The robot has a wifi connection that sometimes drops killing all connections between off-board process and the robot.
Javier gravatar image Javier  ( 2011-08-31 04:01:33 -0500 )edit

answered 2011-08-26 05:11:13 -0500

tingfan gravatar image

updated 2011-08-26 06:36:09 -0500

I modified the to
(1) Use get_system_state to test the existence of roscore. Though I am wondering if there is a formal way to test the existence of roscore.
(2) when disconnected, restart from scratch (init_node, publish ...)

import roslib; roslib.load_manifest('rospy_tutorials')

import rospy
from std_msgs.msg import String

def talker():
    pub = rospy.Publisher('chatter', String)
    rospy.init_node('talker', anonymous=True, log_level=rospy.DEBUG)
    r = rospy.Rate(10) # 10hz
    while not rospy.is_shutdown():

        #query rosmaster status, which will raise socket.error when failure

        str = "hello world %s"%rospy.get_time()

if __name__ == '__main__':
    import time
    import socket
    while 1:
            break; #normal termination, such as shutdown/ctrl-c
        except socket.error:
            print "reconnecting"
edit flag offensive delete link more


rospy is stateful, so the above code does not 'start from scratch'. Subsequent calls to init_node have no effect.
kwc gravatar image kwc  ( 2011-08-27 10:07:51 -0500 )edit

answered 2011-07-26 22:01:25 -0500

Bemfica gravatar image

Just guessing here but what about NetworkSetup page? it didn't help you? there is an external tutorial about "Configuring /etc/hosts". Maybe that's the way.

edit flag offensive delete link more


We've already set the hosts files and testes the connections, but the problem arises when the Wifi connection drops and reconnect, then the offboard computer can't, so far, reconnect to the onboard roscore.
Javier gravatar image Javier  ( 2011-07-27 00:54:34 -0500 )edit

Question Tools


Asked: 2011-07-26 04:04:14 -0500

Seen: 2,663 times

Last updated: Aug 27 '11