-
Notifications
You must be signed in to change notification settings - Fork 1
/
process_darpa_logs.sh
executable file
·63 lines (57 loc) · 1.57 KB
/
process_darpa_logs.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
#!/bin/bash
# Extracts DARPA logs to a subdirectory, merges the bag file from each, then processes the topics
IFS='-'
idx=1
for file in *.tar.gz ; do
echo "processing $file"
read -a agents <<< "${file%.*}"
if [ ${#agents[@]} == 7 ]; then
dir="${agents[6]::-4}"
if [ ${#dir} -le 2 ]; then
dir="master"
fi
elif [ ${#agents[@]} == 9 ]; then
dir="${agents[8]::-4}"
elif [ ${#agents[@]} == 10 ]; then
dir="${agents[8]}"
else
dir="master"
fi
mkdir $dir
cp "$file" "$dir"
cd $dir
echo "extracting $dir"
tar xzf *.tar.gz
rm *.tar.gz
if [ "$dir" != "master" ]; then
echo "processing bag data for $dir"
# Reindex any active bags
if find . -name 'robot_data_*.bag.active' -printf 1 -quit | grep -q 1; then
for robot_active in robot_data_*.bag.active ; do
newfile=${robot_active:0:${#robot_active}-11}
mv "$robot_active" "$newfile.bag"
rosbag reindex "$newfile.bag"
rm "$newfile.orig.bag"
done
fi
for robot_data in robot_data_*.bag ; do
if [ $idx == 1 ]; then
cp "$robot_data" ../temp_$idx.bag
else
let "pidx=$idx-1"
python ~/marble/scripts/bag_utils/bagmerge.py -o ../temp_$idx.bag ../temp_$pidx.bag "$robot_data"
rm ../temp_$pidx.bag
fi
let "idx=$idx+1"
done
fi
find . -name '*log*' | xargs gzip
cd ..
done
echo "moving temp bag to $name.bag"
name=${PWD##*/}
let "pidx=$idx-1"
mv temp_$pidx.bag $name.bag
echo "processing topics"
python ~/marble/scripts/bag_utils/bag_convert_ma_msgs.py $name.bag
mv $name-ma.bag $name.bag