forked from CMU-cabot/cabot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepeat_launch.sh
executable file
·104 lines (85 loc) · 1.71 KB
/
repeat_launch.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
#!/bin/bash
stop_launch() {
kill $launch_pid
wait $launch_pid
exit 0
}
trap 'stop_launch' SIGINT SIGTERM EXIT
function help()
{
echo "Usage:"
echo "-h show this help"
echo "-f set floor"
echo "-t repeat times"
echo "-u if usb recognition of realsense is not, exit"
echo "-n if you don't want to auto stop cabot.service and repeat, use this"
}
floor=0
repeat_times=2
usb_recognition=0
no_repeat=0
wait_map=0
CABOT_INITX=0
CABOT_INITY=0
pwd=`pwd`
scriptdir=`dirname $0`
cd $scriptdir
scriptdir=`pwd`
cd $scriptdir/../
source ./.env
projectdir=`pwd`
project=$(basename $projectdir)
while getopts "hf:t:un" arg; do
case $arg in
h)
help
exit
;;
f)
floor=$OPTARG
;;
t)
repeat_times=$OPTARG
;;
u)
usb_recognition=1
;;
n)
no_repeat=1
repeat_times=1
;;
esac
done
shift $((OPTIND-1))
source ./.env
pause(){
trap true 1 2 3 15
sleep infinity&
wait $!
}
for i in `eval echo {1..$repeat_times}`; do
if [[ -z $(docker ps -q -f "name=${project}-map_server*") ]]; then
wait_map=1
fi
./launch.sh -y &
launch_pid=$!
sleep 10
if [[ $wait_map -eq 1 ]]; then
echo "wait for map server to start"
sleep 20
fi
./cabot_debug/set-floor_and_estimate.sh -f $floor
sleep 10
if [[ $no_repeat -eq 1 ]]; then
pause
fi
kill $launch_pid
wait $launch_pid
if [[ $CABOT_MODEL == "cabot2-gtm" ]] && [[ $usb_recognition -eq 1 ]]; then
count=`lsusb | grep 435 | wc -l`
if [[ $count -le 1 ]]; then
echo "realsense is down"
break
fi
fi
done