Exemplo n.º 1
0
 def __init__(self):
     '''
 Creates a new instance. Find the topic of the master_discovery node using 
 L{master_discovery_fkie.interface_finder.get_changes_topic()}. Also the 
 parameter C{~ignore_hosts} will be analyzed to exclude hosts from sync.
 '''
     self.masters = {}
     # the connection to the local service master
     self.materuri = self.getMasteruri()
     '''@ivar: the ROS master URI of the C{local} ROS master. '''
     self.__lock = threading.RLock()
     #load interface
     self._loadInterface()
     # subscribe to changes notifier topics
     topic_names = interface_finder.get_changes_topic(self.getMasteruri())
     self.sub_changes = dict()
     '''@ivar: {dict} with topics C{(name: L{rospy.Subscriber})} publishes the changes of the discovered ROS masters.'''
     for topic_name in topic_names:
         rospy.loginfo("listen for updates on %s", topic_name)
         self.sub_changes[topic_name] = rospy.Subscriber(
             topic_name, MasterState, self.handlerMasterStateMsg)
     self.__timestamp_local = None
     self.__own_state = None
     self.update_timer = None
     self.own_state_getter = None
     rospy.on_shutdown(self.finish)
     # initialize the ROS services
     rospy.Service('~get_sync_info', GetSyncInfo,
                   self.rosservice_get_sync_info)
     self.retrieveMasters()
 def __init__(self):
     '''
     Creates a new instance. Find the topic of the master_discovery node using
     U{master_discovery_fkie.interface_finder.get_changes_topic()
     <http://docs.ros.org/api/master_discovery_fkie/html/modules.html#interface-finder-module>}.
     Also the parameter C{~ignore_hosts} will be analyzed to exclude hosts from sync.
     '''
     self.masters = {}
     # the connection to the local service master
     self.materuri = masteruri_from_master()
     '''@ivar: the ROS master URI of the C{local} ROS master. '''
     self.__lock = threading.RLock()
     # load interface
     self._load_interface()
     # subscribe to changes notifier topics
     topic_names = interface_finder.get_changes_topic(masteruri_from_master())
     self.sub_changes = dict()
     '''@ivar: `dict` with topics {name: U{rospy.Subscriber<http://docs.ros.org/api/rospy/html/rospy.topics.Subscriber-class.html>}} publishes the changes of the discovered ROS masters.'''
     for topic_name in topic_names:
         rospy.loginfo("listen for updates on %s", topic_name)
         self.sub_changes[topic_name] = rospy.Subscriber(topic_name, MasterState, self._rosmsg_callback_master_state)
     self.__timestamp_local = None
     self.__own_state = None
     self.update_timer = None
     self.own_state_getter = None
     self._join_threads = dict()  # threads waiting for stopping the sync thread
     # initialize the ROS services
     rospy.Service('~get_sync_info', GetSyncInfo, self._rosservice_get_sync_info)
     rospy.on_shutdown(self.finish)
     self.obtain_masters()
 def __init__(self):
     '''
     Creates a new instance. Find the topic of the master_discovery node using
     U{master_discovery_fkie.interface_finder.get_changes_topic()
     <http://docs.ros.org/api/master_discovery_fkie/html/modules.html#interface-finder-module>}.
     Also the parameter C{~ignore_hosts} will be analyzed to exclude hosts from sync.
     '''
     self.masters = {}
     # the connection to the local service master
     self.materuri = masteruri_from_master()
     '''@ivar: the ROS master URI of the C{local} ROS master. '''
     self.__lock = threading.RLock()
     # load interface
     self._load_interface()
     # subscribe to changes notifier topics
     topic_names = interface_finder.get_changes_topic(
         masteruri_from_master())
     self.sub_changes = dict()
     '''@ivar: `dict` with topics {name: U{rospy.Subscriber<http://docs.ros.org/api/rospy/html/rospy.topics.Subscriber-class.html>}} publishes the changes of the discovered ROS masters.'''
     for topic_name in topic_names:
         rospy.loginfo("listen for updates on %s", topic_name)
         self.sub_changes[topic_name] = rospy.Subscriber(
             topic_name, MasterState, self._rosmsg_callback_master_state)
     self.__timestamp_local = None
     self.__own_state = None
     self.update_timer = None
     self.own_state_getter = None
     self._join_threads = dict(
     )  # threads waiting for stopping the sync thread
     # initialize the ROS services
     rospy.Service('~get_sync_info', GetSyncInfo,
                   self._rosservice_get_sync_info)
     rospy.on_shutdown(self.finish)
     self.obtain_masters()
Exemplo n.º 4
0
  def __init__(self):
    '''
    Creates a new instance. Find the topic of the master_discovery node using 
    L{master_discovery_fkie.interface_finder.get_changes_topic()}. Also the 
    parameter C{~ignore_hosts} will be analyzed to exclude hosts from sync.
    '''
    self.masters = {}
    # the connection to the local service master 
    self.materuri = self.getMasteruri()
    '''@ivar: the ROS master URI of the C{local} ROS master. '''
    self.__lock = threading.RLock()
    self.ignore = []
    '''@ivar: the list with host names, which are not sync.'''
    if rospy.has_param('~ignore_hosts'):
      self.ignore[len(self.ignore):] = rospy.get_param('~ignore_hosts')
    topic_names = interface_finder.get_changes_topic(self.getMasteruri())
    self.sub_changes = dict()
    '''@ivar: {dict} with topics C{(name: L{rospy.Subscriber})} publishes the changes of the discovered ROS masters.'''
    for topic_name in topic_names:
      rospy.loginfo("listen for updates on %s", topic_name)
      self.sub_changes[topic_name] = rospy.Subscriber(topic_name, MasterState, self.handlerMasterStateMsg)
    rospy.on_shutdown(self.finish)
    # initialize the ROS services
    rospy.Service('~get_sync_info', GetSyncInfo, self.rosservice_get_sync_info)

    self.update_timer = None
    self.retrieveMasters()
