-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_batch.sh
executable file
·43 lines (33 loc) · 1.11 KB
/
run_batch.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
#!/bin/bash
# Notes (mostly for me)
# $! Contains the process ID of the most recently executed background pipeline
# $? This the exit status of the last executed command
# The linux trap command allows you to catch signals and execute code when they occur
# SIGINT is generated when you type Ctrl-C at the keyboard to interrupt a running script
# kill -INT $pid sends the "interrupt" signal to the process with process ID pid.
# However, the process may decide to ignore the signal, or catch the signal and do
# something before exiting and/or ignore it.
exit_status=0
count = 0
_term() {
exit_status=$? # = 130 for SIGINT
echo "Caught SIGINT signal!"
kill -INT "$child" 2>/dev/null
}
trap _term SIGINT
while :
do
((count=count+1))
roslaunch race sim_for_rtreach_batch.launch \
timeout:=60 num_obstacles:=0 random_seed:=$RANDOM &
child=$!
wait "$child"
if [ $exit_status -eq 130 ]; then
# SIGINT was captured meaning the user
# wants full stop instead of start_simulation.launch
# terminating normally from end of episode so...
echo "stop looping"
break
fi
echo count: $count
done