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 ROSLaunch child server.
37
38 ROSLaunch has a client/server architecture for running remote
39 processes. When a user runs roslaunch, this creates a "parent"
40 roslaunch process. This parent process will then start "child"
41 processes on remote machines. The parent can then invoke methods on
42 this child process to launch remote processes, and the child can
43 invoke methods on the parent to provide feedback.
44 """
45
46 import logging
47 import traceback
48
49 import roslaunch.core
50 import roslaunch.pmon
51 import roslaunch.server
52
54 """
55 ROSLaunchChild infrastructure.
56
57 This must be called from the Python Main thread due to signal registration.
58 """
59
60 - def __init__(self, run_id, name, server_uri):
61 """
62 Startup roslaunch remote client XML-RPC services. Blocks until shutdown
63 @param run_id: UUID of roslaunch session
64 @type run_id: str
65 @param name: name of remote client
66 @type name: str
67 @param server_uri: XML-RPC URI of roslaunch server
68 @type server_uri: str
69 @return: XML-RPC URI
70 @rtype: str
71 """
72 roslaunch.core.set_child_mode(True)
73
74 self.logger = logging.getLogger("roslaunch.child")
75 self.run_id = run_id
76 self.name = name
77 self.server_uri = server_uri
78 self.child_server = None
79 self.pm = None
80
81 roslaunch.pmon._init_signal_handlers()
82
96
98 """
99 Runs child. Blocks until child processes exit.
100 """
101 try:
102 try:
103 self.logger.info("starting roslaunch child process [%s], server URI is [%s]", self.name, self.server_uri)
104 self._start_pm()
105 self.child_server = roslaunch.server.ROSLaunchChildNode(self.run_id, self.name, self.server_uri, self.pm)
106 self.logger.info("... creating XMLRPC server for child")
107 self.child_server.start()
108 self.logger.info("... started XMLRPC server for child")
109
110 self.pm.mainthread_spin()
111 self.logger.info("... process monitor is done spinning")
112 except:
113 self.logger.error(traceback.format_exc())
114 raise
115 finally:
116 if self.pm:
117 self.pm.shutdown()
118 self.pm.join()
119 if self.child_server:
120 self.child_server.shutdown('roslaunch child complete')
121
123 if self.pm:
124 self.pm.shutdown()
125 self.pm.join()
126