Beispiel #1
0
 def retrieveMasters(self):
     '''
 This method use the service 'list_masters' of the master_discoverer to get 
 the list of discovered ROS master. Based on this list the L{SyncThread} for
 synchronization will be created.
 @see: L{master_discovery_fkie.interface_finder.get_listmaster_service()}
 '''
     service_names = interface_finder.get_listmaster_service(
         self.getMasteruri())
     for service_name in service_names:
         rospy.loginfo("service 'list_masters' found on %s", service_name)
         self.__lock.acquire()
         try:
             rospy.wait_for_service(service_name)
             try:
                 discoverMasters = rospy.ServiceProxy(
                     service_name, DiscoverMasters)
                 resp = discoverMasters()
                 masters = []
                 for m in resp.masters:
                     if not m.name in self.ignore:  # do not sync to the master, if it is in ignore list
                         masters.append(m.name)
                         self.updateMaster(m.name, m.uri, m.timestamp,
                                           m.discoverer_name, m.monitoruri)
                 for key in set(self.masters.keys()) - set(masters):
                     self.removeMaster(self.masters[key].name)
             except rospy.ServiceException, e:
                 rospy.logwarn(
                     "ERROR Service call 'list_masters' failed: %s", str(e))
         except:
             import traceback
             rospy.logwarn("ERROR while initial list masters: %s",
                           traceback.format_exc())
         finally:
             self.__lock.release()
 def obtain_masters(self):
     '''
     This method use the service 'list_masters' of the master_discoverer to get
     the list of discovered ROS master. Based on this list the L{SyncThread} for
     synchronization will be created.
     @see: U{master_discovery_fkie.interface_finder.get_listmaster_service()
         <http://docs.ros.org/api/master_discovery_fkie/html/modules.html#interface-finder-module>}
     '''
     if not rospy.is_shutdown():
         service_names = interface_finder.get_listmaster_service(masteruri_from_master(), False)
         for service_name in service_names:
             try:
                 with self.__lock:
                     try:
                         socket.setdefaulttimeout(5)
                         discoverMasters = rospy.ServiceProxy(service_name, DiscoverMasters)
                         resp = discoverMasters()
                         masters = []
                         master_names = [m.name for m in resp.masters]
                         rospy.loginfo("ROS masters obtained from '%s': %s", service_name, master_names)
                         for m in resp.masters:
                             if self._can_sync(m.name):  # do not sync to the master, if it is in ignore list or not in filled sync list
                                 masters.append(m.name)
                             self.update_master(m.name, m.uri, m.timestamp, m.timestamp_local, m.discoverer_name, m.monitoruri, m.online)
                         for key in set(self.masters.keys()) - set(masters):
                             self.remove_master(self.masters[key].name)
                     except rospy.ServiceException, e:
                         rospy.logwarn("ERROR Service call 'list_masters' failed: %s", str(e))
             except:
                 import traceback
                 rospy.logwarn("ERROR while initial list masters: %s", traceback.format_exc())
             finally:
                 socket.setdefaulttimeout(None)
         self.update_timer = threading.Timer(self.UPDATE_INTERVALL, self.obtain_masters)
         self.update_timer.start()
 def run(self):
     '''
     '''
     if self._masteruri:
         found = False
         service_names = interface_finder.get_listmaster_service(self._masteruri, self._wait)
         err_msg = ''
         for service_name in service_names:
             rospy.logdebug("service 'list_masters' found on %s as %s", self._masteruri, service_name)
             if self._wait:
                 rospy.wait_for_service(service_name)
             socket.setdefaulttimeout(3)
             discoverMasters = rospy.ServiceProxy(service_name, DiscoverMasters)
             try:
                 resp = discoverMasters()
             except rospy.ServiceException, e:
                 err_msg = "Service call 'list_masters' failed: %s" % utf8(e)
                 rospy.logwarn(err_msg)
                 self.err_signal.emit(self._masteruri, "Service call '%s' failed: %s" % (service_name, err_msg), False)
             else:
                 if resp.masters:
                     self.master_list_signal.emit(self._masteruri, service_name, resp.masters)
                     found = True
                 else:
                     self.err_signal.emit(self._masteruri, "local 'master_discovery' reports empty master list, it seems he has a problem", False)
             finally:
                 socket.setdefaulttimeout(None)
  def retrieveMasters(self):
    '''
    This method use the service 'list_masters' of the master_discoverer to get 
    the list of discovered ROS master. Based on this list the L{SyncThread} for
    synchronization will be created.
    @see: L{master_discovery_fkie.interface_finder.get_listmaster_service()}
    '''
    service_names = interface_finder.get_listmaster_service(self.getMasteruri(), False)
    for service_name in service_names:
      rospy.loginfo("service 'list_masters' found on %s", service_name)
      self.__lock.acquire()
      try:
