示例#1
0
    def __init__(self):
        # Initialization
        (self.service_name, self.service_description, self.service_priority, self.service_id) = concert_service_utilities.get_service_info()
        self.allocation_timeout = rospy.get_param('allocation_timeout', 15.0)  # seconds

        # Check the scheduler's KnownResources topic
        try:
            rocon_python_comms.find_topic('scheduler_msgs/KnownResources', timeout=rospy.rostime.Duration(5.0), unique=True)
        except rocon_python_comms.NotFoundException as e:
            rospy.logerr("Could not locate the scheduler's known_resources topic. [%s]" % str(e))
            sys.exit(1)

        # Set up the requester
        self._set_requester(self.service_id)
        self.pending_requests = dict()

        # Prepare a basket for storing allocated resources
        # Form: {__resource_uri__:{resource:__Resource.msg__, publisher:__Publisher__}, ...}
        self.linkgraph_info = dict()
        self.publishers = dict()
        self.action_clients_map = dict()
        self.service_proxies_map = dict()

        # Starting a SOAP server as a thread
        try:
            threading.Thread(target=self._start_soap_server).start()
        except:
            rospy.loginfo("Error on SOAP Server Thread...")
示例#2
0
    def __init__(self):
        ####################
        # Discovery
        ####################
        (self.service_name, self.service_description, self.service_priority, self.service_id) = concert_service_utilities.get_service_info()
        try:
            known_resources_topic_name = rocon_python_comms.find_topic('scheduler_msgs/KnownResources', timeout=rospy.rostime.Duration(5.0), unique=True)
        except rocon_python_comms.NotFoundException as e:
            rospy.logerr("AdapterSvc : could not locate the scheduler's known resources topic [%s]" % str(e))
            sys.exit(1)

        ####################
        # Setup
        ####################
        self.allocated_resources = []
        self.requester = self.setup_requester(self.service_id)
        self.lock = threading.Lock()
        self.pending_requests = []
        self.allocated_requests = {}
        self.command=''

        # Subscribe a topic from BPEL service
        self.bpel_service_subscriber = rospy.Subscriber('resources_alloc_request', adapter_msgs.Adapter, self.resources_alloc_request_callback)
        self.bpel_command_subscriber = rospy.Subscriber('command_request', adapter_msgs.Adapter, self.command_request_callback)

        self.allocation_timeout = rospy.get_param('allocation_timeout', 15.0)  # seconds
