forked from dawnkd/light_control
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstartROS.py
More file actions
executable file
·57 lines (44 loc) · 1.48 KB
/
startROS.py
File metadata and controls
executable file
·57 lines (44 loc) · 1.48 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import libtmux
class Window():
START_DIR = "~/catkin_ws"
def __init__(self, name, command, start_dir = "~/catkin_ws"):
self.name = name
self.command = command
self.start_dir = start_dir
def create(self, session):
print(self.name + " started")
window = session.new_window(attach = False,
window_name = self.name,
start_directory = self.start_dir)
pane = window.split_window(attach = False)
pane.send_keys(self.command)
'''
------------------------------------
'''
SESSION_NAME = "ROS"
TOF_DIR = "~/tof_control/SCR"
WINDOWS = [Window("roscore", "roscore"),
Window("tof_c++", "./tof", start_dir = TOF_DIR),
Window("octa_light", "rosrun scr_control SCR_OctaLight_server.py"),
Window("blind", "rosrun scr_control SCR_blind_server.py"),
Window("hvac", "rosrun scr_control SCR_HVAC_server.py"),
Window("tof", "rosrun scr_control SCR_TOF_server.py"),
Window("cos", "rosrun scr_control SCR_COS_server.py")
]
'''
------------------------------------
'''
if __name__ == "__main__":
server = libtmux.Server()
try:
session = server.find_where({"session_name": SESSION_NAME})
session.kill_session()
print("Session '" + SESSION_NAME + "' already exists, deleting...")
except:
pass
session = server.new_session(attach = False,
session_name = SESSION_NAME,
)
for w in WINDOWS:
w.create(session)
print("Services started on tmux session '" + SESSION_NAME + "'")