Esempio n. 1
0
 def update_master(self, mastername, masteruri, timestamp, timestamp_local,
                   discoverer_name, monitoruri, online):
     '''
     Updates the timestamp of the given ROS master, or creates a new SyncThread to
     synchronize the local master with given ROS master.
     @param mastername: the name of the remote ROS master to update or synchronize.
     @type mastername: C{str}
     @param masteruri: the URI of the remote ROS master.
     @type masteruri: C{str}
     @param timestamp: the timestamp of the remote ROS master.
     @type timestamp: L{float64}
     @param timestamp_local: the timestamp of the remote ROS master. (only local changes)
     @type timestamp_local: L{float64}
     @param discoverer_name: the name of the remote master_discoverer node
     @type discoverer_name: C{str}
     @param monitoruri: the URI of the RPC interface of the remote master_discoverer node.
     @type monitoruri: C{str}
     @param online: the current state on the master.
     @type online: C{bool}
     '''
     try:
         with self.__lock:
             if (masteruri != self.materuri):
                 if (is_empty_pattern(self._re_ignore_hosts)
                         or not self._re_ignore_hosts.match(mastername) or
                     (not is_empty_pattern(self._re_sync_hosts) and
                      self._re_sync_hosts.match(mastername) is not None)):
                     # do not sync to the master, if it is in ignore list
                     if self.__resync_on_reconnect and mastername in self.masters:
                         self.masters[mastername].set_online(
                             online, self.__resync_on_reconnect_timeout)
                     if online:
                         if mastername in self.masters:
                             # updates only, if local changes are occured
                             self.masters[mastername].update(
                                 mastername, masteruri, discoverer_name,
                                 monitoruri, timestamp_local)
                         else:
                             self.masters[mastername] = SyncThread(
                                 mastername, masteruri, discoverer_name,
                                 monitoruri, 0.0,
                                 self.__sync_topics_on_demand)
                             if self.__own_state is not None:
                                 self.masters[
                                     mastername].set_own_masterstate(
                                         MasterInfo.from_list(
                                             self.__own_state))
                             self.masters[mastername].update(
                                 mastername, masteruri, discoverer_name,
                                 monitoruri, timestamp_local)
             elif self.__timestamp_local != timestamp_local and self.__sync_topics_on_demand:
                 # get the master info from local discovery master and set it to all sync threads
                 self.own_state_getter = threading.Thread(
                     target=self.get_own_state, args=(monitoruri, ))
                 self.own_state_getter.start()
     except:
         import traceback
         rospy.logwarn("ERROR while update master[%s]: %s", str(mastername),
                       traceback.format_exc())
 def _can_sync(self, mastername):
     result = False
     if is_empty_pattern(self._re_ignore_hosts):
         if is_empty_pattern(self._re_sync_hosts):
             result = True
         elif self._re_sync_hosts.match(mastername) is not None:
             result = True
     elif self._re_ignore_hosts.match(mastername) is None:
         result = True
     elif not is_empty_pattern(self._re_sync_hosts):
         if self._re_sync_hosts.match(mastername) is not None:
             result = True
     return result
Esempio n. 3
0
 def _can_sync(self, mastername):
     result = False
     if is_empty_pattern(self._re_ignore_hosts):
         if is_empty_pattern(self._re_sync_hosts):
             result = True
         elif self._re_sync_hosts.match(mastername) is not None:
             result = True
     elif self._re_ignore_hosts.match(mastername) is None:
         result = True
     elif not is_empty_pattern(self._re_sync_hosts):
         if self._re_sync_hosts.match(mastername) is not None:
             result = True
     return result
Esempio n. 4
0
 def update_master(self, mastername, masteruri, timestamp, timestamp_local, discoverer_name, monitoruri, online):
     '''
     Updates the timestamp of the given ROS master, or creates a new SyncThread to
     synchronize the local master with given ROS master.
     @param mastername: the name of the remote ROS master to update or synchronize.
     @type mastername: C{str}
     @param masteruri: the URI of the remote ROS master.
     @type masteruri: C{str}
     @param timestamp: the timestamp of the remote ROS master.
     @type timestamp: L{float64}
     @param timestamp_local: the timestamp of the remote ROS master. (only local changes)
     @type timestamp_local: L{float64}
     @param discoverer_name: the name of the remote master_discoverer node
     @type discoverer_name: C{str}
     @param monitoruri: the URI of the RPC interface of the remote master_discoverer node.
     @type monitoruri: C{str}
     @param online: the current state on the master.
     @type online: C{bool}
     '''
     try:
         with self.__lock:
             if (masteruri != self.materuri):
                 if (is_empty_pattern(self._re_ignore_hosts) or not self._re_ignore_hosts.match(mastername) or
                         (not is_empty_pattern(self._re_sync_hosts) and self._re_sync_hosts.match(mastername) is not None)):
                     # do not sync to the master, if it is in ignore list
                     if self.__resync_on_reconnect and mastername in self.masters:
                         self.masters[mastername].set_online(online, self.__resync_on_reconnect_timeout)
                     if online:
                         if mastername in self.masters:
                                 # updates only, if local changes are occured
                             self.masters[mastername].update(mastername, masteruri, discoverer_name, monitoruri, timestamp_local)
                         else:
                             self.masters[mastername] = SyncThread(mastername, masteruri, discoverer_name, monitoruri, 0.0, self.__sync_topics_on_demand)
                             if self.__own_state is not None:
                                 self.masters[mastername].set_own_masterstate(MasterInfo.from_list(self.__own_state))
                             self.masters[mastername].update(mastername, masteruri, discoverer_name, monitoruri, timestamp_local)
             elif self.__timestamp_local != timestamp_local and self.__sync_topics_on_demand:
                 # get the master info from local discovery master and set it to all sync threads
                 self.own_state_getter = threading.Thread(target=self.get_own_state, args=(monitoruri,))
                 self.own_state_getter.start()
     except:
         import traceback
         rospy.logwarn("ERROR while update master[%s]: %s", str(mastername), traceback.format_exc())