#        rospy.wait_for_service(service_name)
        try:
          discoverMasters = rospy.ServiceProxy(service_name, DiscoverMasters)
          resp = discoverMasters()
          masters = []
          for m in resp.masters:
            if not m.name in self.ignore: # do not sync to the master, if it is in ignore list
              masters.append(m.name)
              self.updateMaster(m.name, m.uri, m.timestamp, m.discoverer_name, m.monitoruri)
          for key in set(self.masters.keys()) - set(masters):
            self.removeMaster(self.masters[key].name)
        except rospy.ServiceException, e:
          rospy.logwarn("ERROR Service call 'list_masters' failed: %s", str(e))
      except:
        import traceback
        rospy.logwarn("ERROR while initial list masters: %s", traceback.format_exc())
      finally:
        self.__lock.release()
    self.update_timer = threading.Timer(15.0, self.retrieveMasters)
    self.update_timer.start()
 def run(self):
     '''
 '''
     if self._masteruri:
         found = False
         service_names = interface_finder.get_listmaster_service(
             self._masteruri, self._wait)
         err_msg = ''
         for service_name in service_names:
             rospy.logdebug("service 'list_masters' found on %s as %s",
                            self._masteruri, service_name)
             if self._wait:
                 rospy.wait_for_service(service_name)
             socket.setdefaulttimeout(3)
             discoverMasters = rospy.ServiceProxy(service_name,
                                                  DiscoverMasters)
             try:
                 resp = discoverMasters()
             except rospy.ServiceException, e:
                 rospy.logwarn(
                     "ERROR Service call 'list_masters' failed: %s", str(e))
                 err_msg = ''.join(
                     [err_msg, '\n', service_name, ': ',
                      str(e)])
             else:
                 self.master_list_signal.emit(self._masteruri, service_name,
                                              resp.masters)
                 if resp.masters:
                     found = True
             finally:
                 socket.setdefaulttimeout(None)
 def retrieveMasters(self):
   '''
   This method use the service 'list_masters' of the master_discoverer to get 
   the list of discovered ROS master. Based on this list the L{SyncThread} for
   synchronization will be created.
   @see: L{master_discovery_fkie.interface_finder.get_listmaster_service()}
   '''
   if not rospy.is_shutdown():
     rospy.loginfo("Update ROS master list...")
     service_names = interface_finder.get_listmaster_service(self.getMasteruri(), False)
     for service_name in service_names:
       rospy.loginfo("service 'list_masters' found on %s", service_name)
       try:
         with self.__lock:
   #        rospy.wait_for_service(service_name)
           try:
             socket.setdefaulttimeout(5)
             discoverMasters = rospy.ServiceProxy(service_name, DiscoverMasters)
             resp = discoverMasters()
             masters = []
             for m in resp.masters:
 #              if not self._re_ignore_hosts.match(m.name) or self._re_sync_hosts.match(m.name): # do not sync to the master, if it is in ignore list
 #                masters.append(m.name)
               self.updateMaster(m.name, m.uri, m.timestamp, m.timestamp_local, m.discoverer_name, m.monitoruri)
             for key in set(self.masters.keys()) - set(masters):
               self.removeMaster(self.masters[key].name)
           except rospy.ServiceException, e:
             rospy.logwarn("ERROR Service call 'list_masters' failed: %s", str(e))
       except:
         import traceback
         rospy.logwarn("ERROR while initial list masters: %s", traceback.format_exc())
       finally:
         socket.setdefaulttimeout(None)
     self.update_timer = threading.Timer(self.UPDATE_INTERVALL, self.retrieveMasters)
     self.update_timer.start()
 def retrieveMasters(self):
   '''
   This method use the service 'list_masters' of the master_discoverer to get 
   the list of discovered ROS master. Based on this list the L{SyncThread} for
   synchronization will be created.
   @see: L{master_discovery_fkie.interface_finder.get_listmaster_service()}
   '''
   if not rospy.is_shutdown():
     rospy.loginfo("Update ROS master list...")
     service_names = interface_finder.get_listmaster_service(self.getMasteruri(), False)
     for service_name in service_names:
       rospy.loginfo("service 'list_masters' found on %s", service_name)
       try:
         with self.__lock:
   #        rospy.wait_for_service(service_name)
           try:
             socket.setdefaulttimeout(5)
             discoverMasters = rospy.ServiceProxy(service_name, DiscoverMasters)
             resp = discoverMasters()
             masters = []
             for m in resp.masters:
               if not self._re_ignore_hosts.match(m.name) or self._re_sync_hosts.match(m.name): # do not sync to the master, if it is in ignore list
                 masters.append(m.name)
               self.updateMaster(m.name, m.uri, m.timestamp, m.timestamp_local, m.discoverer_name, m.monitoruri)
             for key in set(self.masters.keys()) - set(masters):
               self.removeMaster(self.masters[key].name)
           except rospy.ServiceException, e:
             rospy.logwarn("ERROR Service call 'list_masters' failed: %s", str(e))
       except:
         import traceback
         rospy.logwarn("ERROR while initial list masters: %s", traceback.format_exc())
       finally:
         socket.setdefaulttimeout(None)
     self.update_timer = threading.Timer(self.UPDATE_INTERVALL, self.retrieveMasters)
     self.update_timer.start()
 def obtain_masters(self):
     '''
     This method use the service 'list_masters' of the master_discoverer to get
     the list of discovered ROS master. Based on this list the L{SyncThread} for
     synchronization will be created.
     @see: U{master_discovery_fkie.interface_finder.get_listmaster_service()
         <http://docs.ros.org/api/master_discovery_fkie/html/modules.html#interface-finder-module>}
     '''
     if not rospy.is_shutdown():
         service_names = interface_finder.get_listmaster_service(
             masteruri_from_master(), False)
         for service_name in service_names:
             try:
                 with self.__lock:
                     try:
                         socket.setdefaulttimeout(5)
                         discoverMasters = rospy.ServiceProxy(
                             service_name, DiscoverMasters)
                         resp = discoverMasters()
                         masters = []
                         master_names = [m.name for m in resp.masters]
                         rospy.loginfo("ROS masters obtained from '%s': %s",
                                       service_name, master_names)
                         for m in resp.masters:
                             if not self._re_ignore_hosts.match(
                                     m.name
                             ) or self._re_sync_hosts.match(
                                     m.name
                             ):  # do not sync to the master, if it is in ignore list
                                 masters.append(m.name)
                             self.update_master(m.name, m.uri, m.timestamp,
                                                m.timestamp_local,
                                                m.discoverer_name,
                                                m.monitoruri, m.online)
                         for key in set(self.masters.keys()) - set(masters):
                             self.remove_master(self.masters[key].name)
                     except rospy.ServiceException, e:
                         rospy.logwarn(
                             "ERROR Service call 'list_masters' failed: %s",
                             str(e))
             except:
                 import traceback
                 rospy.logwarn("ERROR while initial list masters: %s",
                               traceback.format_exc())
             finally:
                 socket.setdefaulttimeout(None)
         self.update_timer = threading.Timer(self.UPDATE_INTERVALL,
                                             self.obtain_masters)
         self.update_timer.start()
 def run(self):
     '''
     '''
     if self._masteruri:
         found = False
         service_names = interface_finder.get_listmaster_service(
             self._masteruri, self._wait)
         err_msg = ''
         for service_name in service_names:
             rospy.logdebug("service 'list_masters' found on %s as %s",
                            self._masteruri, service_name)
             if self._wait:
                 rospy.wait_for_service(service_name)
             socket.setdefaulttimeout(3)
             discoverMasters = rospy.ServiceProxy(service_name,
                                                  DiscoverMasters)
             try:
                 resp = discoverMasters()
             except rospy.ServiceException, e:
                 err_msg = "Service call 'list_masters' failed: %s" % utf8(
                     e)
                 rospy.logwarn(err_msg)
                 self.err_signal.emit(
                     self._masteruri, "Service call '%s' failed: %s" %
                     (service_name, err_msg), False)
             else:
                 if resp.masters:
                     self.master_list_signal.emit(self._masteruri,
                                                  service_name,
                                                  resp.masters)
                     found = True
                 else:
                     self.err_signal.emit(
                         self._masteruri,
                         "local 'master_discovery' reports empty master list, it seems he has a problem",
                         False)
             finally:
                 socket.setdefaulttimeout(None)
 def run(self):
   '''
   '''
   if self._masteruri:
     found = False
     service_names = interface_finder.get_listmaster_service(self._masteruri, self._wait)
     err_msg = ''
     for service_name in service_names:
       rospy.logdebug("service 'list_masters' found on %s as %s", self._masteruri, service_name)
       if self._wait:
         rospy.wait_for_service(service_name)
       socket.setdefaulttimeout(3)
       discoverMasters = rospy.ServiceProxy(service_name, DiscoverMasters)
       try:
         resp = discoverMasters()
       except rospy.ServiceException, e:
         rospy.logwarn("ERROR Service call 'list_masters' failed: %s", str(e))
         err_msg = ''.join([err_msg, '\n', service_name, ': ', str(e)])
       else:
         self.master_list_signal.emit(self._masteruri, service_name, resp.masters)
         if resp.masters:
           found = True
       finally:
         socket.setdefaulttimeout(None)
Beispiel #11
0
 def retrieveMasterList(self, masteruri, wait=True):
   '''
   This method use the service 'list_masters' of the master_discovery to get 
   the list of discovered ROS master. The retrieved list will be emitted as 
   masterlist_signal.
   @param masteruri: the ROS master URI
   @type masteruri: C{str}
   @param wait: wait for the service
   @type wait: C{boolean}
   '''
   found = False
   service_names = interface_finder.get_listmaster_service(masteruri, wait)
   for service_name in service_names:
     rospy.loginfo("service 'list_masters' found on %s as %s", masteruri, service_name)
     rospy.wait_for_service(service_name)
     discoverMasters = rospy.ServiceProxy(service_name, DiscoverMasters)
     try:
       resp = discoverMasters()
     except rospy.ServiceException, e:
       rospy.logwarn("ERROR Service call 'list_masters' failed: %s", str(e))
       self.masterlist_err_signal.emit("ERROR Service call 'list_masters' failed: %s", str(e))
     else:
       self.masterlist_signal.emit(resp.masters)
       found = True