def updateSyncInfo(self): ''' This method can be called to update the origin ROS master URI of the nodes and services in new ``master_state``. This is only need, if a synchronization is running. The synchronization service will be detect automatically by searching for the service ending with ``get_sync_info``. The method will be called by :mod:`master_discovery_fkie.master_monitor.MasterMonitor.checkState()`. ''' #'print "updateSyncInfo _create_access_lock try...", threading.current_thread() with self._create_access_lock: #'print " updateSyncInfo _create_access_lock locked", threading.current_thread() master_state = self.__new_master_state sync_info = None # get synchronization info, if sync node is running # to determine the origin ROS MASTER URI of the nodes for name, service in master_state.services.items(): if service.name.endswith('get_sync_info'): if interface_finder.hostFromUri(self.getMasteruri()) == interface_finder.hostFromUri(service.uri): socket.setdefaulttimeout(3) get_sync_info = rospy.ServiceProxy(service.name, GetSyncInfo) try: sync_info = get_sync_info() except rospy.ServiceException, e: rospy.logwarn("ERROR Service call 'get_sync_info' failed: %s", str(e)) finally: socket.setdefaulttimeout(None)
def updateSyncInfo(self): ''' This method can be called to update the origin ROS master URI of the nodes and services in new master_state. This is only need, if a synchronization is running. The synchronization service will be detect automatically by searching for the service ending with C{get_sync_info}. The method will be called by C{checkState()}. ''' #'print "updateSyncInfo _create_access_lock try...", threading.current_thread() with self._create_access_lock: #'print " updateSyncInfo _create_access_lock locked", threading.current_thread() master_state = self.__new_master_state sync_info = None # get synchronization info, if sync node is running # to determine the origin ROS MASTER URI of the nodes for name, service in master_state.services.items(): if service.name.endswith('get_sync_info'): if interface_finder.hostFromUri(self.getMasteruri( )) == interface_finder.hostFromUri(service.uri): socket.setdefaulttimeout(3) get_sync_info = rospy.ServiceProxy( service.name, GetSyncInfo) try: sync_info = get_sync_info() except rospy.ServiceException, e: rospy.logwarn( "ERROR Service call 'get_sync_info' failed: %s", str(e)) finally: socket.setdefaulttimeout(None)
def getMastername(self): ''' Returns the name of the master. If no name is set, the hostname of the ROS master URI will be extracted. :return: the name of the ROS master :rtype: str or ``None`` ''' if self.__mastername is None: try: self.__mastername = interface_finder.hostFromUri( self.getMasteruri()) try: from urlparse import urlparse master_port = urlparse(self.__masteruri).port if master_port != 11311: self.__mastername = '--'.join( [self.__mastername, str(master_port)]) except: pass except: pass return self.__mastername
def updateSyncInfo(self): ''' This method can be called to update the origin ROS master URI of the nodes and services in new ``master_state``. This is only need, if a synchronization is running. The synchronization service will be detect automatically by searching for the service ending with ``get_sync_info``. The method will be called by :mod:`master_discovery_fkie.master_monitor.MasterMonitor.checkState()`. ''' #'print "updateSyncInfo _create_access_lock try...", threading.current_thread() def getNodeuri(nodename, publisher, subscriber, services): for p in publisher: if nodename == p.node: return p.nodeuri for p in subscriber: if nodename == p.node: return p.nodeuri for s in services: if nodename == s.node: return s.nodeuri return None with self._create_access_lock: #'print " updateSyncInfo _create_access_lock locked", threading.current_thread() master_state = self.__new_master_state sync_info = None # get synchronization info, if sync node is running # to determine the origin ROS MASTER URI of the nodes for name, service in master_state.services.items(): if service.name.endswith('get_sync_info'): if interface_finder.hostFromUri(self.getMasteruri( )) == interface_finder.hostFromUri(service.uri): socket.setdefaulttimeout(3) get_sync_info = rospy.ServiceProxy( service.name, GetSyncInfo) try: sync_info = get_sync_info() except rospy.ServiceException, e: rospy.logwarn( "ERROR Service call 'get_sync_info' failed: %s", str(e)) finally: socket.setdefaulttimeout(None)
def getMastername(self): ''' Returns the name of the master. If no name is set, the hostname of the ROS master URI will be extracted. @return: the name of the ROS master @rtype: C{str} or C{None} ''' if self.__mastername is None: try: self.__mastername = interface_finder.hostFromUri(self.getMasteruri()) except: pass return self.__mastername
def getMastername(self): ''' Returns the name of the master. If no name is set, the hostname of the ROS master URI will be extracted. @return: the name of the ROS master @rtype: C{str} or C{None} ''' if self.__mastername is None: try: self.__mastername = interface_finder.hostFromUri( self.getMasteruri()) except: pass return self.__mastername
def updateSyncInfo(self): ''' This method can be called to update the origin ROS master URI of the nodes and services in new master_state. This is only need, if a synchronization is running. The synchronization service will be detect automatically by searching for the service ending with C{get_sync_info}. The method will be called by C{checkState()}. ''' with self._create_access_lock: master_state = self.__new_master_state sync_info = None # get synchronization info, if sync node is running # to determine the origin ROS MASTER URI of the nodes for name, service in master_state.services.items(): if service.name.endswith('get_sync_info'): if interface_finder.hostFromUri(self.getMasteruri()) == interface_finder.hostFromUri(service.uri): socket.setdefaulttimeout(2) get_sync_info = rospy.ServiceProxy(service.name, GetSyncInfo) try: sync_info = get_sync_info() except rospy.ServiceException, e: rospy.logwarn("ERROR Service call 'get_sync_info' failed: %s", str(e)) finally: socket.setdefaulttimeout(None)
def getMastername(self): ''' Returns the name of the master. If no name is set, the hostname of the ROS master URI will be extracted. @return: the name of the ROS master @rtype: C{str} or C{None} ''' if self.__mastername is None: try: self.__mastername = interface_finder.hostFromUri(self.getMasteruri()) try: from urlparse import urlparse master_port = urlparse(self.__masteruri).port if master_port != 11311: self.__mastername = '--'.join([self.__mastername, str(master_port)]) except: pass except: pass return self.__mastername
def getMastername(self): ''' Returns the name of the master. If no name is set, the hostname of the ROS master URI will be extracted. :return: the name of the ROS master :rtype: str or ``None`` ''' if self.__mastername is None: try: self.__mastername = interface_finder.hostFromUri(self.getMasteruri()) try: from urlparse import urlparse master_port = urlparse(self.__masteruri).port if master_port != 11311: self.__mastername = '%s_%d' % (self.__mastername, master_port) except: pass except: pass return self.__mastername