forked from amirx96/rosbag_record_gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrosbag_gui.sh
83 lines (60 loc) · 2.2 KB
/
rosbag_gui.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
#/bin/bash
#constants
GREEN='\033[0;32m'
fin=0 ## initially set finish to zero since no data has been recorded
DIR="$HOME/rosbag-data"
today=`date +%Y-%m-%d:%H:%M:%S`
function clean_up {
if [ "$fin" -eq 0 ] #check if file info was finished processing, if not then exit immediately
then
echo -e "\n SIGTERM initiated before file info was complete, exiting"
exit
fi
#else user interrupted
echo -e "\n ROSBAG finished recording"
#add your post processing scripts after SIGTERM (crtl+c) here:
#EX: echo -e "I love ROS!"
}
trap clean_up SIGHUP SIGINT SIGTERM
function get_topics {
mapfile -t lines < <(rostopic list)
topiclist=$(zenity --list --checklist --title="Select Topics for Recording" --column="select" --column="topic" ${lines[@]} 2>/dev/null) #map stderror to null because zenity produces useless GTK errors.
topiclist=${topiclist[@]}
topiclist=${topiclist//[|]// }
}
function fileinfo {
filename=$(zenity --entry --text "Enter in file name for this bag" 2>/dev/null) #map stderror to null because zenity produces useless GTK errors.
comment=$(zenity --entry --text "Enter comment for this bag" 2>/dev/null) #map stderror to null because zenity produces useless GTK errors.
get_topics
echo "Topics for recording: " $topiclist
cont=1 #continue (1 = no, 0 = yes)
zenity --question --text="Proceed with Data Recording?\n Filename:${filename} \n Topics: ${topiclist}" 2>/dev/null #map stderror to null because zenity produces useless GTK errors.
cont=$? #zenity stores question output in var $?
if [ $cont -eq 0 ]
then
fin=1
if [ ! -d "$DIR" ]
then
echo "Directory " $DIR "not found, creating"
mkdir $DIR
fi
echo "Creating Directory " $DIR"/"$today
mkdir $DIR"/"$today
echo "$comment" >> $DIR"/"$today"/readme.txt"
fi
}
fileinfo #run once
# check to make sure user wants to proceed
while [[ $cont != 0 ]] #check if file info is correct
do
fin=0 #set finish = to zero in case of sigterm
fileinfo
done
fin=1 # file info complete so now sigterm will run postprocess scripts
echo -e "${GREEN}Recording Topics: "$topiclist
rosbag record $topiclist -O $DIR"/"$today"/"$filename
#Author
#Amir Darwesh
#amirdarwesh@gmail.com
#License
#MIT