launchtree_loader.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import sys
00003 
00004 from roslaunch.xmlloader import XmlLoader, loader
00005 from rosgraph.names import get_ros_namespace
00006 
00007 from rqt_launchtree.launchtree_context import LaunchtreeContext
00008 
00009 class LaunchtreeLoader(XmlLoader):
00010 
00011         def _include_tag(self, tag, context, ros_config, default_machine, is_core, verbose):
00012                 inc_filename = self.resolve_args(tag.attributes['file'].value, context)
00013                 ros_config.push_level(inc_filename, unique=True)
00014                 result = super(LaunchtreeLoader, self)._include_tag(tag, context, ros_config, default_machine, is_core, verbose)
00015                 ros_config.pop_level()
00016                 return result
00017 
00018         def _node_tag(self, tag, context, ros_config, default_machine, is_test=False, verbose=True):
00019                 try: 
00020                         if is_test: 
00021                                 self._check_attrs(tag, context, ros_config, XmlLoader.TEST_ATTRS) 
00022                                 (name,) = self.opt_attrs(tag, context, ('name',))  
00023                                 test_name, time_limit, retry = self._test_attrs(tag, context) 
00024                                 if not name: 
00025                                         name = test_name 
00026                         else: 
00027                                 self._check_attrs(tag, context, ros_config, XmlLoader.NODE_ATTRS) 
00028                                 (name,) = self.reqd_attrs(tag, context, ('name',))
00029                 except Exception as e:
00030                         pass # will be handled in super
00031 
00032                 ros_config.push_level(name)
00033                 result = super(LaunchtreeLoader, self)._node_tag(tag, context, ros_config, default_machine, is_test, verbose)
00034                 ros_config.pop_level()
00035                 return result
00036 
00037         def _rosparam_tag(self, tag, context, ros_config, verbose):
00038                 param_file = tag.attributes['file'].value \
00039                         if tag.attributes.has_key('file') else ''
00040                 if param_file != '': 
00041                         param_filename = self.resolve_args(param_file, context)
00042                         level_name = ros_config.push_level(param_filename, unique=True)
00043                 result = super(LaunchtreeLoader, self)._rosparam_tag(tag, context, ros_config, verbose)
00044                 if param_file != '': 
00045                         ros_config.pop_level()
00046                         context.add_rosparam(tag.attributes.get('command', 'load'), param_filename, level_name)
00047                 return result
00048 
00049         def _load_launch(self, launch, ros_config, is_core=False, filename=None, argv=None, verbose=True):
00050                 if argv is None:
00051                         argv = sys.argv
00052 
00053                 self._launch_tag(launch, ros_config, filename)
00054                 self.root_context = LaunchtreeContext(get_ros_namespace(), filename, config=ros_config)
00055                 loader.load_sysargs_into_context(self.root_context, argv)
00056 
00057                 if len(launch.getElementsByTagName('master')) > 0:
00058                         print "WARNING: ignoring defunct <master /> tag"
00059                 self._recurse_load(ros_config, launch.childNodes, self.root_context, None, is_core, verbose)
00060 


rqt_launchtree
Author(s): Philipp Schillinger
autogenerated on Thu Jun 6 2019 17:42:18