Пример #1
0
    def start(self, rapp, remappings, parameters=[]):
        """
        Start the rapp with the specified remappings.

        :param str rapp: ros package resource name of the rapp to start (e.g. rocon_apps/teleop)
        :param remappings: remappings to apply to the rapp when starting.
        :type remappings: [rocon_std_msgs.Remapping]
        :param parameters: paramters to apply to the rapp when starting.
        :type remappings: [rocon_std_msgs.KeyValue]

        .. include:: weblinks.rst

        :raises: :exc:`.FailedToStartRappError`
        """
        if not self.initialised:
            raise FailedToStartRappError("rapp manager's location unknown")
        try:
            unused_response = self.service_proxies.start_rapp(
                rocon_app_manager_srvs.StartRappRequest(name=rapp,
                                                        remappings=remappings,
                                                        parameters=parameters))
            # todo check this response and process it
        except (rospy.service.ServiceException,
                rospy.exceptions.ROSInterruptException) as e:
            # Service not found or ros is shutting down
            raise FailedToStartRappError("%s" % str(e))
Пример #2
0
    def __init__(self):
        self._gateway_name = None  # Name of our local gateway (if available)
        self._gateway_ip = None  # IP/Hostname of our local gateway if available
        self._remote_name = None  # Name (gateway name) for the entity that is remote controlling this app manager
        self._current_rapp = None  # Rapp that is running, otherwise None
        self._application_namespace = None  # Push all app connections underneath this namespace
        roslaunch.pmon._init_signal_handlers()
        self._services = {}
        self._publishers = {}
        self._param = setup_ros_parameters()
        (self._rocon_uri, self._icon) = self._set_platform_info()

        self.caps_list = {}
        self._initialising_services = False

        rospy.loginfo("Rapp Manager : indexing rapps...")
        self._indexer = rapp_repositories.get_combined_index(
            package_whitelist=self._param['rapp_package_whitelist'],
            package_blacklist=self._param['rapp_package_blacklist'])

        if self._param['auto_rapp_installation']:
            try:
                self._dependency_checker = rocon_app_utilities.DependencyChecker(
                    self._indexer)
                rospy.loginfo(
                    "Rapp Manager : auto rapp installation is enabled ..")
            except KeyError as unused_e:
                rospy.logwarn(
                    "Rapp Manager : fails to initialise auto rapp installer. Disabling auto_rapp_installation .."
                )
                self._param['auto_rapp_installation'] = False
        self._runnable_apps, self._installable_apps, self._noninstallable_rapps, self._platform_filtered_apps, self._capabilities_filtered_apps, self._invalid_apps = self._determine_runnable_rapps(
        )

        self._preferred = {}
        self._configure_preferred_rapp_for_virtuals()

        self._init_default_service_names()
        self._init_gateway_services()
        #if we dont depend on gateway we can init services right now
        if not self._param['use_gateway_uuids']:
            self._init_services()

        if self._param['auto_start_rapp']:  # None and '' are both false here
            request = rapp_manager_srvs.StartRappRequest(
                self._param['auto_start_rapp'], [])
            unused_response = self._process_start_app(request)

        self._debug_ignores = {
        }  # a remote_controller_name : timestamp of the last time we logged an ignore response

        rospy.loginfo("Rapp Manager : initialised.")
Пример #3
0
 def _start(self, gateway_name, resource):
     if self._resource == None:
         raise FailedToStartRappsException(
             "this client hasn't been allocated yet [%s]" % self.name)
     start_rapp = rospy.ServiceProxy(
         '/' + gateway_name.lower().replace(' ', '_') + '/start_rapp',
         rapp_manager_srvs.StartRapp)
     request = rapp_manager_srvs.StartRappRequest()
     request.name = resource.rapp
     request.remappings = resource.remappings
     request.parameters = resource.parameters
     try:
         start_rapp(request)
     except (rospy.service.ServiceException,
             rospy.exceptions.ROSInterruptException
             ) as e:  # Service not found or ros is shutting down
         raise FailedToStartRappsException("%s" % str(e))
Пример #4
0
    def __init__(self):
        self.current_rapp = None
        roslaunch.pmon._init_signal_handlers()
        self.parameters = StandaloneParameters()
        self.rocon_uri = rocon_uri.generate_platform_rocon_uri(
            self.parameters.robot_type, self.parameters.robot_name)
        rospy.loginfo("Rapp Manager : rocon_uri: %s" % self.rocon_uri)
        # attempt to parse it, try and make it official
        try:
            rocon_uri.RoconURI(self.rocon_uri)
        except rocon_uri.exceptions.RoconURIValueError as e:
            rospy.logerr(
                "Rapp Manager : rocon_uri is not official, rapp compatibility will probably fail [%s]"
                % str(e))
        self.caps_list = {}

        rospy.loginfo("Rapp Manager : indexing rapps...")
        self.indexer = rapp_repositories.get_combined_index(
            package_whitelist=self.parameters.rapp_package_whitelist,
            package_blacklist=self.parameters.rapp_package_blacklist)

        if self.parameters.auto_rapp_installation:
            try:
                self._dependency_checker = rocon_app_utilities.DependencyChecker(
                )
                rospy.loginfo(
                    "Rapp Manager : auto rapp installation is enabled ..")
            except KeyError as unused_e:
                # TODO add a pointer to docs about configuring the environment for auto rapp installation
                rospy.logwarn(
                    "Rapp Manager : environment not configured for auto rapp installation, disabling."
                )
                self.parameters.auto_rapp_installation = False
        self.runnable_apps, self.installable_apps, self.noninstallable_apps, self.platform_filtered_apps, self.capabilities_filtered_apps, self.invalid_apps = self._determine_runnable_rapps(
        )

        self._configure_preferred_rapp_for_virtuals()

        # ros communications
        self.services = rocon_python_comms.utils.Services([
            ('~list_rapps', rapp_manager_srvs.GetRappList,
             self._process_get_runnable_rapp_list),
            ('~start_rapp', rapp_manager_srvs.StartRapp,
             self._process_start_rapp),
            ('~stop_rapp', rapp_manager_srvs.StopRapp, self._process_stop_rapp)
        ])
        latched = True
        queue_size_five = 5
        self.publishers = rocon_python_comms.utils.Publishers([
            ('~introspection/parameters', std_msgs.String, latched,
             queue_size_five),
            ('~status', rapp_manager_msgs.Status, latched, queue_size_five),
            ('~rapp_list', rapp_manager_msgs.RappList, latched,
             queue_size_five),
            ('~introspection/incompatible_rapp_list',
             rapp_manager_msgs.IncompatibleRappList, latched, queue_size_five)
        ])
        # small pause (convenience only) to let connections to come up
        rospy.rostime.wallsleep(0.5)
        self.publishers.parameters.publish(
            std_msgs.String("%s" % self.parameters))
        self._publish_status()
        self._publish_rapp_list()
        self.publishers.incompatible_rapp_list.publish(
            [], [], self.platform_filtered_apps,
            self.capabilities_filtered_apps)

        # TODO: Currently blacklisted apps and non-whitelisted apps are not provided yet

        if self.parameters.auto_start_rapp:  # None and '' are both false here
            request = rapp_manager_srvs.StartRappRequest()
            request.name = self.parameters.auto_start_rapp
            unused_response = self._process_start_rapp(request)