-
Notifications
You must be signed in to change notification settings - Fork 1
/
roslaunch-dump
executable file
·43 lines (32 loc) · 1.2 KB
/
roslaunch-dump
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import sys
import roslaunch
import yaml
# parse files
files = roslaunch.rlutil.resolve_launch_arguments(sys.argv[1:])
config = roslaunch.config.ROSLaunchConfig()
loader = roslaunch.xmlloader.XmlLoader()
for f in files:
loader.load(f, config, verbose = False)
def machine_to_xml(v):
out = '<machine'
for s in ['name','address', 'env_loader', 'user', 'password', 'ssh_port', 'timeout']:
g = getattr(v, s)
if g is not None:
out +=' %s="%s"' % (s.replace("_","-"),str(g))
return out + '/>\n'
params_dict = {}
for k, v in config.params.items():
params_dict[str(k)] = v.value
class NoAliasDumper(yaml.SafeDumper):
ignore_aliases = lambda self, data: True
sys.stdout.write("<launch>\n")
sys.stdout.write("<rosparam>\n")
sys.stdout.write(yaml.dump(params_dict, Dumper=NoAliasDumper).replace("<","<").replace(">",">")) # mask XML tags
sys.stdout.write("</rosparam>\n")
for k,v in config.machines.items():
if len(k) > 0: # if not local
sys.stdout.write(machine_to_xml(v))
for n in sorted(config.nodes, key=lambda i: i.namespace+i.name): # sort nodes by resolved name
sys.stdout.write(n.to_xml()+"\n")
sys.stdout.write("</launch>\n")