def _set_platform_info(self): ''' Initialises the rapp manager with the appropriate platform info. This is part of the __init__ process. ''' # This might be naive and only work well on ubuntu... os_codename = rospkg.os_detect.OsDetect().get_codename() rosdistro = rospy.get_param("/rosdistro").rstrip( ) # have seen rosdistro set with newline characters messing things up rocon_uri = "rocon:/" + self._param['robot_type'] + \ "/" + self._param['robot_name'] + \ "/" + rosdistro + \ "/" + os_codename try: filename = rocon_utilities.find_resource_from_string( self._param['robot_icon']) icon = rocon_utilities.icon_to_msg(filename) except exceptions.NotFoundException: rospy.logwarn("App Manager : icon resource not found [%s]" % self._param['robot_icon']) icon = rocon_std_msgs.Icon() except ValueError: rospy.logwarn("App Manager : invalid resource name [%s]" % self._param['robot_icon']) icon = rocon_std_msgs.Icon() return (rocon_uri, icon)
def icon_to_msg(filename): ''' Loads the specified filename and puts in `rocon_std_msgs.Icon`_ format :param str filename: to the icon resource. :returns: the icon in msg format :rtype: `rocon_std_msgs.Icon`_ :todo:: should really raise a not found error if filename could not be found .. include:: weblinks.rst ''' icon = rocon_std_msgs.Icon() if filename is None or not filename: return icon unused_basename, extension = os.path.splitext(filename) if extension.lower() == ".jpg" or extension.lower() == ".jpeg": icon.format = "jpeg" elif extension.lower() == ".png": icon.format = "png" else: icon.format = "" return icon icon.data = open(filename, "rb").read() return icon
def __init__(self, stop_app_postexec_fn): ''' @param stop_app_postexec_fn : callback to fire when a listener detects an app getting stopped. @type method with no args ''' self._stop_app_postexec_fn = stop_app_postexec_fn self.app_list = {} self.rocon_master_info = {} self.is_connect = False self.is_app_running = False self.key = uuid.uuid4() self.app_pid = 0 # this might be naive and only work well on ubuntu... os_codename = OsDetect().get_codename() # this would be great as a configurable parameter name = "rqt_remocon_" + self.key.hex self.rocon_uri = rocon_uri.parse( "rocon:/pc/" + name + "/" + rocon_std_msgs.Strings.URI_WILDCARD + "/" + os_codename ) # be also great to have a configurable icon...with a default self.platform_info = rocon_std_msgs.PlatformInfo(version=rocon_std_msgs.Strings.ROCON_VERSION, uri=str(self.rocon_uri), icon=rocon_std_msgs.Icon() ) print("[remocon_info] info component initialised")
def __init__(self, ros_master_uri, host_name): super(InteractionsRemocon, self).__init__() self.key = uuid.uuid4() self.ros_master_uri = ros_master_uri self.ros_master_port = urlparse(self.ros_master_uri).port self.host_name = host_name self.name = "rqt_remocon_" + self.key.hex console.loginfo("Connection Details") console.loginfo(" Node Name: " + self.name) console.loginfo(" ROS_MASTER_URI: " + self.ros_master_uri) console.loginfo(" ROS_HOSTNAME: " + self.host_name) self.launched_interactions = LaunchedInteractions() # terminal for roslaunchers and other shell executables try: self.roslaunch_terminal = rocon_launch.create_terminal() except (rocon_launch.UnsupportedTerminal, rocon_python_comms.NotFoundException) as e: console.warning( "Cannot find a suitable terminal, falling back to the current terminal [%s]" % str(e)) self.roslaunch_terminal = rocon_launch.create_terminal( rocon_launch.terminals.active) self.namespaces = [] self.active_namespace = None self.rocon_uri = "rocon:/" self.active_pairing = None self.active_paired_interaction_hashes = [] # TODO a configurable icon...with a default self.platform_info = rocon_std_msgs.MasterInfo( version=rocon_std_msgs.Strings.ROCON_VERSION, rocon_uri=str(self.rocon_uri), icon=rocon_std_msgs.Icon(), description="") self.service_proxies = None self.subscribers = None self.pairings_table = get_pairings(self.active_namespace) self.interactions_table = get_interactions(self.active_namespace, "rocon:/") self.namespace_scanner = NamespaceScanner() self.namespace_scanner.signal_updated.connect(self.interactions_found, Qt.QueuedConnection) # self.namespace_scanner.busy_dialog.show() self.namespace_scanner.start() self.remocon_status_publisher = rospy.Publisher( "/remocons/" + self.name, interaction_msgs.RemoconStatus, latch=True, queue_size=5) self._publish_remocon_status()
def _set_platform_info(self): ''' Initialises the rapp manager with the appropriate platform info. This is part of the __init__ process. ''' # This might be naive and only work well on ubuntu... os_codename = rospkg.os_detect.OsDetect().get_codename() rocon_uri = "rocon:/" + self._param['robot_type'].lower().replace(' ', '_') + \ "/" + self._param['robot_name'].lower().replace(' ', '_') + \ "/" + rocon_python_utils.ros.get_rosdistro() + \ "/" + os_codename try: filename = rocon_python_utils.ros.find_resource_from_string( self._param['robot_icon']) icon = rocon_python_utils.ros.icon_to_msg(filename) except exceptions.NotFoundException: rospy.logwarn("Rapp Manager : icon resource not found [%s]" % self._param['robot_icon']) icon = rocon_std_msgs.Icon() except ValueError: rospy.logwarn("Rapp Manager : invalid resource name [%s]" % self._param['robot_icon']) icon = rocon_std_msgs.Icon() return (rocon_uri, icon)
def interactions_found(self): # self.namespace_scanner.busy_dialog.cancel() self.namespaces = self.namespace_scanner.namespaces print("Namespaces %s" % self.namespaces) self.active_namespace = None if not self.namespaces else self.namespaces[ 0] self.rocon_uri = rocon_uri.parse( rocon_uri.generate_platform_rocon_uri('pc', self.name) + "|" + utils.get_web_browser_codename()) self.active_pairing = None self.active_paired_interaction_hashes = [] # be also great to have a configurable icon...with a default self.platform_info = rocon_std_msgs.MasterInfo( version=rocon_std_msgs.Strings.ROCON_VERSION, rocon_uri=str(self.rocon_uri), icon=rocon_std_msgs.Icon(), description="") # Load Data self.pairings_table = get_pairings(self.active_namespace) self.interactions_table = get_interactions(self.active_namespace, "rocon:/") self.service_proxies = rocon_python_comms.utils.ServiceProxies([ (self.active_namespace + "request_interaction", interaction_srvs.RequestInteraction), (self.active_namespace + "start_pairing", interaction_srvs.StartPairing), (self.active_namespace + "stop_pairing", interaction_srvs.StopPairing) ]) self.subscribers = rocon_python_comms.utils.Subscribers([ (self.active_namespace + "pairing_status", interaction_msgs.PairingStatus, self._subscribe_pairing_status_callback) ]) console.logdebug( "Remocon : interactions namespace found -> signalling the ui.") self.signal_updated.emit() self._publish_remocon_status()
def icon_to_msg(filename): ''' Loads the specified filename and puts in rocon_std_msgs.Icon format @param : filename to the icon resource. @type : string ''' icon = rocon_std_msgs.Icon() if filename == None or filename == "": return icon unused_basename, extension = os.path.splitext(filename) if extension.lower() == ".jpg" or extension.lower() == ".jpeg": icon.format = "jpeg" elif extension.lower() == ".png": icon.format = "png" else: icon.format = "" return icon icon.data = open(filename, "rb").read() return icon
def __init__(self, stop_interaction_postexec_fn): ''' @param stop_app_postexec_fn : callback to fire when a listener detects an app getting stopped. @type method with no args ''' self._interactions_table = InteractionsTable() self._stop_interaction_postexec_fn = stop_interaction_postexec_fn self.is_connect = False self.key = uuid.uuid4() self._ros_master_port = None try: self._roslaunch_terminal = rocon_launch.create_terminal() except (rocon_launch.UnsupportedTerminal, rocon_python_comms.NotFoundException) as e: console.warning( "Cannot find a suitable terminal, falling back to the current terminal [%s]" % str(e)) self._roslaunch_terminal = rocon_launch.create_terminal( rocon_launch.terminals.active) # this might be naive and only work well on ubuntu... os_codename = OsDetect().get_codename() webbrowser_codename = utils.get_web_browser_codename() # this would be good as a persistant variable so the user can set something like 'Bob' self.name = "rqt_remocon_" + self.key.hex self.rocon_uri = rocon_uri.parse("rocon:/pc/" + self.name + "/" + rocon_std_msgs.Strings.URI_WILDCARD + "/" + os_codename + "|" + webbrowser_codename) # be also great to have a configurable icon...with a default self.platform_info = rocon_std_msgs.PlatformInfo( version=rocon_std_msgs.Strings.ROCON_VERSION, uri=str(self.rocon_uri), icon=rocon_std_msgs.Icon()) console.logdebug("Interactive Client : initialised") self.pairing = None # if an interaction is currently pairing, this will store its hash # expose underlying functionality higher up self.interactions = self._interactions_table.generate_role_view """Get a dictionary of interactions belonging to the specified role."""
def __init__(self, stop_interaction_postexec_fn): ''' @param stop_app_postexec_fn : callback to fire when a listener detects an app getting stopped. @type method with no args ''' self._interactions_table = InteractionsTable() self._stop_interaction_postexec_fn = stop_interaction_postexec_fn self.is_connect = False self.key = uuid.uuid4() self._ros_master_port = None try: self._roslaunch_terminal = rocon_launch.create_terminal() except (rocon_launch.UnsupportedTerminal, rocon_python_comms.NotFoundException) as e: console.warning( "Cannot find a suitable terminal, falling back to the current terminal [%s]" % str(e)) self._roslaunch_terminal = rocon_launch.create_terminal( rocon_launch.terminals.active) # this would be good as a persistant variable so the user can set something like 'Bob' self.name = "rqt_remocon_" + self.key.hex self.rocon_uri = rocon_uri.parse( rocon_uri.generate_platform_rocon_uri('pc', self.name) + "|" + utils.get_web_browser_codename()) # be also great to have a configurable icon...with a default self.platform_info = rocon_std_msgs.MasterInfo( version=rocon_std_msgs.Strings.ROCON_VERSION, rocon_uri=str(self.rocon_uri), icon=rocon_std_msgs.Icon(), description="") self.currently_pairing_interaction_hashes = [] self.active_one_sided_interaction = None # expose underlying functionality higher up self.interactions = self._interactions_table.generate_role_view """Get a dictionary of interactions belonging to the specified role."""