forked from UPenn-RoboCup/UPennDev2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_all.lua
executable file
·113 lines (103 loc) · 2.41 KB
/
start_all.lua
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env luajit
assert(arg, "Run from the shell")
--local kind = assert(arg[1], "Specify vision or motion")
dofile'include.lua'
local color = require'util'.color
local LUA = 'luajit'
local wizards = {
{'lidar_chest', },
{'lidar_head', },
{'camera', 1},
{'camera', 2},
{'audio', 1},
{'audio', 2},
{'rpc', },
{'feedback', },
{'mesh', },
{'slam', },
}
local runs = {
'dcm',
'imu'
}
unix.chdir(HOME..'/Run')
local function gen_screen(name, script, ...)
local args = {...}
return table.concat({
'screen',
'-S',
name..table.concat(args),
'-L',
'-dm',
LUA,
name..'_wizard.lua',
...
},' ')
end
for i, wizard in ipairs(wizards) do
local name = wizard[1]
local scriptname = wizard[1]..'_wizard.lua'
local name_w_args = wizard[2] and scriptname..' '..wizard[2] or scriptname
-- Kill any previous instances
local ret = io.popen("pkill -f "..name_w_args):lines()
for pid in ret do
print('Killed Process', pid)
end
end
for i, wizard in ipairs(wizards) do
local name = wizard[1]
local scriptname = wizard[1]..'_wizard.lua'
local name_w_args = wizard[2] and scriptname..' '..wizard[2] or scriptname
local script = gen_screen(name, name..'_wizard.lua', unpack(wizard, 2))
local status = os.execute(script)
print(color(name, 'yellow'), 'starting')
print(script)
end
-- Print starting the robot
if RUN_ROBOT then
unix.chdir(ROBOT_HOME)
for i, run in ipairs(runs) do
-- Kill any previous instances
local ret = io.popen("pkill -f "..run):lines()
for i, pid in ret do
print('Killed Process', pid)
end
local script = gen_screen(run, 'run_'..run..'.lua')
local status = os.execute(script)
print(color(run, 'yellow'), 'starting')
--print(script)
unix.usleep(1e6)
end
end
-- Check the status
unix.sleep(1)
for i, wizard in ipairs(wizards) do
local name = wizard[1]
-- Kill any previous instances
local ret = io.popen("pgrep -fla "..name):lines()
local started = false
for pid in ret do
if pid then started = true end
end
if started then
print(color(name, 'green'), 'started')
else
print(color(name, 'red'), 'not started')
end
end
if RUN_ROBOT then
unix.sleep(1)
for i, name in ipairs(runs) do
-- Kill any previous instances
local ret = io.popen("pgrep -f "..name):lines()
local started = false
for pid in ret do
if pid then started = true end
end
if started then
print(color(name, 'green'), 'started')
else
print(color(name, 'red'), 'not started')
end
end
end