Beispiel #1
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 _init_ros_service(self):
     try:
         enable_service = rocon_python_comms.find_service('concert_msgs/EnableService', timeout=rospy.rostime.Duration(5.0), unique=True)
         self.ros_services['enable_service'] = rospy.ServiceProxy(enable_service, EnableService)
         update_service_config = rocon_python_comms.find_service('concert_msgs/UpdateServiceConfig', timeout=rospy.rostime.Duration(5.0), unique=True)
         self.ros_services['update_service_config'] = rospy.ServiceProxy(update_service_config, UpdateServiceConfig)
     except NotFoundException as e:
         raise e
 def _get_namespaces(self):
     """
     Getting the name space with running the rapp
     @return name space list
     @type list
     """
     get_rapp_list_service_names = rocon_python_comms.find_service('rocon_app_manager_msgs/GetRappList', timeout=rospy.rostime.Duration(5.0), unique=False)
     return get_rapp_list_service_names
Beispiel #4
0
 def __init__(self):
     """
     Search for handle of concert software farm and get ready to serve high level system's requests
     """
     software_farm_srv_name = rocon_python_comms.find_service(
         'concert_msgs/AllocateSoftware',
         timeout=rospy.rostime.Duration(5.0),
         unique=True)
     self._software_farm_srv = rospy.ServiceProxy(
         software_farm_srv_name, concert_srvs.AllocateSoftware)
     self._allocated_softwares = []
     rospy.on_shutdown(self._shutdown)
Beispiel #5
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.")
Beispiel #6
0
    def __init__(self):
        '''
        Don't do any loading here, just set up infrastructure and overrides from
        the solution.

        :raises: rocon_python_comms.NotFoundException, rospy.exceptions.ROSException,
               rospy.exceptions.ROSInterruptException
        '''
        try:
            service_name = rocon_python_comms.find_service('rocon_interaction_msgs/SetInteractions',
                                                           timeout=rospy.rostime.Duration(15.0),
                                                           unique=True)
        except rocon_python_comms.NotFoundException as e:
            raise rocon_python_comms.NotFoundException(
                "failed to find unique service of type 'rocon_interaction_msgs/SetInteractions' [%s]"
                % str(e))
        self._set_interactions_proxy = rospy.ServiceProxy(service_name, interaction_srvs.SetInteractions)
Beispiel #7
0
    def __init__(self):
        '''
        Don't do any loading here, just set up infrastructure and overrides from
        the solution.

        :raises: rocon_python_comms.NotFoundException, rospy.exceptions.ROSException,
               rospy.exceptions.ROSInterruptException
        '''
        try:
            service_name = rocon_python_comms.find_service('rocon_interaction_msgs/SetInteractions',
                                                           timeout=rospy.rostime.Duration(15.0),
                                                           unique=True)
        except rocon_python_comms.NotFoundException as e:
            raise rocon_python_comms.NotFoundException(
                "failed to find unique service of type 'rocon_interaction_msgs/SetInteractions' [%s]"
                % str(e))
        self._set_interactions_proxy = rospy.ServiceProxy(service_name, interaction_srvs.SetInteractions)
Beispiel #8
0
 def run(self):
     # TODO : replace with a connection cache proxy instead of find_service
     while not self.shutdown_requested:
         start_time = None
         timeout = 0.5
         timout_sequence_count = 0
         try:
             start_time = rospy.get_time()
             service_names = rocon_python_comms.find_service(
                 'rocon_interaction_msgs/GetInteractions',
                 timeout=rospy.rostime.Duration(timeout),
                 unique=False)
             self.namespaces = [
                 rosgraph.names.namespace(service_name)
                 for service_name in service_names
             ]
             console.logdebug(
                 "NamespaceScanner : interactions service found -> signaling the remocon."
             )
             self.signal_updated.emit()
             break
         except rocon_python_comms.NotFoundException:
             # unfortunately find_service doesn't distinguish between timed out
             # and not found because ros master is not up yet
             #
             # also, ros might not be up yet (this gets started before we get into rqt and
             # it is rqt that is responsible for firing rospy.init_node).
             #
             # In this case, is_shutdown is still, false (because we didn't start yet) and
             # we get here immediately (i.e. before the timeout triggers).
             #
             # So....poor man's way of checking rospy.is_shutdown() without having rospy.init_node around
             if (rospy.get_time() - start_time) < timeout:
                 # can happen the first time it finds the service within the timeout
                 # so check for multiple occurences
                 timout_sequence_count += 1
                 if timout_sequence_count > 3:
                     rospy.logdebug(
                         "NamespaceScanner : ros master probably down, breaking out."
                     )
                     # game over at this point, the rqt plugin will have to be restarted
                     # so as to catch a new master
                     break
    def _connect(self,
                 rocon_master_name="",
                 ros_master_uri="http://localhost:11311",
                 host_name='localhost'):

        # 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
        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:
        rospy.init_node(self.name, disable_signals=True)
        try:
            get_interactions_service_name = rocon_python_comms.find_service(
                'rocon_interaction_msgs/GetInteractions',
                timeout=rospy.rostime.Duration(5.0),
                unique=True)
            get_roles_service_name = rocon_python_comms.find_service(
                'rocon_interaction_msgs/GetRoles',
                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:
            message = "failed to find all of the interactions' publications and services [%s]" % str(
                e)
            console.logerror("InteractiveClient : %s" % message)
            return (False, message)

        self.get_interactions_service_proxy = rospy.ServiceProxy(
            get_interactions_service_name,
            rocon_interaction_srvs.GetInteractions)
        self.get_roles_service_proxy = rospy.ServiceProxy(
            get_roles_service_name, rocon_interaction_srvs.GetRoles)
        self.request_interaction_service_proxy = rospy.ServiceProxy(
            request_interaction_service_name,
            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")