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

Reconnect to ROSCORE

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

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
0

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

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

Comments

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 -0600 )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: http://www.ros.org/wiki/ronin
kwc gravatar image kwc  ( 2011-08-28 06:34:15 -0600 )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 -0600 )edit
0

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

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

Comments

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 -0600 )edit
0

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

tingfan gravatar image

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

I modified the talker.py 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
        rospy.get_master().getSystemState()
        #end-of-checking

        str = "hello world %s"%rospy.get_time()
        rospy.loginfo(str)
        pub.publish(str)
        r.sleep()

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

Comments

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 -0600 )edit

Question Tools

Stats

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

Seen: 2,714 times

Last updated: Aug 27 '11