-
Notifications
You must be signed in to change notification settings - Fork 0
/
stagerosgym.bash
executable file
·225 lines (138 loc) · 5.36 KB
/
stagerosgym.bash
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
#!/bin/bash
# Manage stage_environments simulation
# Use: ./stagerosgym.bash [start [--no_gui]|start-dev [--no_gui]|stop|status|pause|resume|speedup <value>|footprints]
#
# Note: start-dev was added to run containers on PC with nvidia options:
# I don't want to break the config for robot
if [ "x$1" == "xstatus" ]; then
echo "====================================="
echo "Status"
echo ""
echo "Docker"
docker ps
echo "---------"
echo ""
echo "ROS"
docker exec -it rchomeedu-1804-melodic bash -ci "rosnode list"
echo "---------"
echo ""
echo "====================================="
echo ""
elif [[ $1 == start || $1 == start-dev ]]; then
# stage_environments
echo "====================================="
echo "Starting stage_environments ..."
if [ `docker image ls | grep iocchi/stage_environments | wc -l` == 0 ]; then
docker pull iocchi/stage_environments
fi
# No modifications
if [[ $1 == start ]]; then
if [ `docker container ls | grep iocchi/stage_environments | wc -l` == 0 ]; then
wget -N https://bitbucket.org/iocchi/stage_environments/raw/master/docker_create.bash
mv docker_create.bash stage_docker_create.bash
chmod a+x stage_docker_create.bash
./stage_docker_create.bash
fi
# Modified script for development
elif [[ $1 == start-dev ]]; then
bash nvidia-scripts/stage_docker_create.bash
fi
docker start stage_environments
sleep 3
if [ `docker ps | grep stage_environments | wc -l` == 0 ]; then
echo "ERROR Container stage_environments not running"
echo "====================================="
echo ""
exit 1
fi
echo "stage_environments running"
echo "====================================="
echo ""
sleep 5
# rchome_edu
echo "====================================="
echo "Starting rc-home-edu-learn-ros ..."
if [ `docker image ls | grep iocchi/rchomeedu-1804-melodic | wc -l` == 0 ]; then
docker pull iocchi/rchomeedu-1804-melodic
fi
# No modifications
if [[ $1 == start ]]; then
if [ `docker container ls | grep iocchi/rchomeedu-1804-melodic | wc -l` == 0 ]; then
wget -N https://raw.githubusercontent.com/robocupathomeedu/rc-home-edu-learn-ros/master/docker/1804/create.bash
mv create.bash rchomeedu_docker_create.bash
chmod a+x rchomeedu_docker_create.bash
./rchomeedu_docker_create.bash
fi
# Modified script for development
elif [[ $1 == start-dev ]]; then
bash nvidia-scripts/rchomeedu_docker_create.bash
fi
docker start rchomeedu-1804-melodic
sleep 3
if [ `docker ps | grep rchomeedu-1804-melodic | wc -l` == 0 ]; then
echo "ERROR Container rchomeedu-1804-melodic not running"
echo "====================================="
echo ""
exit 1
fi
echo "rc-home-edu-learn-ros running"
echo "====================================="
echo ""
sleep 5
echo "====================================="
echo "Starting simulation"
s1=stage_environments
#docker exec -it stage_environments tmux new-window -t "$s1" -n "1"
docker exec -it stage_environments tmux send-keys -t "$s1:0" "rosrun stage_environments start_simulation.py $2 DISB1" C-M
echo "Simulation running"
echo "====================================="
echo ""
sleep 5
echo "====================================="
echo "Starting robot behaviors"
s2=rchomeedu
docker exec -it rchomeedu-1804-melodic tmux new-session -d -s "$s2"
docker exec -it rchomeedu-1804-melodic tmux new-window -t "$s2"
docker exec -it rchomeedu-1804-melodic tmux send-keys -t "$s2:0" "cd ~/src/marrtino_apps/navigation" C-M
docker exec -it rchomeedu-1804-melodic tmux send-keys -t "$s2:0" "roslaunch obstacle_avoidance.launch" C-M
sleep 3
docker exec -it rchomeedu-1804-melodic tmux send-keys -t "$s2:1" "rosparam set /gradientBasedNavigation/max_vel_x 0.3" C-M
echo "Robot behaviors running"
echo "====================================="
echo ""
elif [ "x$1" == "xstop" ]; then
echo "====================================="
echo "Stopping stagerosgym application...."
docker exec -it stage_environments tmux send-keys -t "$s1:0" "rosrun stage_environments quit.sh" C-M
docker exec -it rchomeedu-1804-melodic tmux send-keys -t "$s2:0" C-c
sleep 3
docker stop rchomeedu-1804-melodic
docker stop stage_environments
docker rm rchomeedu-1804-melodic
docker rm stage_environments
echo "...done"
echo "====================================="
echo ""
elif [ "x$1" == "xpause" ]; then
echo "====================================="
echo "Simulation paused"
docker exec -it stage_environments bash -ci "rostopic pub stageGUIRequest std_msgs/String \"data: 'pause'\" --once"
echo "====================================="
echo ""
elif [ "x$1" == "xresume" ]; then
echo "====================================="
echo "Simulation resumed"
docker exec -it stage_environments bash -ci "rostopic pub stageGUIRequest std_msgs/String \"data: 'resume'\" --once"
echo "====================================="
echo ""
elif [ "x$1" == "xspeedup" ]; then
SPEEDUPVALUE=1.0
if [ ! "$2" == "" ]; then
SPEEDUPVALUE=$2
fi
docker exec -it stage_environments bash -ci "rostopic pub stageGUIRequest std_msgs/String \"data: 'speedup_$SPEEDUPVALUE'\" --once"
elif [ "x$1" == "xfootprints" ]; then
docker exec -it stage_environments bash -ci "rostopic pub stageGUIRequest std_msgs/String \"data: 'footprints'\" --once"
else
echo "Use: $0 [start [--no_gui]|start-dev [--no_gui]|stop|status|pause|resume|speedup <value>|footprints]"
fi