示例#3
0
    def _connect(self, rocon_master_name="", ros_master_uri="http://localhost:11311", host_name='localhost'):
        # remocon name would be good as a persistant configuration variable by the user
        # so they can set something like 'Bob'.
        remocon_name = 'rqt_remocon'
        unique_name = remocon_name + "_" + self.key.hex

        # uri is obtained from the user, stored in ros_master_uri
        os.environ["ROS_MASTER_URI"] = ros_master_uri
        os.environ["ROS_HOSTNAME"] = host_name

        print "[remocon_info] connect RemoconInfo "
        print "[remocon_info] ROS_MASTER_URI: " + str(os.environ["ROS_MASTER_URI"])
        print "[remocon_info] Node Name: " + str(unique_name)
        # Need to make sure we give it a unique node name and we need a unique uuid
        # for the remocon-role manager interaction anyway:

        rospy.init_node(unique_name, disable_signals=True)

        try:
            rocon_master_info_topic_name = rocon_python_comms.find_topic('rocon_std_msgs/MasterInfo', timeout=rospy.rostime.Duration(5.0), unique=True)
            get_interactions_service_name = rocon_python_comms.find_service('rocon_interaction_msgs/GetInteractions', timeout=rospy.rostime.Duration(5.0), unique=True)
            request_interaction_service_name = rocon_python_comms.find_service('rocon_interaction_msgs/RequestInteraction', timeout=rospy.rostime.Duration(5.0), unique=True)
        except rocon_python_comms.NotFoundException as e:
            console.logerror("RemoconInfo : failed to find either rocon master info or interactions topics and services' [%s]" % str(e))
            return False

        self.info_sub = rospy.Subscriber(rocon_master_info_topic_name, rocon_std_msgs.MasterInfo, self._info_callback)
        self.get_interactions_service_proxy = rospy.ServiceProxy(get_interactions_service_name, rocon_interaction_srvs.GetInteractions)
        self.request_interaction_service_proxy = rospy.ServiceProxy(request_interaction_service_name, rocon_interaction_srvs.RequestInteraction)
        self.remocon_status_pub = rospy.Publisher("remocons/" + unique_name, rocon_interaction_msgs.RemoconStatus, latch=True)

        self._pub_remocon_status(0, False)
        self.is_connect = True
        self.is_valid_info = False
        return True
    def _setup_subscribers(self):
        """
        Hunt for the conductor's namespace and setup subscribers.
        """
        while not rospy.is_shutdown() and not self._trigger_shutdown:
            try:
                graph_topic_name = rocon_python_comms.find_topic(
                    'concert_msgs/ConductorGraph',
                    timeout=rospy.rostime.Duration(0.1),
                    unique=True)
                (namespace,
                 unused_topic_name) = graph_topic_name.rsplit('/', 1)
                clients_topic_name = namespace + "/concert_clients"  # this is assuming they didn't remap this bugger.
                break
            except rocon_python_comms.NotFoundException:
                pass  # just loop around
        if rospy.is_shutdown() or self._trigger_shutdown:
            return
        self.is_conductor = True
        self.namespace = namespace

        # get data on all clients, even those not connected
        rospy.Subscriber(graph_topic_name, concert_msgs.ConductorGraph,
                         self._update_clients_callback)
        # get the periodic data of connected clients
        rospy.Subscriber(clients_topic_name, concert_msgs.ConcertClients,
                         self.update_connection_statistics)
示例#5
0
    def __init__(self):

        try:
            known_resources_topic_name = rocon_python_comms.find_topic(
                'scheduler_msgs/KnownResources',
                timeout=rospy.rostime.Duration(5.0),
                unique=True)
        except rocon_python_comms.NotFoundException as e:
            self.logerr(
                "could not locate the scheduler's known resources topic [%s]" %
                str(e))
            sys.exit(1)

        self.setup_variables()

        self.lock = threading.Lock()
        self.concert_clients_subscriber = rospy.Subscriber(
            known_resources_topic_name, scheduler_msgs.KnownResources,
            self.ros_scheduler_known_resources_callback)
        self.available_resource_publisher = rospy.Publisher(
            self.available_resource_publisher_name,
            rocon_std_msgs.StringArray,
            latch=True,
            queue_size=1)
        self.available_resources = []
        self.requester = self.setup_requester(self.service_id)
        self.pending_requests = []
        self.allocated_requests = {}
        self.allocate_resource_service_pair_server = rocon_python_comms.ServicePairServer(
            self.capture_topic_name,
            self.capture_callback,
            concert_service_msgs.CaptureResourcePair,
            use_threads=True)
        self.allocation_timeout = rospy.get_param('allocation_timeout',
                                                  15.0)  # seconds
