def load(self, argv): ''' @param argv: the list with argv parameter needed to load the launch file. The name and value are separated by C{:=} @type argv: C{[str]} @return True, if the launch file was loaded @rtype boolean @raise LaunchConfigException: on load errors ''' try: roscfg = roslaunch.ROSLaunchConfig() loader = roslaunch.XmlLoader() self.argv = self.resolveArgs(argv) loader.load(self.Filename, roscfg, verbose=False, argv=self.argv) self.__roscfg = roscfg nm.file_watcher().add_launch(self.__masteruri, self.__launchFile, self.__launch_id, self.getIncludedFiles(self.Filename)) if not nm.is_local(nm.nameres().getHostname(self.__masteruri)): files = self.getIncludedFiles(self.Filename, regexp_list=[QRegExp("\\bdefault\\b"), QRegExp("\\bvalue=.*pkg:\/\/\\b"), QRegExp("\\bvalue=.*package:\/\/\\b"), QRegExp("\\bvalue=.*\$\(find\\b")]) nm.file_watcher_param().add_launch(self.__masteruri, self.__launchFile, self.__launch_id, files) except roslaunch.XmlParseException, e: test = list(re.finditer(r"environment variable '\w+' is not set", str(e))) message = str(e) if test: message = ''.join([message, '\n', 'environment substitution is not supported, use "arg" instead!']) raise LaunchConfigException(message)
def load(self, argv): ''' :param argv: a list with argv parameter needed to load the launch file. The name and value are separated by `:=` :type argv: list(str) :return: True, if the launch file was loaded and argv, used while launch :rtype: tuple(bool, []) :raise LaunchConfigException: on load errors ''' try: self._capabilities = None self._robot_description = None roscfg = roslaunch.ROSLaunchConfig() loader = roslaunch.XmlLoader() self.argv = self.resolve_args(argv) loader.load(self.filename, roscfg, verbose=False, argv=self.argv) self.__roscfg = roscfg if 'arg' in loader.root_context.resolve_dict: self.resolve_dict = loader.root_context.resolve_dict['arg'] self.changed = True except roslaunch.XmlParseException as e: test = list( re.finditer(r"environment variable '\w+' is not set", utf8(e))) message = utf8(e) if test: message = '%s\nenvironment substitution is not supported, use "arg" instead!' % message raise LaunchConfigException(message) return True, self.argv
def roslaunch_load_check(ctx): config = roslaunch.ROSLaunchConfig() loader = roslaunch.XmlLoader() # TODO load roscore for launch_file in ctx.launch_files: loader.load(launch_file, config, verbose=False) try: config.assign_machines() except roslaunch.RLException as e: return str(e)
def _load_roslaunch_config(ctx): config = roslaunch.ROSLaunchConfig() loader = roslaunch.XmlLoader() # TODO load roscore for launch_file in ctx.launch_files: loader.load(launch_file, config, verbose=False) try: config.validate() config.assign_machines() except roslaunch.RLException, e: return config, []
def launch_core(self): self.log('Launching ros core services') # Create a roslauncher config = roslaunch.ROSLaunchConfig() config.master.auto = config.master.AUTO_RESTART launcher = roslaunch.ROSLaunchRunner(config) launcher.launch() return launcher
def launch(package, launch_name, args = []): ros_master_id = rospy.get_param("/run_id") pkg_path = rospkg.RosPack().get_path( package ) launch_path = "%s/launch/%s" % ( pkg_path, launch_name) loader = roslaunch.XmlLoader() config = roslaunch.ROSLaunchConfig() loader.load( launch_path, config, argv=args ) runner = roslaunch.ROSLaunchRunner( ros_master_id, config ) runner.launch()
def launch_core(): # Launch the core, generate the run_id # in the future this may need a rewrite as roslaunch gets the # ability to remotely launch cores, but for now this is fine config = roslaunch.ROSLaunchConfig() config.master.auto = config.master.AUTO_START run_id = roslaunch.core.generate_run_id() core_launcher = roslaunch.ROSLaunchRunner(run_id, config) core_launcher.launch() return core_launcher
def load(self, argv): ''' :param argv: a list with argv parameter needed to load the launch file. The name and value are separated by `:=` :type argv: list(str) :return: True, if the launch file was loaded and argv, used while launch :rtype: tuple(bool, []) :raise LaunchConfigException: on load errors ''' try: self._capabilities = None self._robot_description = None roscfg = roslaunch.ROSLaunchConfig() loader = roslaunch.XmlLoader() self.argv = self.resolve_args(argv) loader.ignore_unset_args = False loader.load(self.filename, roscfg, verbose=False, argv=self.argv) self.__roscfg = roscfg if 'arg' in loader.root_context.resolve_dict: self.resolve_dict = loader.root_context.resolve_dict['arg'] self.changed = True # check for depricated parameter diag_dep = DiagnosticArray() if self._monitor_servicer is not None: diag_dep.header.stamp = rospy.Time.now() for n in roscfg.nodes: node_fullname = roslib.names.ns_join(n.namespace, n.name) associations_param = roslib.names.ns_join( node_fullname, 'associations') if associations_param in roscfg.params: ds = DiagnosticStatus() ds.level = DiagnosticStatus.WARN ds.name = node_fullname ds.message = 'Deprecated parameter detected' ds.values.append(KeyValue('deprecated', 'associations')) ds.values.append(KeyValue('new', 'nm/associations')) rospy.logwarn( "'associations' is deprecated, use 'nm/associations'! found for node: %s in %s" % (node_fullname, self.filename)) diag_dep.status.append(ds) if self._monitor_servicer is not None: # set diagnostics self._monitor_servicer._monitor._callback_diagnostics(diag_dep) except roslaunch.XmlParseException as e: test = list( re.finditer(r"environment variable '\w+' is not set", utf8(e))) message = utf8(e) if test: message = '%s\nenvironment substitution is not supported, use "arg" instead!' % message raise LaunchConfigException(message) return True, self.argv
def RunThread(self, arg): # Create a roslauncher config = roslaunch.ROSLaunchConfig() # Try loading the XML file try: loader = roslaunch.XmlLoader() loader.load(execution_path('ethernet_test.xml'), config) except roslaunch.XmlParseException, e: wx.CallAfter( self.Cancel, 'Could not load back-end XML to launch necessary nodes. Make sure the GUI is up to date.' ) return
def _load_roslaunch_config(ctx): config = roslaunch.ROSLaunchConfig() loader = roslaunch.XmlLoader() # TODO load roscore for launch_file in ctx.launch_files: loader.load(launch_file, config, verbose=False) try: config.assign_machines() except roslaunch.RLException as e: return config, [] machines = [] for n in itertools.chain(config.nodes, config.tests): if n.machine not in machines: machines.append(n.machine) return config, machines
def launch_script(self, script): self.log('Launching roslaunch file %s' % (script)) # Create a roslauncher config = roslaunch.ROSLaunchConfig() # Try loading the XML file try: loader = roslaunch.XmlLoader() loader.load(script, config) # Bring up the nodes launcher = roslaunch.ROSLaunchRunner(config) launcher.launch() except roslaunch.RLException, e: self.log('Failed to launch roslaunch file %s: %s' % (script, e)) return None
def syntastic_checker(): import re import roslaunch import roslaunch.loader conf = roslaunch.ROSLaunchConfig() loader = roslaunch.XmlLoader() try: loader.load(vimp.buf.name, conf, verbose=False) except roslaunch.XmlParseException as e: rx = re.compile('(?:while processing (?P<filename>.*):\n)*' '(?P<text>.*)' '(?:: line (?P<lnum>\d+), column (?P<col>\d+))?') g = rx.match(e.message) if g is not None: return [syntastic.Error(**g.groupdict())] else: return [ syntastic.Error(text='UPDATE RE TO HANDLE THIS TYPE OF' 'ERROR MESSAGE!' + str(e.message)) ] except roslaunch.loader.LoadException as e: return [syntastic.Error(text=str(e.message))] except roslaunch.RLException as e: return [syntastic.Error(text=str(e.message))] # no parsing errors, but there could be warnigns warn = list() for e in conf.config_errors: g = re.match(r'\[(.*)\] (.*)', e) if g is not None: fn, text = g.groups() warn.append(syntastic.Error(filename=fn, text=text, type='W')) continue g = re.match(r'WARN: (.*)', e) if g is not None: warn.append(syntastic.Error(text=g.groups()[0], type='W')) continue warn.append( syntastic.Error(text='vim-ros does not know how to ' 'parse this warning: "%s"' % e, type='W')) return warn
def RunThread(self, arg): #Create a roslauncher config = roslaunch.ROSLaunchConfig() self.count = 1 self.finished = False self.testcount = 1 self.ready = False # Try loading the test XML file try: xmlFile = execution_path( str('xml/' + self.serial1 + '_forearm_test.xml')) loader = roslaunch.XmlLoader() loader.load(xmlFile, config) except roslaunch.XmlParseException, e: wx.CallAfter( self.Cancel, 'Could not load back-end XML to launch necessary nodes. Make sure the GUI is up to date.' ) return