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 Scripting interface for roslaunch
37 """
38
39 from roslaunch.core import Node, Master, RLException
40
41 import roslaunch.config
42 import roslaunch.parent
43 import roslaunch.xmlloader
44
46 """
47 ROSLaunchParent represents the main 'parent' roslaunch process. It
48 is responsible for loading the launch files, assigning machines,
49 and then starting up any remote processes. The __main__ method
50 delegates most of runtime to ROSLaunchParent.
51
52 This must be called from the Python Main thread due to signal registration.
53 """
54
56 """
57 @raise RLException: if fails to initialize
58 """
59 import rosgraph.masterapi
60 master = rosgraph.masterapi.Master('/roslaunch_script')
61 uuid = master.getParam('/run_id')
62 self.parent = roslaunch.parent.ROSLaunchParent(uuid, [], is_core=False)
63 self.started = False
64
66 """
67 Load roslaunch file
68
69 @param f: filename
70 @type f: str
71 """
72 raise NotImplemented
73
75 """
76 Load roslaunch string
77
78 @param s: string representation of roslaunch config
79 @type s: str
80 """
81 raise NotImplemented
82
84 """
85 Launch a roslaunch node instance
86
87 @param node: roslaunch Node instance
88 @type node: roslaunch.Node
89 @return: node process
90 @rtype: roslaunch.Process
91 @raise RLException: if launch fails
92 """
93 if not self.started:
94 raise RLException("please start ROSLaunch first")
95 elif not isinstance(node, Node):
96 raise ValueError("arg must be of type Node")
97
98 proc, success = self.parent.runner.launch_node(node)
99 if not success:
100 raise RLException("failed to launch %s/%s"%(node.package, node.type))
101 return proc
102
104 """
105 Start roslaunch. This will launch any pre-configured launches and spin up the process monitor thread.
106 """
107 self.parent.start(auto_terminate=False)
108 self.started = True
109
112
115
118