示例#6
0
    def __init__(self):
        # Initialization
        (self.service_name, self.service_description, self.service_priority, self.service_id) = concert_service_utilities.get_service_info()
        self.allocation_timeout = rospy.get_param('allocation_timeout', 15.0)  # seconds

        # Check the scheduler's KnownResources topic
        try:
            rocon_python_comms.find_topic('scheduler_msgs/KnownResources', timeout=rospy.rostime.Duration(5.0), unique=True)
        except rocon_python_comms.NotFoundException as e:
            rospy.logerr("Could not locate the scheduler's known_resources topic. [%s]" % str(e))
            sys.exit(1)

        self.action_invocation_flag = 0

        # Set up the requester
        self._set_requester(self.service_id)
        self.pending_requests = dict()

        self.linkgraph_info = dict()
        self.publishers = dict()
        self.subscribers = dict()
        self.action_clients_map = dict()
        self.service_proxies_map = dict()
        self.callback_bpel_method_map = dict()

        # Prepare a basket for storing allocated resources
        # Form: {__resource_uri__:{resource:__Resource.msg__, publisher:__Publisher__}, ...}
        self.allocated_resources = dict()

        # Starting a SOAP server as a thread
        try:
            threading.Thread(target=self._start_soap_server).start()
        except:
            rospy.loginfo("Error on SOAP Server Thread...")

        # Set Publisher to invoke rapp
        #rospy.loginfo("Publisher to invoke rapp is set...")
        #self.rapp_pub = rospy.Publisher('/service_invoke', String, queue_size=DEFAULT_QUEUE_SIZE)
        #self.rapp_pub2 = rospy.Publisher("/sphero_backstep_cmd", String, queue_size=10)

        # Set Subscriber for Testing
        #self.test_sub = rospy.Subscriber("/fault/test", String, self._test)
        rospy.loginfo("Register Subscriber: /fault/test")
def console_only_main(node_name='concert_service_info',
                      title='Concert Service Information'):
    rospy.init_node(node_name)

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

    service_info_proxy = rocon_python_comms.SubscriberProxy(
        topic_name, concert_msgs.Services)
    try:
        service_info_proxy.wait_for_publishers()
    except rospy.exceptions.ROSInterruptException:
        rospy.logwarn(
            'Concert Service Info : ros shut down before concert info could be found.'
        )

    trial = 0
    MAX_TRIAL = 5
    while not rospy.is_shutdown():
        result = service_info_proxy(rospy.Duration(0.2))
        if result:
            service_info = result
            break
        rospy.rostime.wallsleep(1.0)  # human time
        trial = trial + 1

        if trial > MAX_TRIAL:
            rospy.logerr(
                'Concert Service info : concert is not found within ' +
                str(MAX_TRIAL) + ' trials')
            sys.exit(1)

    rocon_console.pretty_println('Concert Service Information',
                                 rocon_console.bold)
    for s in service_info.services:
        print_info('  Resource      : ', s.resource_name)
        print_info('  Name          : ', s.name)
        print_info('  Description   : ', s.description)
        print_info('  Author        : ', s.author)
        print_info('  Priority      : ', s.priority)
        print_info('  Launcher Type : ', s.launcher_type)
        print_info('  Status        : ', s.status)
        print_info('  Enabled       : ', s.enabled)
        print ''
示例#8
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
示例#9
0
    def set_topic_for_resource(self, msg):
        '''
          Set a topic for resource

          @param msg : incoming message
          @type msg: scheduler_msgs.ServiceMsg
        '''
        topic_name = "/services/adapter/required_resources"
        # rostopic find topic_name
        try:
            # assuming all topics here come in as /x/y/z/topicname or /x/y/z/topicname_355af31d
            topic_names = rocon_python_comms.find_topic('scheduler_msgs/SchedulerRequests', timeout=rospy.rostime.Duration(5.0), unique=False)
            topic_name = min(topic_names, key=len)
        except rocon_python_comms.NotFoundException:
            raise rocon_python_comms.NotFoundException("couldn't find the concert scheduler topics, aborting")
