Ejemplo n.º 1
0
 def __init__(self):
     '''
     Retrieves ``name``, ``description`` and ``icon`` parameters from the
     parameter server and publishes them on a latched ``info`` topic.
     The icon parameter must be a ros resource name (pkg/filename).
     '''
     ##################################
     # Pubs, Subs and Services
     ##################################
     self._publishers = {}
     # efficient latched publisher, put in the public concert namespace.
     self._parameters = self._setup_ros_parameters()
     self._publishers["info"] = rospy.Publisher("info",
                                                rocon_std_msgs.MasterInfo,
                                                latch=True,
                                                queue_size=1)
     master_info = rocon_std_msgs.MasterInfo()
     master_info.name = self._parameters['name']
     master_info.description = self._parameters['description']
     master_info.icon = rocon_python_utils.ros.icon_resource_to_msg(
         self._parameters['icon'])
     master_info.version = rocon_std_msgs.Strings.ROCON_VERSION
     self._publishers['info'].publish(master_info)
     # Aliases
     self.spin = rospy.spin
     """Spin function, currently this just replicates the rospy spin function since everything is done in the constructor."""
Ejemplo n.º 2
0
 def __init__(self):
     '''
     Retrieves ``name``, ``description`` and ``icon`` parameters from the
     parameter server and publishes them on a latched ``info`` topic.
     The icon parameter must be a ros resource name (pkg/filename).
     '''
     ##################################
     # Pubs, Subs and Services
     ##################################
     self.publishers = {}
     # efficient latched publisher, put in the public concert namespace.
     self.parameters = Parameters()
     self.publishers["info"] = rospy.Publisher("~info",
                                               rocon_std_msgs.MasterInfo,
                                               latch=True,
                                               queue_size=1)
     master_info = rocon_std_msgs.MasterInfo()
     master_info.name = self.parameters.name
     master_info.description = self.parameters.description
     master_info.rocon_uri = rocon_uri.generate_platform_rocon_uri(
         self.parameters.type, self.parameters.name)
     try:
         master_info.icon = rocon_python_utils.ros.icon_resource_to_msg(
             self.parameters.icon)
     except rospkg.ResourceNotFound as e:
         rospy.logwarn(
             "Master Info : no icon found, using a default [%s][%s]" %
             (self.parameters.icon, e))
         master_info.icon = rocon_python_utils.ros.icon_resource_to_msg(
             "rocon_bubble_icons/rocon_logo.png")
     master_info.version = rocon_std_msgs.Strings.ROCON_VERSION
     self.publishers['info'].publish(master_info)
     # Aliases
     self.spin = rospy.spin
     """Spin function, currently this just replicates the rospy spin function since everything is done in the constructor."""
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
def get_master_info(timeout=1.0):
    '''
      Tries to gather the rocon master info but if not available, return
      with a rocon_std_msgs.MasterInfo_ object filled with appropriate information
      ("Unknown Master" ...).

      :param double timeout: how long to blather around looking for the master info topic.

      :returns: the master information
      :rtype: rocon_std_msgs.MasterInfo_

      .. include:: weblinks.rst
    '''
    # default values
    master_info = rocon_std_msgs.MasterInfo()
    master_info.name = "Unknown Master"
    master_info.description = "Unknown"
    master_info.version = rocon_std_msgs.Strings.ROCON_VERSION
    master_info.icon = rocon_python_utils.ros.icon_resource_to_msg(
        'rocon_icons/unknown.png')

    try:
        topic_name = rocon_python_comms.find_topic(
            'rocon_std_msgs/MasterInfo',
            timeout=rospy.rostime.Duration(timeout),
            unique=True)
    except rocon_python_comms.NotFoundException as e:
        print(
            rocon_console.red +
            "failed to find unique topic of type 'rocon_std_msgs/MasterInfo' [%s]"
            % str(e) + rocon_console.reset)
        master_info.description = "Is it rocon enabled? See http://wiki.ros.org/rocon_master_info"
        return master_info

    master_info_proxy = rocon_python_comms.SubscriberProxy(
        topic_name, rocon_std_msgs.MasterInfo)
    try:
        master_info_proxy.wait_for_publishers()
    except rospy.exceptions.ROSInterruptException:
        rospy.logwarn(
            "Concert Info : ros shut down before rocon master info could be retrieved."
        )
        master_info.description = "Unkonwn"
        return master_info

    result = master_info_proxy(rospy.Duration(0.2))
    if result:
        master_info = result  # rocon_std_msgs.MasterInfo
    return master_info
Ejemplo n.º 5
0
 def __init__(self):
     ##################################
     # Pubs, Subs and Services
     ##################################
     self.publishers = {}
     # efficient latched publisher, put in the public concert namespace.
     self.param = self._setup_ros_parameters()
     self.publishers["info"] = rospy.Publisher("info",
                                               rocon_std_msgs.MasterInfo,
                                               latch=True)
     master_info = rocon_std_msgs.MasterInfo()
     master_info.name = self.param['name']
     master_info.description = self.param['description']
     master_info.icon = rocon_python_utils.ros.icon_resource_to_msg(
         self.param['icon'])
     master_info.version = rocon_std_msgs.Strings.ROCON_VERSION
     self.publishers['info'].publish(master_info)
     # Aliases
     self.spin = rospy.spin
Ejemplo n.º 6
0
    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()
Ejemplo n.º 7
0
def main(node_name='master_info', title='Master Information'):
    '''
      Establishes a connection and prints master information to the console.
    '''

    rospy.init_node(node_name)
    try:
        topic_name = rocon_python_comms.find_topic('rocon_std_msgs/MasterInfo', timeout=rospy.rostime.Duration(5.0), unique=True)
    except rocon_python_comms.NotFoundException as e:
        print(console.red + "failed to find unique topic of type 'rocon_std_msgs/MasterInfo' [%s]" % str(e) + console.reset)
        sys.exit(1)

    master_info_proxy = rocon_python_comms.SubscriberProxy(topic_name, rocon_std_msgs.MasterInfo)
    try:
        master_info_proxy.wait_for_publishers()
    except rospy.exceptions.ROSInterruptException:
        rospy.logwarn("Concert Info : ros shut down before concert info could be found.")

    master_info = rocon_std_msgs.MasterInfo()
    while not rospy.is_shutdown():
        result = master_info_proxy(rospy.Duration(0.2))
        if result:
            master_info = result
            break
        rospy.rostime.wallsleep(1.0)  # human time

    console.pretty_println(title, console.bold)
    print(console.cyan + "  Name       : " + console.yellow + master_info.name + console.reset)
    print(console.cyan + "  Description: " + console.yellow + master_info.description + console.reset)
    print(console.cyan + "  Icon       : " + console.yellow + master_info.icon.resource_name + console.reset)
    print(console.cyan + "  Version    : " + console.yellow + master_info.version + console.reset)

    if qt_available:
        icon = rocon_python_utils.ros.find_resource_from_string(master_info.icon.resource_name)
        signal.signal(signal.SIGINT, signal.SIG_DFL)  # make sure this comes after the rospy call, otherwise it will handle signals.
        app = QtGui.QApplication(sys.argv)
        window = Window(master_info.name, master_info.description, master_info.version, icon)
        window.show()
        sys.exit(app.exec_())
    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."""