-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.sh
executable file
·236 lines (191 loc) · 8.05 KB
/
start.sh
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/usr/bin/bash
# Change name also in stop.sh
TMUX_NAME=perception-tmux
DOCKER_CONTAINER_NAME=ergocub_perception_container
echo "Start this script inside the ergoCub visual perception root folder"
usage() { echo "Usage: $0 [-i ip_address] [-n nameserver] [-y (to start yarp server] [-s (to start source)] [-r repeater] [-b (just bash)]" 1>&2; exit 1; }
while getopts i:ysbhn:r flag
do
case "${flag}" in
i) SERVER_IP=${OPTARG};;
n) YARP_NAMESERVER=${OPTARG};;
y) START_YARP_SERVER='1';;
r) REPEATER='1';;
s) START_SOURCE='1';;
b) JUST_BASH='1';;
h) usage;;
*) usage;;
esac
done
# Start the container with the right options
docker run --gpus=all -v "$(pwd)":/home/ergocub/perception -itd --rm \
--gpus=all \
--env DISPLAY=$DISPLAY \
--env PYTHONPATH=/home/ergocub/perception \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--ipc=host \
--network=host --name $DOCKER_CONTAINER_NAME ar0s/ergocub-perception-image bash
# Create tmux session
tmux new-session -d -s $TMUX_NAME
tmux set-option -t $TMUX_NAME status-left-length 140
tmux set -t $TMUX_NAME -g pane-border-status top
tmux set -t $TMUX_NAME -g mouse on
# Just bash?
if [ -n "$JUST_BASH" ] # Variable is non-null
then
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux a -t $TMUX_NAME
exit 0
fi
# COMPONENTS #######################################################################
# Human Detection
tmux rename-window -t $TMUX_NAME components
tmux select-pane -T "Human Detection"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/human_detection.py" Enter
tmux split-window -h -t $TMUX_NAME
# Human Pose Estimation
tmux select-pane -T "Human Pose Estimation"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "export HUMAN_X_FILTER_ALPHA=0.3" Enter
tmux send-keys -t $TMUX_NAME "export HUMAN_Y_FILTER_ALPHA=0.1" Enter
tmux send-keys -t $TMUX_NAME "python scripts/human_pose_estimation.py" Enter
tmux split-window -h -t $TMUX_NAME
# Action Recognition Pipeline
tmux select-pane -T "Action Recognition"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/action_recognition.py" Enter
tmux split-window -h -t $TMUX_NAME
# Focus Detector
tmux select-pane -T "Focus Detection"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/focus_detection.py" Enter
tmux split-window -h -t $TMUX_NAME
# Grasping Pipeline
tmux select-pane -T "Grasping Pipeline"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/grasping_pipeline.py" Enter
tmux split-window -h -t $TMUX_NAME
# Segmentation
tmux select-pane -T "Segmentation"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/segmentation.py" Enter
# I/O #######################################################################
tmux select-layout -t $TMUX_NAME tiled
tmux new-window -t $TMUX_NAME
tmux rename-window -t $TMUX_NAME input/output
# Source
tmux select-pane -T "Source"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
if [ -n "$START_SOURCE" ] # Variable is non-null
then
tmux send-keys -t $TMUX_NAME "sleep 5" Enter # Wait for manager to start
tmux send-keys -t $TMUX_NAME "python scripts/source.py" Enter
fi
tmux split-window -h -t $TMUX_NAME
# Sink
tmux select-pane -T "Sink"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/sink.py" Enter
tmux split-window -h -t $TMUX_NAME
# Recorder
tmux select-pane -T "Recorder"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/recorder.py"
tmux split-window -h -t $TMUX_NAME
# 3D Shape Completion Visualizer
tmux select-pane -T "3D Shape Completion Visualizer"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/od3dviz.py"
tmux split-window -h -t $TMUX_NAME
# Human Console
tmux select-pane -T "Human Console"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/human_console2.py" Enter
tmux split-window -h -t $TMUX_NAME
# REALSENSE GUI
tmux select-pane -T "RealSense GUI"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/realsense_gui.py" Enter
# COMMUNICATION #######################################################################
tmux select-layout -t $TMUX_NAME tiled
tmux new-window -t $TMUX_NAME
tmux rename-window -t $TMUX_NAME communication
# Manager
tmux select-pane -T "Manager"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/manager.py" Enter
tmux split-window -h -t $TMUX_NAME
# YarpManager
tmux select-pane -T "Bash"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux split-window -h -t $TMUX_NAME
# Yarp Server
tmux select-pane -T "Yarp Server"
# Set Yarp Server Configurations
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
if [ -n "$YARP_NAMESERVER" ] # Variable is non-null
then
tmux send-keys -t $TMUX_NAME "yarp namespace $YARP_NAMESERVER" Enter
fi
if [ -n "$SERVER_IP" ] # Variable is non-null
then
tmux send-keys -t $TMUX_NAME "yarp conf $SERVER_IP 10000" Enter
fi
if [ -n "$REPEATER" ] # Variable is non-null
then
tmux send-keys -t $TMUX_NAME "yarp repeat /depthCamera/rgbImage:r" Enter
fi
if [ -n "$START_YARP_SERVER" ] # Variable is non-null
then
tmux send-keys -t $TMUX_NAME "yarpserver --write" Enter
# else
# tmux send-keys -t $TMUX_NAME "yarp detect --write" Enter
fi
if [ -n "$REPEATER" ] # Variable is non-null
then
tmux split-window -h -t $TMUX_NAME
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "yarp repeat /depthCamera/depthImage:r" Enter
fi
if [ -n "$REPEATER" ] # Variable is non-null
then
tmux split-window -h -t $TMUX_NAME
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "sleep 3 && ./connect_camera.sh" Enter
fi
tmux split-window -h -t $TMUX_NAME
# RPC server
tmux select-pane -T "RPC Server"
tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
tmux send-keys -t $TMUX_NAME "cd perception" Enter
tmux send-keys -t $TMUX_NAME "python scripts/rpc_server.py" Enter
tmux split-window -h -t $TMUX_NAME
tmux select-layout -t $TMUX_NAME tiled
# tmux new-window -t $TMUX_NAME
# tmux rename-window -t $TMUX_NAME gaze
# YarpManager
# tmux select-pane -T "iKinGazeCtrl"
# tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
# tmux send-keys -t $TMUX_NAME "iKinGazeCtrl --from .yarp/gaze_config.ini"
# tmux split-window -h -t $TMUX_NAME
# tmux select-pane -T "GazeController"
# tmux send-keys -t $TMUX_NAME "docker exec -it $DOCKER_CONTAINER_NAME bash" Enter
# tmux send-keys -t $TMUX_NAME "python scripts/gaze_controller.py"
tmux select-window -t "components"
# Attach
tmux a -t $TMUX_NAME