示例#10
0
    def __init__(self):
        ####################
        # Initiate SOAP Server
        ####################
        self.soap_server = Starter()
        self.soap_server.daemon = True
        self.soap_server.start()

        ####################
        # Discovery
        ####################
        (self.service_name, self.service_description, self.service_priority,
         self.service_id) = concert_service_utilities.get_service_info()
        try:
            known_resources_topic_name = rocon_python_comms.find_topic(
                'scheduler_msgs/KnownResources',
                timeout=rospy.rostime.Duration(5.0),
                unique=True)
        except rocon_python_comms.NotFoundException as e:
            rospy.logerr(
                "AdapterSvc : could not locate the scheduler's known resources topic [%s]"
                % str(e))
            sys.exit(1)

        ####################
        # Setup
        ####################
        self.allocated_resources = []
        self.requester = self.setup_requester(self.service_id)
        self.lock = threading.Lock()
        self.pending_requests = []
        self.allocated_requests = {}
        self.command = ''

        # Subscribe a topic from BPEL service
        self.bpel_package_subscriber = rospy.Subscriber(
            'package_find_request', String, self.package_find_request_callback)
        self.bpel_service_subscriber = rospy.Subscriber(
            'resources_alloc_request', adapter_msgs.Adapter,
            self.resources_alloc_request_callback)
        self.bpel_command_subscriber = rospy.Subscriber(
            'command_request', adapter_msgs.Adapter,
            self.command_request_callback)

        self.allocation_timeout = rospy.get_param('allocation_timeout',
                                                  15.0)  # seconds
示例#11
0
    def set_topic_for_resource(self, msg):
        '''
          Set a topic for resource

          @param msg : incoming message
          @type msg: scheduler_msgs.ServiceMsg
        '''
        topic_name = "/services/adapter/required_resources"
        # rostopic find topic_name
        try:
            # assuming all topics here come in as /x/y/z/topicname or /x/y/z/topicname_355af31d
            topic_names = rocon_python_comms.find_topic(
                'scheduler_msgs/SchedulerRequests',
                timeout=rospy.rostime.Duration(5.0),
                unique=False)
            topic_name = min(topic_names, key=len)
        except rocon_python_comms.NotFoundException:
            raise rocon_python_comms.NotFoundException(
                "couldn't find the concert scheduler topics, aborting")
示例#12
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
示例#13
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_())
示例#14
0
 def test_fake_remocon(self):
     """ Loading... """
     try:
         topic_name = rocon_python_comms.find_topic(
             'rocon_interaction_msgs/InteractiveClients',
             timeout=rospy.rostime.Duration(5.0),
             unique=True)
         rospy.loginfo("TestRemocons : found interactions manager at %s" %
                       topic_name)
     except rocon_python_comms.NotFoundException as e:
         self.fail("couldn't find the interactions topics")
     rospy.Subscriber(topic_name, interaction_msgs.InteractiveClients,
                      self.callback)
     count = 0
     timeout_time = time.time() + 5.0
     while not rospy.is_shutdown(
     ) and self.number_of_interactive_clients != 1:
         rospy.rostime.wallsleep(0.1)
         if time.time() > timeout_time:
             break
     self.assertEqual(
         self.number_of_interactive_clients, 1,
         'timed out waiting for publication of our fake remocon')
示例#15
0
    def _setup_rapp_manager_connections(self):
        try:
            start_rapp_service_name = rocon_python_comms.find_service('rocon_app_manager_msgs/StartRapp', timeout=rospy.rostime.Duration(60.0), unique=True)
            stop_rapp_service_name = rocon_python_comms.find_service('rocon_app_manager_msgs/StopRapp', timeout=rospy.rostime.Duration(60.0), unique=True)
            status_topic_name = rocon_python_comms.find_topic('rocon_app_manager_msgs/Status', timeout=rospy.rostime.Duration(60.0), unique=True)
        except rocon_python_comms.NotFoundException as e:
            rospy.logerr("Interactions : timed out trying to find the rapp manager start_rapp, stop_rapp services and status topic [%s]" % str(e))

        self.start_rapp = rospy.ServiceProxy(start_rapp_service_name, rocon_app_manager_srvs.StartRapp)
        self.stop_rapp = rospy.ServiceProxy(stop_rapp_service_name, rocon_app_manager_srvs.StopRapp)
        self.status_subscriber = rospy.Subscriber(status_topic_name, rocon_app_manager_msgs.Status, self._ros_status_subscriber)

        try:
            self.start_rapp.wait_for_service(15.0)
            self.stop_rapp.wait_for_service(15.0)
            # I should also check the subscriber has get_num_connections > 0 here
            # (need to create a wait_for_publisher in rocon_python_comms)
            self.initialised = True
            rospy.loginfo("Interactions : initialised rapp handler connections for pairing.")
        except rospy.ROSException:
            rospy.logerr("Interactions : rapp manager services disappeared.")
        except rospy.ROSInterruptException:
            rospy.logerr("Interactions : ros shutdown while looking for the rapp manager services.")