Exemplo n.º 5
0
 def __init__(self):
   '''
   Creates a new instance. Find the topic of the master_discovery node using 
   L{master_discovery_fkie.interface_finder.get_changes_topic()}. Also the 
   parameter C{~ignore_hosts} will be analyzed to exclude hosts from sync.
   '''
   self.masters = {}
   # the connection to the local service master 
   self.materuri = self.getMasteruri()
   '''@ivar: the ROS master URI of the C{local} ROS master. '''
   self.__lock = threading.RLock()
   #load interface
   self._loadInterface()
   # subscribe to changes notifier topics
   topic_names = interface_finder.get_changes_topic(self.getMasteruri())
   self.sub_changes = dict()
   '''@ivar: {dict} with topics C{(name: L{rospy.Subscriber})} publishes the changes of the discovered ROS masters.'''
   for topic_name in topic_names:
     rospy.loginfo("listen for updates on %s", topic_name)
     self.sub_changes[topic_name] = rospy.Subscriber(topic_name, MasterState, self.handlerMasterStateMsg)
   self.__timestamp_local = None
   self.__own_state = None
   self.update_timer = None
   self.own_state_getter = None
   self._join_threads = dict() # threads waiting for stopping the sync thread
   # initialize the ROS services
   rospy.Service('~get_sync_info', GetSyncInfo, self.rosservice_get_sync_info)
   rospy.on_shutdown(self.finish)
   self.retrieveMasters()
 def registerByROS(self, masteruri, wait=False):
   '''
   This method creates a ROS subscriber to received the notifications of ROS 
   master updates. The retrieved messages will be emitted as state_signal.
   @param masteruri: the ROS master URI
   @type masteruri: C{str}
   @param wait: wait for the topic
   @type wait: C{boolean}
   '''
   found = False
   topic_names = interface_finder.get_changes_topic(masteruri, wait)
   self.stop()
   self.sub_changes = []
   for topic_name in topic_names:
     rospy.loginfo("listen for updates on %s", topic_name)
     sub_changes = rospy.Subscriber(topic_name, MasterState, self.handlerMasterStateMsg)
     self.sub_changes.append(sub_changes)
     found = True
   return found
Exemplo n.º 7
0
 def registerByROS(self, masteruri, wait=True):
   '''
   This method creates a ROS subscriber to received the notifications of ROS 
   master updates. The retrieved messages will be emitted as state_signal.
   @param masteruri: the ROS master URI
   @type masteruri: C{str}
   @param wait: wait for the topic
   @type wait: C{boolean}
   '''
   found = False
   topic_names = interface_finder.get_changes_topic(masteruri, wait)
   self.stop()
   self.sub_changes = []
   for topic_name in topic_names:
     rospy.loginfo("listen for updates on %s", topic_name)
     sub_changes = rospy.Subscriber(topic_name, master_discovery_fkie.msg.MasterState, self.handlerMasterStateMsg)
     self.sub_changes.append(sub_changes)
     found = True
   return found
 def registerByROS(self, masteruri, wait=False):
     '''
     This method creates a ROS subscriber to received the notifications of ROS
     master updates. The retrieved messages will be emitted as state_signal.
     @param masteruri: the ROS master URI
     @type masteruri: C{str}
     @param wait: wait for the topic
     @type wait: C{boolean}
     @return: the topic name or an empty string
     '''
     result = ''
     topic_names = interface_finder.get_changes_topic(masteruri, wait)
     self.stop()
     self.sub_changes = []
     for topic_name in topic_names:
         rospy.loginfo("listen for updates on %s", topic_name)
         sub_changes = rospy.Subscriber(topic_name, MasterState,
                                        self.handlerMasterStateMsg)
         self.sub_changes.append(sub_changes)
         result = topic_name
     return result
Exemplo n.º 9
0
 def __init__(self):
     '''
 Creates a new instance. Find the topic of the master_discovery node using 
 L{master_discovery_fkie.interface_finder.get_changes_topic()}. Also the 
 parameter C{~ignore_hosts} will be analyzed to exclude hosts from sync.
 '''
     self.masters = {}
     # the connection to the local service master
     self.materuri = self.getMasteruri()
     '''@ivar: the ROS master URI of the C{local} ROS master. '''
     self.__lock = threading.RLock()
     self.ignore = []
     '''@ivar: the list with host names, which are not sync.'''
     if rospy.has_param('~ignore_hosts'):
         self.ignore[len(self.ignore):] = rospy.get_param('~ignore_hosts')
     topic_names = interface_finder.get_changes_topic(self.getMasteruri())
     self.sub_changes = dict()
     '''@ivar: {dict} with topics C{(name: L{rospy.Subscriber})} publishes the changes of the discovered ROS masters.'''
     for topic_name in topic_names:
         rospy.loginfo("listen for updates on %s", topic_name)
         self.sub_changes[topic_name] = rospy.Subscriber(
             topic_name, MasterState, self.handlerMasterStateMsg)
     rospy.on_shutdown(self.finish)
     self.retrieveMasters()