-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_bag.sh
executable file
·102 lines (92 loc) · 2.98 KB
/
test_bag.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
#also the organization is horrible. TODO please please fix
source /opt/ros/kinetic/setup.bash
IFS='
'
count=1
practice_count=1
practice_merge_file=''
if [ $# -eq 0 ]
then
echo Input a bag file
fi
for var in "$@"
do
echo For bag file ${var}:
if [[ $var == *bag.active ]]
then
echo Reindexing
rosbag reindex $var
fi
if [[ $var == *.orig.active ]]
then
echo orig.active found -- skipping
continue
fi
echo Writing data to file
$HOME/2018RobotCode/zebROS_ws/devel/lib/rosbag_scripts/rosbag_scripts_node $var
filename=$(basename $var)
any_data=$(rosbag info $var | grep /frcrobot/match_data)
if [ ! -z "$any_data" -a "$any_data" != " " ]
then
echo This has match data
matchNumber=$(grep -m1 matchNumber temp_file.txt | cut -c14-15)
if [ $matchNumber = 0 ]
then
echo this is a practice match
number=$(echo $var | cut -c21-26)
if [[ $number == '_0.bag' ]]
then
echo this is the first of a series of split practice bags
practice_count=1
echo Match number is zero -- renaming to practice${var}
cp $var $HOME/2018RobotCode/practice$(basename $var)
practice_merge_file=practice$(basename $var)
continue
elif [[ $var == *${practice_count}.bag ]]
# && -e $practice_merge_file ]]
then
echo this is one of a series of split practice bags. merging to $practice_merge_file
cp $HOME/2018RobotCode/$practice_merge_file $HOME/2018RobotCode/unmerged_${practice_merge_file}
~/2018RobotCode/zebROS_ws/src/rosbag_scripts/scripts/merge_bagfiles.py $practice_merge_file $var unmerged_$practice_merge_file -v
practice_count=$(( $practice_count + 1 ))
continue
else
echo an error has occured -- renaming practice${var} without merging. either cannot find master or the count is incorrect
echo Match number is zero -- renaming to practice${var}
cp $var $HOME/2018RobotCode/practice$(basename $var)
continue
fi
fi
alliance_data=$(grep this temp_file.txt)
if [ ! -z "$alliance_data" -a "$alliance_data" != " " ]
then
echo This has alliance data.
matchNumber=$(grep -m1 matchNumber temp_file.txt | cut -c14-15)
if [ $matchNumber = 0 ]
then
echo Match number is zero -- renaming
cp $var $HOME/2018RobotCode/match0$(basename $var)
continue
fi
bag_name=Match${matchNumber}
if [ -e ${bag_name}*.bag ]
then
echo This match already has a bag file -- merging to ${bag_name}_${count}.bag
~/2018RobotCode/zebROS_ws/src/rosbag_scripts/scripts/merge_bagfiles.py ${bag_name}_${count}.bag $var ${bag_name}*.bag -v
rm ${bag_name}_$(( $count - 1)).bag
rm ${bag_name}.bag
count=$(( $count + 1 ))
else
echo Renaming bag file to ${bag_name}.bag
cp $var $HOME/2018RobotCode/${bag_name}.bag
fi
else
echo This does not have alliance data -- renaming to prematch${var}
cp $var $HOME/2018RobotCode/prematch$(basename $var)
fi
else
echo This does not have match data -- renaming to practice${var}
cp $var $HOME/2018RobotCode/practice$(basename $var)
fi
#rm temp_file.txt
done