示例#16
0
def find_scheduler_requests_topic(timeout=rospy.rostime.Duration(5.0)):
    '''
      Do a lookup to find the scheduler requests topic.

      :param timeout: raise an exception if nothing is found before this timeout occurs.
      :type timeout: rospy.rostime.Duration

      :returns: the fully resolved name of the topic
      :rtype: str

      :raises rocon_python_comms.NotFoundException: if no topic is found within the timeout
    '''
    try:
        # assuming all topics here come in as /x/y/z/topicname or /x/y/z/topicname_355af31d
        topic_names = rocon_python_comms.find_topic(
            'scheduler_msgs/SchedulerRequests',
            timeout=rospy.rostime.Duration(5.0),
            unique=False)
        topic_name = min(topic_names, key=len)
    except rocon_python_comms.NotFoundException:
        raise rocon_python_comms.NotFoundException(
            "couldn't find the concert scheduler topics, aborting")
    return topic_name
示例#17
0
    def __init__(self):
        ####################
        # Discovery
        ####################
        (self.service_name, self.service_description,
         self.service_id) = concert_service_utilities.get_service_info()
        try:
            known_resources_topic_name = rocon_python_comms.find_topic(
                'scheduler_msgs/KnownResources',
                timeout=rospy.rostime.Duration(5.0),
                unique=True)
        except rocon_python_comms.NotFoundException as e:
            rospy.logerr(
                "TeleopPimp : could not locate the scheduler's known resources topic [%s]"
                % str(e))
            sys.exit(1)

        ####################
        # Setup
        ####################
        self.concert_clients_subscriber = rospy.Subscriber(
            known_resources_topic_name, scheduler_msgs.KnownResources,
            self.ros_scheduler_known_resources_callback)
        self.available_teleops_publisher = rospy.Publisher(
            'available_teleops', rocon_std_msgs.StringArray, latch=True)
        self.teleopable_robots = []
        self.requester = self.setup_requester(self.service_id)
        self.lock = threading.Lock()
        self.pending_requests = []
        self.allocated_requests = {}

        self.allocate_teleop_service_pair_server = rocon_python_comms.ServicePairServer(
            'capture_teleop',
            self.ros_capture_teleop_callback,
            rocon_service_msgs.CaptureTeleopPair,
            use_threads=True)
        self.allocation_timeout = 5.0  # seconds
def get_services_info():
    '''
      Used to get concert_service_info
       
      resultdict stores key as resource_name and value as tuple of services info
      keyList stores list of resoure_names to be used as key's for resultdict
 
      :returns: the concert service information as a tuple (keyList, resultdict)
      :rtype: (list, dictionary)
    '''
    resultdict = {}
    keyList = []
    try:
        topic_name = rocon_python_comms.find_topic(
            'concert_msgs/Services',
            timeout=rospy.rostime.Duration(5.0),
            unique=True)
    except rocon_python_comms.NotFoundException as e:
        print(
            rocon_console.red +
            "failed to find unique topic of type 'concert_msgs/Services' [%s]"
            % str(e) + rocon_console.reset)
        sys.exit(1)

    service_info_proxy = rocon_python_comms.SubscriberProxy(
        topic_name, concert_msgs.Services)
    try:
        service_info_proxy.wait_for_publishers()
    except rospy.exceptions.ROSInterruptException:
        rospy.logwarn(
            'Concert Service Info : ros shut down before concert info could be found.'
        )

    trial = 0
    MAX_TRIAL = 5
    while not rospy.is_shutdown():
        result = service_info_proxy(rospy.Duration(0.2))
        if result:
            service_info = result
            break
        rospy.rostime.wallsleep(1.0)  # human time
        trial = trial + 1
        if trial > MAX_TRIAL:
            rospy.logerr(
                'Concert Service info : concert is not found within ' +
                str(MAX_TRIAL) + ' trials')
            sys.exit(1)

    for s in service_info.services:
        objResult = Object()
        objResult.resource_name = s.resource_name
        objResult.name = s.name
        objResult.description = s.description
        objResult.author = s.author
        objResult.priority = s.priority
        objResult.launcher_type = s.launcher_type
        objResult.status = s.status
        objResult.enabled = s.enabled
        objResult.icon = s.icon
        resultdict[objResult.resource_name] = (objResult)
        keyList.append(objResult.resource_name)
    return (keyList, resultdict)
