def __init__(self, monitor_port=11611, domain=''): '''.......................................................................... Initialize method of the local master. @param monitor_port: The port of the RPC Server, used to get more information about the ROS master. @type monitor_port: int ..........................................................................''' if rospy.has_param('~rosmaster_hz'): Discoverer.ROSMASTER_HZ = rospy.get_param('~rosmaster_hz') self.master_monitor = MasterMonitor(monitor_port) name = self.master_monitor.getMastername() # create the txtArray for the zeroconf service of the ROS master materuri = self.master_monitor.getMasteruri() # test the host for local entry masterhost, masterport = MasterInfo.MasteruriToAddr(materuri) if (masterhost in ['localhost', '127.0.0.1']): sys.exit("'%s' is not reachable for other systems. Change the ROS_MASTER_URI!", masterhost) rpcuri = ''.join(['http://', socket.gethostname(), ':', str(monitor_port), '/']) txtArray = ["timestamp=%s"%str(0), "master_uri=%s"%materuri, "zname=%s"%rospy.get_name(), "rpcuri=%s"%rpcuri] # the Zeroconf class, which contains the QMainLoop to receive the signals from avahi Zeroconf.__init__(self, name, '_ros-master._tcp', masterhost, masterport, domain, txtArray) # the list with all ROS master neighbors with theirs SyncThread's and all Polling threads self.masters = MasterList(self.masterInfo, self.requestResolve, self.checkLocalMaster) # set the callback to finish all running threads rospy.on_shutdown(self.finish)