示例#19
0
 def _init_ros_subscriber(self):
     try:
         subscriber_topic_name = rocon_python_comms.find_topic('concert_msgs/Services', timeout=rospy.rostime.Duration(5.0), unique=True)
         self.ros_subscribers['service_list'] = rospy.Subscriber(subscriber_topic_name, concert_msgs.Services, self.update_service_list)
     except NotFoundException as e:
         raise e
示例#20
0
    def _connect(self,
                 ros_master_uri="http://localhost:11311",
                 host_name='localhost'):

        self._ros_master_port = urlparse(os.environ["ROS_MASTER_URI"]).port
        console.logdebug("Interactive Client : Connection Details")
        console.logdebug("Interactive Client :   Node Name: " + self.name)
        console.logdebug("Interactive Client :   ROS_MASTER_URI: " +
                         ros_master_uri)
        console.logdebug("Interactive Client :   ROS_HOSTNAME: " + host_name)
        console.logdebug("Interactive Client :   ROS_MASTER_PORT: %s" %
                         self._ros_master_port)

        # Need to make sure we give init a unique node name and we need a unique uuid
        # for the remocon-role manager interaction anyway:

        try:
            console.logdebug(
                "Interactive Client : Get interactions service Handle")
            interactions_namespace = rocon_python_comms.find_service_namespace(
                'get_interactions',
                'rocon_interaction_msgs/GetInteractions',
                unique=True)
            remocon_services = self._set_remocon_services(
                interactions_namespace)
        except rocon_python_comms.MultipleFoundException as e:
            message = "multiple interactions' publications and services [%s] are found. Please check services" % str(
                e)
            console.logerror("InteractiveClientInterface : %s" % message)
            return (False, message)
        except rocon_python_comms.NotFoundException as e:
            message = "failed to find all of the interactions' publications and services for [%s]" % str(
                e)
            console.logerror("InteractiveClientInterface : %s" % message)
            return (False, message)

        self.get_interactions_service_proxy = rospy.ServiceProxy(
            remocon_services['get_interactions'],
            rocon_interaction_srvs.GetInteractions)
        self.get_roles_service_proxy = rospy.ServiceProxy(
            remocon_services['get_roles'], rocon_interaction_srvs.GetRoles)
        self.request_interaction_service_proxy = rospy.ServiceProxy(
            remocon_services['request_interaction'],
            rocon_interaction_srvs.RequestInteraction)
        self.remocon_status_pub = rospy.Publisher(
            "remocons/" + self.name,
            rocon_interaction_msgs.RemoconStatus,
            latch=True,
            queue_size=10)

        try:
            # if its available, should be quick to find this one since we found the others...
            pairing_topic_name = rocon_python_comms.find_topic(
                'rocon_interaction_msgs/Pair',
                timeout=rospy.rostime.Duration(0.5),
                unique=True)
            self.pairing_status_subscriber = rospy.Subscriber(
                pairing_topic_name, rocon_interaction_msgs.Pair,
                self._subscribe_pairing_status_callback)
        except rocon_python_comms.NotFoundException as e:
            console.logdebug(
                "Interactive Client : support for paired interactions disabled [not found]"
            )

        self._publish_remocon_status()
        self.is_connect = True
        return (True, "success")